resilify_websocket library

Opt-in package:web_socket_channel integration for resilify.

Re-exports WebSocketChannel so callers don't need a second import for the channel factory.

Classes

CircuitBreaker
Wraps an unreliable operation with the circuit-breaker resilience pattern: after failureThreshold consecutive failures the breaker "opens" and fast-fails calls for resetTimeout; one probe call is then admitted, and its outcome decides whether the breaker closes or reopens.
Error<T>
The failed variant of a Result.
Failure
An immutable, structured description of why an operation failed.
ReconnectConfig
Configuration for WebSocketResultHandler's exponential-backoff reconnect loop.
Result<T>
A type-safe representation of an operation that either produced a value of type T (Success) or failed with a Failure (Error).
ResultCache<K, V>
An in-memory cache for Result values with optional TTL expiry.
ResultDeduplicator<K, V>
Ensures only one Future<Result<V>> is in flight per key at any time.
RetryHelper
Static helpers for retrying Result-returning async operations.
Success<T>
The successful variant of a Result.
WebSocketChannel
A StreamChannel that communicates over a WebSocket.
WebSocketResultHandler<T>
A reconnecting, Result-flavored wrapper around a WebSocketChannel.

Enums

CircuitBreakerState
State of a CircuitBreaker.
FailureKind
Categorical tag describing what kind of thing went wrong, independent of any HTTP status code or human-readable message.
FailureType
Structural category of a Failure.

Extensions

FlattenResultX on Result<Result<T>>
Collapses a nested Result into a single layer. If the outer is an Error, it is returned unchanged; otherwise the inner Result is returned.
FutureResultX on Future<Result<T>>
Async helpers on Future<Result<T>>.
FutureToResultX on Future<T>
Bridges a regular Future<T> (which signals failure by throwing) into a Future<Result<T>> without writing Result.tryRunAsync(() => future) at every call site.
ResultAsyncX on Result<T>
Async transformations applied directly to a Result (not a future).
ResultListX on Result<List<T>>
Extensions that operate on the elements inside a successful list result.
ResultX on Result<T>
Synchronous helpers on Result.
StreamResultX on Stream<Result<T>>
Extensions for working with streams of Result values without unwrapping each event manually.

Typedefs

LogCallback = void Function(String line)
Sink for log lines emitted by resilify interceptors and handlers.
MessageParser<T> = T Function(dynamic raw)
Decodes a raw WebSocket frame (String or List<int>) into a typed message of type T.
WebSocketChannelFactory = WebSocketChannel Function()
Factory for opening a WebSocketChannel. Re-invoked on each reconnect.

Exceptions / Errors

ResultUnwrapException
Thrown by ResultX.getOrThrow when called on an Error.