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 modules, 4 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.

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
⌂ 换网址