Skip to main content

Configuration

last-mile-delivery ships three binaries (cmd/api, cmd/mcp, cmd/a2a). All of them are configured only through environment variables: there is no config file, no flag and no secret-manager integration in the repository. REST, MCP and A2A are unauthenticated fleet-wide, so there is no token or key to configure.

The service runs on real Postgres (and, in cmd/api, real Kafka) only (ADR 0005): a missing mandatory variable is a boot error that names it, raised before the listener binds. Test-only variables do not exist in this repo (the integration tests start their own containers with testcontainers). The values below were read from cmd/*/main.go, cmd/api/config.go, cmd/*/telemetry.go and internal/adapters/outbound/telemetry/telemetry.go.

cmd/api​

The REST API, the three Kafka consumers and the outbox relay in one process.

VariableDefaultRequired?Meaning
HTTP_ADDR:8080noListen address of the REST server (also serves /healthz and /readyz).
DATABASE_URLnoneyesPostgres DSN. Missing = boot error DATABASE_URL is required: this context runs on real Postgres, there is no in-memory mode. Embedded migrations run at boot; the outbox, the Idempotency-Key store and every repository live here.
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect (non-pooled) DSN used only for the boot migrations, because golang-migrate's advisory lock does not survive PgBouncer transaction pooling. Empty = DATABASE_URL.
KAFKA_BROKERSnoneyesComma-separated broker list (entries trimmed, blanks dropped). Missing = boot error KAFKA_BROKERS is required: this context runs on real Kafka (outbox relay, consumers, /readyz). Used by the consumers, the outbox relay and the /readyz metadata check. In the fleet's kind cluster the single broker is localhost:9092 from the host.
LINEHAUL_CONSUMER_GROUPnoneyesKafka consumer group id of the linehaul consumer (topic retailnetwork.linehaul-transportation.events, event LoadArrived). Missing = boot error LINEHAUL_CONSUMER_GROUP is required: the consumer always runs on real Kafka. A shared or defaulted group would let two services steal each other's offsets, so there is no default.
NODE_TOPOLOGY_CONSUMER_GROUPnoneyesConsumer group id of the node-topology consumer (topic retailnetwork.node-topology.events, events NodeRegistered, ServiceAreaAssigned). Same boot error shape.
SHIPPING_CONSUMER_GROUPnoneyesConsumer group id of the shipping consumer (topic retailnetwork.shipping-and-tracking.events, event LabelIssued). Same boot error shape.
OUTBOX_RELAY_INTERVAL1snoPause between relay passes that did not fill a batch. A Go duration (500ms, 2s) or plain seconds (2, 0.5). Unparsable or non-positive values log a WARN and use the default.
OUTBOX_MAX_ATTEMPTS20noFailures after which the relay stops claiming an outbox row. 0 = unlimited. Negative or unparsable values log a WARN and use 20, so a typo never removes the cap.
SHUTDOWN_DRAIN_DELAY5snoAfter SIGINT/SIGTERM /readyz flips to 503 and the process waits this long before closing the listener. 0 disables the wait. Negative or unparsable values log a WARN and use 5s. Read when the signal arrives, not at boot.
LOG_LEVELinfonodebug, info, warn (or warning), error, case-insensitive; anything else silently falls back to info. Logs are JSON on stdout.
OTEL_SERVICE_NAMElast-mile-deliverynoservice.name of spans and metrics, and the Loki app label.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint, host:port or a full URL. A bare host:port is normalised to http://host:port (and the variable is rewritten in place). Export never blocks: an unreachable Collector costs telemetry, not availability.
SERVICE_VERSIONdevnoservice.version resource attribute.
ENVIRONMENTlocalnodeployment.environment.name resource attribute.

Boot validation reports the first problem only (DATABASE_URL, then KAFKA_BROKERS, then the three groups in the order above). There is no mode matrix: with the five mandatory variables set, the three consumers and the relay all start.

cmd/mcp​

Read-only MCP server (Streamable HTTP). It never dials Kafka, so it has no KAFKA_BROKERS and no consumer group.

