RateLimitedRequestAttemptConfig<T> constructor

RateLimitedRequestAttemptConfig<T>({
  1. required String domain,
  2. required String source,
  3. Map<String, String>? defaultExtraData,
  4. int? maxAttempts,
  5. Duration? timeframe,
  6. Future<void> onRateLimitExceeded(
    1. Session session,
    2. T nonce
    )?,
  7. String nonceToString(
    1. T nonce
    )?,
  8. T nonceFromString(
    1. String nonce
    )?,
})

Creates a new RateLimitedRequestAttemptUtil instance.

At least one of maxAttempts or timeframe must be provided.

Throws ArgumentError if both maxAttempts and timeframe are null.

Implementation

RateLimitedRequestAttemptConfig({
  required this.domain,
  required this.source,
  this.defaultExtraData,
  this.maxAttempts,
  this.timeframe,
  this.onRateLimitExceeded,
  final String Function(T nonce)? nonceToString,
  final T Function(String nonce)? nonceFromString,
}) : assert(
       maxAttempts != null || timeframe != null,
       'At least one of maxAttempts or timeframe must be provided',
     ) {
  this.nonceToString = nonceToString ?? _nonceToString;
  this.nonceFromString = nonceFromString ?? _nonceFromString;
}