v0.0.591 implement namespaced PubSub Broker in dataext
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled

This commit is contained in:
2025-07-16 12:44:55 +02:00
parent a29aec8fb5
commit 64f2cd7219
5 changed files with 679 additions and 3 deletions

View File

@@ -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: