v0.0.591 implement namespaced PubSub Broker in dataext
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package syncext
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -26,6 +27,15 @@ func WriteChannelWithTimeout[T any](c chan T, msg T, timeout time.Duration) bool
|
||||
}
|
||||
}
|
||||
|
||||
func WriteChannelWithContext[T any](ctx context.Context, c chan T, msg T) error {
|
||||
select {
|
||||
case c <- msg:
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
|
||||
func ReadNonBlocking[T any](c chan T) (T, bool) {
|
||||
select {
|
||||
case msg := <-c:
|
||||
|
Reference in New Issue
Block a user