MCPcopy Index your code
hub / github.com/EmbarkStudios/tryhard

github.com/EmbarkStudios/tryhard @0.5.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.5.2 ↗ · + Follow
44 symbols 92 edges 3 files 7 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

💫 tryhard

Embark Embark Crates.io Docs dependency status Build status

tryhard makes it easy to retry futures that might fail. You can control the number of retries, the backoff strategy, and the max duration.

Examples

First imagine you have some async function that can fail:

async fn read_file(path: &str) -> Result<String, std::io::Error> {
    // ...
}

Calling that function and retrying at most 10 times with no delay between attempts can be done like so:

tryhard::retry_fn(|| read_file("Cargo.toml"))
    .retries(10)
    .await?;

You can also retry with a fixed delay between attempts:

tryhard::retry_fn(|| read_file("Cargo.toml"))
    .retries(10)
    .fixed_backoff(Duration::from_millis(100))
    .await?;

Or exponential backoff, where the delay doubles each time, with a max delay of 1 second:

tryhard::retry_fn(|| read_file("Cargo.toml"))
    .retries(10)
    .exponential_backoff(Duration::from_millis(10))
    .max_delay(Duration::from_secs(1))
    .await?;

See the docs for more details.

Contributing

Contributor Covenant

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Extension points exported contracts — how you extend this code

BackoffStrategy (Interface)
Trait for computing the amount of delay between attempts. [6 implementers]
src/backoff_strategies.rs
OnRetry (Interface)
Trait allowing you to run some future when a retry occurs. Could for example to be used for logging or other kinds of te [3 …
src/on_retry.rs

Core symbols most depended-on inside this repo

retry_fn
called by 14
src/lib.rs
custom_backoff
called by 11
src/lib.rs
retries
called by 10
src/lib.rs
on_retry
called by 7
src/lib.rs
with_config
called by 5
src/lib.rs
no_backoff
called by 1
src/lib.rs
fixed_backoff
called by 1
src/lib.rs
linear_backoff
called by 1
src/lib.rs

Shape

Method 17
Function 15
Class 9
Interface 2
Enum 1

Languages

Rust100%

Modules by API surface

src/lib.rs34 symbols
src/backoff_strategies.rs7 symbols
src/on_retry.rs3 symbols

For agents

$ claude mcp add tryhard \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact