pubsub

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package pubsub implements cluster-wide publishing and subscribing of events

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	logr.Logger
	// contains filtered or unexported fields
}

Broker is a pubsub Broker implemented using postgres' listen/notify

func NewBroker

func NewBroker(logger logr.Logger, db otf.DB) *Broker

func (*Broker) Publish added in v0.0.33

func (b *Broker) Publish(event otf.Event)

Publish sends an event to subscribers, via postgres to subscribers on other machines, and via the local broker to subscribers within the same process.

func (*Broker) Register

func (b *Broker) Register(t reflect.Type, getter otf.Getter)

Register a means of reassembling a postgres message back into an otf event

func (*Broker) Start

func (b *Broker) Start(ctx context.Context, isListening chan struct{}) error

Start the pubsub daemon; listen to notifications from postgres and forward to local pubsub broker. The listening channel is closed once the broker has started listening; from this point onwards published messages will be forwarded.

func (*Broker) Subscribe added in v0.0.33

func (b *Broker) Subscribe(ctx context.Context, prefix string) (<-chan otf.Event, error)

Subscribe subscribes the caller to a stream of events. Prefix is an identifier prefixed to a random string to helpfully identify the subscriber in metrics.

Jump to

Keyboard shortcuts

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