Skip to main content

Timers

Struct Timers 

Source
pub struct Timers { /* private fields */ }

Implementations§

Source§

impl Timers

Source

pub fn new() -> Timers

Source

pub fn restore(&mut self, records: Vec<TimerRecord>)

Adopt restored records.

Source

pub fn arm( &mut self, d: &Durable, deadline_ms: u64, owner: Value, payload: Value, ) -> Result<String, StoreError>

Arm a durable timer. owner names who to notify ({"kind": "tool", "node": n, "req": id} / {"kind": "step", "run": r, "step": s} / …).

Source

pub fn disarm(&mut self, d: &Durable, id: &str) -> Result<(), StoreError>

Disarm (delete) a timer — armed or still settling (a cancelled run’s timers arrive here through owned_by, which reports both, so a row that fired moments ago is deleted rather than left to re-fire after a restart).

Source

pub fn fire(&mut self, d: &Durable, now: u64) -> Vec<TimerRecord>

Fire every due timer: returns them, removed from the wheel but NOT yet from the store.

The caller runs the effect (on_timer) after this returns, and that effect is only durable once the same tick reaches its checkpoint. Deleting the row first opens a window in which a crash loses BOTH the timer and its consequence: the suspended step the timer owned would have nothing left to wake it — poll_waits does not look at the timer-backed wait kinds — so the run wedges forever while the reactor keeps spinning at its 5 ms floor around a step that can never advance. Effects are at-least-once by design (RFC 0025 §7: every effect carries an idempotency key and a replay is expected), so the survivable direction is the other one — keep the row until the consequence is durable and let a crash inside the window re-fire the timer on restore.

Source

pub fn settle(&mut self, d: &Durable)

Delete the rows of timers whose effect has been checkpointed. Idempotent (a delete that is lost re-fires the timer once more, which is safe).

Source

pub fn contains(&self, id: &str) -> bool

Whether id is still armed (a settling timer has already fired).

Source

pub fn next_deadline(&self) -> Option<u64>

The earliest deadline (for idle decisions).

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn owned_by(&self, pred: impl Fn(&Value) -> bool) -> Vec<String>

Timers owned by something matching pred — armed and settling, so a cancelled run takes its just-fired rows with it.

Source

pub fn status(&self) -> Value

Trait Implementations§

Source§

impl Default for Timers

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more