Skip to main content

IntervalHandler

Trait IntervalHandler 

Source
pub trait IntervalHandler: Send + Sync {
    // Required methods
    fn handle<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        block: &'life1 BlockSummary,
        ctx: &'life2 IndexContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), IndexerError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn interval(&self) -> u64;
    fn name(&self) -> &str;
}
Expand description

Handler that fires every N blocks.

Useful for periodic tasks such as taking snapshots, computing aggregates, flushing caches, or emitting metrics at regular block intervals.

Required Methods§

Source

fn handle<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, block: &'life1 BlockSummary, ctx: &'life2 IndexContext, ) -> Pin<Box<dyn Future<Output = Result<(), IndexerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called every interval() blocks.

The handler receives the current block summary and indexing context. Returning an error will propagate up to the index loop.

Source

fn interval(&self) -> u64

How often this handler should fire, measured in blocks.

For example, returning 100 means this handler fires on blocks 0, 100, 200, 300, etc.

Source

fn name(&self) -> &str

Human-readable handler name for logging and diagnostics.

Implementors§