concurrency

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Index

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 IntChannelT added in v0.0.13

type IntChannelT int

type StringChannelT added in v0.0.13

type StringChannelT string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL