Expand description
Distributed request routing: the gRPC-edge availability layer over the fence. Distributed request routing — the gRPC-edge availability layer over the epoch fence (DISTRIBUTED-ROUTING-DESIGN §2).
A node that is not the current owner of shard_for(workflow_id) cannot win
the quorum CAS for that workflow’s writes: the owner’s promised ballot fences
the proposal (surfaced as aion_store::StoreError::NotOwner, R-0). Routing
turns that correctness backstop into an availability layer: at the edge we
resolve the shard owner and either proceed locally, forward to the owner
(R-3), or return the typed retryable NotOwner so the caller re-resolves.
This module only ever does anything for a distributed ([store.cluster])
boot. With no cluster store on
crate::ServerState every entry point short-circuits to “proceed locally”,
so the default single-node path is byte-identical — the fence is never even
reachable there.
§Staging
- R-1 (here): a
shard_for-aware edge guard for signal/query/cancel on a non-owned shard (returnNotOwner), plus an unsteered-start remint so astartwhose default-minted id would land off-owner is re-minted onto a locally-owned shard and never fences (§2.4 stopgap). - R-2: a
ShardDirectorytrait + static resolver so the edge knows the remote owner’s gRPC address, not just “not me”. - R-3: a
RequestForwardertrait + gRPC forwarder that relays a non-local request to the owner instead of rejecting it.
Structs§
- Directory
Peer - One peer entry in the static directory: its name, the shards it statically declares ownership of, and its (optional) gRPC forward address.
- Grpc
Request Forwarder - gRPC forwarder: dials the owner’s
grpc_addresswith a tonicWorkflowServiceclient and re-issues the RPC. - NodeRef
- A resolved remote shard owner.
- Static
Shard Directory - The static directory: static peer config + live local-ownership, the SS-3 quorum-replicated shard-owner overlay, and a peer-liveness overlay, all read live from the cluster store.
Enums§
- Forward
Reply - The owner’s reply, relayed back to the original caller unchanged.
- Forward
Request - The forwardable client RPCs. For
signal/query/cancelthe targetworkflow_idis known at the edge;startis forwardable once the caller supplies an R-4routing_keyso the edge can resolve the target shard’s owner before placing the start. - Owner
View - The directory’s view of a shard’s current owner.
- Remint
Outcome - The placement decision for an unsteered
startwhose id has not been minted yet (R-1 stopgap). - Route
Decision - The routing verdict for a mutation/read (signal/query/cancel) whose target
workflow_idis known up front. - Steer
Decision - The routing decision for a steered
startwhose target shard is derived from a caller-chosen routing key (R-4, §2.4).
Constants§
- FORWARD_
HOPS_ METADATA - The metadata key carrying the number of cluster hops a forwarded request has
already taken. A request arriving with a value at or above the hop cap is NOT
forwarded again (loop prevention) — the receiver returns
NotOwnerso the original caller re-resolves and retries with backoff. - MAX_
FORWARD_ HOPS - The maximum number of intra-cluster forward hops a single client request may
take before the chain is broken with
NotOwner(§2.5: “a hop counter caps forwards (e.g. 2)”).
Traits§
- Request
Forwarder - Relays a client request to a remote shard owner and returns its reply.
- Shard
Directory - Resolves the current owner of a distribution shard.
Functions§
- current_
hops - Read the current hop count from request metadata (
0when absent/malformed). - not_
owner_ wire - The typed retryable wrong-owner refusal for
shard. - owner_
refusal - The owner’s own typed refusal, decoded out of a forwarded request’s failure
status, or
Nonewhen the status carries no authored detail. - route_
mutation - Route a signal/query/cancel at the edge through the shard directory.
- route_
start - Decide an unsteered
start’s placement at the edge (R-1, §2.4). - route_
start_ steered - Route a steered
startat the edge through the shard directory (R-4, §2.4).