transport library

The transport-authoring API: channels and frames, the message parser and router, the flow-control interfaces, and the helpers a server needs to drain.

Re-exports package:rpc_dart/rpc_dart.dart, so a transport imports this library alone.

Classes

ByteBuffer
A sequence of bytes underlying a typed data object.
ByteData
A fixed-length, random-access sequence of bytes that also provides random and unaligned access to the fixed-width integers and floating point numbers represented by those bytes.
BytesBuilder
Builds a list of bytes, allowing bytes and lists of bytes to be added at the end.
ConsoleOutput
Pretty-prints log records to stdout with optional ANSI colors.
Endian
Endianness of number representation.
Float32List
A fixed-length list of IEEE 754 single-precision binary floating-point numbers that is viewable as a TypedData.
Float32x4
Four 32-bit floating point values.
Float32x4List
A fixed-length list of Float32x4 numbers that is viewable as a TypedData.
Float64List
A fixed-length list of IEEE 754 double-precision binary floating-point numbers that is viewable as a TypedData.
Float64x2
Float64x2 immutable value type and operations.
Float64x2List
A fixed-length list of Float64x2 numbers that is viewable as a TypedData.
GrpcHealthCheckContract
gRPC Health Checking service contract (grpc.health.v1.Health).
GrpcHealthCheckRequest
Health check request. service is the fully-qualified service name (e.g. "grpc.health.v1.Health"). Empty string means the overall server.
GrpcHealthCheckResponse
Health check response carrying the status of a service.
GrpcHealthServiceStatus
Manages per-service health status and notifies watchers on changes.
Int16List
A fixed-length list of 16-bit signed integers that is viewable as a TypedData.
Int32List
A fixed-length list of 32-bit signed integers that is viewable as a TypedData.
Int32x4
Int32x4 and operations.
Int32x4List
A fixed-length list of Int32x4 numbers that is viewable as a TypedData.
Int64List
A fixed-length list of 64-bit signed integers that is viewable as a TypedData.
Int8List
A fixed-length list of 8-bit signed integers.
IRpcAdvisoryChannelError
Marks a channel error that does NOT mean the connection is gone.
IRpcChannel
Raw bidirectional byte channel -- the minimal transport primitive.
IRpcCodec<T>
Contract for encoding and decoding messages.
IRpcConnectionBuffer
One connection-wide total of request bytes held un-consumed.
IRpcContract
Base interface for all contracts.
IRpcFlowCredit
Flow-control metering a higher layer takes over for a stream.
IRpcInterceptor
Interceptor interface.
IRpcMultiplexedChannel
Multiplexed message channel -- sits between a raw transport and IRpcTransport.
IRpcReconnectOutcome
The outcome of a reconnecting transport's next attempt; see IRpcTransport.reconnectOutcome.
IRpcSerializable
Base interface for RPC messages that can be turned into bytes.
IRpcServer
Interface for RPC servers.
IRpcTransport
Transport interface with Stream ID multiplexing.
LogConfig
Snapshot of controller configuration (for remote control / diagnostics).
LogController
Central log dispatcher.
LogEnricher
Enricher adds fields to every log record passing through the pipeline.
LogEvent
A point-in-time log event.
LogFilter
Filter criteria for log subscriptions and queries.
LogOutput
Interface for log output backends.
LogRecord
Base type for all log records flowing through the pipeline.
LogRedactor
Redacts sensitive fields from log record data.
LogScope
Lightweight logging handle bound to a scope name and controller.
LogSpan
A completed operation span with duration.
LogSpanHandle
Handle to an active (in-progress) span.
LogSpanStart
Marks the beginning of a span.
RingBufferOutput
In-memory circular buffer that keeps the last N log records.
RpcBackoffPolicy
Strategy for computing delays between retry/reconnect attempts.
RpcBadRequest
Describes field-level validation errors.
RpcBinaryCodec<T>
Generic binary codec wrapper.
RpcBool
Wrapper for a boolean value.
RpcBufferedBroadcastController<T>
A broadcast stream controller that retains events while it has no listener and replays them, in arrival order, to the first subscriber.
RpcCallCancelled
The call was cancelled: its consumer cancelled the response stream before it ended, or the call threw RpcCancelledException.
RpcCallerContract
Client-side contract that invokes methods (does not register them).
RpcCallerEndpoint
Client-side RPC endpoint for sending requests.
RpcCallerEndpointMetrics
What an RpcCallerEndpoint reports.
RpcCallFailed
The call failed with error.
RpcCallInfo
The call an interceptor is running in: the endpoint, the method and the current RpcContext.
RpcCallObserverInterceptor<S>
An interceptor that sees every call start and end, for all four call shapes.
RpcCallOutcome
How an observed call ended. See RpcCallObserverInterceptor.
RpcCallScope
Structured concurrency scope for an RPC call.
RpcCallSucceeded
The call completed: a response, or a response stream that ended with no error.
RpcCancellationToken
Operation cancellation token (analogous to context.CancelFunc in Go).
RpcCborCodec
CBOR (Concise Binary Object Representation) implementation for RPC. Format reference: RFC 7049 https://tools.ietf.org/html/rfc7049
RpcChannelCloseReason
Why a channel is closing on the peer's account; see IRpcChannel.closeFor.
RpcChannelFrame
Multiplexed frame format for IRpcChannel-based transports.
RpcChannelTransport
Full IRpcTransport built from an IRpcMultiplexedChannel.
RpcCircuitBreakerInterceptor
Interceptor that implements the circuit breaker pattern.
RpcClientConnecting
Waiting before the next connection attempt.
RpcClientConnection
Manages a reconnecting RPC client transport with observable state.
RpcClientConnectionState
Observable state emitted by RpcClientConnection.
RpcClientDisconnected
Reconnect permanently stopped because max attempts exceeded or RpcClientConnection.shouldReconnect returned false.
RpcClientIdle
No connection has been started yet (or RpcClientConnection.disconnect was called).
RpcClientOffline
Transport dropped — reconnect loop running.
RpcClientOnline
Transport connected and ready for calls.
RpcCloseForOversize
The peer's message was larger than the policy allows.
RpcCloseForProtocolError
The peer sent something malformed or broke the security policy.
RpcCodec<T extends IRpcSerializable>
CBOR serializer for RPC messages.
RpcCompressionCodec
Interface for a pluggable compression codec.
RpcConnectionHost
The per-connection half of a server: the endpoint for each connection, its release when the connection ends, the connection cap, and drain-then-close.
RpcConstants
Fixed values of the 5-byte gRPC message prefix.
RpcContext
gRPC-style RPC context - holds call metadata, timeouts, cancellation tokens, and other contextual information.
RpcContextKey<T extends Object>
A typed key for a value an RpcContext carries.
RpcDebugInfo
Server-side debug information (stack traces, diagnostic details).
RpcDecodedFrame
A decoded multiplexed frame.
RpcDouble
Wrapper for a double value.
RpcEndpointBase
Base class for all RPC endpoints.
RpcEndpointHealth
Health report for an RPC endpoint.
RpcEndpointMetrics
A snapshot of an endpoint's counters, from RpcEndpointBase.collectEndpointMetrics.
RpcEndpointPingExchange
Manages sending a ping and handling its response for an endpoint.
RpcEndpointPingProtocol
Ping protocol constants and metadata between endpoints.
RpcEndpointPingResult
Ping result between endpoints.
RpcErrorDetail
A structured error detail attached to RpcStatusException.
RpcErrorInfo
Describes the cause of an error with a reason, domain, and metadata.
RpcExponentialBackoff
Exponential backoff: baseDelay * 2^attempt, capped at maxDelay.
RpcFieldViolation
A single field validation error.
RpcFixedBackoff
Fixed delay between every attempt.
RpcFrameMultiplexedChannel
IRpcMultiplexedChannel that wraps a raw IRpcChannel with frame encoding.
RpcGrpcCompression
Minimal gRPC message compression helpers.
RpcHeader
Represents a single HTTP/2 header.
RpcHeaders
gRPC-semantic header name constants.
RpcHealthStatus
Snapshot of a component's health.
RpcInt
Wrapper for an integer value.
RpcList<T extends IRpcSerializable>
Specialized list for objects implementing IRpcSerializable.
RpcMessageFrame
Packs and unpacks the 5-byte gRPC message prefix: one compression-flag byte (0 or 1), then the payload length as a big-endian uint32.
RpcMessageHeader
What RpcMessageFrame.parseHeader read out of a 5-byte gRPC prefix.
RpcMessageParser
Parser that reassembles fragmented gRPC messages.
RpcMetadata
Request/response metadata (a set of gRPC headers).
RpcMethod
Describes how a method should be registered and invoked.
RpcNull
Wrapper for null.
RpcNum
Wrapper for a numeric value.
RpcPeerContract
Bidirectional peer contract — registers handlers AND makes outgoing calls through the same RpcPeerEndpoint.
RpcPeerEndpoint
Bidirectional peer endpoint — can both send requests and handle incoming ones.
RpcPeerEndpointMetrics
What an RpcPeerEndpoint reports: the responder counters and the caller ones.
RpcPeerMode
Each connection gets an RpcPeerEndpoint; both sides may start calls.
RpcPrimitiveMessage<T>
Base class for all primitive message types.
RpcProtoReader
Reads protobuf wire format from bytes, one field at a time.
RpcProtoWireType
Protobuf wire types this library reads and writes.
RpcProtoWriter
Writes protobuf wire format.
RpcRateLimit
Describes a rate-limit algorithm and its parameters.
RpcRateLimitInterceptor
Rate-limiting interceptor for RpcResponderEndpoint.
RpcRawErrorDetail
An unknown/unrecognized error detail preserved as raw bytes.
RpcRecentIds
A set of the stream ids added most recently, bounded by capacity.
RpcRemoved
Marks an inherited RPC method as removed in this contract version.
RpcResponderContract
Server-side contract that registers and handles methods.
RpcResponderEndpoint
Server-side RPC endpoint that handles incoming requests.
RpcResponderEndpointMetrics
What an RpcResponderEndpoint reports.
RpcResponderMode
Each connection gets an RpcResponderEndpoint; only the client starts calls.
RpcRetryInfo
Tells the client how long to wait before retrying.
RpcRetryInterceptor
Interceptor that retries failed unary calls with backoff.
RpcSecurityPolicy
Centralized security/robustness limits for transports and parsers.
RpcServerMode
What a server builds for each connection, and how the application's contracts get onto it.
RpcService
Marks a service interface to generate caller/responder wrappers.
RpcStreamIdManager
Stream ID manager for HTTP/2 connections.
RpcStreamRouter
Per-stream delivery for a transport that multiplexes many calls.
RpcString
Wrapper for a string value.
RpcTrailers
The metadata frames a transport builds itself rather than receives: status trailers, the cancellation notice, and the trailers a caller synthesizes for a response that is not gRPC.
RpcTransportMessage
Transport-layer message with Stream ID support.
RpcWriteBacklog
Stops reading a peer while too much of what was written to it is unsent.
RpcWriteCoalescer
Joins the frames written in one event-loop turn into one write.
SamplingConfig
Per-level sampling configuration.
TypedData
A typed view of a sequence of bytes.
TypedDataList<E>
A TypedData fixed-length List-view on the bytes of buffer.
Uint16List
A fixed-length list of 16-bit unsigned integers that is viewable as a TypedData.
Uint32List
A fixed-length list of 32-bit unsigned integers that is viewable as a TypedData.
Uint64List
A fixed-length list of 64-bit unsigned integers that is viewable as a TypedData.
Uint8ClampedList
A fixed-length list of 8-bit unsigned integers.
Uint8List
A fixed-length list of 8-bit unsigned integers.

