eventbus

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 3 Imported by: 4

README

GitHub Test Status GoDoc License Go Report CodeFactor Maintainability Codecov

Follow on Twitter Chat LinkedIn Buy Me A Coffee PayPal Venmo Cash App GitHub Sponsors

Simple publish/subscribe asynchronous event bus

Licensing License

This program is free software: you can redistribute it and/or modify it under the terms of the Apache license.

Documentation

Index

Constants

View Source
const (
	PriorityLow int = iota
	PriorityHigh
	PriorityCritical
)

The priority levels for event bus messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBus

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

EventBus handles sending and receiving events.

func NewEventBus

func NewEventBus() *EventBus

NewEventBus initializes and returns an EventBus object.

func (*EventBus) Publish

func (eb *EventBus) Publish(topic string, p int, args ...interface{})

Publish sends req on the channel labeled with name.

func (*EventBus) Stop

func (eb *EventBus) Stop()

Stop prevents any additional requests from being sent.

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(topic string, fn interface{})

Subscribe registers the callback to be executed for all requests on the topic.

func (*EventBus) Unsubscribe

func (eb *EventBus) Unsubscribe(topic string, fn interface{})

Unsubscribe deregisters the callback from the topic.

Jump to

Keyboard shortcuts

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