pubsub

package
v0.0.2-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRunning = errors.New("not running")

ErrNotRunning is the error with message "not running"

Functions

func AfterThreadStart

func AfterThreadStart(t *testing.T) <-chan time.Time

AfterThreadStart waits for the duration of delay thread start

func SleepForThreadStart

func SleepForThreadStart(t *testing.T)

SleepForThreadStart pass go routine for the duration of delay thread start

Types

type Bus

type Bus interface {
	Publisher
	Subscribe() (Subscriber, error)
	Close()
	Done() <-chan struct{}
}

Bus is an async event bus that allows subscriptions to behave as a bus themselves. When an event is published, it is sent to all subscribers asynchronously - a subscriber cannot block other subscribers.

NOTE: this should probably be in util/event or something (not in provider/event)

func NewBus

func NewBus() Bus

NewBus runs a new bus and returns bus details

type Event

type Event interface{}

Event interface

type Publisher

type Publisher interface {
	Publish(Event) error
}

type Subscriber

type Subscriber interface {
	Events() <-chan Event
	Clone() (Subscriber, error)
	Close()
	Done() <-chan struct{}
}

Subscriber emits events it sees on the channel returned by Events(). A Clone() of a subscriber will emit all events that have not been emitted from the cloned subscriber. This is important so that events are not missed when adding subscribers for sub-components (see `provider/bidengine/{service,order}.go`)

Jump to

Keyboard shortcuts

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