Skip to main content

RebuildDriver

Trait RebuildDriver 

Source
pub trait RebuildDriver {
    // Required methods
    async fn rebuild(
        &self,
        id: &ProjectionId,
    ) -> Result<RebuildOutcome, RuntimeError>;
    fn can_rebuild(&self, id: &ProjectionId) -> bool;
}
Expand description

External rebuild driver trait (KR-003).

Implement this trait in your orchestration layer to drive projection rebuilds based on tracker health state. The runtime never calls this trait itself — it is for external callers that poll projection health and decide when to rebuild.

§Example flow

1. Orchestrator polls tracker.health(&id) -> Stale
2. Orchestrator calls driver.rebuild(&id) -> Ok(outcome)
3. Orchestrator calls runtime.record_projection_build(id, ...) or
   runtime.record_projection_failure(id, error)
4. Tracker state transitions to Healthy or remains Stale

Required Methods§

Source

async fn rebuild( &self, id: &ProjectionId, ) -> Result<RebuildOutcome, RuntimeError>

Execute a rebuild for the given projection.

Returns a RebuildOutcome on success, or an error if the rebuild could not be attempted. The caller is responsible for reporting the outcome back to the tracker via record_projection_build() or record_projection_failure().

Source

fn can_rebuild(&self, id: &ProjectionId) -> bool

Check whether this driver can handle a rebuild for the given projection.

Returns false if the projection kind/scope is not supported by this driver. The orchestrator can use this to skip unsupported projections without error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§