MARS documentation
Rust librariesmars-server

mars-server · anchor

Public declarations and documentation for mars-server::anchor.

Package: mars-server · Workspace version: 0.1.0 · Module: anchor

This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.

anchor::config

Provider-neutral durable anchor outbox execution.

The worker owns no Sigil types and never holds a database transaction while invoking [AnchorPort]. Production uses the Sigil SDK adapter; deterministic adapters remain explicitly test-gated.

pub mod config;

Source line: 7.

anchor::sigil

#[cfg(feature = "sigil")]
pub mod sigil;

Source line: 9.

anchor::test_adapter

#[cfg(any(test, feature = "test-anchor"))]
pub mod test_adapter;

Source line: 11.

pub use config::AnchorWorkerConfig;

pub use config::AnchorWorkerConfig;

Source line: 23.

anchor::AnchorSubmission

Complete MARS-owned payload handed to an external ledger adapter.

#[derive(Debug, Clone, PartialEq)]
pub struct AnchorSubmission {
pub intent_id: String,
pub entry_did: String,
pub sequence: u64,
pub operation: AnchorOperation,
pub payload: serde_json::Value,
pub created_at: DateTime<Utc>
}

Source line: 27.

anchor::AnchorPortReceipt

Provider-neutral submitted or confirmed observation.

#[derive(Debug, Clone, PartialEq)]
pub struct AnchorPortReceipt {
pub receipt_key: String,
pub transaction_id: String,
pub state: AnchorReceiptState,
pub block_height: Option<u64>,
pub proof: Option<serde_json::Value>,
pub observed_at: DateTime<Utc>
}

Source line: 51.

anchor::AnchorPortReceipt::submitted

#[must_use]
pub fn submitted(
        receipt_key: impl Into<String>,
        transaction_id: impl Into<String>,
        observed_at: DateTime<Utc>,
    ) -> Self;

Source line: 62.

anchor::AnchorPortReceipt::confirmed

#[must_use]
pub fn confirmed(
        receipt_key: impl Into<String>,
        transaction_id: impl Into<String>,
        block_height: u64,
        observed_at: DateTime<Utc>,
    ) -> Self;

Source line: 78.

anchor::AnchorPortError

Explicitly classified adapter failure.

#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum AnchorPortError {
    #[error("retryable anchor adapter failure: {0}")]
    Retryable(String),
    #[error("permanent anchor adapter failure: {0}")]
    Permanent(String),
}

Source line: 137.

anchor::AnchorPortError::retryable

#[must_use]
pub fn retryable(message: impl Into<String>) -> Self;

Source line: 146.

anchor::AnchorPortError::permanent

#[must_use]
pub fn permanent(message: impl Into<String>) -> Self;

Source line: 151.

anchor::AnchorPort

Ledger adapter boundary owned by MARS.

Implementations must honor submission.intent_id as the idempotency key. submit may therefore be called again after an expired lease when a worker crashed after the external side effect but before receipt persistence.

#[async_trait]
pub trait AnchorPort: Send + Sync {
    /// Emergency backpressure gate checked before the worker leases any row.
    fn submissions_paused(&self) -> bool ;

    async fn submit(
        &self,
        submission: &AnchorSubmission,
    ) -> Result<AnchorPortReceipt, AnchorPortError>;

    async fn observe(
        &self,
        submission: &AnchorSubmission,
        receipt: &AnchorPortReceipt,
    ) -> Result<AnchorPortReceipt, AnchorPortError>;
}

Source line: 166.

anchor::AnchorReadinessPort

Provider-neutral deep-readiness probe retained by protected health checks.

#[async_trait]
pub trait AnchorReadinessPort: Send + Sync {
    async fn check(&self) -> Result<serde_json::Value, AnchorPortError>;
}

Source line: 186.

anchor::WorkerRunState

Why one worker pass did or did not execute.

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WorkerRunState {
    Disabled,
    AdapterUnregistered,
    SubmissionPaused,
    Executed,
}

Source line: 192.

anchor::AnchorWorkerRun

Outcomes from one bounded worker pass.

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AnchorWorkerRun {
pub state: WorkerRunState,
pub claimed: u64,
pub submitted: u64,
pub confirmed: u64,
pub failed: u64,
pub abandoned: u64,
pub infrastructure_failures: u64
}

Source line: 201.

anchor::AnchorWorkerHealthSnapshot

Operator-visible snapshot of the anchor supervisor's process-local health.

#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct AnchorWorkerHealthSnapshot {
pub degraded: bool,
pub consecutive_failures: u32,
pub last_error: Option<String>,
pub last_success_at: Option<DateTime<Utc>>
}

Source line: 227.

anchor::AnchorWorkerHealth

Shared health handle retained by both the worker and HTTP diagnostics.

#[derive(Debug, Clone, Default)]
pub struct AnchorWorkerHealth {

}

Source line: 236.

anchor::AnchorWorkerHealth::snapshot

#[must_use]
pub fn snapshot(&self) -> AnchorWorkerHealthSnapshot;

Source line: 242.

anchor::AnchorWorker

One multi-replica-safe anchor outbox worker.

pub struct AnchorWorker {

}

Source line: 269.

anchor::AnchorWorker::new

pub fn new(
        worker_id: impl Into<String>,
        store: Arc<dyn EntryStore>,
        port: Option<Arc<dyn AnchorPort>>,
        config: AnchorWorkerConfig,
    ) -> Result<Self, ServerError>;

Source line: 278.

anchor::AnchorWorker::health

Clone the supervisor health handle for protected diagnostics.

#[must_use]
pub fn health(&self) -> AnchorWorkerHealth;

Source line: 302.

anchor::AnchorWorker::run_once

Execute at most one configured batch.

Claiming and durable transitions happen in short store transactions. Adapter calls occur strictly between those transactions.

pub async fn run_once(&self, now: DateTime<Utc>) -> Result<AnchorWorkerRun, ServerError>;

Source line: 310.

anchor::AnchorWorker::run_until_shutdown

Run bounded passes until the process shutdown signal changes.

Production wiring calls this only after registering a reviewed adapter. Enabling the loop without one is an explicit configuration error rather than a silent no-op.

pub async fn run_until_shutdown(
        &self,
        mut shutdown: tokio::sync::watch::Receiver<bool>,
    ) -> Result<(), ServerError>;

Source line: 401.

Source provenance

Source: mars-server/src/anchor/mod.rs · SHA-256 582898e6ac798e1dd75a7d62c5f2a5be8d0182dd7f37a7d32b0b6162962284df. Package overview.

On this page