Add the source-aligned CDC template, and key the canonical template's topics
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>
This commit is contained in:
1 parent
ca6bea351a
commit
866bcfe238
44 files changed
+2505
-11
No files matched your search
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "urn:bus:{{system}}:raw:{{source_schema}}.{{source_object}}",
|
||||
"title": "ERP customer (raw)",
|
||||
"description": "A row of the ERP's {{source_schema}}.{{source_object}} table as Debezium captured it, with the source's own column names, codes and key. The __ fields are the capture's own: which operation produced the record, the table it came from, the log position, and when the source committed it. This is the source's truth, unreshaped: it is kept so the canonical records can be rebuilt without going back to the ERP.",
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"required": ["id"],
|
||||
"properties": {
|
||||
"id": {"type": "integer", "description": "The ERP's own customer key. The message key of this topic."},
|
||||
"cust_name": {"type": ["string", "null"], "description": "Customer name as the ERP holds it. The ERP allows it to be empty."},
|
||||
"cust_type": {"type": ["string", "null"], "description": "I = individual, O = organisation. Any other value is a record the transform rejects."},
|
||||
"status_code": {"type": ["string", "null"], "description": "A active, P prospect, S suspended, I inactive, C closed."},
|
||||
"birth_date": {"type": ["integer", "null"], "description": "Days since 1970-01-01, as Debezium encodes a DATE. Individuals only."},
|
||||
"trading_name": {"type": ["string", "null"], "description": "Trading name, organisations only."},
|
||||
"updated": {"type": ["string", "null"], "format": "date-time", "description": "When the ERP last changed the row."},
|
||||
"__op": {"type": ["string", "null"], "description": "r snapshot read, c insert, u update, d delete."},
|
||||
"__table": {"type": ["string", "null"], "description": "The source table."},
|
||||
"__lsn": {"type": ["integer", "null"], "description": "PostgreSQL log sequence number of the change."},
|
||||
"__source_ts_ms": {"type": ["integer", "null"], "description": "When the source committed the change, epoch milliseconds."},
|
||||
"__deleted": {"type": ["string", "null"], "description": "\"true\" on a record produced by a delete."}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "urn:bus:{{system}}:dlq:capture",
|
||||
"title": "ERP capture dead letter",
|
||||
"description": "A record Kafka Connect could not read, convert or transform at all. Connect writes the original message unchanged and puts the failure in the record's headers, so nothing here can be assumed about the payload's shape. Records land here only when the ERP or the connector produce something the converter cannot parse; a record that parses but is not valid canonically goes to {{system}}.dlq.",
|
||||
"type": ["object", "string", "null"],
|
||||
"description_of_headers": "__connect.errors.topic, .partition, .offset, .exception.class, .exception.message and .stage identify what failed and where."
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "urn:bus:{{system}}:dlq",
|
||||
"title": "{{product_name}} dead letter",
|
||||
"description": "A record {{product_name}} could not turn into something {{target_product_name}} accepts, with the reason and the original. It is here rather than in the canonical product because a record that fails validation inside a canonical product's Flink job stops that domain's ingestion; the producer owns what it cannot produce. Keyed by the source key, so every rejection of one source row lands on one partition in order.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["source_system", "source_object", "source_key", "stage", "reason", "record"],
|
||||
"properties": {
|
||||
"source_system": {"type": "string", "description": "The source system the record came from."},
|
||||
"source_object": {"type": "string", "description": "The source object, as the source names it."},
|
||||
"source_key": {"type": "string", "description": "The source's own key for the record."},
|
||||
"stage": {"type": "string", "enum": ["transform"], "description": "Where it was rejected. Capture failures land on {{system}}.dlq.capture instead."},
|
||||
"reason": {"type": "string", "description": "Why it cannot be published: the canonical rule it breaks, in words, naming the field."},
|
||||
"record": {"type": "string", "description": "The raw record as JSON text, so it can be corrected at the source and replayed."},
|
||||
"rejected_at": {"type": ["string", "null"], "format": "date-time", "description": "When the transform rejected it."}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user