Skip to main content

Domain events

The domain view of the event catalogue: which aggregate raises each event, what triggers it and which policy reacts to a consumed one. The wire shapes (fields, topics, envelope) are on Events; the decision record is ADR 0005.

Source: internal/domain/outboundload/events.go, internal/domain/shippingpackage/events.go, internal/domain/billoflading/events.go, internal/adapters/outbound/events/*.go, internal/adapters/inbound/kafka/*.go, apis/asyncapi.yaml.

Every published event is also written to the analytics twin under the same CloudEvents id. The prefix of every published type is com.warehouse.wms.outbound-shipping..

Published (13)​

EventFull CloudEvents typeRaised byTriggerConsumers
LoadPlannedcom.warehouse.wms.outbound-shipping.outboundload.LoadPlannedOutboundLoad.Planthe first manifested package of a cutoff keyanalytics only
LoadDoorAssigned...outboundload.LoadDoorAssignedOutboundLoad.AssignDooran outbound appointment names the load's cptanalytics only
LoadingStarted...outboundload.LoadingStartedOutboundLoad.StartLoadinga trailer docked at the load's dooryard-management (intended)
LoadClosed...outboundload.LoadClosedOutboundLoad.CloseLoadthe supervisor closes the loadyard-management (intended)
LoadReopened...outboundload.LoadReopenedOutboundLoad.ReopenLoadthe supervisor reopens a closed loadyard-management (intended)
LoadCancelled...outboundload.LoadCancelledOutboundLoad.CancelLoadthe supervisor cancels a planned loadanalytics only
ShipmentConfirmed...outboundload.ShipmentConfirmedOutboundLoad.ConfirmShipmentTrailerDeparted for a CLOSED loadorder-management; network-fulfillment (intended)
PackageStaged...shippingpackage.PackageStagedShippingPackage.Stagea staging scananalytics only
PackageLoaded...shippingpackage.PackageLoadedShippingPackage.Loada loading scananalytics only
PackageUnloaded...shippingpackage.PackageUnloadedShippingPackage.Unloadan unload scananalytics only
PackageMissedLoad...shippingpackage.PackageMissedLoadShippingPackage.FlagMissedLoadthe sweep, or a departure while the load was loadingorder-management, exception-management
BillOfLadingIssued...billoflading.BillOfLadingIssuedBillOfLading.Issuethe ship confirmationanalytics only
BillOfLadingVoided...billoflading.BillOfLadingVoidedBillOfLading.Voidthe supervisor voids the documentanalytics only

"Intended" means ADR 0005 names the consumer but the consumer has no handler on its develop (see Integration).

State changes that raise no event: assigning a package to a load, AttachTrailer, MarkShipped, MarkShortShipped. The facts reach the outside through LoadClosed.short_shipped_count and ShipmentConfirmed.

Consumed (9, plus the own analytics stream)​

EventFull CloudEvents typeProducerPolicyEffect
PackageManifestedcom.warehouse.wes.fulfillment-execution.package.PackageManifestedfulfillment-executionPlanLoadFromCutoff, AssignPackageToLoadplan or join the open load, package EXPECTED (ExpectPackage)
PackageDivertedcom.warehouse.wes.fulfillment-execution.package.PackageDivertedfulfillment-executionDropDivertedpackage SHORT_SHIPPED with reason DIVERTED (DivertPackage)
CPTScheduleChangedcom.warehouse.wes.process-path-management.cptschedule.CPTScheduleChangedprocess-path-managementcutoff copyreplace the site's schedule (ApplyCptSchedule)
ZoneRegisteredcom.warehouse.wms.facility-layout.zone.ZoneRegisteredfacility-layoutstaging-location copysave zone to site (ApplyLayout)
LocationSlotRegisteredcom.warehouse.wms.facility-layout.locationslot.LocationSlotRegisteredfacility-layoutstaging-location copysave location and role (ApplyLayout)
DockAppointmentBookedcom.warehouse.wms.dock-scheduling.dockappointment.DockAppointmentBookeddock-schedulingDoorFromAppointmentassign the door (BookAppointment)
TrailerDockedcom.warehouse.wms.yard-management.trailer.TrailerDockedyard-managementStartOnDockattach the trailer, start loading (DockTrailer)
DoorWorkCompletedcom.warehouse.wms.yard-management.trailer.DoorWorkCompletedyard-managementrecord onlycopy the completion (RecordDoorWork)
TrailerDepartedcom.warehouse.wms.yard-management.trailer.TrailerDepartedyard-managementConfirmOnDeparture, FlagDepartureWithoutCloseconfirm or flag (OnDeparture)

The own analytics consumer folds seven of the thirteen published types into load_board (ProjectBoard).

Policies (when X then Y)​

WhenThenPolicy name in the code
PackageManifestedplan the load if none is open, expect and assign the packagePlanLoadFromCutoff, AssignPackageToLoad
PackageDivertedshort-ship the packageDropDiverted
outbound DockAppointmentBooked naming a cptassign the doorDoorFromAppointment
TrailerDocked at the load's doorattach the trailer and start loadingStartOnDock
TrailerDeparted on a CLOSED loadconfirm, ship the packages, issue the bill of ladingConfirmOnDeparture
TrailerDeparted on a LOADING loadflag every package not loaded, never confirmFlagDepartureWithoutClose
the cutoff passes with packages not loadedflag them onceSweepMissedLoad

Delivery and versioning​

At-least-once delivery with the CloudEvents id as the dedupe key; every payload carries the aggregate version after the change; a breaking payload change would be a new .v2 type and dataschema, never a mutation of v1. Within one aggregate id the Kafka key keeps events ordered on one partition.