retry-strategy 0.2.0

A better asynchronous retry tool based on Tokio.
Documentation
  • Coverage
  • 55%
    11 out of 20 items documented1 out of 16 items with examples
  • Size
  • Source code size: 18.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.38 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • huster-zhangpeng

retry-strategy

A better asynchronous retry tool based on Tokio. The original Tokio::timeout function ends after a single timeout, but a single timeout may be affected by random factors. For example, establishing a connection or making an HTTP request often requires three timeout retries. If all retries fail, it is considered a final timeout.

Retry-strategy provides rich and simple timeout settings, allowing you to easily and flexibly set the number of retries, the duration of each timeout, and even more complex strategies. We hope it brings convenience to you.

Installation

Add dependencies to your Cargo.toml:

[dependencies]
retry-strategy = "0.2"

Examples

use retry_strategy::prelude::*;

let tcp_connection = retry(
    vec![100.ms(), 200.ms(), 300.ms()], 
    |_n| TcpStream::connect("127.0.0.1:8080")
).await?;