Skip to main content

Configuration

product-discovery ships four binaries (cmd/api, cmd/a2a, cmd/mcp, cmd/rebuild). Each is configured only through environment variables: there is no config file, no flag and no secret-manager integration in the repository. REST, A2A and MCP are unauthenticated fleet-wide, so there is no token or key to configure.

The service runs on real Postgres and real Kafka only: cmd/api has no in-memory mode and no consumer that can be switched off. A missing mandatory variable is a boot error that names it, raised before any connection is opened and before a listener binds. Test-only variables do not exist in this repository (the integration tests start their own containers). Semantics below were taken from reading the code; nothing here is a captured run.

cmd/api (REST and the three Kafka consumers)​

VariableDefaultRequired?MeaningSource
HTTP_ADDR:8080noListen address of the REST server (also serves /healthz and /readyz).cmd/api/main.go (run)
DATABASE_URLnoneyesPostgres DSN. Missing = boot error DATABASE_URL is required: this context runs on real Postgres, there is no in-memory mode. The embedded migrations run at boot.cmd/api/config.go (loadRuntime)
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 falls back to DATABASE_URL.cmd/api/main.go (buildDeps)
KAFKA_BROKERSnoneyesComma-separated broker list (entries trimmed, blanks dropped). Missing = boot error KAFKA_BROKERS is required: this context runs on real Kafka (consumers, dead letters, /readyz). In the fleet's kind cluster the single broker is reachable from the host at localhost:9092.cmd/api/config.go (loadRuntime, splitList)
OFFER_AVAILABILITY_CONSUMER_GROUPnoneyesStable Kafka consumer group id of the offer-availability consumer (topic retailnetwork.offer-availability.events). No default and no literal in code; the deployment chooses it. Missing = boot error OFFER_AVAILABILITY_CONSUMER_GROUP is required: the consumer always runs on real Kafka.cmd/api/config.go (consumerGroupEnvs), cmd/api/workers.go
PRODUCT_CONTENT_CONSUMER_GROUPnoneyesGroup id of the product-content consumer (topic retailnetwork.product-content.events).cmd/api/config.go, cmd/api/workers.go
PRICING_CONSUMER_GROUPnoneyesGroup id of the pricing consumer (topic retailnetwork.pricing.events).cmd/api/config.go, cmd/api/workers.go
PRICE_BAND_EDGESempty = 2500,5000,10000,25000noAscending positive integers in minor units; they cut the price facet into bands. A non-ascending, zero, negative or non-numeric list is a boot error (PRICE_BAND_EDGES "..." must be ascending positive integers (minor units)). Keep it equal to the A2A agent's value so both facets agree.cmd/api/config.go (parseBandEdges)
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 (ignoring invalid SHUTDOWN_DRAIN_DELAY) and use 5s. Read when the signal arrives, not at boot.cmd/api/config.go (shutdownDrainDelay)
LOG_LEVELinfonodebug, info, warn (or warning), error, case-insensitive. Any other value silently falls back to info. Logs are JSON on stdout.cmd/api/config.go (newLogger)
OTEL_SERVICE_NAMEproduct-discoverynoservice.name of spans and metrics (and the app label Loki sees).cmd/api/telemetry.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint, host:port or URL. Export never blocks: an unreachable Collector costs telemetry, never availability.cmd/api/telemetry.go, internal/adapters/outbound/telemetry/telemetry.go
SERVICE_VERSIONdevnoservice.version resource attribute.cmd/api/telemetry.go
ENVIRONMENTlocalnodeployment.environment.name resource attribute.internal/adapters/outbound/telemetry/telemetry.go

cmd/api reports one problem at a time (the first one wins): it checks DATABASE_URL, then KAFKA_BROKERS, then the three consumer groups in the order above, then PRICE_BAND_EDGES.

cmd/a2a (read-only Agent2Agent agent)​

The agent reads Postgres only. It has no Kafka variable, starts no consumer and publishes nothing (ADR 0007).

VariableDefaultRequired?MeaningSource
A2A_ADDR:8093noListen address of the agent (JSON-RPC on / and /a2a, Agent Card, /healthz).cmd/a2a/config.go (defaultAddr)
A2A_AGENT_URLnoneyesAbsolute http(s) URL advertised on the Agent Card, for example http://product-discovery-a2a.warehouse-systems.svc.cluster.local:8093/. Missing, relative, or a non-http(s) scheme is a boot error (A2A_AGENT_URL=... is not an absolute http(s) URL).cmd/a2a/config.go (checkAgentURL)
DATABASE_URLnoneyesPostgres DSN of the same database cmd/api writes. Missing = boot error.cmd/a2a/config.go (loadBootConfig)
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the boot migrations (the same idempotent migrations cmd/api runs).cmd/a2a/config.go
PRICE_BAND_EDGESempty = 2500,5000,10000,25000noAs in cmd/api; keep equal to the api's so facets agree. Same validation.cmd/a2a/config.go (parseBandEdges)
LOG_LEVELinfonoAs in cmd/api.cmd/a2a/config.go (newLogger)
OTEL_SERVICE_NAMEproduct-discovery-a2anoservice.name of spans and metrics.cmd/a2a/telemetry.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint.cmd/a2a/telemetry.go
SERVICE_VERSIONdevnoservice.version and the version shown on the Agent Card.cmd/a2a/main.go (newAgent)
ENVIRONMENTlocalnodeployment.environment.name.internal/adapters/outbound/telemetry/telemetry.go

