Skip to main content

CronWatermarkStore

Trait CronWatermarkStore 

Source
pub trait CronWatermarkStore: Send + Sync {
    // Required methods
    fn read<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn advance<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source: &'life1 str,
        cursor: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<DateTime<Utc>, KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        source: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, KernelError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Available on crate feature harness-kernel only.
Expand description

Where each cron wake source left off (spec 3.2 §7.4, §7.13): the instant through which its ticks are accounted for, by source name.

A cursor only moves forward: advance keeps the later of the stored cursor and the one given, so replicas that watch one schedule and write in any order never move it back, and a tick already accounted for is never planned again.

§Example

use adk_kernel::CronWatermarkStore;
use adk_kernel::stores::InMemoryCronWatermarkStore;
use chrono::{TimeZone, Utc};

let store = InMemoryCronWatermarkStore::new();
let nine = Utc.with_ymd_and_hms(2026, 10, 24, 9, 0, 0).unwrap();
let eight = Utc.with_ymd_and_hms(2026, 10, 24, 8, 0, 0).unwrap();
assert_eq!(store.advance("nightly", nine).await?, nine);
// An earlier cursor, from a replica behind this one, leaves it where it is.
assert_eq!(store.advance("nightly", eight).await?, nine);
assert_eq!(store.read("nightly").await?, Some(nine));

Required Methods§

Source

fn read<'life0, 'life1, 'async_trait>( &'life0 self, source: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

The cursor of source, or None when it never ran.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn advance<'life0, 'life1, 'async_trait>( &'life0 self, source: &'life1 str, cursor: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<DateTime<Utc>, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Moves the cursor of source to cursor unless it is already later, and returns the cursor as stored. Cursors keep microseconds.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, source: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, KernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Deletes the cursor of source; false when there was none.

§Errors

Returns KernelError::Store when the backend fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§