-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented a retry mechanism - Added RetryConfig struct to specify retry behavior - Introduced RetryableClient for convenient interaction with remote service, including automatic retries for network issues - Separated transaction sending and response retrieval for improved code organization Co-authored-by: Ahmed Sagdati <[email protected]> Co-authored-by: MujkicA <[email protected]> Co-authored-by: hal3e <[email protected]>
- Loading branch information
1 parent
c145802
commit 337d0ea
Showing
40 changed files
with
1,137 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Retrying requests | ||
|
||
The [`Provider`](https://docs.rs/fuels/0.47.0/fuels/accounts/provider/struct.Provider.html) can be configured to retry a request upon receiving a `io::Error`. | ||
|
||
> Note: Currently all node errors are received as `io::Error`s. So, if configured, a retry will happen even if, for example, a transaction failed to verify. | ||
We can configure the number of retry attempts and the retry strategy as detailed below. | ||
|
||
## RetryConfig | ||
|
||
The retry behavior can be altered by giving a custom `RetryConfig`. It allows for configuring the maximum number of attempts and the interval strategy used. | ||
|
||
```rust, ignore | ||
{{#include ../../../packages/fuels-accounts/src/provider/retry_util.rs:retry_config}} | ||
``` | ||
|
||
```rust, ignore | ||
{{#include ../../../examples/providers/src/lib.rs:configure_retry}} | ||
``` | ||
|
||
## Interval strategy - Backoff | ||
|
||
`Backoff` defines different strategies for managing intervals between retry attempts. | ||
Each strategy allows you to customize the waiting time before a new attempt based on the number of attempts made. | ||
|
||
### Variants | ||
|
||
- `Linear(Duration)`: `Default` Increases the waiting time linearly with each attempt. | ||
- `Exponential(Duration)`: Doubles the waiting time with each attempt. | ||
- `Fixed(Duration)`: Uses a constant waiting time between attempts. | ||
|
||
```rust, ignore | ||
{{#include ../../../packages/fuels-accounts/src/provider/retry_util.rs:backoff}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.