concurrency

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 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.

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() chan MsgT

Subscribe subscribes to the broker.

func (*Broker[ChannelT, MsgT]) SubscribeChannel added in v0.0.12

func (b *Broker[ChannelT, MsgT]) SubscribeChannel(channel ChannelT) chan MsgT

SubscribeChannel subscribes to the broker.

func (*Broker[ChannelT, MsgT]) Unsubscribe

func (b *Broker[ChannelT, MsgT]) Unsubscribe(msgCh chan MsgT)

Unsubscribe unsubscribes from the broker.

func (*Broker[ChannelT, MsgT]) UnsubscribeChannel added in v0.0.12

func (b *Broker[ChannelT, MsgT]) UnsubscribeChannel(channel ChannelT, msgCh chan MsgT)

UnsubscribeChannel 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

Source Files

  • broker.go

Jump to

Keyboard shortcuts

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