rpc_dart library

The application API: contracts, endpoints, context, errors, codecs, resilience, logging and the channel transport with its in-memory pairs.

A transport author also imports package:rpc_dart/transport.dart, which re-exports this library.

Every name is listed on purpose. The integration-only primitives have their own explicit list in internal.dart. Other names are internal to the package, whatever their spelling.

dart:typed_data is re-exported whole: payloads are Uint8List, and the generator emits part files, which cannot import it themselves.

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
Four 32-bit integer values.
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.
IRpcCodec<T>
Contract for encoding and decoding messages.
IRpcContract
Base interface for all contracts.
IRpcInterceptor
Interceptor interface.
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.
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
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.
RpcClientConnectionMetrics
An immutable snapshot of a RpcClientConnection's lifetime counters.
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.
RpcClientSuspended
Reconnects are suspended and no live transport is attached.
RpcCodec<T extends IRpcSerializable>
CBOR serializer for RPC messages.
RpcCompressionCodec
Interface for a pluggable compression codec.
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).
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.
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.
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.
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.
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.
RpcReconnectPolicy
An opt-in reconnect policy based on RPC status and server pushback.
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.
RpcString
Wrapper for a string value.
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

ByteDataComparison on ByteData
Range comparison operation on ByteData.
Int16ListComparison on Int16List
Range comparison operation on Int16List.
Int32ListComparison on Int32List
Range comparison operation on Int32List.
Int64ListComparison on Int64List
Range comparison operation on Int64List.
Int8ListComparison on Int8List
Range comparison operation on Int8List.
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.
Uint16ListComparison on Uint16List
Range comparison operation on Uint16List.
Uint32ListComparison on Uint32List
Range comparison operation on Uint32List.
Uint64ListComparison on Uint64List
Range comparison operation on Uint64List.
Uint8ClampedListComparison on Uint8ClampedList
Range comparison operation on Uint8ClampedList.
Uint8ListComparison on Uint8List
Range comparison operation on Uint8List.

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.

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.
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.