VariableDefaultRequired?Meaning
MCP_ADDR:8090noListen address. Serves /healthz, and the MCP endpoint on both /mcp and /.
DATABASE_URLnoneyesPostgres DSN of the service database that cmd/api owns. Missing = boot error DATABASE_URL is required: this context runs on real Postgres.
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the (idempotent) boot migrations; this binary can boot against a fresh database before cmd/api has.
SERVICE_VERSION1.0.0 for the MCP server version, dev for service.versionnoThe two are read separately: MCP clients see 1.0.0 unless set; telemetry shows dev unless set.
ENVIRONMENTunset (logged), local for the telemetry attributenodeployment.environment.name; also logged at boot.
LOG_LEVELinfonoAs cmd/api.
OTEL_SERVICE_NAMElast-mile-delivery-mcpnoservice.name.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs cmd/api.

cmd/a2a​

Read-only A2A (Agent2Agent) agent, JSON-RPC 2.0 over HTTP. It never dials Kafka.

VariableDefaultRequired?Meaning
A2A_ADDR:8093noListen address. Serves /healthz, /.well-known/agent-card.json, and JSON-RPC on / and /a2a.
A2A_AGENT_URLnoneyesAbsolute http(s) URL (with a host) that the Agent Card advertises for the JSON-RPC endpoint, for example http://last-mile-delivery-a2a.warehouse-systems.svc.cluster.local:8093/. Missing or not absolute = boot error before telemetry, any connection and the listener.
DATABASE_URLnoneyesPostgres DSN. Missing = boot error DATABASE_URL is required: this context runs on real Postgres. With a bad A2A_AGENT_URL as well, both problems are reported together (errors.Join).
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the boot migrations.
SERVICE_VERSION1.0.0 for the Agent Card, dev for service.versionnoRead separately, as in cmd/mcp.
ENVIRONMENTunset (logged), local for the telemetry attributenodeployment.environment.name; logged at boot with agent_url.
LOG_LEVELinfonoAs cmd/api.
OTEL_SERVICE_NAMElast-mile-delivery-a2anoservice.name.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noAs cmd/api.

cmd/lm-projector (analytics projector, ADR 0012)​

Writes ONLY the separate analytical database; never opens the OLTP database. Reads this context's own two topics, retailnetwork.last-mile-delivery.events and retailnetwork.last-mile-delivery.analytics, with one reader; dead-letters poison to retailnetwork.last-mile-delivery.analytics.dlq. Serves /healthz and /readyz on the admin port.

VariableDefaultRequired?Meaning
ANALYTICS_DATABASE_URLnoneyesDirect DSN of the analytical database (read-write; runs the embedded analytical migrations). Chart: analytics.database.projectorUrl or analytics.database.existingSecret.
KAFKA_BROKERSnoneyesComma-separated brokers. Chart: kafka.brokers.
ANALYTICS_CONSUMER_GROUPlast-mile-delivery-analyticsnoThe projector's fixed consumer group. Chart: analytics.projector.consumerGroup.
ADMIN_ADDR:8091no/healthz and /readyz listen address. Chart: analytics.projector.adminAddr.
LOG_LEVELinfonodebug, info, warn/warning, error. Chart: analytics.logLevel.
OTEL_SERVICE_NAMElast-mile-delivery-projectornoservice.name. Chart: otel.serviceName + -projector.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint. Chart: otel.endpoint.
SERVICE_VERSIONdevnoservice.version. Chart: the image tag.
ENVIRONMENTlocalnodeployment.environment.name. Chart: environment.

cmd/lm-reports (read-only analytics reports, ADR 0012)​

GET /reports/route-efficiency, /reports/attempt-outcomes, /reports/wave-utilisation, /reports/freshness, /healthz, /readyz over a read-only pool (15 s statement timeout). No Kafka, no OLTP database.

