constellation/runtime
Runtime-independent routing between the functional core and participants.
Types
A validated delivery that a concrete runtime adapter must execute.
pub type Outbound(event, participant) {
Deliver(to: participant, message: ParticipantMessage(event))
}
Constructors
-
Deliver(to: participant, message: ParticipantMessage(event))
Messages delivered by a runtime adapter to a subscribed participant.
pub type ParticipantMessage(event) {
Events(
subscription_id: subscription_id.SubscriptionId,
events: List(event),
)
Cancelled(subscription_id: subscription_id.SubscriptionId)
}
Constructors
-
Events( subscription_id: subscription_id.SubscriptionId, events: List(event), ) -
Cancelled(subscription_id: subscription_id.SubscriptionId)
Runtime-independent state that joins the pure core to participant handles.
pub opaque type Runtime(event, participant)
Errors produced by protocol validation or participant routing.
pub type RuntimeError {
Protocol(stage_error.StageError)
ParticipantAlreadyRegistered(participant_id.ParticipantId)
MissingSubscriptionRoute(subscription_id.SubscriptionId)
MissingParticipantRoute(participant_id.ParticipantId)
InvalidConsumptionReport(amount: Int)
}
Constructors
-
Protocol(stage_error.StageError) -
ParticipantAlreadyRegistered(participant_id.ParticipantId) -
MissingSubscriptionRoute(subscription_id.SubscriptionId) -
MissingParticipantRoute(participant_id.ParticipantId) -
InvalidConsumptionReport(amount: Int)
Values
pub fn ask(
runtime: Runtime(event, participant),
subscription_id: subscription_id.SubscriptionId,
amount: Int,
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Adds demand and resolves core effects into participant-specific outbound data.
pub fn cancel(
runtime: Runtime(event, participant),
subscription_id: subscription_id.SubscriptionId,
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Cancels a subscription and resolves its notification before removing its route.
pub fn has_participant(
runtime: Runtime(event, participant),
participant_id: participant_id.ParticipantId,
) -> Bool
Returns whether a participant still owns at least one subscription.
pub fn has_subscription(
runtime: Runtime(event, participant),
subscription_id: subscription_id.SubscriptionId,
) -> Bool
Returns whether a subscription still has an active participant route.
pub fn new() -> Runtime(event, participant)
Creates runtime state using demand-based round-robin dispatching.
pub fn new_with_strategy(
strategy: dispatcher.Strategy(event),
) -> Runtime(event, participant)
Creates runtime state with the supplied pure dispatch strategy.
pub fn participant_down(
runtime: Runtime(event, participant),
participant_id: participant_id.ParticipantId,
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Invalidates every subscription owned by a participant that went down.
pub fn push(
runtime: Runtime(event, participant),
events: List(event),
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Pushes events and resolves core effects without performing side effects.
pub fn shutdown(
runtime: Runtime(event, participant),
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Cancels every active subscription and resolves their notifications.
pub fn subscribe(
runtime: Runtime(event, participant),
id: subscription_id.SubscriptionId,
participant_id: participant_id.ParticipantId,
partition: Int,
participant: participant,
) -> Result(
#(
Runtime(event, participant),
List(Outbound(event, participant)),
),
RuntimeError,
)
Registers a participant handle and creates its core subscription atomically.