pub struct CallOptions {
pub deadline: Option<Instant>,
pub routing_policy: RoutingPolicy,
pub filter_unhealthy: bool,
pub trace_context: Option<TraceContext>,
pub max_in_flight_per_target: u32,
pub stream_window_initial: Option<u32>,
pub request_window_initial: Option<u32>,
pub request_headers: Vec<(String, Vec<u8>)>,
pub cancel_token: Option<u64>,
}Expand description
Options for MeshNode::call and MeshNode::call_service.
Fields§
§deadline: Option<Instant>Hard deadline for the call. The future returned by call
races a tokio::time::sleep_until; whichever fires first
wins. On timeout the caller emits a CANCEL event for
call_id so the server can drop the in-flight handler.
None means no deadline; the caller waits indefinitely
(or until the future is dropped).
routing_policy: RoutingPolicyHow call_service picks a target. Ignored by call
(which takes an explicit target_node_id). Default:
RoundRobin.
filter_unhealthy: boolSkip candidates whose ProximityGraph entry reports
!is_available() (i.e. Unhealthy or Unknown).
Default true. Candidates with no proximity entry at all
are KEPT — absence of evidence is not evidence of
unhealth, and a freshly-announced service shouldn’t be
filtered just because pingwaves haven’t propagated yet.
trace_context: Option<TraceContext>W3C Trace Context to propagate to the server. When Some,
the call sets FLAG_RPC_PROPAGATE_TRACE on the request and
emits traceparent / tracestate headers; the server’s
RpcContext::trace_context will be populated with the same
values. nRPC is transport-only — application code on both
sides reads / writes this via whatever tracing backend it
has wired up (tracing-opentelemetry, Datadog, etc.).
max_in_flight_per_target: u32Per-call concurrency cap. Future Phase 2 work; v1 ignores
this and the per-Mesh RpcClientPending doesn’t bound
in-flight count.
stream_window_initial: Option<u32>Streaming responses only. Initial credit window for
per-streaming-response flow control. When Some(n), the
caller emits nrpc-stream-window-initial: n on the
REQUEST and the server’s pump task awaits one credit per
emitted chunk. The returned RpcStream auto-grants 1
credit per consumed chunk so the in-flight credit holds
near n (or use RpcStream::grant for batched / custom
cadence). None (the default) → unbounded: server pumps
chunks as fast as the publish path can take them
(back-compat / pre-flow-control behavior). Ignored by
non-streaming call / call_service.
request_window_initial: Option<u32>Client-streaming / duplex only. Initial credit window
for per-call request-direction flow control. Mirror of
Self::stream_window_initial for the upload direction. When
Some(n), the caller emits nrpc-request-window-initial: n
on the REQUEST and its send().await sink awaits one
credit per pushed chunk; the server refills via
DISPATCH_RPC_REQUEST_GRANT events. None → unbounded:
caller’s send sink doesn’t block (legacy / fast-path).
Ignored by unary call / call_streaming.
Bidi streaming plan (Phase C).
request_headers: Vec<(String, Vec<u8>)>Caller-supplied request headers. Appended to the wire
RpcRequestPayload::headers after any auto-generated
headers (trace context, stream-window). Useful for
application-level metadata the server needs at
dispatch-time — e.g., the net-where predicate
header (Phase 9b of CAPABILITY_SYSTEM_SDK_PLAN.md) that
services consult for predicate-pushdown filtering.
Each entry is (name, value_bytes). Names use the lowercase
cyberdeck-* / nrpc-* convention; the substrate doesn’t
validate names beyond the MAX_RPC_HEADER_NAME_LEN cap
enforced at encode time.
Default: empty.
cancel_token: Option<u64>Caller-side cancel token. Mint via
MeshNode::reserve_cancel_token; pair with
MeshNode::cancel from any thread to abort the in-flight
call. None (or Some(0) — the “no token” sentinel) → no
cancel slot is reserved and the call has no external abort
path beyond Drop-on-future-cancellation.
Honored uniformly by every call shape: call, call_service,
call_streaming, call_client_stream, call_duplex. The
substrate registers the token in a per-mesh cancel registry
at call construction and removes it on resolution (success,
error, or Drop). A cancel that fires mid-flight surfaces to
the caller as RpcError::Cancelled and emits CANCEL on
the wire via the existing per-call-shape guards (UnaryCallGuard,
ClientStreamCallRaw::Drop, DuplexCallRaw::Drop).
Cancel-before-register is race-safe: a cancel that arrives
in the gap between reserve_cancel_token and the call’s
internal register step latches a pre-cancel flag on the
registry’s orphan entry; the subsequent register observes
it and the call short-circuits to RpcError::Cancelled
without ever publishing the REQUEST.
Trait Implementations§
Source§impl CallOptionsExt for CallOptions
impl CallOptionsExt for CallOptions
Source§fn with_request_header(
self,
name: impl Into<String>,
value: impl Into<Vec<u8>>,
) -> Self
fn with_request_header( self, name: impl Into<String>, value: impl Into<Vec<u8>>, ) -> Self
(name, value_bytes) request header. Names
follow the lowercase cyberdeck-* / nrpc-* convention.Source§fn with_where(self, pred: &Predicate) -> Result<Self, PredicateRpcEncodeError>
fn with_where(self, pred: &Predicate) -> Result<Self, PredicateRpcEncodeError>
net::adapter::net::behavior::Predicate as the
net-where request header. The predicate rides as
JSON-encoded PredicateWire bytes per the substrate’s
predicate_to_rpc_header contract;
services opting into predicate-pushdown decode via
RpcContextExt::where_predicate. Read moreSource§impl Clone for CallOptions
impl Clone for CallOptions
Source§fn clone(&self) -> CallOptions
fn clone(&self) -> CallOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more