VariableDefaultRequired?Meaning
ANALYTICS_READER_DATABASE_URLvalue of ANALYTICS_DATABASE_URLyes (one of the two)DSN of a read-only role on the analytical database. Chart: analytics.database.reportsUrl (falls back to projectorUrl).
ANALYTICS_DATABASE_URLnonenoSingle-role local fallback; the chart never renders it for the reports pod.
HTTP_ADDR:8092noListen address. Chart: analytics.reports.httpAddr.
LOG_LEVELinfonoAs above. Chart: analytics.logLevel.
OTEL_SERVICE_NAMElast-mile-delivery-reportsnoservice.name. Chart: otel.serviceName + -reports.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint. Chart: otel.endpoint.
SERVICE_VERSIONdevnoservice.version. Chart: the image tag.
ENVIRONMENTlocalnodeployment.environment.name. Chart: environment.

Readiness​

GET /readyz exists on cmd/api only. It is 200 only when the shutdown drain gate is open and Postgres answers a ping and a Kafka broker answers a metadata request that names no topic (reachability only). The verdict is cached for 3 s and one round of checks is bounded by 2 s. A failed dependency is a 503 application/problem+json of type dependency-unavailable with detail not ready: kafka or not ready: postgres. /healthz is liveness only and exists on all three binaries. cmd/mcp and cmd/a2a have no /readyz. Topics are not part of readiness: the broker creates them on first write.

Compiled-in settings (not configurable)​

These are constants in the source; changing them needs a code change.

SettingValueSource
HTTP ReadHeaderTimeout (all three binaries)5 scmd/*/main.go
HTTP graceful shutdown timeout10 s (cmd/api also waits at most 10 s per worker)cmd/api/main.go (shutdownTimeout, workerDrainTimeout), cmd/mcp/main.go, cmd/a2a/main.go
Telemetry flush on shutdown5 scmd/api/telemetry.go
Metrics export interval15 sinternal/adapters/outbound/telemetry/telemetry.go
Postgres pool10 connections, statement_timeout = 5sinternal/adapters/outbound/postgres/pool.go
Boot retry (migrations, first ping)5 attempts, backoff 1 s, 2 s, 4 s, 8 s (15 s in total)internal/bootretry/bootretry.go
Outbox relay batch size100 rows per pass; a full batch is followed at once by another passinternal/adapters/outbound/outbox/relay.go
Kafka produceracks=all, hash balancer on the message key (the aggregate id), AllowAutoTopicCreationinternal/adapters/outbound/kafka/writer.go
Consumer retry backoff200 ms doubling to a 5 s cap, at most 5 handling attempts, then <topic>.dlqinternal/adapters/inbound/kafka/kafka.go, deadletter.go
Broker connection blips in a consumerup to 10 consecutive transient fetch failures are slept off; the 11th ends the consumer and the process exitsinternal/adapters/inbound/kafka/kafka.go (maxTransientFetchFailures)
/readyz verdict cache / check timeout3 s / 2 sinternal/adapters/inbound/http/readiness.go
Idempotency key retention24 h (idempotency.TTL, one constant for the lookup and the purge); the retention loop of cmd/api deletes older rows every hour, 1000 per statement (fixed, not configurable)internal/application/idempotency/idempotency.go, internal/adapters/outbound/postgres/idempotency.go (PurgeExpired), cmd/api/retention.go, table idempotency_keys
Idempotency-Key length / request body limit1 to 128 printable ASCII characters / 64 KiBinternal/adapters/inbound/http/idempotency.go, response.go (maxBodyBytes)
Topics producedretailnetwork.last-mile-delivery.events, retailnetwork.last-mile-delivery.analyticsinternal/adapters/outbound/kafka/encoder.go
Topics consumedretailnetwork.linehaul-transportation.events, retailnetwork.node-topology.events, retailnetwork.shipping-and-tracking.eventsinternal/adapters/inbound/kafka/consumer.go

What is deliberately absent​

  • No auth variables. REST, MCP and A2A are unauthenticated; access control is the in-cluster boundary.
  • No *_MODE variables. The consumers and the relay always run; the chart refuses any *_MODE in extraEnv.
  • No topic-name variables. Topic names are constants.
  • Chart values. charts/last-mile-delivery maps these variables onto the pods; see the Runbook.