pubsub

package
v0.0.0-...-d8f8204 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

type PubSub struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PubSub holds publishers and subscribers

func New

func New() *PubSub

New inits a PubSub system

func (*PubSub) HasSubscribers

func (ps *PubSub) HasSubscribers() bool

HasSubscribers returns true if pubsub system has subscribers

func (*PubSub) Publish

func (ps *PubSub) Publish(item interface{})

Publish message to the subscribers. Note that publish is always nob-blocking send so that we don't block on slow receivers. Hence receivers should use buffered channel so as not to miss the published events.

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(subCh chan interface{}, doneCh chan struct{}, filter func(entry interface{}) bool)

Subscribe - Adds a subscriber to pubsub system

type Sub

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

Sub - subscriber entity.

Jump to

Keyboard shortcuts

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