Skip to main content

SettlementHook

Trait SettlementHook 

Source
pub trait SettlementHook: Send + Sync {
    // Required method
    fn observe(
        &self,
        observation: &SettlementObservation,
        idempotency_key: &SettlementIdempotencyKey,
    ) -> Result<SettlementOutcome, SettlementHookError>;
}
Expand description

Hook routing finalized receipts through chio-settle/ops.rs.

The trait is dyn-compatible so the kernel observer slot can hold a Arc<dyn SettlementHook>. Implementations MUST:

  • Treat observe as observer-only relative to receipt bytes: the receipt is already signed and persisted before this method runs, and a hook MUST NOT mutate the receipt store.
  • Process observations in (finalized_at, receipt_id) order when batching is necessary (see SettlementObservation::ordering_key).
  • Be safe to call concurrently from a tokio runtime; the kernel observer slot does not serialize calls.
  • Keep observe bounded and local. An accepted outcome must follow a durable local write, not unbounded network I/O.
  • Make durable effects idempotent by receipt id. Lease recovery may replay an observation after a process exits or an invocation exceeds its lease. The supplied key makes the receipt identity and claim version explicit; hooks MUST deduplicate effects by receipt_id across row versions.

Required Methods§

Source

fn observe( &self, observation: &SettlementObservation, idempotency_key: &SettlementIdempotencyKey, ) -> Result<SettlementOutcome, SettlementHookError>

Observe a finalized receipt and route it through the settlement pipeline. See the trait-level docs for ordering and failure semantics.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§