Aller au contenu principal

Communication

ChannelUseConventions
REST/JSON via the gatewayPublic API (browsers, scripts, devices)/v1/ URL versioning, one OpenAPI 3.1 spec per service, cursor pagination, RFC 9457 errors
ConnectRPCInternal synchronous queries (permission checks, lookups)proto/, generated into pkg/gen; gRPC compatible, served over HTTP on the service port
KafkaInternal asynchronous eventsTopics <service>.<aggregate>.v1, CloudEvents 1.0 JSON, key = aggregate ID

Devices and external integrations only use the HTTP API; Kafka is internal.

REST conventions​

  • Errors: application/problem+json with type, title, status, a machine-readable code, optional detail, instance and per-field fields for validation errors (pkg/problem).
  • Pagination: limit (default 25, max 200) and an opaque cursor; responses are {"items": [...], "next_cursor": "..."} (pkg/pagination). Lists are ordered by ascending ULID unless stated.
  • Request ID: a well-formed incoming request ID is reused, otherwise generated (pkg/httpx), and propagated to audit records and logs.
  • Health: /healthz (liveness), /readyz (readiness: dependencies registered with AddCheck). Prometheus metrics are served on a separate private listener (METRICS_ADDR).

Gateway routing​

PrefixUpstreamAccess
/v1/auth/*gateway itselfsee gateway
/v1/public/settingsauthzanonymous, cached
/v1/authz/*authzauthenticated
/v1/members/*membersauthenticated
/v1/audit/*auditauthenticated
/v1/files, /v1/inventory, /v1/events, /v1/public/events, /v1/public/calendar, /v1/borrowingphase 2–3 servicesplanned
/v1/searchsearchauthenticated
/v1/devicesdevicesauthenticated (device API keys: /v1/devices/agent/* only)

Upstreams come from GATEWAY_ROUTES (prefix=url,..., longest prefix wins). An unrouted /v1/* path answers 503; paths outside /v1/ answer 404; /v1/public/* is the only anonymous area.

CloudEvents envelope​

pkg/cloudevent builds CloudEvents 1.0 structured-mode JSON:

{
"specversion": "1.0",
"id": "01J…",
"source": "members",
"type": "members.member.created",
"subject": "<aggregate ID, also the Kafka key>",
"time": "2026-10-06T10:00:00Z",
"datacontenttype": "application/json",
"data": {},
"traceparent": "00-…",
"atlactorkind": "user",
"atlactorid": "<Keycloak ID>",
"atlsite": "paris",
"atlversion": 3
}

type follows <service>.<aggregate>.<event>. Extensions carry the actor, the site and the aggregate version; traceparent lets consumers continue the trace.