Skip to main content

MultiChainCoordinator

Struct MultiChainCoordinator 

Source
pub struct MultiChainCoordinator { /* private fields */ }
Expand description

Tracks and coordinates multiple chain indexer instances.

This is a state-management layer: it stores the runtime state of each chain and provides query/mutation primitives. The actual indexer tasks (which require an RPC provider) are started by the caller using the config returned from [chain_state].

Implementations§

Source§

impl MultiChainCoordinator

Source

pub fn new(config: MultiChainConfig) -> Self

Create a new coordinator from the given config.

All chains in config.chains are registered in the IndexerState::Idle state — they are not started automatically.

Source

pub async fn add_chain(&self, config: IndexerConfig) -> Result<(), IndexerError>

Register a new chain at runtime.

Returns an error if a chain with the same id already exists.

Source

pub async fn remove_chain(&self, chain_id: &str) -> Result<(), IndexerError>

Remove a chain from the coordinator.

The caller is responsible for ensuring the underlying task is stopped before calling this method. Returns an error if the chain is not found.

Source

pub async fn pause_chain(&self, chain_id: &str) -> Result<(), IndexerError>

Pause a chain by transitioning it to IndexerState::Stopping.

Only chains in an active state (Backfilling, Live, ReorgRecovery) can be paused. Returns an error if the chain is not found or not active.

Source

pub async fn resume_chain(&self, chain_id: &str) -> Result<(), IndexerError>

Resume a paused or stopped chain by transitioning it back to IndexerState::Backfilling.

Returns an error if the chain is not found or is already active.

Source

pub async fn update_state( &self, chain_id: &str, new_state: IndexerState, error: Option<String>, ) -> Result<(), IndexerError>

Update the state of a chain. Called by the underlying indexer task.

Source

pub async fn record_block( &self, chain_id: &str, block_number: u64, events: u64, ) -> Result<(), IndexerError>

Record a new block processed by a chain.

Source

pub async fn health(&self) -> Vec<ChainHealth>

Returns health snapshots for every registered chain.

Source

pub async fn chain_health(&self, chain_id: &str) -> Option<ChainHealth>

Returns health for a specific chain by id.

Source

pub async fn chain_state(&self, chain_id: &str) -> Option<ChainInstance>

Returns a clone of the runtime state for a single chain.

Source

pub async fn chains(&self) -> Vec<String>

Returns the ids of all registered chains.

Source

pub async fn active_chains(&self) -> Vec<String>

Returns the ids of all chains that are actively indexing.

Source

pub async fn is_all_healthy(&self) -> bool

Returns true when every registered chain is healthy (active, no error).

Source

pub async fn all_past_block(&self, min_block: u64) -> bool

Returns true when every registered chain has reached at least min_block.

Source

pub async fn chain_count(&self) -> usize

Returns the number of registered chains.

Source

pub fn config(&self) -> &MultiChainConfig

Returns the coordinator config.

Source

pub fn uptime(&self) -> Duration

Returns how long the coordinator has been running.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more