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
observeas 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 (seeSettlementObservation::ordering_key). - Be safe to call concurrently from a tokio runtime; the kernel observer slot does not serialize calls.
- Keep
observebounded 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_idacross row versions.
Required Methods§
Sourcefn observe(
&self,
observation: &SettlementObservation,
idempotency_key: &SettlementIdempotencyKey,
) -> Result<SettlementOutcome, SettlementHookError>
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".