Datasource

Trait Datasource 

Source
pub trait Datasource: Send + Sync {
    // Required methods
    fn consume<'life0, 'async_trait>(
        &'life0 self,
        id: DatasourceId,
        sender: Sender<(Updates, DatasourceId)>,
        cancellation_token: CancellationToken,
        metrics: Arc<MetricsCollection>,
    ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_types(&self) -> Vec<UpdateType>;
}
Expand description

A source of update streams that the pipeline can consume from.

Implement this trait if you provide data into the indexing pipeline (e.g., blocks, transactions, accounts, deletions, or Bitcoin blocks). Implementations should:

  • Be cancel-safe: return promptly when cancellation_token is cancelled
  • Backpressure-aware: respect the sender capacity, awaiting sends
  • Metrics-friendly: update gauges/counters to aid observability

Required Methods§

Source

fn consume<'life0, 'async_trait>( &'life0 self, id: DatasourceId, sender: Sender<(Updates, DatasourceId)>, cancellation_token: CancellationToken, metrics: Arc<MetricsCollection>, ) -> Pin<Box<dyn Future<Output = IndexerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start producing updates and forward them to the provided sender.

Implementations may batch updates and can send any of the Updates variants. The method should exit when cancellation_token is triggered or when a fatal error occurs.

Source

fn update_types(&self) -> Vec<UpdateType>

Advertise which update kinds this datasource will emit.

This is used by the pipeline to route updates efficiently and to activate only the relevant pipes/filters.

Implementors§