Skip to main content

UpstashSnapshotSource

Trait UpstashSnapshotSource 

Source
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§

Source

fn name(&self) -> &'static str

Human-readable name used in log messages.

Source

fn key(&self) -> &str

Redis key (already versioned).

Source

fn ttl_seconds(&self) -> u64

TTL in seconds for the SET EX command.

Source

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.

Source

fn on_success(&self, built_at_ms: u64, elapsed: Duration)

Called after a successful Redis write.

Source

fn on_skip(&self)

Called when next_payload returned None (unchanged).

Source

fn on_error(&self)

Called when either next_payload or the Redis write failed.

Provided Methods§

Source

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).

Implementors§