Skip to main content

EventStorming

Design-level EventStorming of the last mile, following the EventStorming glossary and cheat sheet. Sticky-note colours: orange domain event, blue command, yellow aggregate, lilac policy, green read model, pink external system or hotspot. Events are named as the code publishes them; read models are the rm_* tables.

Source: internal/application/usecases/*.go, internal/domain/*/events.go, internal/adapters/inbound/kafka/consumers.go.

Process level: from arrival to the doorstep​

Hotspots​

HotspotWhat the code does today
A wave is full or closed when a package arrivesthe package is tried against the next eligible wave, else it waits AT_STATION and PackageInductionDeferred is published
A wave is cancelled with packages in itthey are re-inducted onto the next eligible wave in the same transaction (G17), else deferred
The wave is dispatched while packages are on no routethey are re-inducted (A11)
Two packages for one addressone stop: they share a stopKey, take one capacity unit and must travel on one stop of a route
Label data not yet arrived at inductionthe package is its own stop (pkg:<trackingNumber>)
A partner is deactivated with planned routesthe planned routes are not re-checked (G34: only new routes need an active partner)
Who reads the cancel, deferred and return eventsother contexts do: DeliveryWaveCancelled is consumed by delivery-promise and order-sourcing, PackageInductionDeferred by delivery-promise, PackageReturnInitiated by shipping-and-tracking; this context's own projector also reads the cancel and return events (Domain events)
A driver reports a delivered package twicealready-delivered, enforced in the aggregate and by a partial unique index
An attempt arrives on a route that was never startedroute-not-started (409)

Policies​

PolicyTriggerReaction
InductOnArrivalLoadArrivedinduct every package into the earliest eligible wave, record the arrival, defer the unplaced
InductDeferredOnSchedulea wave is scheduledinduct the packages waiting at the station, oldest first, at most 1000
RetryNextWavea FAILED attemptplace the package on the next eligible wave unless this is the third failure
CompleteWaveOnLastRoutedispatch, or a route completescomplete the DISPATCHED wave when no route is left uncompleted
re-inductioncancel, dispatchmove the packages the wave cannot run

Big picture​