Repository navigation
fix(events): publish driver-assigned records on driver.{id} - #311
Merged
Merged
Conversation
Lifecycle events for records assigned to a driver (orders, and anything
with a driver_assigned_uuid) went only to driverAssigned.{uuid} and
driverAssigned.{public_id}. Clients that follow the {type}.{id}
convention, such as the Navigator driver app and the console scheduler,
listen on driver.{public_id} and never received them.
They now also go to driver.{public_id} and driver.{uuid}, where the
driver's location and geofence events already arrive. driverAssigned.*
is still published for existing subscribers and is marked deprecated.
broadcastOn() now returns each channel name once.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #311 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 8881 8884 +3
===========================================
Files 472 472
Lines 27918 27929 +11
===========================================
+ Hits 27918 27929 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
Problem
Fleetbase publishes resource events on
{type}.{id}channels. Lifecycle events for records assigned to a driver (order.created,order.dispatched,order.driver_assigned,order.completed, … and anything with adriver_assigned_uuid) went only to a separate relationship channel,driverAssigned.{uuid}/driverAssigned.{public_id}.Root cause:
ResourceLifecycleEvent::addRelationshipSpecificChannels()builds the channel prefix from the relationship name (driverAssigned) rather than the model type (driver).Clients that follow the convention listen on
driver.{public_id}and never get these events. Examples: the Navigator v3 driver app (useDriverChannel: "FleetOps broadcasts … order assignment, dispatch … todriver.{public_id}") and the console scheduler board. The driver's location, geofence and FleetOpsOrderChanged/OrderDriverUnassignedevents already go todriver.*, so the order lifecycle events were the only ones missing.Change
driverAssignedrelationship now publishes todriver.{public_id}anddriver.{uuid}as well asdriverAssigned.*. Both ids are used, as for every other channel.broadcastOn()now returns each channel name once (uniqueChannels(), first one wins). This drops duplicates such ascompany.{uuid}coming from both the session and the model.SocketClusterService::filterChannels()already removed duplicates at publish time; this makes the list the event declares match.Compatibility
driverAssigned.*is kept and marked deprecated in a code comment. Nothing in this monorepo, Navigator, or the storefront app subscribes to it, but the v1.6.70 release notes advertised it ("Order lifecycle events reachdriverAssigned.{driver uuid}again", #306), so external clients may rely on it. It can be removed in a later release.No authorization changes: drivers (self channel), console users and API credentials (company match) can already subscribe to
driver.{id}.Tests
EventsAndExceptionsTest: relationship channel tests now assertdriver.{uuid}/driver.{public_id}alongsidedriverAssigned.*. New tests check that no channel name repeats and thatuniqueChannels()keeps order.pestsuite passes locally (2183 tests). php-cs-fixer is clean on both files.EventContractsTest,NotificationAndMailContractsTest,FuelEfficiencyAndCanceledHandlersTestandOrderFailedChannelsTestpass against this branch.No FleetOps change is needed: its own events already use
driver.*.Docs: fleetbase/fleetbase.io#134 (follow-up to the merged #133) points readers at
driver.{public_id}. Merge it after this ships.