sui_indexer::handlers

Trait Handler

Source
pub trait Handler<T>: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn load<'life0, 'async_trait>(
        &'life0 self,
        batch: Vec<T>,
    ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_watermark_hi<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = IndexerResult<Option<u64>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_watermark_hi<'life0, 'async_trait>(
        &'life0 self,
        watermark: CommitterWatermark,
    ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn get_max_committable_checkpoint<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = IndexerResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Methods§

Source

fn name(&self) -> String

return handler name

Source

fn load<'life0, 'async_trait>( &'life0 self, batch: Vec<T>, ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

commit batch of transformed data to DB

Source

fn get_watermark_hi<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = IndexerResult<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

read high watermark of the table DB

Source

fn set_watermark_hi<'life0, 'async_trait>( &'life0 self, watermark: CommitterWatermark, ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates the relevant entries on the watermarks table with the full CommitterWatermark, which tracks the latest epoch, cp, and tx sequence number of the committed batch.

Provided Methods§

Source

fn get_max_committable_checkpoint<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = IndexerResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

By default, return u64::MAX, which means no extra waiting is needed before commiting; get max committable checkpoint, for handlers that want to wait for some condition before commiting, one use-case is the objects snapshot handler, which waits for the lag between snapshot and latest checkpoint to reach a certain threshold.

Implementors§