broadcaster

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 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.

Documentation

Overview

Package broadcaster publishes events, which are changes, such as to a registry's providers, or its sessions, to the channels which watch it, so a server's clients see the changes as they happen

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

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

Broadcaster sends the events which are published to each channel which is watching it. It's watched from when it's made, until it stops running, and again when it runs again. It's safe to use concurrently.

func New

func New() *Broadcaster

New returns a broadcaster, which can be watched

func (*Broadcaster) Publish

func (b *Broadcaster) Publish(event schema.Event)

Publish sends the event to each channel which is watching, which can receive it now. It never waits, so it can be called under a lock, which keeps the events in the order of the changes.

func (*Broadcaster) Run

func (b *Broadcaster) Run(ctx context.Context) error

Run runs the broadcaster until the context is cancelled, when every watch ends, with ErrServiceUnavailable, as there will be no more events, such as when the server is stopping, and it isn't watched again until it runs again. It returns nil.

func (*Broadcaster) Watch

func (b *Broadcaster) Watch(ctx context.Context, ch chan<- schema.Event) (<-chan error, error)

Watch sends the events which are published to the channel, from when it returns, as it's watching before it does, until the context is cancelled, or the broadcaster stops running, as there will be no more events. It returns a channel which is sent nil when the context is cancelled, or ErrServiceUnavailable when the broadcaster stops running, once the watch has ended, after which no more events are sent to the channel, so it can be closed. A broadcaster which has stopped running isn't watched, and returns ErrServiceUnavailable, until it runs again. An event isn't waited for the channel to receive, so a channel which is full misses it, and one which needs every event should be buffered. Returns ErrBadParameter when there's no channel, and ErrConflict when the channel is watching already.

Directories

Path Synopsis
Package cmd has the broadcaster's commands and flags
Package cmd has the broadcaster's commands and flags
Package httpclient is a client of the broadcaster's HTTP API
Package httpclient is a client of the broadcaster's HTTP API
Package httphandler has the broadcaster's HTTP API, which streams its events to clients
Package httphandler has the broadcaster's HTTP API, which streams its events to clients

Jump to

Keyboard shortcuts

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