Trait ExtractionStateGateway

Source
pub trait ExtractionStateGateway {
    // Required methods
    fn get_state<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        chain: &'life2 Chain,
    ) -> Pin<Box<dyn Future<Output = Result<ExtractionState, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn save_state<'life0, 'life1, 'async_trait>(
        &'life0 self,
        state: &'life1 ExtractionState,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Store and retrieve state of Extractors.

Sometimes extractors may wish to persist their state across restart. E.g. substreams based extractors need to store the cursor, so they can continue processing where they left off.

Extractors are uniquely identified by a name and the respective chain which they are indexing.

Required Methods§

Source

fn get_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, chain: &'life2 Chain, ) -> Pin<Box<dyn Future<Output = Result<ExtractionState, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieves the state of an extractor instance from a storage.

§Parameters
  • name A unique name for the extractor instance.
  • chain The chain this extractor is indexing.
§Returns

Ok if the corrsponding state was retrieved successfully, Err in case the state was not found.

Source

fn save_state<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 ExtractionState, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Saves the state of an extractor instance to a storage.

Creates an entry if not present yet, or updates an already existing entry.

§Parameters
  • state The state of the extractor that needs to be saved.
§Returns

Ok, if state was stored successfully, Err if the state is not valid.

Implementors§