Documentation
¶
Index ¶
- Variables
- type Payload
- type PubSub
- type Sub
- func (s *Sub[T, P]) Close()
- func (s *Sub[T, P]) Receive() (topic T, msg P, err error)
- func (s *Sub[T, P]) ReceiveCh() <-chan Payload[T, P]
- func (s *Sub[T, P]) ReceiveTimeout(timeout time.Duration) (topic T, msg P, err error)
- func (s *Sub[T, P]) ReceiveTimeout2(timeout time.Duration, c1 <-chan struct{}) (topic T, msg P, err error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCancelled = errors.New("cancelled")
ErrCancelled error returned when context is cancelled
View Source
var ErrTimeout = errors.New("timeout")
ErrTimeout error returned when timeout occurs
Functions ¶
This section is empty.
Types ¶
type Payload ¶
type Payload[T comparable, P any] struct { Topic T Msg P }
type PubSub ¶
type PubSub[T comparable, P any] struct { sync.Mutex // contains filtered or unexported fields }
PubSub contains and manage the map of topics -> subscribers
func NewPubSub ¶
func NewPubSub[T comparable, P any]() *PubSub[T, P]
type Sub ¶
type Sub[T comparable, P any] struct { // contains filtered or unexported fields }
Sub subscriber will receive messages published on a Topic in his ch
func (*Sub[T, P]) Close ¶
func (s *Sub[T, P]) Close()
Close will remove the subscriber from the Topic subscribers
func (*Sub[T, P]) ReceiveTimeout ¶
ReceiveTimeout returns a message received on the channel or timeout
Click to show internal directories.
Click to hide internal directories.