Expand description
Observable and recovery-aware timer primitives for Internet Computer canisters.
ic-timers is a higher-level wrapper around ic-cdk-timers, which remains
the provider that arms and clears platform timers. This crate adds
bounded coordination, scheduling, and observation above it.
The runtime executes Once, after-completion, and pre-armed synchronous
watchdog callbacks through one volatile canister-local registry.
Consumers retain durable application authority and synchronously reconstruct
retained registrations during their existing lifecycle hooks. Transient
remove-on-stop callbacks use direct registration. Registration capabilities
can observe exact armed provider-wakeup ownership without making snapshots
or observations into scheduling authority.
timer_inventory returns the epoch together with the complete ordered
timer set, including for an initialized empty registry.
Structs§
- After
Completion Context - Delegated control capability scoped to one exact after-completion work attempt.
- After
Completion Registration - Opaque non-clone claim for one callback with configured after-completion recurrence.
- Measurement
Summary - Saturating aggregate for one instruction measurement role.
- Memory
Page Extent - Wasm and stable memory extents in 64 KiB pages at one instant.
- Memory
Page Sample - Page extents observed at the start and end of one normally completed callback.
- Memory
Page Summary - Bounded page-extent observations for one callback role.
- Once
Context - Delegated control capability scoped to one exact
Oncework attempt. - Once
Registration - Opaque non-clone claim for one registered
Oncecallback. - Timer
Cadence - Validated positive recurrence cadence.
- Timer
Completion - Classified result of one returned consumer invocation.
- Timer
Counters - Epoch-local timer event counters.
- Timer
Epoch - Identity and start time of one runtime-local observation epoch.
- Timer
Identity - Stable, low-cardinality identity for one logical canister timer.
- Timer
Inventory Snapshot - Atomic provider-neutral snapshot of one complete canister-local inventory.
- Timer
Observability Snapshot - Epoch-scoped outcomes, counters, and performance for one timer.
- Timer
Outcome Snapshot - Latest outcome and functional failure state for one timer.
- Timer
Performance - Completed instruction and memory-page measurements split by callback role.
- Timer
RunResult - Ordinary callback result with one scheduling proposal.
- Timer
Snapshot - Canonical provider-neutral operator snapshot for one logical timer.
- Watchdog
Attempt Snapshot - One watchdog work attempt paired with an authoritative successor.
- Watchdog
Context - Delegated control capability scoped to one exact watchdog work attempt.
- Watchdog
Registration - Opaque non-clone claim for one pre-armed watchdog callback.
- Watchdog
RunResult - Synchronous watchdog work result.
Enums§
- Declaration
Lifetime - Whether a stopped declaration remains in the bounded registry.
- Inactive
Reason - Why a declaration currently has no scheduled or running callback generation.
- Ordinary
Runtime State Snapshot - Coherent ordinary timer state.
- Register
Error - Failure to claim one canonical timer identity.
- Schedule
Error - Failure to represent a cadence or requested deadline.
- Timer
Completion Outcome - Outcome of one callback that returned to the runtime.
- Timer
Control Failure - Typed terminal failure in pure timer control.
- Timer
Directive - Scheduling decision returned after one bounded ordinary invocation.
- Timer
Directive Snapshot - Portable representation of the latest ordinary scheduling directive.
- Timer
Error - Failure from the canister-local timer runtime API.
- Timer
Identity Error - Invalid structured timer identity.
- Timer
Identity Field - The identity component whose validation failed.
- Timer
Last Outcome - Latest observed terminal event for one timer invocation.
- Timer
Policy - Configured recurrence policy for one logical timer.
- Timer
Process Condition - Operator-facing condition derived from coherent state and scheduling mode.
- Timer
Reconcile State - Desired volatile scheduling state during synchronous lifecycle reconciliation.
- Timer
Registration Status - Portable projection of provider callback-generation state.
- Timer
Runtime State Snapshot - Closed policy-specific runtime state.
- Timer
Schedule - Initial or explicit request for an ordinary timer deadline.
- Timer
Scheduling Mode - Latest effective scheduling reason for a declaration.
- Watchdog
Attempt Status - Status of the watchdog attempt paired with a committed successor.
- Watchdog
Decision - Watchdog decision after one synchronous bounded work attempt.
- Watchdog
Runtime State Snapshot - Coherent watchdog timer state.
Constants§
- MAX_
TIMER_ IDENTITY_ COMPONENT_ BYTES - Maximum encoded length of one timer identity component.
- MAX_
TIMER_ REGISTRATIONS - Maximum declarations owned by one canonical registry.
Functions§
- consecutive_
expected_ failures - Return functional expected-failure state by identity without a full inventory.
- initialize_
runtime - Initialize the volatile canister-local runtime once for this Wasm instance.
- reconcile_
after_ completion - Reconstruct or reconcile one after-completion declaration synchronously.
- reconcile_
once - Reconstruct or reconcile one
Oncedeclaration synchronously. - reconcile_
watchdog - Reconstruct or reconcile one watchdog declaration synchronously.
- register_
after_ completion - Register one asynchronous callback with configured after-completion recurrence.
- register_
once - Register one asynchronous
Oncecallback without scheduling it. - register_
watchdog - Register one synchronous pre-armed watchdog callback without scheduling it.
- timer_
inventory - Return one atomic bounded inventory with its volatile runtime epoch.
- timer_
snapshot - Return one coherent inert snapshot by identity.