Skip to content

gordon-platform

Purpose

Runtime library crate every Gordon v7 service composes. Provides outbound HTTP with retry and circuit breaking, inbound Axum trace-context middleware, tracing-subscriber initialisation, Postgres LISTEN/NOTIFY pub/sub for manager-internal channels, and the full W3C TraceContext struct. Extracted from the legacy combined library to separate runtime plumbing from near-frozen wire contracts. A telemetry tweak no longer forces a major bump across five services.

Version + status

0.4.0 — moderate churn. Drift ceiling: 2 minors max. Default features are empty; each consumer enables only what it uses.

Feature flags

FeatureActivates
httpOutbound Client, RetryPolicy, CircuitBreakerConfig
http-middlewareAxum inbound middleware for W3C trace-context propagation (implies http)
telemetrytracing-subscriber init with JSON / pretty formatters and env-driven filters
ipcPostgres LISTEN/NOTIFY publisher + subscriber
timeInjectable Clock + TestClock for virtual-sleep test support

Public surface

  • httpClient (reqwest-backed), RetryPolicy, CircuitBreakerConfig. Per-host breaker registry backed by parking_lot::Mutex — the critical section never crosses .await.
  • http-middleware — Axum Layer that extracts a W3C traceparent from inbound requests and injects a TraceContext into extensions. Derives a stable trace_id from an X-Request-Id header via SHA-256 when no traceparent is present.
  • telemetryinit(filter) wires tracing-subscriber with JSON formatter for production and pretty formatter for development, driven by RUST_LOG.
  • ipcPublisher + Subscriber over LISTEN/NOTIFY. Manager-internal channels (bot lifecycle events, deploy state) stay off the NATS bus by design.
  • traceTraceContext: full W3C traceparent v00 struct (parse, format, child-span derive). Moved here from gordon-kernel at the kernel 2.0 batch (DP-15a, 2026-05-17). Runtime callers (HTTP middleware, span emission, pg-NOTIFY stamping) are runtime concerns and belong in this crate. The wire scalar TraceId stays in gordon-kernel so gordon-protocol is not forced to depend on gordon-platform.
  • timeClock trait + TestClock impl for deterministic time in tests.

Dependencies of note

  • gordon-kernel (^2) — TraceId + GordonError taxonomy.
  • gordon-domain (^1) — domain types referenced by some IPC channel payloads.
  • axum (optional, http-middleware) — tower-compatible middleware layer.
  • sqlx (optional, ipc) — Postgres LISTEN/NOTIFY driver.
  • parking_lot (optional, http) — Mutex for the per-host breaker registry.

Invariants

  • Zero #[allow(...)].
  • No domain types in default surface. A pure-runtime crate — if a type names a strategy, market, order, or intent concept, it belongs in gordon-domain or gordon-protocol.
  • Default features are empty. Never enable features in gordon-platform itself. Consumers opt in.
  • TraceContext ownership. Since kernel 2.0, the full W3C traceparent struct lives here. New trace-runtime helpers belong in trace.rs; wire validation helpers belong in gordon-kernel::trace.
  • No service binaries. Library crate only — no main.rs.

Where it lives

  • Repo: gordon-platform/
  • kellnr: https://kellnr.lepaux.com/crates/gordon-platform (LAN-only)
  • gordon-kernelTraceId scalar; TraceContext moved here at 2.0.
  • gordon-bus — IPC (ipc feature) complements NATS for manager-internal channels.
  • gordon-domain — domain types referenced by IPC payloads.

Gordon — keep compounding without blowing up