pub trait UpstashSnapshotSource: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn key(&self) -> &str;
fn ttl_seconds(&self) -> u64;
fn next_payload<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, u64)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn on_success(&self, built_at_ms: u64, elapsed: Duration);
fn on_skip(&self);
fn on_error(&self);
// Provided method
fn min_interval(&self) -> Option<Duration> { ... }
}Expand description
A single snapshot source that produces compressed payloads for the batch publisher.
Required Methods§
Sourcefn ttl_seconds(&self) -> u64
fn ttl_seconds(&self) -> u64
TTL in seconds for the SET EX command.
Sourcefn next_payload<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, u64)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn next_payload<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, u64)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Produce the next payload. Returns Ok(Some((compressed_bytes, built_at_ms))) when a new
snapshot is available, Ok(None) when the data is unchanged since the last call, or
Err on failure.
Sourcefn on_success(&self, built_at_ms: u64, elapsed: Duration)
fn on_success(&self, built_at_ms: u64, elapsed: Duration)
Called after a successful Redis write.
Provided Methods§
Sourcefn min_interval(&self) -> Option<Duration>
fn min_interval(&self) -> Option<Duration>
Minimum interval between publishes for this source. The scheduler ticks
at 1s but sources with a longer cadence (e.g. marquee movers at 15s)
return None from next_payload until enough time has passed.
Default: no throttle (eligible every tick).