constellation/domains/subscription
Subscription identity, partition, and demand values.
Types
An active downstream subscription and its remaining demand.
pub opaque type Subscription
Errors returned while changing subscription demand.
pub type SubscriptionError {
InvalidDemand(Int)
InsufficientDemand
}
Constructors
-
InvalidDemand(Int) -
InsufficientDemand
Values
pub fn add_demand(
subscription: Subscription,
amount: Int,
) -> Result(Subscription, SubscriptionError)
Adds positive downstream capacity without reactivating cancelled subscriptions.
pub fn consume_demand(
subscription: Subscription,
amount: Int,
) -> Result(Subscription, SubscriptionError)
Consumes positive capacity while preventing demand from becoming negative.
pub fn demand(subscription: Subscription) -> Int
Returns the subscription’s remaining event capacity.
pub fn id(
subscription: Subscription,
) -> subscription_id.SubscriptionId
Returns this subscription’s stable identity.
pub fn new(
id: subscription_id.SubscriptionId,
participant: participant_id.ParticipantId,
) -> Subscription
Creates an active subscription with zero demand in the default partition.
pub fn new_with_partition(
id: subscription_id.SubscriptionId,
participant: participant_id.ParticipantId,
partition: Int,
) -> Subscription
Creates an active subscription with zero demand in a dispatcher partition.
pub fn participant_id(
subscription: Subscription,
) -> participant_id.ParticipantId
Returns the participant that owns this subscription.
pub fn partition(subscription: Subscription) -> Int
Returns the dispatcher partition assigned to this subscription.