events

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 9 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 struct {
	// contains filtered or unexported fields
}

Broker fans out events to live subscribers and replays recent history to resuming ones. A single mutex guards nextID, history, AND subscribers so that Publish and subscribeFrom are strictly serialized: an event is either captured in a new subscriber's replay snapshot (published before the subscribe critical section) or fanned out to it (published after), never both (which would double-deliver and break the client's per-frame ACK) and never neither (the delivery gap this collapse closes). Do not reintroduce a second lock: the fan-out below runs inside the critical section and relies on being serialized against subscriber registration/removal.

func NewBroker

func NewBroker(delivery ...attachmentDeliveryStore) *Broker

func (*Broker) AcknowledgeAgent added in v0.1.18

func (b *Broker) AcknowledgeAgent(ctx context.Context, agentID string, eventID string) error

func (*Broker) DurableDeliveryConfigured added in v0.1.18

func (b *Broker) DurableDeliveryConfigured() bool

func (*Broker) Publish

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

func (*Broker) SetNow added in v0.1.19

func (b *Broker) SetNow(now func() (time.Time, error))

SetNow injects the domain clock before the broker starts serving requests.

func (*Broker) Subscribe

func (b *Broker) Subscribe(ctx context.Context) <-chan protocol.Event

func (*Broker) SubscribeAgent added in v0.1.18

func (b *Broker) SubscribeAgent(ctx context.Context, agentID string) (<-chan protocol.Event, error)

SubscribeAgent establishes a persistent per-agent delivery baseline on the first attachment and replays every stored message event after the last ACK on later attachments. The broker lock makes replay registration atomic with live fan-out.

func (*Broker) SubscribeFrom

func (b *Broker) SubscribeFrom(ctx context.Context, lastEventID string) <-chan protocol.Event

func (*Broker) SubscribeFromContext added in v0.1.19

func (b *Broker) SubscribeFromContext(ctx context.Context, lastEventID string) (<-chan protocol.Event, error)

SubscribeFromContext reports failures before registering a subscriber.

Jump to

Keyboard shortcuts

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