Skip to main content

Configuration

Order Sourcing ships three binaries from one image: cmd/api (REST, nine Kafka consumers, queue sweep, outbox relay), cmd/mcp (read-only MCP server) and cmd/a2a (read-only Agent2Agent agent). All three run on real PostgreSQL only; cmd/api also needs real Kafka. There is no in-memory mode and no log sink. A missing mandatory variable is a boot error that names the variable, raised before the listener binds.

Source: cmd/api/main.go (loadRuntime), cmd/api/telemetry.go, cmd/mcp/main.go, cmd/a2a/main.go (loadBootConfig), internal/adapters/outbound/telemetry/telemetry.go.

Durations accept Go syntax (15s, 500ms); OUTBOX_RELAY_INTERVAL also accepts plain seconds (2). An invalid optional value is logged at WARN and the default is used.

cmd/api​

VariableDefaultRequiredMeaning
DATABASE_URLnoneyesPostgres DSN of the service pool. Unset = boot error DATABASE_URL is required.
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect (session-mode) DSN used only by the boot migrations; golang-migrate holds a session advisory lock that a transaction-pooling proxy cannot honour.
KAFKA_BROKERSnoneyesComma-separated host:port list, used by the outbox relay, the nine consumers and the /readyz broker check. Unset or blank = boot error.
CUSTOMER_ORDERING_CONSUMER_GROUPnoneyesStable consumer group id for topic retailnetwork.customer-ordering.events.
DELIVERY_PROMISE_CONSUMER_GROUPnoneyesGroup id for retailnetwork.delivery-promise.events.
LAST_MILE_DELIVERY_CONSUMER_GROUPnoneyesGroup id for retailnetwork.last-mile-delivery.events.
LINEHAUL_TRANSPORTATION_CONSUMER_GROUPnoneyesGroup id for retailnetwork.linehaul-transportation.events.
NODE_PERFORMANCE_CONSUMER_GROUPnoneyesGroup id for retailnetwork.node-performance.events.
NODE_TOPOLOGY_CONSUMER_GROUPnoneyesGroup id for retailnetwork.node-topology.events.
OFFER_AVAILABILITY_CONSUMER_GROUPnoneyesGroup id for retailnetwork.offer-availability.events.
SHIPPING_AND_TRACKING_CONSUMER_GROUPnoneyesGroup id for retailnetwork.shipping-and-tracking.events.
VENDOR_CONNECTIVITY_CONSUMER_GROUPnoneyesGroup id for retailnetwork.vendor-connectivity.events.
EVENT_PUBLISHERkafkanoOnly kafka (or unset) is accepted. log is refused ("not supported") and any other value is a boot error.
HTTP_ADDR:8080noREST listen address.
SWEEP_INTERVAL15snoPeriod of the virtual-queue sweep (releases due assignments, re-optimises the other queued ones).
OUTBOX_RELAY_INTERVAL1snoPoll interval of the outbox relay.
OUTBOX_MAX_ATTEMPTS20noPublish failures before the relay excludes a row; 0 = unlimited. Negative or non-numeric = default.
SHUTDOWN_DRAIN_DELAY5snoWait between flipping /readyz to 503 and closing the listener; 0 disables the wait.
LOG_LEVELinfonodebug, info, warn (or warning), error; case-insensitive, anything else = info.
OTEL_SERVICE_NAMEorder-sourcingnoservice.name of spans and metrics.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint, bare host:port (becomes http://) or a URL. Export never blocks.
SERVICE_VERSIONdevnoservice.version resource attribute.
ENVIRONMENTlocalnodeployment.environment.name resource attribute.

The consumer-group variables must be stable and service-prefixed (the chart CI values use order-sourcing-<producer>). Never derive them from a pod name: a rescheduled pod must resume from its committed offsets.

cmd/mcp​

Read-only. Dials Postgres only: no Kafka, no relay, no consumers, no sweep.

VariableDefaultRequiredMeaning
DATABASE_URLnoneyesPostgres DSN (the database cmd/api owns).
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the idempotent boot migrations.
MCP_ADDR:8090noStreamable HTTP listen address.
LOG_LEVELinfonoAs for cmd/api.
OTEL_SERVICE_NAMEorder-sourcing-mcpnoservice.name of spans and metrics.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint.
SERVICE_VERSIONdevnoservice.version, also logged at boot.
ENVIRONMENTlocalnodeployment.environment.name, also logged at boot.

cmd/a2a​

Read-only. Dials Postgres only. Both required variables are validated together and reported in one error.

VariableDefaultRequiredMeaning
DATABASE_URLnoneyesPostgres DSN.
A2A_AGENT_URLnoneyesAbsolute http(s) URL of this agent's JSON-RPC endpoint, advertised on the Agent Card (for example http://<release>-a2a.<ns>.svc.cluster.local:8093/). Relative or schemeless values are refused at boot.
A2A_ADDR:8093noListen address.
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the idempotent boot migrations.
LOG_LEVELinfonoAs for cmd/api.
OTEL_SERVICE_NAMEorder-sourcing-a2anoservice.name of spans and metrics.
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint.
SERVICE_VERSIONdevnoservice.version, logged at boot and shown on the Agent Card.
ENVIRONMENTlocalnodeployment.environment.name, logged at boot.

cmd/os-projector (analytics projector, ADR 0013)​

Writes ONLY the separate analytical database; never opens the OLTP database. Reads retailnetwork.order-sourcing.events and retailnetwork.order-sourcing.analytics, dead-letters poison to retailnetwork.order-sourcing.analytics.dlq. Serves /healthz and /readyz on the admin port.

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

cmd/os-reports (read-only analytics reports, ADR 0013)​

GET /reports/sourcing-mix, /reports/order-splits, /reports/cost-to-serve, /reports/freshness, /healthz, /readyz over a read-only pool (15s statement timeout). No Kafka, no OLTP database. GET /reports/sourcing-mix reads sourcing_decisions.carrier_assignment_id (analytics migration 0002, ADR 0018), which the projector applies at its boot: roll the projector out BEFORE the reports binary, or the sourcing-mix report answers 500 until the projector has restarted.

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

Helm values to variables​

charts/order-sourcing/values.yaml maps one key to one variable. The nine consumer groups (config.<producer>ConsumerGroup) and kafka.brokers are required by the chart as well: it refuses to render without them. See Runbook for deployment details.