msg

package
v0.0.0-...-72a1578 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Msg

type Msg struct {
	// contains filtered or unexported fields
}

Msg is

func New

func New(sender uuid.UUID, topic Topic, payload interface{}) Msg

New is the Msg factor function

func (Msg) PID

func (m Msg) PID() uuid.UUID

PID returns the sender's PID

func (Msg) Payload

func (m Msg) Payload() interface{}

Payload returns the message data

func (Msg) Topic

func (m Msg) Topic() Topic

Topic returns the message topic

type PubSub

type PubSub struct {
	// contains filtered or unexported fields
}

func NewPublisher

func NewPublisher(pid uuid.UUID) *PubSub

func (*PubSub) Forward

func (p *PubSub) Forward(m Msg)

func (*PubSub) Publish

func (p *PubSub) Publish(topic Topic, payload interface{})

func (*PubSub) Stop

func (p *PubSub) Stop()

Stop closes all subscription channels owned by the publisher

func (*PubSub) Subscribe

func (p *PubSub) Subscribe(pid uuid.UUID, topic Topic) (<-chan Msg, error)

Subscribe returns a channel on which the pubisher writes the specified topic

func (*PubSub) Unsubscribe

func (p *PubSub) Unsubscribe(pid uuid.UUID)

Unsubscribe closes all channels associated with a PID

type Publisher

type Publisher interface {
	Subscribe(pid uuid.UUID, topic Topic) (<-chan Msg, error)
	Unsubscribe(pid uuid.UUID)
}

type Topic

type Topic int
const (
	Status Topic = iota
	Control
	Config
)

Jump to

Keyboard shortcuts

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