Documentation
¶
Index ¶
- type Broker
- func (b *Broker) AcknowledgeAgent(ctx context.Context, agentID string, eventID string) error
- func (b *Broker) DurableDeliveryConfigured() bool
- func (b *Broker) Publish(event protocol.Event)
- func (b *Broker) SetNow(now func() (time.Time, error))
- func (b *Broker) Subscribe(ctx context.Context) <-chan protocol.Event
- func (b *Broker) SubscribeAgent(ctx context.Context, agentID string) (<-chan protocol.Event, error)
- func (b *Broker) SubscribeFrom(ctx context.Context, lastEventID string) <-chan protocol.Event
- func (b *Broker) SubscribeFromContext(ctx context.Context, lastEventID string) (<-chan protocol.Event, error)
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 (*Broker) AcknowledgeAgent ¶ added in v0.1.18
func (*Broker) DurableDeliveryConfigured ¶ added in v0.1.18
func (*Broker) SetNow ¶ added in v0.1.19
SetNow injects the domain clock before the broker starts serving requests.
func (*Broker) SubscribeAgent ¶ added in v0.1.18
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.