pubsub

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: Apache-2.0 Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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