RetryConfig class final
Recommended defaults: 4 attempts, 100ms initial, 30s max, full jitter, retry on the four transient codes above. Override individual fields via the named parameters.
Constructors
-
RetryConfig({int maxAttempts = 4, Duration initial = const Duration(milliseconds: 100), Duration max = const Duration(seconds: 30), Duration minDelay = Duration.zero, double multiplier = 2.0, double decorrelationFactor = 3.0, RetryStrategy strategy = RetryStrategy.full, bool honorRetryAfter = true, bool allowNonIdempotent = false, Set<
Code> retryableCodes = defaultRetryableCodes, bool isRetryable(ConnectException error)?, double jitterSource()?, Future<void> sleep(Duration delay)?}) -
Builds a RetryConfig with RFC 0006 defaults.
const
Properties
- allowNonIdempotent → bool
-
Bypass the schema-driven idempotency safety gate. Default false:
methods without
idempotency_level = IDEMPOTENT(orNO_SIDE_EFFECTS) are not retried. Set true only when paired with an idempotency-key interceptor and a server that deduplicates by key.final - decorrelationFactor → double
-
Bound for RetryStrategy.decorrelated: each draw is taken from
[initial, prev * decorrelationFactor].final - hashCode → int
-
The hash code for this object.
no setterinherited
- honorRetryAfter → bool
-
When true (default), a server-supplied
retry-afterheader orgoogle.rpc.RetryInfodetail overrides the locally-computed backoff.final - initial → Duration
-
Initial backoff floor and seed for the per-attempt ceiling.
final
- isRetryable → bool Function(ConnectException error)?
-
Custom predicate, overriding retryableCodes when non-null.
final
- jitterSource → double Function()?
-
Source of the uniform
[0.0, 1.0)jitter draw. Defaults to defaultJitterSource (Random.secure).final - max → Duration
-
Maximum local backoff. Does not clamp server-supplied retry hints.
final
- maxAttempts → int
-
Maximum attempts, including the first call. RFC 0006 default is 4.
Clamped to a minimum of 2 by the interceptor.
final
- minDelay → Duration
-
Optional floor for RetryStrategy.full. Ignored by
RetryStrategy.decorrelated, whose floor is always initial.
final
- multiplier → double
-
Growth factor applied to the per-attempt ceiling under
RetryStrategy.full.
final
-
retryableCodes
→ Set<
Code> -
Status codes that trigger a retry when isRetryable is null.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sleep
→ Future<
void> Function(Duration delay)? -
Hook used to pause between attempts. Defaults to Future.delayed.
Tests inject a fake to capture the requested delay sequence.
final
- strategy → RetryStrategy
-
Jitter scheme selecting between full and decorrelated.
final
Methods
-
copyWith(
{int? maxAttempts, Duration? initial, Duration? max, Duration? minDelay, double? multiplier, double? decorrelationFactor, RetryStrategy? strategy, bool? honorRetryAfter, bool? allowNonIdempotent, Set< Code> ? retryableCodes, bool isRetryable(ConnectException error)?, double jitterSource()?, Future<void> sleep(Duration delay)?}) → RetryConfig - Returns a copy with the given fields overridden. Mirrors the Go implementation's pattern of starting from defaults and tweaking.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited