proposal: mapping on arrival - a business key becomes a relation, and a gate ignores what is not understood - #42
Open
iliyan-velichkov wants to merge 1 commit into
Conversation
… a gate ignores what is not understood
An `inbound` entry ingests the arriving JSON as the entity, which is only
expressible when the sender's payload already IS the entity, field for field. A
real arrival contract is an envelope, so an application can declare its entity,
its deduplication, its process trigger and its arrival - and still need custom
code purely because a relation arrives as a name instead of a reference.
Proposes two optional keys, valid on every arrival because they describe the
payload rather than the transport: `accept` gates on the envelope keys it names,
and `map` fills a property from an envelope key or - given `{ lookup, by, from }`
- from the record a business key identifies.
The rules carry their reasons. `by` must identify at most one record, because a
lookup that could match several would have to pick one and picking silently is
worse than failing. A lookup matching none rejects the arrival, because a record
stored with an unresolved reference cannot be traced back to the party that asked
for it. A message the gate does not match is acknowledged and ignored rather than
failed, because redelivery cannot change the outcome.
Mirrors 0017's argument in the other direction: the format admitted a declared
envelope for messages leaving on the grounds that real contracts are not records,
and an arriving message is the same contract read the other way.
Proven by the reference implementation in eclipse-dirigible/dirigible#6769.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
proposals/0021-arrival-mapping.md. Touches nothing underversions/, per the proposal-first rule.This is the half #30 named and left for its own proposal: the same problem
0017solved for messages leaving, read in the other direction.The gap
An
inboundentry ingests the arriving JSON as the entity, which is only expressible when the sender's payload already is the entity, field for field. A real arrival contract is an envelope:{ "messageId": "9f9d1c9e-...", "type": "user.assignment.requested", "version": 1, "tenantId": "acme", "email": "new.user@example.com", "role": "User" }So an application can declare its entity, its deduplication, its process trigger and its arrival, and still need custom code purely because a relation arrives as a name instead of a reference. That is the outcome worth avoiding: the construct looks like it covers the case, and the hand-off is discovered when the first payload lands.
What it proposes
Two optional keys, valid on every arrival, because they describe the payload rather than the transport:
Omitting them keeps today's meaning exactly, so no existing file changes.
The three rules worth arguing about
Each is in the proposal with its reasoning, because each is a refusal:
by:must identify at most one record (a field declared unique, or the entity's key). A lookup that could match several would have to pick one, and picking silently is a worse outcome than failing — so it is refused when the file is read, not when two rows first collide.The proposal also states what stays out: a general transformation language. Three value forms and one lookup shape cover the contracts people actually have; more than that moves the arrival out of the model into a second program written in a worse language, and the honest answer there is a hand-written handler over the same write path.
Implementation
Proven in the reference implementation before proposing: eclipse-dirigible/dirigible#6769 (PR), including the runtime evidence that a business key really becomes the stored reference, that a non-matching envelope is ignored with a warning, and that an unresolvable one is rejected rather than stored half-resolved.