Enums

ConsoleFormat
Console output format.
GrpcServingStatus
gRPC serving status per the health checking protocol.
LogSpanStatus
Status of a completed span.
RpcCallDirection
Which way a call goes, from the endpoint running the interceptor.
RpcCircuitBreakerState
Circuit breaker states.
RpcContentTypeValidation
How a peer's missing content-type is treated.
RpcDataTransferMode
Data transfer modes in RPC contracts.
RpcHealthLevel
Health level of an RPC component.
RpcLogLevel
Log severity levels.
RpcMethodType
The four call shapes, for registration and for @RpcMethod.
RpcServiceKind
Communication pattern for a service contract.
RpcStatus
The gRPC status codes. code is the number on the wire.

Extensions

RpcBoolX on bool
Extension to wrap bool as RpcBool.
RpcDoubleX on double
Extension to wrap double as RpcDouble.
RpcHealthLevelSeverity on RpcHealthLevel
Extension to compare health-level severity.
RpcIntX on int
Extension to wrap int as RpcInt.
RpcNullX on void
Extension to wrap void as RpcNull.
RpcNumX on num
Extension to wrap num as RpcNum.
RpcStringX on String
Extension to wrap String as RpcString.

Constants

kInternalErrorWireMessage → const String
The grpc-message sent for an error the handler did NOT describe itself.

