resilify_chopper library
Opt-in package:chopper integration for resilify.
Adds .toResult() on Future<Response<T>> returned by Chopper services.
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
-
ChopperResponseResultX
on Future<
Response< BodyType> > -
Converts a Chopper
Future<Response<BodyType>>into aFuture<Result<BodyType>>. -
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.
Functions
-
defaultChopperFailureMapper<
BodyType> (Response< BodyType> response) → Failure -
Default ChopperFailureMapper used when none is provided to
.toResult.
Typedefs
-
ChopperFailureMapper<
BodyType> = Failure Function(Response< BodyType> response) -
Builds a Failure from a non-successful Chopper
Response. - 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.