The first template of the source-aligned family: one data product per source system, capturing a database by CDC and turning what it emits into what a canonical product accepts. It runs on the Integration Bus, not in a domain, and is deployed with the `data-bus` CLI. What it produces, and what its tests hold it to: raw topics in the source's own shape; deterministic identity, so a re-snapshot upserts rather than duplicating; validation against the canonical product's rules before publishing, with what fails going to the product's own dead-letter topic with the reason; keying by the canonical identifier; provenance in headers; and an archive in the bus object store that can be replayed back onto the raw topic. The worked example captures an ERP customer table and delivers into Canonical Party in the digital-core domain: 12 smoke checks, 37 unit tests, including a poison record that is quarantined while the next record still arrives. The canonical template's topics now declare the key producers must set, which is the other half of that contract. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
# A stand-in for the ERP, for tests only.
|
|
#
|
|
# The real source system belongs to another team and is not on this machine, so the product
|
|
# ships the smallest thing that behaves like it: the same table, the same types, logical
|
|
# decoding switched on so Debezium can replicate from it, and a seed of rows — including the
|
|
# rows that must be rejected.
|
|
#
|
|
# uv run data-bus fixture up semprini-data-product-templates/source_aligned_cdc_data_product/example
|
|
# uv run data-bus fixture down ... (removes the volume, so the next start reseeds)
|
|
#
|
|
# It joins semprini_bus because that is where bus-connect reaches it. Nothing else may depend
|
|
# on it: it is not part of the bus stack, and a deployed product points at the real ERP.
|
|
|
|
services:
|
|
source-{{system}}:
|
|
image: postgres:17.6-bookworm
|
|
container_name: source-{{system}}
|
|
restart: unless-stopped
|
|
mem_limit: 384m
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- wal_level=logical # Debezium reads the write-ahead log; without this there is no CDC
|
|
- -c
|
|
- max_replication_slots=4
|
|
- -c
|
|
- max_wal_senders=4
|
|
environment:
|
|
POSTGRES_USER: {{system}}
|
|
POSTGRES_PASSWORD: ${ERP_SOURCE_PASSWORD:-{{system}}}
|
|
POSTGRES_DB: {{system}}
|
|
volumes:
|
|
- ./init:/docker-entrypoint-initdb.d:ro
|
|
- source-{{system}}-data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U {{system}} -d {{system}}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
logging:
|
|
driver: json-file
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "2"
|
|
networks:
|
|
- bus
|
|
|
|
volumes:
|
|
source-{{system}}-data:
|
|
|
|
networks:
|
|
bus:
|
|
name: semprini_bus # created by semprini-data/stack-data.sh
|
|
external: true
|