Skip to content

Add schedule_timer_until absolute-deadline timer#37

Open
pinodeca wants to merge 1 commit into
mainfrom
feature/schedule-timer-until
Open

Add schedule_timer_until absolute-deadline timer#37
pinodeca wants to merge 1 commit into
mainfrom
feature/schedule-timer-until

Conversation

@pinodeca

Copy link
Copy Markdown
Contributor

Closes #34.

Summary

Adds OrchestrationContext::schedule_timer_until(deadline: std::time::SystemTime) — an absolute wall-clock deadline timer that complements the existing relative schedule_timer(delay).

/// Schedule a timer that fires at an absolute wall-clock deadline.
pub fn schedule_timer_until(&self, deadline: std::time::SystemTime) -> DurableFuture<()>;

This matches domains where the target is intrinsically an absolute timestamp (cron ticks, SLAs, scheduled-at times — e.g. pg_durable's wait_for_schedule), removing the manual deadline - now clamp and the extra recorded utc_now reading the relative form requires.

Implementation

  • Converts deadline to ms-since-epoch and emits Action::CreateTimer { fire_at_ms } directly, reusing the existing timer future/replay path.
  • A deadline already in the past (or pre-epoch) clamps to fire_at_ms = 0, firing immediately on the next turn.
  • schedule_timer and schedule_timer_until now share a private schedule_timer_at_ms helper, keeping a single timer code path.

Backwards compatibility

Purely additive. No changes to existing signatures, the on-history action/event schema (Action::CreateTimer / TimerCreated already store an absolute fire_at_ms), the provider's visible_at handling, or replay semantics. Safe for rolling/mixed-version clusters.

Tests

  • schedule_timer_until_fires_at_deadline — fires at an absolute deadline.
  • schedule_timer_until_past_deadline_fires_immediately — past deadline fires immediately.

Validated with cargo nt, cargo clippy --all-targets --all-features (clean), and cargo test --doc.

Add OrchestrationContext::schedule_timer_until(deadline), an absolute
wall-clock deadline timer variant that complements the existing relative
schedule_timer. A deadline already in the past fires immediately.

The change is purely additive: it reuses the existing timer future and
replay path via a shared schedule_timer_at_ms helper, with no changes to
the action/event schema, the provider's visible_at handling, or replay
semantics.

Closes #34
@pinodeca pinodeca force-pushed the feature/schedule-timer-until branch from 57634ff to 28cc21e Compare June 23, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an absolute-deadline timer variant (e.g. schedule_timer_until(deadline))

1 participant