Functions

approxJsonBytes(Object? value) → int
Approximate size of value's JSON form, without encoding it: the UTF-16 code units of every string, keys included, plus 8 for each other scalar. An IRpcSerializable counts as its IRpcSerializable.toJson.
drainUntilIdle({required FutureOr<int> pending(), required Duration budget, LogScope? logger, String unit = 'call'}) → Future<void>
Waits for a server's in-flight work to finish, up to budget.
grpcStatusFromHttpStatus(int httpStatus) → RpcStatus
The gRPC status for a non-200 HTTP response, for every transport.
isFaultError(Object error) → bool
RpcStatus.isFault for a caught error. A throw that carries no status is a fault: an unclassifiable failure is not an application answering. An RpcPeerFaultException is not, whatever its status: the peer sent it.
notifyWithoutDying(String what, void body(), {LogScope? logger}) → void
Runs an observability callback without letting it take the process out.
requestEndedMidMessage() → RpcStatusException
What a responder of any shape answers a request that ends inside a gRPC frame: INTERNAL, as grpc-go does, raised as the peer's fault.
responseEndedMidMessage() → RpcStatusException
What a caller of any shape ends with when the response ends inside a gRPC frame: INTERNAL, not the peer's OK.
rpcPeerText(String text, {bool asciiOnly = true, int? maxRunes}) → String
text a peer sent, made safe to put in a log or an error message.
wireStatusFor(Object error) → ({Uint8List? detailsBin, String message, RpcStatus status})
Translates an error thrown by a handler into what may go on the wire.

