pub struct Resync { /* private fields */ }client only.Expand description
Builds the pull that brings a receiver back in sync.
use ocpi_kit::client::Resync;
use ocpi_kit::types::DateTime;
let last_success: DateTime = "2024-03-01T10:00:00Z".parse()?;
let now: DateTime = "2024-03-01T14:00:00Z".parse()?;
let plan = Resync::new().plan(last_success, now);
// The window starts before the last success, so nothing written around the cut is missed.
assert!(plan.query.date_from.unwrap() < last_success);
assert_eq!(plan.query.date_to, Some(now));Implementations§
Source§impl Resync
impl Resync
Sourcepub const fn with_overlap(self, overlap: Duration) -> Self
pub const fn with_overlap(self, overlap: Duration) -> Self
How far back the window reaches beyond the last successful pull.
Sourcepub const fn with_poll_interval(self, interval: Duration) -> Self
pub const fn with_poll_interval(self, interval: Duration) -> Self
The routine polling interval.
Sourcepub fn with_splay(self, fraction: f32) -> Self
pub fn with_splay(self, fraction: f32) -> Self
How much of the interval the splay may add or remove, as a fraction. Clamped to 0.0..=1.0.
Sourcepub const fn with_page_limit(self, limit: u64) -> Self
pub const fn with_page_limit(self, limit: u64) -> Self
Asks for a specific page size.
Sourcepub fn plan(&self, last_success: DateTime, now: DateTime) -> ResyncPlan
pub fn plan(&self, last_success: DateTime, now: DateTime) -> ResyncPlan
The query that catches up everything changed since last_success, up to now.
Sourcepub fn incremental(&self, last_success: DateTime) -> PageQuery
pub fn incremental(&self, last_success: DateTime) -> PageQuery
The query for a routine incremental pull, with no end bound.
An open-ended window keeps picking up objects written while the crawl runs, which is what
a steady-state poll wants; use Resync::plan when a closed interval matters.
Sourcepub fn splayed_interval(&self, seed: DateTime) -> Duration
pub fn splayed_interval(&self, seed: DateTime) -> Duration
The polling interval with splay applied, so a fleet of clients does not synchronise.
The splay is derived from seed rather than from a random number generator, so a given
client polls at a stable, uncorrelated offset and the behaviour is reproducible in tests.