events

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Data  string
	Topic string
}

type EventBus

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

func New

func New() *EventBus

func (*EventBus) Publish

func (e *EventBus) Publish(topic string, data string)

Publish data to a given topic.

func (*EventBus) PublishJson

func (e *EventBus) PublishJson(topic string, data interface{}) error

func (*EventBus) Subscribe

func (e *EventBus) Subscribe(topic string, ch chan Event)

Subscribe to an emitter topic using a channel.

func (*EventBus) Unsubscribe

func (e *EventBus) Unsubscribe(topic string, ch chan Event)

Unsubscribe a channel from a given topic.

func (*EventBus) UnsubscribeAll

func (e *EventBus) UnsubscribeAll()

Removes all of the event listeners for the server. This is used when a server is being deleted to avoid a bunch of de-reference errors cropping up. Obviously should also check elsewhere and handle a server reference going nil, but this won't hurt.

Jump to

Keyboard shortcuts

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