Typedefs

RpcBidirectionalStreamNext<TRequest, TResponse> = FutureOr<Stream<TResponse>> Function(RpcContext context, Stream<TRequest> requests)
Handler type for the next step of a bidirectional-stream call.
RpcClientStreamNext<TRequest, TResponse> = Future<TResponse> Function(RpcContext context, Stream<TRequest> requests)
Handler type for the next step of a client-stream call.
RpcRetryPredicate = bool Function(Object error)
Predicate that decides whether an error is retryable.
RpcServerStreamNext<TRequest, TResponse> = FutureOr<Stream<TResponse>> Function(RpcContext context, TRequest request)
Handler type for the next step of a server-stream call.
RpcUnaryNext<TRequest, TResponse> = Future<TResponse> Function(RpcContext context, TRequest request)
Handler type for the next step of a unary call.

Exceptions / Errors

RpcCancelledException
Operation cancellation exception, carrying CANCELLED.
RpcCircuitBreakerOpenException
Exception thrown when a circuit breaker is open.
RpcClosedException
A closed endpoint or transport was asked to do work.
RpcDeadlineExceededException
Deadline-exceeded exception, carrying DEADLINE_EXCEEDED.
RpcException
Base exception for the RPC core.
RpcFrameException
Thrown when an incoming multiplexed frame violates protocol limits or is malformed (oversized declared payload, bad metadata encoding).
RpcMetadataViolationException
Metadata failed RpcSecurityPolicy.validateMetadata.
RpcNoConnectionException
A reconnecting connection with no live transport — and which of the two such states it is.
RpcRateLimitException
Thrown by RpcRateLimitInterceptor when a call exceeds the configured limit.
RpcStatusException
An exception thrown from an RPC handler to return a specific gRPC status code to the caller.