Sync Server gRPC Dispatch Flow
The Sync Server is the fan-out point.stateset-api hands it one order; it submits that order to
every downstream system the tenant has configured β StateSet, NetSuite, DCL, Cart.com β and reports
per-target results.
The important consequence, which shapes everything below: one call can partially succeed.
The flow
Service contract
stateset.sync.v1.OrderIntegrationService, default port 50051:
SubmitOrderRequest
CreateOrderPayload carries shopify_order_id, order_number, line_items[], created_at,
tags[], location_id, workflow_id, and netsuite_id. Each line item carries sku, title,
quantity, price, variant_id, and shopify_line_item_id.
SubmitOrderResponse
Authentication
Credentials go in gRPC metadata, not the payload. Two schemes, tried in order:
An unparseable bearer token fails
UNAUTHENTICATED. Keys are matched against the tenantβs active
key set, and a successful match updates that keyβs last-used timestamp asynchronously.
Status codes and what they mean
The server maps its internal errors onto gRPC statuses deliberately. This mapping is the retry policy:FAILED_PRECONDITION is the one worth special handling. It means the tenant has no configuration
for that integration β retrying forever will never fix it, and it usually indicates onboarding was
left incomplete rather than a transient fault. Alert on it instead of burying it in a retry queue.Retrying safely
At-least-once delivery means duplicates are expected, and the fan-out makes them asymmetric. Two things make this tractable:- Retry per target, not per call. When you have partial results, use the single-target RPCs β
CreateNetSuiteSalesOrder,CreateDclBatch,CreateCartOrderβ to complete only what failed. - Key downstream deduplication on
shopify_order_id. It is stable across retries in a way that an internal ID generated per attempt is not.