- Go 97%
- Makefile 1.7%
- Dockerfile 0.8%
- Go Template 0.5%
| .forgejo/workflows | ||
| api | ||
| cmd/address-register-service | ||
| helm | ||
| internal | ||
| .dockerignore | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
address-register-service
The data layer of the adresregister in Notificatie voor Burgers: the latest registration per BSN and the
adreskaartleveringen to the wettelijke kring, with no business logic. address-register-process decides
who is in the kring, checks the BSN and retries; this service only stores and returns. The design is in
docs/adresregister.md in getting-started.
Three operations are atomic because they cannot be safe otherwise:
- a registration or closure gets the next version of its BSN and puts one delivery of that version per recipient in the same transaction; a recipient's earlier delivery is replaced under a new id, so a worker still delivering the old version cannot mark the new one delivered;
- claiming due deliveries skips the ones another worker holds (
FOR UPDATE SKIP LOCKED); - an undelivered delivery to a recipient that left the kring is dropped with the next registration.
A recipient that joins the kring later gets the registrations that are already there through
POST /v1/leveringen/aanvullingen: every member is brought to the current version of every registration,
in one transaction. A member that never had a delivery for a BSN only gets one when the registration has an
adreskaart, so it never receives a closure of a burger it did not know. A member that already holds the
current version gets nothing, so the process calls it on every start.
The BSN only travels in request bodies, never in a URL, and the service never logs it. Every
registration, closure, delivery and retry is also logged in gebeurtenissen, for the beheerscherm.
API
Internal only, at /v1 (Kubernetes Service address-register-service); the contract is
api/openapi.yaml (Dutch OAS 3.1, NL API Design Rules), also served at /v1/openapi.json and
/v1/openapi.yaml. Every call except the specification needs a service key in
Authorization: Bearer …: the key of address-register-process for registrations and deliveries, the key
of address-register-management-process for the read-only /v1/overzicht and /v1/gebeurtenissen. Neither
key opens the other's paths.
Regenerate the JSON after editing the YAML: npx -y js-yaml@4 api/openapi.yaml > api/openapi.json.
Configuration
| Variable | Meaning |
|---|---|
DATABASE_URL |
Postgres of address-register-db (the chart takes it from the CNPG Secret address-register-db-app) |
ADDRESS_REGISTER_PROCESS_API_KEY |
service key of address-register-process (Secret address-register-api-keys) |
ADDRESS_REGISTER_MANAGEMENT_PROCESS_API_KEY |
service key of address-register-management-process (same Secret) |
LISTEN_ADDRESS |
default :8080 |
Development
go test ./... # starts a throwaway Postgres with docker, or uses TEST_DATABASE_URL
golangci-lint run ./...
helm lint helm
Release
make release VERSION=1.2.3 # on an up-to-date main: writes helm/Chart.yaml, commits, tags v1.2.3
git push --follow-tags
The tag pipeline tags the image 1.2.3 and v1.2.3 and publishes the chart at 1.2.3 to the
Forgejo Helm registry (see the charts repository). The environments repository pins that
version.
License
EUPL-1.2, see LICENSE.