pub struct HostDeliveryRecord { /* private fields */ }Expand description
One item’s journey to one host destination, as the ledger holds it.
Immutable: every transition returns a new record. The ledger decides whether a transition is allowed and writes the result, so the rules about what may follow what live in one place and an adapter cannot invent a shortcut through them.
Implementations§
Source§impl HostDeliveryRecord
impl HostDeliveryRecord
Sourcepub fn queued(
item: HostDeliveryItem,
target: HostDeliveryTarget,
policy: HostDeliveryPolicy,
created_at: OffsetDateTime,
) -> Result<Self, DomainError>
pub fn queued( item: HostDeliveryItem, target: HostDeliveryTarget, policy: HostDeliveryPolicy, created_at: OffsetDateTime, ) -> Result<Self, DomainError>
A new delivery, queued, with its identity derived from what it is.
pub const fn id(&self) -> &HostDeliveryId
pub const fn item(&self) -> &HostDeliveryItem
pub const fn target(&self) -> &HostDeliveryTarget
pub const fn policy(&self) -> &HostDeliveryPolicy
pub const fn state(&self) -> &HostDeliveryState
pub const fn attempt(&self) -> DeliveryAttempt
pub const fn created_at(&self) -> OffsetDateTime
pub const fn updated_at(&self) -> OffsetDateTime
pub const fn history(&self) -> &DeliveryHistory
Sourcepub fn is_offerable_at(&self, now: OffsetDateTime) -> bool
pub fn is_offerable_at(&self, now: OffsetDateTime) -> bool
Whether a host could be handed this delivery at now.
A live lease excludes everyone else; an expired one does not, and that is the whole of the exclusion rule. A delivery an activation adapter already pushed stays offerable, because reaching a host is not the same as the host having answered.
Sourcepub fn live_lease_at(&self, now: OffsetDateTime) -> Option<&HostDeliveryLease>
pub fn live_lease_at(&self, now: OffsetDateTime) -> Option<&HostDeliveryLease>
The lease currently excluding other holders, if one still does.
Sourcepub fn leased(&self, lease: HostDeliveryLease, now: OffsetDateTime) -> Self
pub fn leased(&self, lease: HostDeliveryLease, now: OffsetDateTime) -> Self
Handed out exclusively.
Sourcepub fn delivered(
&self,
receipt: HostActivationReceipt,
now: OffsetDateTime,
) -> Self
pub fn delivered( &self, receipt: HostActivationReceipt, now: OffsetDateTime, ) -> Self
Pushed to the host by an activation adapter.
Sourcepub fn acknowledged(
&self,
observation: HostDeliveryObservation,
now: OffsetDateTime,
) -> Self
pub fn acknowledged( &self, observation: HostDeliveryObservation, now: OffsetDateTime, ) -> Self
The host said what it saw.
Sourcepub fn processed(&self, action: ProcessedActionRef, now: OffsetDateTime) -> Self
pub fn processed(&self, action: ProcessedActionRef, now: OffsetDateTime) -> Self
The host acted, and named the act.
Sourcepub fn failed(&self, reason: DeliveryFailureReason, now: OffsetDateTime) -> Self
pub fn failed(&self, reason: DeliveryFailureReason, now: OffsetDateTime) -> Self
Given up on, with the attempt that gave up counted.
Sourcepub fn requeued(&self, now: OffsetDateTime) -> Self
pub fn requeued(&self, now: OffsetDateTime) -> Self
Back in the queue after a failed attempt, which is counted.
Sourcepub fn released(&self, now: OffsetDateTime) -> Self
pub fn released(&self, now: OffsetDateTime) -> Self
Back in the queue because a holder gave up its lease, uncounted.
Releasing is not failing: a host that hands work back untouched has not used up one of the delivery’s chances.
Sourcepub fn expired(&self, cause: DeliveryExpiryCause, now: OffsetDateTime) -> Self
pub fn expired(&self, cause: DeliveryExpiryCause, now: OffsetDateTime) -> Self
No longer worth making.
Sourcepub fn superseded(
&self,
by: Option<HostDeliveryId>,
now: OffsetDateTime,
) -> Self
pub fn superseded( &self, by: Option<HostDeliveryId>, now: OffsetDateTime, ) -> Self
Closed because its destination was replaced.
by is the delivery opened in its place, when the work follows.
Sourcepub fn re_addressed(
&self,
target: HostDeliveryTarget,
now: OffsetDateTime,
) -> Result<Self, DomainError>
pub fn re_addressed( &self, target: HostDeliveryTarget, now: OffsetDateTime, ) -> Result<Self, DomainError>
The same delivery offered to a different destination.
A new identity, because the destination is part of what a delivery is: the replacement can be superseded, acknowledged and counted on its own without disturbing the record it follows.