resilify_http library
Opt-in package:http integration for resilify.
Pulls in package:http as a transitive dependency. Import only if you
intend to use HttpResultHandler. For richer features (interceptors, file
transfers) prefer the Dio integration.
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.
- HttpResultHandler
-
A thin, opt-in adapter that wraps
package:httpcalls in Result values. -
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 aFuture<Result<T>>without writingResult.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
-
JsonParser<
T> = T Function(Object? json) -
Decodes an already-decoded JSON value (typically
Map<String, dynamic>orList<dynamic>) into a typed modelT. - 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.