Documentation ¶
Index ¶
- type Broker
- func (b *Broker[ChannelT, MsgT]) Publish(msg MsgT)
- func (b *Broker[ChannelT, MsgT]) PublishChannel(channel ChannelT, msg MsgT)
- func (b *Broker[ChannelT, MsgT]) Start()
- func (b *Broker[ChannelT, MsgT]) Stop()
- func (b *Broker[ChannelT, MsgT]) Subscribe() *Subscription[ChannelT, MsgT]
- func (b *Broker[ChannelT, MsgT]) SubscribeChannel(channel ChannelT) *Subscription[ChannelT, MsgT]
- func (b *Broker[ChannelT, MsgT]) Unsubscribe(sub *Subscription[ChannelT, MsgT])
- type EmptyMsgT
- type IntChannelT
- type StringChannelT
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker[ChannelT comparable, MsgT any] struct { // contains filtered or unexported fields }
Broker is a message broadcaster to multiple subscribers (channels).
func NewBroker ¶
func NewBroker[ChannelT comparable, MsgT any](defaultChannel ChannelT) *Broker[ChannelT, MsgT]
NewBroker creates a new Broker.
func (*Broker[ChannelT, MsgT]) Publish ¶
func (b *Broker[ChannelT, MsgT]) Publish(msg MsgT)
Publish publishes a message to the broker on default channel.
func (*Broker[ChannelT, MsgT]) PublishChannel ¶ added in v0.0.12
func (b *Broker[ChannelT, MsgT]) PublishChannel(channel ChannelT, msg MsgT)
PublishChannel publishes a message to the broker.
func (*Broker[ChannelT, MsgT]) Start ¶
func (b *Broker[ChannelT, MsgT]) Start()
Start starts the broker. Must be called before adding any new subscribers.
func (*Broker[ChannelT, MsgT]) Stop ¶ added in v0.0.14
func (b *Broker[ChannelT, MsgT]) Stop()
Stop stops the broker.
func (*Broker[ChannelT, MsgT]) Subscribe ¶
func (b *Broker[ChannelT, MsgT]) Subscribe() *Subscription[ChannelT, MsgT]
Subscribe subscribes to the broker on default channel.
func (*Broker[ChannelT, MsgT]) SubscribeChannel ¶ added in v0.0.12
func (b *Broker[ChannelT, MsgT]) SubscribeChannel(channel ChannelT) *Subscription[ChannelT, MsgT]
SubscribeChannel subscribes to the broker.
func (*Broker[ChannelT, MsgT]) Unsubscribe ¶
func (b *Broker[ChannelT, MsgT]) Unsubscribe(sub *Subscription[ChannelT, MsgT])
Unsubscribe unsubscribes from the broker.
type EmptyMsgT ¶ added in v0.0.13
type EmptyMsgT *struct{}
type Subscription ¶ added in v0.0.17
type Subscription[ChannelT comparable, MsgT any] struct { // contains filtered or unexported fields }
func NewSubscription ¶ added in v0.0.17
func NewSubscription[ChannelT comparable, MsgT any](broker *Broker[ChannelT, MsgT], channel ChannelT, msgCh chan MsgT) *Subscription[ChannelT, MsgT]
func (*Subscription[ChannelT, MsgT]) Channel ¶ added in v0.0.17
func (s *Subscription[ChannelT, MsgT]) Channel() chan MsgT
func (*Subscription[ChannelT, MsgT]) Close ¶ added in v0.0.17
func (s *Subscription[ChannelT, MsgT]) Close()
Close closes the subscription.
Click to show internal directories.
Click to hide internal directories.