pubsub

package
v0.1.0-cvefix.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 2 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) NumSubscribers

func (ps *PubSub) NumSubscribers() int32

NumSubscribers returns the number of current 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