Skip to content

Class RpcPeerOptions

Namespace: DotBoxD.Services.Peer
Assembly: DotBoxD.Services.dll

Options for DotBoxD.Services.Peer.RpcPeer and DotBoxD.Services.Server.RpcHost.

public sealed class RpcPeerOptions

objectRpcPeerOptions

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object, object), object.ToString()

public const int DefaultInboundQueueCapacity = 1024

int

public const int DefaultMaxAcceptedPeers = 1024

int

public const int DefaultMaxConcurrentInboundDispatch = 1

int

Default DotBoxD.Services.Peer.RpcPeerOptions.MaxInboundBytes: 64 MiB of in-flight inbound frames per peer.

public const long DefaultMaxInboundBytes = 67108864

long

public const int DefaultMaxInboundStreamsPerPeer = 1024

int

public const int DefaultMaxInboundStreamsPerRequest = 32

int

public const int DefaultMaxPendingRequests = 4096

int

When true, non-streaming inbound calls do not allocate per-request cancellation state. The handler receives System.Threading.CancellationToken.None and inbound Cancel frames for those calls are ignored. Streaming calls still allocate cancellation state so stream cleanup and response-stream teardown remain cancellable.

public bool DisableInboundRequestCancellation { get; init; }

bool

This is a low-allocation option for trusted peers and handlers whose work is short or bounded elsewhere. Peer shutdown waits for those handlers instead of interrupting them. Leave it disabled when callers must be able to stop in-flight handlers with a Cancel frame or when handlers depend on the supplied cancellation token.

When true, generated generic System.Threading.Tasks.ValueTask unary proxy calls may use a pooled response source instead of the default System.Threading.Tasks.Task path.

public bool EnableLowAllocationValueTaskInvocations { get; init; }

bool

The optimized path is only used when DotBoxD.Services.Peer.RpcPeerOptions.RequestTimeout is System.Threading.Timeout.InfiniteTimeSpan and the caller does not pass a cancellable token. It can run continuations inline on the peer read loop and follows the normal System.Threading.Tasks.ValueTask single-consumption rules. Leave this disabled unless the peer is on a measured, trusted hot path and every returned System.Threading.Tasks.ValueTask is awaited exactly once.

Optional hook, invoked on the side that runs the service, that turns an exception thrown by a handler into the error returned to the caller. Return an DotBoxD.Services.Diagnostics.RpcErrorInfo to surface that message and type to the caller, or null to keep the default opaque “Internal error.” response for that exception.

When this is null (the default) every handler exception is reported opaquely so internal failure detail is never leaked. Framework protocol errors (service, method, and instance not found) keep their own typed mapping and are not routed through this hook.

Exposing exception detail can leak sensitive information, so this is opt-in — only enable it for trusted peers, or map exceptions to safe, caller-facing messages. The shortcut ExceptionTransformer = ex => RpcErrorInfo.FromException(ex) exposes every exception's message and type. The hook may be invoked concurrently when `DotBoxD.Services.Peer.RpcPeerOptions.MaxConcurrentInboundDispatch` is greater than one, so keep it thread-safe.

public Func<Exception, RpcErrorInfo?>? ExceptionTransformer { get; init; }

Func<Exception, RpcErrorInfo?>?

Maximum queued inbound requests. The default applies bounded read-side backpressure. Null dispatches inbound requests immediately, does not cap concurrent dispatch work, and should only be used with trusted peers or externally bounded transports. In wait mode, request admission waits for bounded dispatch queue space.

public int? InboundQueueCapacity { get; init; }

int?

A peer demuxes responses, cancels, and inbound requests over a single read loop. In DotBoxD.Services.Transport.QueueFullMode.Wait mode that loop parks when the request queue is full, which also pauses reading responses to this peer’s own outbound calls. For a bidirectional peer whose inbound handlers call back into the same peer, size this capacity above the maximum number of inbound requests that can arrive ahead of those callbacks’ responses, or use null (unbounded) or DotBoxD.Services.Transport.QueueFullMode.DropIncoming; otherwise an under-sized Wait queue can stall a reentrant response until DotBoxD.Services.Peer.RpcPeerOptions.RequestTimeout.

Maximum accepted peers a host may keep active or in hand-off at once. The default bounds host-side peer state and read-loop work before request, frame, or transport limits apply. Set to null only when peer admission is bounded externally.

public int? MaxAcceptedPeers { get; init; }

int?

Maximum number of inbound requests dispatched concurrently when DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity is set. The default of 1 dispatches serially per connection (preserving ordering and bounding work). Raise it for concurrent per-connection dispatch; total in-flight inbound work is then bounded by DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity + this value. Ignored when DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity is null (which dispatches immediately and does not cap concurrency).

public int MaxConcurrentInboundDispatch { get; init; }

int

Maximum total bytes of in-flight inbound request frames buffered for dispatch when DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity is set. DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity bounds frame count only, so it alone permits up to capacity × max-frame-size bytes (a hostile or overwhelming peer sending large frames can otherwise pin that much memory). This caps the peak independent of frame size; the default is 64 MiB. A frame larger than the budget is still admitted when no other inbound work is in flight, so one oversized request never deadlocks. Set to null to disable the byte bound (count-only). Ignored when DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity is null (which does not buffer or bound).

public long? MaxInboundBytes { get; init; }

long?

Maximum active inbound stream receivers held by this peer. This bounds per-peer receiver state before stream registration allocates receiver objects.

public int MaxInboundStreamsPerPeer { get; init; }

int

Maximum inbound stream handles a single request may declare before dispatch. This bounds pre-handler stream validation and receiver setup work for untrusted peers.

public int MaxInboundStreamsPerRequest { get; init; }

int

Maximum concurrent outbound calls waiting for responses.

public int MaxPendingRequests { get; init; }

int

Policy used when DotBoxD.Services.Peer.RpcPeerOptions.InboundQueueCapacity is set and the request queue is full.

public QueueFullMode QueueFullMode { get; init; }

QueueFullMode

When true, inbound request frames are answered with an explicit “this peer does not accept inbound calls” error rather than a “service not found” error. Use it to make a get-only (“client”) peer’s one-directional intent explicit. This is not an authentication or authorization boundary.

public bool RejectInboundCalls { get; init; }

bool

Default per-call timeout for proxies created by this peer. Must be a positive System.TimeSpan (at most System.Int32.MaxValue milliseconds) or System.Threading.Timeout.InfiniteTimeSpan to disable the timeout.

public TimeSpan RequestTimeout { get; init; }

TimeSpan

Optional service provider for dispatcher factories that resolve dependencies.

public IServiceProvider? ServiceProvider { get; init; }

IServiceProvider?