Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator[Key comparable] struct { // contains filtered or unexported fields }
Coordinator manages concurrent execution of sessions identified by Key. At most one drain is active per key; additional demands are coalesced into a single pending rerun.
func (*Coordinator[Key]) AwaitIdle ¶
func (c *Coordinator[Key]) AwaitIdle(key Key)
AwaitIdle blocks until no drain is active for the given key.
func (*Coordinator[Key]) Complete ¶
func (c *Coordinator[Key]) Complete(key Key) DemandType
Complete signals that a drain has finished. Call this when the session's work is done so the coordinator can start a pending rerun.
func (*Coordinator[Key]) HasPending ¶
func (c *Coordinator[Key]) HasPending(key Key) bool
HasPending returns true if there is a pending demand for the given key.
func (*Coordinator[Key]) Interrupt ¶
func (c *Coordinator[Key]) Interrupt(key Key)
Interrupt stops the current drain for the given key.
func (*Coordinator[Key]) Run ¶
func (c *Coordinator[Key]) Run(key Key) context.Context
Run starts an explicit drain for the given key. If a drain is already active, the demand is coalesced. Returns a context that is cancelled when the drain completes or is interrupted.
func (*Coordinator[Key]) Wake ¶
func (c *Coordinator[Key]) Wake(key Key)
Wake sends an advisory signal that new work may be available. If no drain is active, this is a no-op (the caller should use Run).
type DemandType ¶
type DemandType int
DemandType distinguishes explicit runs requests from advisory wake signals.
const ( DemandRun DemandType = iota // explicit drain — caller wants results DemandWake // advisory — new durable work may be available )