http_extensions_retry 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

http_extensions : retry #

An [http extension] that retries failed requests.

Usage #

final client = ExtendedClient(
  inner: Client(),
  extensions: [
    RetryExtension(
        logger: Logger("Retry"),
        defaultOptions: RetryOptions(
          const RetryOptions(
      retries: 3, // Number of retries before a failure
      retryInterval: const Duration(seconds: 5), // Interval between each retry
      retryEvaluator: (error, response) => error != null, // Evaluating if a retry is necessary regarding the error or the response. It is a good candidate for updating authentication token in case of a unauthorized error (be careful with concurrency though). error or response are at least null
        )),
  ],
);

0.1.1 #

  • Fixed issues with copied StreamRequests

0.1.0 #

  • Initial version

example/example.dart

import 'package:http_extensions/http_extensions.dart';
import 'package:http_extensions_retry/http_extensions_retry.dart';
import 'package:logging/logging.dart';
import 'package:http/http.dart';

main() async {
  // Displaying logs
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('${record.level.name}: ${record.time}: ${record.message}');
  });

  final client = ExtendedClient(
    inner: Client(),
    extensions: [
      RetryExtension(
          logger: Logger("Retry"),
          defaultOptions: RetryOptions(
            retryInterval: const Duration(seconds: 5),
          )),
    ],
  );

  /// Sending a failing request for 3 times with a 5s interval
  try {
    await client.get("http://www.mqldkfjmdisljfmlksqdjfmlkj.dev");
  } catch (e) {
    print("End error : $e");
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  http_extensions_retry: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:http_extensions_retry/http_extensions_retry.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
87
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:http_extensions_retry/http_extensions_retry.dart.

Health suggestions

Format lib/http_extensions_retry.dart.

Run dartfmt to format lib/http_extensions_retry.dart.

Format lib/src/extension.dart.

Run dartfmt to format lib/src/extension.dart.

Maintenance suggestions

The package description is too short. (-13 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
http ^0.12.0+1 0.12.0+2
http_extensions ^0.1.1 0.1.2
logging ^0.11.3 0.11.3+2
meta ^1.1.6 1.1.7
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6