RetryConfig class final
This class represents an automatic retry configuration.
Exponential BackOff Algorithm and Jitter
Simply increasing the wait time exponentially is still not sufficient to distribute retry timing. In addition to simply increasing the interval exponentially, adding a random number called Jitter is effective. This method allows for even greater flexibility in distributing the timing of retries.
import 'package:bluesky/bluesky.dart';
void main() async {
final bluesky = Bluesky(
accessJwt: 'YOUR_TOKEN_HERE',
retryConfig: RetryConfig(
maxAttempts: 5,
),
timeout: Duration(seconds: 20),
);
}
The interval, which increases with the number of retries, is then calculated as follows.
(2 ^ retryCount) + jitter(Random Number between 0 ~ 3)
Remarks
Please note that ArgumentError is always raised if a negative number is passed to the maxAttempts field of RetryConfig.
Constructors
- RetryConfig({required int maxAttempts, Jitter? jitter, dynamic onExecute(RetryEvent event)?})
- Returns the new instance of RetryConfig.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- jitter → Jitter
-
The user defined jitter.
final
- maxAttempts → int
-
Maximum number of retry attempts.
final
- onExecute → dynamic Function(RetryEvent event)?
-
A callback function to be called when the retry is executed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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