pub struct Deadline { /* private fields */ }Expand description
A registered regulatory deadline for a single process stream.
Create with Deadline::new, persist via DeadlineStore::register, and
cancel via DeadlineStore::cancel when the process advances past the
deadline before it fires.
The label field identifies the deadline type (e.g.
"aperak-response-window") and is used by the scheduler to dispatch the
correct timeout command.
Implementations§
Source§impl Deadline
impl Deadline
Sourcepub fn new(
stream_id: StreamId,
process_id: ProcessId,
tenant_id: TenantId,
workflow_id: WorkflowId,
label: impl Into<Box<str>>,
due_at: OffsetDateTime,
) -> Self
pub fn new( stream_id: StreamId, process_id: ProcessId, tenant_id: TenantId, workflow_id: WorkflowId, label: impl Into<Box<str>>, due_at: OffsetDateTime, ) -> Self
Construct a new deadline.
deadline_id and created_at are generated automatically.
workflow_id must match the WorkflowId under which the owning
process was started (i.e. process.workflow_id().clone()). The
deadline scheduler uses it to reconstruct a ProcessIdentity and
route the TimeoutExpired command to the correct workflow type.
Sourcepub fn is_due(&self, now: OffsetDateTime) -> bool
pub fn is_due(&self, now: OffsetDateTime) -> bool
Return true when this deadline has passed relative to now.
use mako_engine::deadline::Deadline;
use mako_engine::ids::{ProcessId, StreamId, TenantId};
use mako_engine::version::WorkflowId;
use time::{Duration, OffsetDateTime};
let past = Deadline::new(
StreamId::new("process/x"),
ProcessId::new(),
TenantId::new(),
WorkflowId::new("gpke-supplier-change", "FV2025-10-01"),
"aperak-response-window",
OffsetDateTime::now_utc() - Duration::seconds(1),
);
assert!(past.is_due(OffsetDateTime::now_utc()));Sourcepub fn deadline_id(&self) -> DeadlineId
pub fn deadline_id(&self) -> DeadlineId
The unique identifier of this deadline.
Sourcepub fn process_id(&self) -> ProcessId
pub fn process_id(&self) -> ProcessId
The process instance this deadline belongs to.
Sourcepub fn workflow_id(&self) -> &WorkflowId
pub fn workflow_id(&self) -> &WorkflowId
The workflow that owns this process.
Used by the deadline scheduler to reconstruct a ProcessIdentity
and route the TimeoutExpired command to the correct workflow type.
Sourcepub fn label(&self) -> &str
pub fn label(&self) -> &str
The human-readable label identifying the deadline type (e.g.
"aperak-response-window").
Sourcepub fn due_at(&self) -> OffsetDateTime
pub fn due_at(&self) -> OffsetDateTime
When this deadline expires.
Sourcepub fn created_at(&self) -> OffsetDateTime
pub fn created_at(&self) -> OffsetDateTime
When this deadline was registered.