docs: timers guide#9
Conversation
Review: TimersMust fix
Suggestions
Verified
|
Review feedback (marc0olo):
- Add "Common patterns" section (cleanup, data aggregation, state transitions)
- Add FAQ section from portal (DTS, await behavior, overlapping timers)
- Fix heartbeat interval wording to match portal ("close to finalization rate")
- Add time conversion packages (Motoko mops, Rust crates)
- Add limitations section (relative time only, security warning, resolution)
- Add "What's next" links to lifecycle, concepts, and costs pages
Source-verified fixes (from .sources/cdk-rs and .sources/motoko-core):
- Update all Rust snippets to ic-cdk-timers v1.0.0 API: set_timer takes
a future (async {}), set_timer_interval takes FnMut() -> Future (|| async {})
- Remove obsolete ic_cdk::spawn pattern (no longer needed)
- Add set_timer_interval_serial for state-mutating periodic tasks
- Add idempotency warning and CDK rate limits (250 global, 5 per timer)
- Verify Motoko postupgrade spelling and duration 0 behavior against source
The previous wording claimed system time is the same for all messages in a round. The actual guarantee from motoko-core Time.mo:42 is that time is constant within a single message execution only.
1e7a6e5 to
21bf406
Compare
|
Feedback addressed: From review:
Source-verified fixes (from new
Verification status: All 20 technical claims verified against |
Summary
ic-cdk-timersv1.0.0) and Motoko (mo:core/Timerv2.1.0): one-shot, recurring, serial, and cancellationic_cdk::api::time()/Time.now()) with per-message consistency guaranteeAll Rust snippets verified against
ic-cdk-timersv1.0.0 (set_timertakes futures,set_timer_intervaltakesFnMut() -> Future). All Motoko snippets verified againstmotoko-corev2.1.0 and compiler v1.3.0.Sync recommendation
Informed by
dfinity/portalperiodic-tasks-timers.mdx + time-and-timestamps.mdx,dfinity/cdk-rsic-cdk-timers/src/lib.rs, andcaffeinelabs/motoko-coresrc/Timer.mo