copyWith method

RetryConfig copyWith({
  1. int? maxAttempts,
  2. Duration? initial,
  3. Duration? max,
  4. Duration? minDelay,
  5. double? multiplier,
  6. double? decorrelationFactor,
  7. RetryStrategy? strategy,
  8. bool? honorRetryAfter,
  9. bool? allowNonIdempotent,
  10. Set<Code>? retryableCodes,
  11. bool isRetryable(
    1. ConnectException error
    )?,
  12. double jitterSource()?,
  13. Future<void> sleep(
    1. Duration delay
    )?,
})

Returns a copy with the given fields overridden. Mirrors the Go implementation's pattern of starting from defaults and tweaking.

Implementation

RetryConfig copyWith({
  int? maxAttempts,
  Duration? initial,
  Duration? max,
  Duration? minDelay,
  double? multiplier,
  double? decorrelationFactor,
  RetryStrategy? strategy,
  bool? honorRetryAfter,
  bool? allowNonIdempotent,
  Set<Code>? retryableCodes,
  bool Function(ConnectException error)? isRetryable,
  double Function()? jitterSource,
  Future<void> Function(Duration delay)? sleep,
}) {
  return RetryConfig(
    maxAttempts: maxAttempts ?? this.maxAttempts,
    initial: initial ?? this.initial,
    max: max ?? this.max,
    minDelay: minDelay ?? this.minDelay,
    multiplier: multiplier ?? this.multiplier,
    decorrelationFactor: decorrelationFactor ?? this.decorrelationFactor,
    strategy: strategy ?? this.strategy,
    honorRetryAfter: honorRetryAfter ?? this.honorRetryAfter,
    allowNonIdempotent: allowNonIdempotent ?? this.allowNonIdempotent,
    retryableCodes: retryableCodes ?? this.retryableCodes,
    isRetryable: isRetryable ?? this.isRetryable,
    jitterSource: jitterSource ?? this.jitterSource,
    sleep: sleep ?? this.sleep,
  );
}