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
| Feature | Activates |
|---|---|
http | Outbound Client, RetryPolicy, CircuitBreakerConfig |
http-middleware | Axum inbound middleware for W3C trace-context propagation (implies http) |
telemetry | tracing-subscriber init with JSON / pretty formatters and env-driven filters |
ipc | Postgres LISTEN/NOTIFY publisher + subscriber |
time | Injectable Clock + TestClock for virtual-sleep test support |
Public surface
http—Client(reqwest-backed),RetryPolicy,CircuitBreakerConfig. Per-host breaker registry backed byparking_lot::Mutex— the critical section never crosses.await.http-middleware— AxumLayerthat extracts a W3Ctraceparentfrom inbound requests and injects aTraceContextinto extensions. Derives a stabletrace_idfrom anX-Request-Idheader via SHA-256 when notraceparentis present.telemetry—init(filter)wirestracing-subscriberwith JSON formatter for production and pretty formatter for development, driven byRUST_LOG.ipc—Publisher+SubscriberoverLISTEN/NOTIFY. Manager-internal channels (bot lifecycle events, deploy state) stay off the NATS bus by design.trace—TraceContext: full W3Ctraceparentv00 struct (parse, format, child-span derive). Moved here fromgordon-kernelat 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 scalarTraceIdstays ingordon-kernelsogordon-protocolis not forced to depend ongordon-platform.time—Clocktrait +TestClockimpl for deterministic time in tests.
Dependencies of note
gordon-kernel(^2) —TraceId+GordonErrortaxonomy.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) —Mutexfor 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-domainorgordon-protocol. - Default features are empty. Never enable features in
gordon-platformitself. Consumers opt in. TraceContextownership. Since kernel 2.0, the full W3C traceparent struct lives here. New trace-runtime helpers belong intrace.rs; wire validation helpers belong ingordon-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)
Related
- gordon-kernel —
TraceIdscalar;TraceContextmoved here at 2.0. - gordon-bus — IPC (
ipcfeature) complements NATS for manager-internal channels. - gordon-domain — domain types referenced by IPC payloads.