ilkersevim_retry 0.1.0 copy "ilkersevim_retry: ^0.1.0" to clipboard
ilkersevim_retry: ^0.1.0 copied to clipboard

Retry policies with backoff, jitter, and cancel tokens. Pure Dart; injectable RetryDelay for testable waits.

example/main.dart

import 'package:ilkersevim_retry/ilkersevim_retry.dart';

Future<void> main() async {
  const RetryPolicy policy = RetryPolicy(
    maxAttempts: 3,
    baseDelay: Duration(milliseconds: 1),
    jitter: false,
  );

  Future<void> immediateDelay(final Duration _) async {}

  int attempts = 0;
  final int result = await policy.executeWithRetry<int>(
    action: () async {
      attempts++;
      if (attempts < 3) {
        throw StateError('transient');
      }
      return attempts;
    },
    delay: immediateDelay,
  );

  print('succeeded after $result attempts');
}
1
likes
0
points
94
downloads

Publisher

unverified uploader

Weekly Downloads

Retry policies with backoff, jitter, and cancel tokens. Pure Dart; injectable RetryDelay for testable waits.

Repository (GitHub)
View/report issues

Topics

#retry #async #dart

License

unknown (license)

More

Packages that depend on ilkersevim_retry