events

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

type Hub[T any] struct {
	// contains filtered or unexported fields
}

Hub is an event hub allowing broadcasting of events to subscribers.

func NewHub

func NewHub[T any]() *Hub[T]

func (*Hub[T]) Broadcast

func (h *Hub[T]) Broadcast(ctx context.Context, event T) error

Broadcast an event to all subscribers synchronously. Returns an error if the context expires before all subscribers were invoked.

func (*Hub[T]) Subscribe

func (h *Hub[T]) Subscribe(ctx context.Context) <-chan T

Subscribe to events. Returns a channel which will receives all broadcast events. The channel is closed whenever the context expires. Subscribers should receive events from the channel in a timely manner.

Jump to

Keyboard shortcuts

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