Skip to main content

DerivedStateConsumer

Trait DerivedStateConsumer 

pub trait DerivedStateConsumer:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn state_version(&self) -> u32;
    fn extension_version(&self) -> &'static str;
    fn load_checkpoint(
        &mut self,
    ) -> Result<Option<DerivedStateCheckpoint>, DerivedStateConsumerFault>;
    fn apply(
        &mut self,
        envelope: &DerivedStateFeedEnvelope,
    ) -> Result<(), DerivedStateConsumerFault>;
    fn flush_checkpoint(
        &mut self,
        checkpoint: DerivedStateCheckpoint,
    ) -> Result<(), DerivedStateConsumerFault>;

    // Provided methods
    fn config(&self) -> DerivedStateConsumerConfig { ... }
    fn setup(
        &mut self,
        _ctx: DerivedStateConsumerContext,
    ) -> Result<(), DerivedStateConsumerSetupError> { ... }
    fn shutdown(&mut self, _ctx: DerivedStateConsumerContext) { ... }
}
Expand description

Stateful consumer interface for the dedicated derived-state feed scaffold.

This trait is intentionally synchronous for the initial scaffold so implementers can model deterministic state application and checkpointing before runtime dispatch details are fixed.

Required Methods§

fn name(&self) -> &'static str

Stable consumer name used in logs and telemetry.

fn state_version(&self) -> u32

Consumer-owned schema/state version written into durable checkpoints.

fn extension_version(&self) -> &'static str

Stable consumer implementation version written into durable checkpoints.

fn load_checkpoint( &mut self, ) -> Result<Option<DerivedStateCheckpoint>, DerivedStateConsumerFault>

Loads the most recent durable checkpoint when present.

§Errors

Returns a structured fault when the checkpoint cannot be loaded or decoded.

fn apply( &mut self, envelope: &DerivedStateFeedEnvelope, ) -> Result<(), DerivedStateConsumerFault>

Applies one feed envelope in canonical sequence order.

§Errors

Returns a structured fault when the consumer cannot apply the event.

fn flush_checkpoint( &mut self, checkpoint: DerivedStateCheckpoint, ) -> Result<(), DerivedStateConsumerFault>

Persists a durable checkpoint for later replay or recovery.

§Errors

Returns a structured fault when checkpoint persistence fails.

Provided Methods§

fn config(&self) -> DerivedStateConsumerConfig

Returns static feed subscriptions requested by this consumer.

fn setup( &mut self, _ctx: DerivedStateConsumerContext, ) -> Result<(), DerivedStateConsumerSetupError>

Called once after the worker thread is created and before any replay or live apply.

§Errors

Returns a startup error when the consumer cannot initialize its runtime-owned resources.

fn shutdown(&mut self, _ctx: DerivedStateConsumerContext)

Called once before the worker thread exits.

Implementors§