concurrency

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 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]() *Broker[ChannelT, MsgT]

NewBroker creates a new Broker.

func (*Broker[ChannelT, MsgT]) Close

func (b *Broker[ChannelT, MsgT]) Close()

Close stops the broker.

func (*Broker[ChannelT, MsgT]) Publish

func (b *Broker[ChannelT, MsgT]) Publish(channel ChannelT, msg MsgT)

Publish publishes a message to the broker.

func (*Broker[ChannelT, MsgT]) Start

func (b *Broker[ChannelT, MsgT]) Start()

Start starts the broker.

func (*Broker[ChannelT, MsgT]) Subscribe

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

Subscribe subscribes to the broker.

func (*Broker[ChannelT, MsgT]) Unsubscribe

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

Unsubscribe unsubscribes from the broker.

Source Files

  • broker.go

Jump to

Keyboard shortcuts

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