resilify_retrofit library

Opt-in package:retrofit integration for resilify.

Adds .toResult() extensions on the Future<T> and Future<HttpResponse<T>> returned by Retrofit-generated clients. Pulls in both dio and retrofit as transitive dependencies.

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

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.
RetrofitFutureResultX on Future<T>
Converts a Retrofit Future<T> (the typical generated return type) into a Future<Result<T>>.
RetrofitHttpResponseResultX on Future<HttpResponse<T>>
Converts a Retrofit Future<HttpResponse<T>> (returned when you opt-in to the full response object) into a Future<Result<T>>.
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.

Exceptions / Errors

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