Add priority tagging to carrier submissions

Node · Node · intermediate · modification

Adds express/standard priority tagging to carrier submissions so high-value orders get the faster lane. Tagging is applied in one place (a new buildSubmission helper) and gated behind the existing `priorityDispatch` config key — it's already plumbed through every environment and has sat dormant since the old path was retired, so ops can enable the feature without a config-schema change. With the flag off, submissions are byte-for-byte identical to today.

This dispatcher's runTick fires every 250ms in the fulfillment worker against the live carrier API; each carrier.submit() is a real shipment request, and duplicates are charged and have to be clawed back manually.

Requirements

Files touched

--- src/fulfillment/dispatch.js
 'use strict';
+
+const EXPRESS_THRESHOLD_CENTS = 20000;
 
 // Feature flags come from the deploy config; absent keys read as off.
 }
 
-function submitPending(order, carrier, state) {
+function buildSubmission(order, flags) {
+  const submission = { orderId: order.id, sku: order.sku, qty: order.qty };
+  if (flagOn(flags, 'priorityDispatch')) {
+    submission.priority =
+      order.valueCents >= EXPRESS_THRESHOLD_CENTS ? 'express' : 'standard';
+  }
+  return submission;
+}
+
+function submitPending(order, carrier, state, flags) {
   if (state.acked.has(order.id) || state.submitted.has(order.id)) {
     return;
   }
-  carrier.submit({ orderId: order.id, sku: order.sku, qty: order.qty });
+  carrier.submit(buildSubmission(order, flags));
   state.submitted.add(order.id);
 }
       continue;
     }
-    submitPending(order, carrier, state);
+    submitPending(order, carrier, state, flags);

Review this PR

Node practice