Skip to main content

Shared Go platform modules

Status: Partially implemented and actively adopted. Package names on this page were verified in dx-common-go source. A capability that does not exist under platform/ is not presented as if it does.

dx-common-go/platform is the infrastructure kernel consumed by CDPG services. It standardizes boot, transports, persistence mechanics, delivery, identity propagation, health, and lifecycle. It must not contain catalogue rules, grant semantics, billing logic, query policy, or another service’s data model.

Shared Go platform module map

Module inventory

ModuleOwnsDoes not ownStatus
platform/bootstrapBoot order, dependency construction, serving, supervised workers, drain and closeBusiness object graph or use casesImplemented
platform/configTyped file/env binding, platform defaults, validation hooksSecrets or remote configuration authorityImplemented
platform/httpTyped handlers, route tables, envelopes, validation, error mapping, middleware, health/docs mountingRoute business semantics or authorization policyImplemented
platform/grpc and platform/grpc/serverIdentity-aware clients and unary server/interceptorsPublic API ownership or streaming policyPartially implemented
platform/errorsStable error classes and mapping primitivesUser-facing business copyImplemented
platform/pagingBounded page requests/resultsQuery planningImplemented
platform/database/sqlPool-neutral SQL interfaces, transaction propagation, query/repository helpersSchema/domain designImplemented
platform/database/sql/pgxExplicit driver escape hatchGeneral repository APIImplemented
platform/cache and platform/cache/redisCache contract, memory/Redis adapters, cache-aside helpersDurable truth or business invalidation factsImplemented
platform/events and platform/events/amqpTyped event envelope, bus, outbox, dispatcher, retry/DLQ/replay adapterBusiness event vocabulary or consumer side effectsImplemented; fleet adoption partial
platform/idempotencyDurable idempotency record mechanicsDeciding which operation needs an idempotency keyImplemented
platform/leaseDurable ownership, renewal, interruption, loss signalingWork definition or retry policyImplemented
platform/executorLifecycle-owned per-request background executionUnlimited fire-and-forget workImplemented
platform/security/identityVerified subject/actor/delegation value and contextCredential verification or authorizationImplemented
platform/security/workloadDestination audience verification, caller/subject-asserter controlUser login or business permissionImplemented
platform/security/workload/issuerClient credentials and short destination-token cacheSubject authorizationImplemented
platform/observability/healthLiveness/readiness registry and dependency checksFull telemetry backendImplemented

Search, Elasticsearch, S3 storage, JWT/JWKS user authentication, metrics, tracing, audit helpers, notification/email, resilience, and test utilities currently exist as focused top-level foundation packages rather than as complete platform/* modules. Use their present source-backed APIs where a current service already proves the pattern; do not invent platform/search, platform/storage, platform/authz, or platform/test imports.

Responsibility matrix

CapabilityShared platform ownsService owns
BootstrapCorrect lifecycle and shutdown orderDependency declaration and wiring
ConfigurationBinding, precedence, shared defaultsService fields, validation, safe values
HTTP/gRPCTransport mechanics and cross-cutting middlewareContracts, operation semantics, route posture
ErrorsClassification and renderingDomain meaning and contextual wrapping
SQLPool/transaction/query mechanicsSchema, queries, invariants, isolation choice
CacheStorage abstraction and cache-aside mechanicsKeys, TTL, invalidation events, safe fallback
EventsEnvelope, delivery adapter, outbox mechanicsEvent names, versions, payloads, side effects
WorkersSupervision, leases, cancellation primitivesWork selection, retry classification, reconciliation
IdentityVerified context representation and boundary verificationRequired actor/subject semantics for an operation
AuthorizationReusable clients/types when implementedResource/action mapping and enforcement
ObservabilityCommon signal mechanicsBusiness dimensions, SLOs, alerts, runbooks
TestingShared fakes/harnesses where availableDomain, contract, security, recovery, and workflow tests

Consumption rule

Pin a reviewed dx-common-go version. During local workspace development, a go.work file or temporary replace may point to the adjacent clone. Do not publish a service release whose module file points to a developer’s filesystem.

Upgrade platform code upstream first: add or fix the general capability in dx-common-go, test it there, release it, then adopt it in services. Copying shared infrastructure into one repository creates a second behavior and a second security patch path.

Continue with bootstrap and configuration, HTTP and gRPC, persistence and cache, events and workers, and identity and operations.