{"id":13595130,"url":"https://github.com/Xuanwo/backon","last_synced_at":"2025-04-09T10:32:57.151Z","repository":{"id":41822265,"uuid":"480787444","full_name":"Xuanwo/backon","owner":"Xuanwo","description":"Make retry like a built-in feature provided by Rust.","archived":false,"fork":false,"pushed_at":"2025-03-27T13:28:06.000Z","size":259,"stargazers_count":825,"open_issues_count":22,"forks_count":40,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T15:58:13.967Z","etag":null,"topics":["async","backoff","retry","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/backon/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xuanwo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Xuanwo"]}},"created_at":"2022-04-12T11:48:23.000Z","updated_at":"2025-04-01T09:07:53.000Z","dependencies_parsed_at":"2023-01-21T20:46:39.895Z","dependency_job_id":"e53925a8-78f1-4fad-8873-8f6ed0d6a8cc","html_url":"https://github.com/Xuanwo/backon","commit_stats":{"total_commits":87,"total_committers":16,"mean_commits":5.4375,"dds":"0.24137931034482762","last_synced_commit":"781b3670a08d5c979c69e70b1eb17346eef15054"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xuanwo%2Fbackon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xuanwo%2Fbackon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xuanwo%2Fbackon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xuanwo%2Fbackon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xuanwo","download_url":"https://codeload.github.com/Xuanwo/backon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248020593,"owners_count":21034459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","backoff","retry","rust"],"created_at":"2024-08-01T16:01:44.479Z","updated_at":"2025-04-09T10:32:52.143Z","avatar_url":"https://github.com/Xuanwo.png","language":"Rust","funding_links":["https://github.com/sponsors/Xuanwo"],"categories":["Rust"],"sub_categories":[],"readme":"# BackON \u0026emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![](https://img.shields.io/discord/1111711408875393035?logo=discord\u0026label=discord)](https://discord.gg/8ARnvtJePD)\n\n[Build Status]: https://img.shields.io/github/actions/workflow/status/Xuanwo/backon/ci.yml?branch=main\n[actions]: https://github.com/Xuanwo/backon/actions?query=branch%3Amain\n[Latest Version]: https://img.shields.io/crates/v/backon.svg\n[crates.io]: https://crates.io/crates/backon\n\n\u003cimg src=\"./.github/assets/logo.jpeg\" alt=\"BackON\" width=\"38.2%\"/\u003e\n\nMake **retry** like a built-in feature provided by Rust.\n\n- **Simple**: Just like a built-in feature: `your_fn.retry(ExponentialBuilder::default()).await`.\n- **Flexible**: Supports both blocking and async functions.\n- **Powerful**: Allows control over retry behavior such as [`when`](https://docs.rs/backon/latest/backon/struct.Retry.html#method.when) and [`notify`](https://docs.rs/backon/latest/backon/struct.Retry.html#method.notify).\n- **Customizable**: Supports custom retry strategies like [exponential](https://docs.rs/backon/latest/backon/struct.ExponentialBuilder.html), [constant](https://docs.rs/backon/latest/backon/struct.ConstantBuilder.html), etc.\n- **Adaptable**: Works on all platforms supported by Rust, including both `wasm` and `no-std`.\n\n---\n\n## Quick Start\n\n### Retry an async function.\n\n```rust\nuse anyhow::Result;\nuse backon::ExponentialBuilder;\nuse backon::Retryable;\n\nasync fn fetch() -\u003e Result\u003cString\u003e {\n    Ok(\"hello, world!\".to_string())\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    let content = fetch\n        // Retry with exponential backoff\n        .retry(ExponentialBuilder::default())\n        // Sleep implementation, required if no feature has been enabled\n        .sleep(tokio::time::sleep)\n        // When to retry\n        .when(|e| e.to_string() == \"EOF\")\n        // Notify when retrying\n        .notify(|err: \u0026anyhow::Error, dur: Duration| {\n            println!(\"retrying {:?} after {:?}\", err, dur);\n        })\n        .await?;\n    println!(\"fetch succeeded: {}\", content);\n\n    Ok(())\n}\n```\n\n### Retry a blocking function.\n\n```rust\nuse anyhow::Result;\nuse backon::BlockingRetryable;\nuse backon::ExponentialBuilder;\n\nfn fetch() -\u003e Result\u003cString\u003e {\n    Ok(\"hello, world!\".to_string())\n}\n\nfn main() -\u003e Result\u003c()\u003e {\n    let content = fetch\n        // Retry with exponential backoff\n        .retry(ExponentialBuilder::default())\n        // Sleep implementation, required if no feature has been enabled\n        .sleep(std::thread::sleep)\n        // When to retry\n        .when(|e| e.to_string() == \"EOF\")\n        // Notify when retrying\n        .notify(|err: \u0026anyhow::Error, dur: Duration| {\n            println!(\"retrying {:?} after {:?}\", err, dur);\n        })\n        .call()?;\n    println!(\"fetch succeeded: {}\", content);\n\n    Ok(())\n}\n```\n\n## Contributing\n\nCheck out the [CONTRIBUTING.md](./CONTRIBUTING.md) guide for more details on getting started with contributing to this\nproject.\n\n## Getting help\n\nSubmit [issues](https://github.com/Xuanwo/backon/issues/new/choose) for bug report or asking questions\nin [discussion](https://github.com/Xuanwo/backon/discussions/new?category=q-a).\n\n## License\n\nLicensed under \u003ca href=\"./LICENSE\"\u003eApache License, Version 2.0\u003c/a\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXuanwo%2Fbackon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FXuanwo%2Fbackon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXuanwo%2Fbackon/lists"}