Shared messaging and outbox contract crate for FSCL services.
It contains:
EventEnvelope: canonical wire payload and outbox payloadOutboxRecord: persisted outbox state around an envelopeschema: embedded outbox SQL and shared schema constants
+------------------+
| fscl-messaging |
+---------+--------+
^
|
+-----------------+-----------------+
| |
| |
+----+-----+ +-----+----------------+
| fscl-core| | fscl-outbox-publisher|
+----------+ +-----------------------+
^
|
+----+----------------+
| view-specific services|
+----------------------+
This crate is the shared contract layer. It is intentionally below the service crates.
schema.rs / sql/outbox.sql -> code-level outbox contract
envelope.rs -> wire payload contract
outbox.rs -> persisted outbox state contract
env / ConfigMap / Secret -> runtime values outside this crate
fscl-messaging does not read env vars.
It centralizes code-level contract values only:
OUTBOX_TABLE: shared outbox table nameOUTBOX_NOTIFY_CHANNEL: shared PostgreSQL notify channel nameOUTBOX_SCHEMA_VERSION: schema version markerOUTBOX_SCHEMA_SQL: embedded SQL for the shared outbox schemaensure_outbox_schema: apply the embedded outbox SQL through asqlxPostgres pool
ensure_outbox_schema serializes concurrent installers with a PostgreSQL advisory transaction lock, so multiple services can call it during startup without racing each other through the DDL.
Example:
use fscl_messaging::ensure_outbox_schema;
use sqlx::PgPool;
async fn install_outbox(pool: &PgPool) -> Result<(), sqlx::Error> {
ensure_outbox_schema(pool).await
}Meaning of the main types:
EventEnvelope: the canonical event payload written to outbox and published on the wireOutboxRecord: the envelope plus publisher state such aspublished_at,attempts, andlast_error
cd fscl-messaging
cargo testNo .env file is required for this crate.
Scaffold only: fscl-messaging is not deployed directly.
Its contracts are reflected indirectly in the Kubernetes manifests under fscl/doc/rust/fscl-k8s:
- the outbox schema must be applied by the database-owning service
- the notify channel stays fixed by code contract
- runtime values such as
NATS_URLand subject prefix are injected by ConfigMaps and Secrets