eventbus

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventKindNotFound = errors.New("eventbus: event kind does not exist")
	ErrEventNotFound     = errors.New("eventbus: event could not be found")
)

Functions

This section is empty.

Types

type EventBus

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

EventBus is a central handler for all things related to events within the application.

func New

func New(storage storage.DB, retention time.Duration, pruneInterval time.Duration) (*EventBus, error)

New create a new instance of the eventbus and populates the log from disk.

func (*EventBus) Get

func (eb *EventBus) Get(id int64) (events.Event, error)

Get returns a single event by id. Returns a eventbus.ErrEventNotFound if the event could not be located.

func (*EventBus) GetAll

func (eb *EventBus) GetAll(reverse bool) <-chan events.Event

GetAll returns all events. Returns events from oldest to newest unless reverse parameter is set.

func (*EventBus) Publish

func (eb *EventBus) Publish(evt events.EventTypeDetails) int64

Publish allows caller to emit a new event to the eventbus. Might block until it can publish to all listeners.

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(kind events.EventType) (Subscription, error)

Subscribe returns a channel in which the caller can listen for all events of a particular type.

func (*EventBus) Unsubscribe

func (eb *EventBus) Unsubscribe(sub Subscription)

type Subscription

type Subscription struct {
	Events chan events.Event
	// contains filtered or unexported fields
}

Subscription is a representation of a new Subscription to a certain topic.

Jump to

Keyboard shortcuts

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