pubsub

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker[T resource.Resource] struct {
	// contains filtered or unexported fields
}

Broker allows clients to publish events and subscribe to events

func NewBroker

func NewBroker[T resource.Resource](logger Logger) *Broker[T]

NewBroker constructs a pub/sub broker.

func (*Broker[T]) Publish

func (b *Broker[T]) Publish(t resource.EventType, payload T)

Publish an event to subscribers.

func (*Broker[T]) Shutdown added in v0.1.4

func (b *Broker[T]) Shutdown()

Shutdown the broker, terminating any subscriptions.

func (*Broker[T]) Subscribe

func (b *Broker[T]) Subscribe(ctx context.Context) <-chan resource.Event[T]

Subscribe subscribes the caller to a stream of events. The returned channel is closed when the broker is shutdown.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

Jump to

Keyboard shortcuts

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