RateLimitedRequestAttemptConfig<T> class

Configuration for rate limiting request attempts.

This class provides configuration for the RateLimitedRequestAttemptUtil to track and limit attempts based on domain, source, and nonce.

The rate limiting can be configured in two ways:

  • By attempt count: Limits the total number of attempts (requires maxAttempts)
  • By timeframe: Limits attempts within a rolling window (requires timeframe)

Both mechanisms can be used together, but at least one of maxAttempts or timeframe must be provided.

At least one of maxAttempts or timeframe must be provided.

Type parameter T represents the type of the nonce.

Constructors

RateLimitedRequestAttemptConfig({required String domain, required String source, Map<String, String>? defaultExtraData, int? maxAttempts, Duration? timeframe, Future<void> onRateLimitExceeded(Session session, T nonce)?, String nonceToString(T nonce)?, T nonceFromString(String nonce)?})
Creates a new RateLimitedRequestAttemptUtil instance.

Properties

defaultExtraData Map<String, String>?
Default extra data to be logged for the attempt.
final
domain String
The domain of the attempt.
final
hashCode int
The hash code for this object.
no setterinherited
maxAttempts int?
The maximum number of attempts allowed.
final
nonceFromString ↔ T Function(String nonce)
Converts the nonce from a string.
latefinal
nonceToString String Function(T nonce)
Converts the nonce to a string.
latefinal
onRateLimitExceeded Future<void> Function(Session session, T nonce)?
Optional callback called when rate limit is exceeded.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source String
The source of the attempt.
final
timeframe Duration?
The timeframe within which attempts are counted.
final

Methods

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