All problems are reported together (errors.Join), so an operator fixes the environment in one pass.

cmd/mcp (read-only MCP server)​

The server reads Postgres only. It has no Kafka variable, starts no consumer, publishes nothing and has no auth variable (ADR 0009).

VariableDefaultRequired?MeaningSource
MCP_ADDR:8090noListen address (Streamable HTTP on /mcp and /, plus /healthz).cmd/mcp/config.go
DATABASE_URLnoneyesPostgres DSN of the same database cmd/api writes. Missing = boot error DATABASE_URL is required.cmd/mcp/config.go
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the boot migrations (the same idempotent migrations cmd/api runs).cmd/mcp/config.go
PRICE_BAND_EDGESempty = 2500,5000,10000,25000noAs in cmd/api; keep equal to the api's so facets agree. Same validation.cmd/mcp/config.go
LOG_LEVELinfonoAs in cmd/api.cmd/mcp/config.go
OTEL_SERVICE_NAMEproduct-discovery-mcpnoservice.name of spans and metrics.cmd/mcp/telemetry.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint.cmd/mcp/telemetry.go
SERVICE_VERSIONdevnoservice.version.cmd/mcp/telemetry.go
ENVIRONMENTlocalnodeployment.environment.name.internal/adapters/outbound/telemetry/telemetry.go

cmd/rebuild (ops job: snapshot backfill)​

The job never runs on a user request. It needs no Kafka configuration (Runbook).

VariableDefaultRequired?MeaningSource
DATABASE_URLnoneyesPostgres DSN; the job runs the embedded migrations against it and folds the snapshots into the projections. Missing = DATABASE_URL is required.cmd/rebuild/main.go (requiredEnv)
OFFER_AVAILABILITY_URLnoneyesBase URL of offer-availability (GET /catalog, ops-only GET /listings).cmd/rebuild/main.go
PRICING_URLnoneyesBase URL of pricing (GET /item-prices).cmd/rebuild/main.go
PRODUCT_CONTENT_URLnoneyesBase URL of product-content (GET /product-contents, GET /categories).cmd/rebuild/main.go
LOG_LEVELinfonoParsed with slog.Level.UnmarshalText: debug, info, warn, error (an unparsable value falls back to info).cmd/rebuild/main.go (newLogger)
OTEL_SERVICE_NAMEproduct-discovery-rebuildnoservice.name. The job exports once on exit; a missing Collector costs telemetry, never the run.cmd/rebuild/main.go (startTelemetry)
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noCollector OTLP/gRPC endpoint.cmd/rebuild/main.go
SERVICE_VERSIONdevnoservice.version.cmd/rebuild/main.go
ENVIRONMENTlocalnodeployment.environment.name.internal/adapters/outbound/telemetry/telemetry.go

The rebuild does not read PRICE_BAND_EDGES (bands are computed at query time, not stored), nor MIGRATIONS_DATABASE_URL (it migrates through DATABASE_URL).

Readiness​

GET /readyz on cmd/api 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 a round of checks is bounded by 2 s. /healthz is liveness only. cmd/a2a and cmd/mcp serve /healthz but have no /readyz. Topics are not part of readiness. Details in Runbook.

Compiled-in settings (not configurable)​

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

SettingValueSource
HTTP ReadHeaderTimeout (api, a2a, mcp)5 scmd/api/main.go, cmd/a2a/main.go, cmd/mcp/main.go
HTTP graceful shutdown timeout / per-consumer drain timeout10 s / 10 scmd/api/main.go (shutdownTimeout, workerDrainTimeout)
Telemetry flush on shutdown5 scmd/api/telemetry.go (telemetryFlushTimeout)
Postgres pool size and statement timeout10 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 total)internal/bootretry/bootretry.go
Consumer retry backoff200 ms doubling to a 5 s capinternal/adapters/inbound/kafka/kafka.go (DefaultRetryInitial, DefaultRetryMax)
Handling attempts before a message is dead-lettered5internal/adapters/inbound/kafka/deadletter.go (domainMaxHandlerAttempts)
Transient broker-connection failures tolerated in a row10, then the consumer returns and the process exits non-zerointernal/adapters/inbound/kafka/kafka.go (maxTransientFetchFailures)
Dead-letter topic<topic>.dlqinternal/adapters/inbound/kafka/deadletter.go (DLQSuffix)
Topics consumedretailnetwork.offer-availability.events, retailnetwork.product-content.events, retailnetwork.pricing.eventsinternal/adapters/inbound/kafka/handlers.go
/readyz verdict cache / check timeout3 s / 2 sinternal/adapters/inbound/http/readiness.go

What is deliberately absent​

  • No Kafka producer variables. The service publishes nothing, so there is no outbox relay, relay interval or max-attempts knob.
  • No consumer mode switches. All three consumers always run; there is no *_MODE variable.
  • No auth variables. REST, A2A and MCP are unauthenticated fleet-wide.
  • No CORS, rate-limit or feature-flag variables.
  • Chart values. charts/product-discovery maps these variables onto the pod (database.*, kafka.brokers, config.*, rebuild.*); see Runbook.