feat(entity,pekko): carry the journal coordinate into view processors #46
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/support!46
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/projection-event-coordinate-main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Forward-ports the journal-coordinate change from
release/0.1.x(released as0.1.23) onto the 0.2.x line.Why
A projected event arrives in an
EventEnvelopethat names its journal position — persistence id and sequence number.ProjectionHandlerdiscarded that position and passed only the payload to theViewProcessor, so a view had no stable identity to key its read-model records on. Re-running a projection without clearing the read model first re-inserted every record instead of overwriting it.The alternative considered was hashing the event JSON. The coordinate is better on every axis: it needs no canonical serialization, it survives event-schema changes, and it tells two byte-identical events from one command apart — which no payload hash can do.
What
EventCoordinate(persistenceId, sequenceNr)— the journal position, inentity.CoordinatedViewProcessor[Event]— receives the event together with its coordinate.CoordinatedProjectionHandler— reads the coordinate off the envelope;coordinateOfis a public seam so a view's identity can be tested without a projection running.PekkoProjectionSupport.runSingleCoordinated— the coordinate-carrying registration.Additive only.
ViewProcessor,ProjectionHandlerandrunSinglekeep their signatures and behaviour;ProjectionHandlernow delegates throughCoordinatedViewProcessor.lift, so one implementation serves both paths.Tests
New test modules for
entity(JVM + ScalaJS, shared sources) andpekko-persistence. 12 tests: coordinate identity, replay stability, discrimination by sequence number and by persistence id, payload-independence, and the handler passing the transformed event plus its coordinate onward.Every test was mutation-checked. Replacing the coordinate in
process()withEventCoordinate(envelope.persistenceId, 0L)fails exactly one test — the composition test — proving it covers something the pure tests do not.Full suite green: 652 tests, 0 failures. Clean compile of all modules, 0 warnings.
Differences from the released branch
0.2.2-SNAPSHOT; the0.1.23bump is not ported.CoordinatedProjectionHandlerSpecdrops a scoping block and passes theRuntimeexplicitly. The project's scalafmt config rejects the block form, but__.checkFormatdoes not resolve on test submodules, so neither the local gate nor CI saw it —release/0.1.xstill carries the unformatted version.