पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv7.0.1

dio_smart_retry

Dio और Dio पैकेज के लिए रीट्राई लाइब्रेरी, प्यार से बनाई गई। डिफ़ॉल्ट रूप से, केवल उचित रीट्राई योग्य HTTP स्थितियों के लिए ही अनुरोध को दोहराया जाएगा।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
2.1 लाख
लाइक
314
Pub अंक
145

पैकेज इंस्टॉल करें

flutter pub add dio_smart_retry

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

Dio Smart Retry एक रीट्राई उपकरण है जो Dio HTTP क्लाइंट के लिए डिज़ाइन किया गया है, जो पूर्वनिर्धारित शर्तों के आधार पर अनुरोधों को स्वचालित रूप से दोहराता है। यह डिफ़ॉल्ट रूप से केवल ऐसे HTTP स्थिति कोड के लिए रीट्राई करता है जिन्हें रीट्राई के लिए माना जाता है, जैसे 5xx सर्वर त्रुटियाँ या नेटवर्क समय समाप्त होने के कारण। सरलता और विश्वसनीयता के साथ बनाया गया, यह मौजूदा Dio सेटअप में बिना किसी दिक्कत के एकीकृत होता है। यह पैकेज सभी प्रमुख प्लेटफॉर्म के लिए समर्थन करता है, जिनमें Android, iOS, Web, macOS, Windows और Linux शामिल हैं, जिससे यह क्रॉस-प्लेटफॉर्म Flutter ऐप्स में विश्वसनीय नेटवर्क ऑपरेशन के लिए आदर्श बन जाता है।

उपयोग

  • अस्थायी नेटवर्क विफलताओं का प्रबंधन
  • सर्वर त्रुटियों के लिए स्वचालित पुनर्प्रयास
  • खराब कनेक्टिविटी के दौरान ऐप की लचीलापन में सुधार करना
  • API कॉल में त्रुटि हैंडलिंग को सरल बनाना
  • व्यावसायिक कोड में हस्तचालित पुनर्प्रयास तर्क को कम करना

मुख्य विशेषताएँ

  • पुनर्याचनीय HTTP स्थितियों के लिए स्वचालित पुनर्याचन
  • Dio के साथ आसान एकीकरण
  • कई प्लेटफॉर्म का समर्थन करता है
  • कॉन्फ़िगरेबल रीट्राई व्यवहार
  • हल्का और न्यूनतम ओवरहेड

इनके लिए उपयुक्त

  • अक्सर API कॉल वाले Flutter ऐप्स
  • विश्वसनीय नेटवर्क संचार की आवश्यकता वाले ऐप्स
  • सरल पुनर्प्रयास तर्क की खोज कर रहे विकासकर्मी
  • HTTP अनुरोध के लिए Dio का उपयोग करने वाले प्रोजेक्ट
  • बॉयलरप्लेट त्रुटि संभाल को कम करना चाहने वाली टीमें

विचार योग्य बातें

  • ग्राहक त्रुटियों (4xx) के लिए डिफ़ॉल्ट रूप से पुनर्प्रयास नहीं करता है
  • कस्टम पुनर्प्रयास तंत्र को अतिरिक्त कॉन्फ़िगरेशन की आवश्यकता होती है
  • Dio-आधारित HTTP क्लाइंट्स तक सीमित
  • उच्च-प्रतीक्षा वातावरण के लिए समायोजन की आवश्यकता हो सकती है
  • मूल रीट्राई के अतिरिक्त कोई निर्मित बैकऑफ स्ट्रेटेजी नहीं है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Pub Version Dart SDK Version style: very good analysis License

Dio Smart Retry

Flexible retry library for Dio package. This is a next generation of an abandoned dio_retry package.
By default, the request will be retried only for appropriate retryable http statuses.
Also, it supports dynamic delay between retries.
Null Safety.

Contents

Getting Started for Dio

  1. Add package to pubspec.yaml: dio_smart_retry: ^7.0.0 **
  2. Import package: import 'package:dio_smart_retry/dio_smart_retry.dart'

** For the old dio (ver. 4.+) use dio_smart_retry: ^1.4.0

Usage

Just add an interceptor to your dio:

final dio = Dio();
// Add the interceptor
dio.interceptors.add(RetryInterceptor(
  dio: dio,
  logPrint: print, // specify log function (optional)
  retries: 3, // retry count (optional)
  retryDelays: const [ // set delays between retries (optional)
    Duration(seconds: 1), // wait 1 sec before first retry
    Duration(seconds: 2), // wait 2 sec before second retry
    Duration(seconds: 3), // wait 3 sec before third retry
  ],
));

/// Sending a failing request for 3 times with 1s, then 2s, then 3s interval
await dio.get('https://mock.codes/500');

See example/dio_smart_retry_example.dart.

Default retryable status codes list

Responses with these http status codes will be retried by default:

  • 408: RequestTimeout
  • 429: TooManyRequests
  • 500: InternalServerError
  • 502: BadGateway
  • 503: ServiceUnavailable
  • 504: GatewayTimeout
  • 440: LoginTimeout (IIS)
  • 460: ClientClosedRequest (AWS Elastic Load Balancer)
  • 499: ClientClosedRequest (ngnix)
  • 520: WebServerReturnedUnknownError
  • 521: WebServerIsDown
  • 522: ConnectionTimedOut
  • 523: OriginIsUnreachable
  • 524: TimeoutOccurred
  • 525: SSLHandshakeFailed
  • 527: RailgunError
  • 598: NetworkReadTimeoutError
  • 599: NetworkConnectTimeoutError It's possible to override this list

Disable retry

It's possible to manually disable retry for a specified request. Use disableRetry extension for that:

final request = RequestOptions(path: '/')
  ..disableRetry = true;
await dio.fetch<String>(request);

or

final options = Options()
  ..disableRetry = true;
await dio.get<String>('/', options: options);

Add extra retryable status codes

It's possible to add you own retryable status codes. Use retryableExtraStatuses parameter for that. Here is an example:

RetryInterceptor(
  dio: dio,
  retryableExtraStatuses: { status401Unauthorized },
)

or:

RetryInterceptor(
  dio: dio,
  retryableExtraStatuses: { 401 },
)

Override retryable statuses

It's possible to override default retryable status codes list. Just make new instance of DefaultRetryEvaluator and pass your status codes there.
Here is an example:

final myStatuses = { status400BadRequest, status409Conflict };
dio.interceptors.add(
  RetryInterceptor(
    dio: dio,
    logPrint: print,
    retryEvaluator: DefaultRetryEvaluator(myStatuses).evaluate,
  ),
);

await dio.get<dynamic>('https://mock.codes/400');

Migrating to 7.0

Use MultipartFile instead of MultipartFileRecreatable.

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 3 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट