pubsub

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 2 Imported by: 5

README

Internal publish/subscribe library

GoDoc Build Status Go Report Card codecov

This library contains a handy type for internal publish/subscribe in a service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventRouter

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

EventRouter is a channel event router. It will route events (or entities) based on the EUI. There may be multiple subscribers to the same EUI and each will receive a separate event. The channels are buffered and if the subscribers can't keep up with the events they will be dropped silently by the router.

func NewEventRouter

func NewEventRouter(channelLength int) EventRouter

NewEventRouter creates a new event router

func (*EventRouter) Publish

func (e *EventRouter) Publish(id interface{}, event interface{})

Publish publishes a gateway event to subscribers. If there are no subscribers the event will be ignored. If the event subscribers can't keep up with the events the events will be silently dropped.

func (*EventRouter) Subscribe

func (e *EventRouter) Subscribe(identifier interface{}) <-chan interface{}

Subscribe subscribes to events for a particular gateway

func (*EventRouter) Unsubscribe

func (e *EventRouter) Unsubscribe(ch <-chan interface{})

Unsubscribe from channel

Jump to

Keyboard shortcuts

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