constellation/core
Deterministic protocol transitions for demand-driven stages.
Types
Protocol state owned by a stage.
Its representation is hidden so subscriptions, demand, dispatch order, and buffered events can only change through validated commands.
pub opaque type StageState(event)
Values
pub fn buffered_events(state: StageState(event)) -> List(event)
Returns buffered events in FIFO order for inspection and testing.
pub fn is_cancelled(
state: StageState(event),
id: subscription_id.SubscriptionId,
) -> Bool
Reports whether an ID belongs to a subscription cancelled in this stage.
pub fn new() -> StageState(event)
Creates an empty stage using demand-based round-robin dispatching.
pub fn new_with_strategy(
strategy: dispatcher.Strategy(event),
) -> StageState(event)
Creates an empty stage with the supplied dispatch strategy.
pub fn subscription(
state: StageState(event),
id: subscription_id.SubscriptionId,
) -> Result(subscription.Subscription, stage_error.StageError)
Looks up an active subscription and distinguishes cancelled IDs from unknown IDs.
pub fn update(
state: StageState(event),
command: command.Command(event),
) -> Result(
#(StageState(event), List(effect.Effect(event))),
stage_error.StageError,
)
Applies one protocol command and returns the new state plus runtime effects.