https://github.com/rye/eb
♻️ Run commands with exponential backoff 📈
https://github.com/rye/eb
clap-rs cli exponential-backoff hacktoberfest rust
Last synced: 9 months ago
JSON representation
♻️ Run commands with exponential backoff 📈
- Host: GitHub
- URL: https://github.com/rye/eb
- Owner: rye
- License: gpl-3.0
- Created: 2019-07-11T14:40:21.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T23:04:51.000Z (about 1 year ago)
- Last Synced: 2025-03-28T00:19:41.609Z (about 1 year ago)
- Topics: clap-rs, cli, exponential-backoff, hacktoberfest, rust
- Language: Rust
- Homepage:
- Size: 466 KB
- Stars: 81
- Watchers: 1
- Forks: 3
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# eb
`eb` is a small utility that runs a command with exponential backoff.
`eb` only exits once a status code of `0` has been returned by the command it is calling, or once killed by a Ctrl+C or other signal.
You can use `eb` much like `watch`:
```console
$ eb -- ssh -oConnectTimeout=0 host
```
## Installing it
You can install `eb` via
```console
$ cargo install eb
```
and you can update it via the same command.
### Features
We currently support these (cargo) features:
- **`simple_logger`** enables the `simple_logger` logger.
There are _no features_ enabled by default.
## The algorithm
In the above console input, `eb` will watch the command and keep track of how long it takes to fail.
Upon the first failure, a "slot time" is set to the time it took for the command to fail.
In each instance, after `n` failures, a random number of slot times between `0` and `2^n - 1` is chosen, and these slot times are delayed through.
So, after the first failure, `eb` will either wait `0` or `1` slot times; after the second failure this number increases to between `0` and `3`.
The exponent `n` is `clamp`ed to be within the range `0` and `MAX_N` where `MAX_N` is some predefined number; in our case this is `10`.
In practice, this means that after `10` collisions, the possible upper bound on delay does not increase.
Because commands take a variable amount of time to complete, the slot time is adjusted to be the _average_ of all execution times.
The delay will start very quickly after the command fails.
Because of the way the algorithm works, it is recommended to use `eb` in situations where the given command will fail quickly.
This will result in a proportionally small maximum delay time.
## License
```
eb: A command executor exercising exponential backoff
Copyright (C) 2019-2021 Kristofer J. Rye
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
```