Skip to content

Commit

Permalink
Change jitter implementation
Browse files Browse the repository at this point in the history
Decorrelated jitter has a major flaw: clamping. Retry intervals can get
repeatedly clamped to the maximum allowed duration. This effectively
removes any jitter.

The implementation in this library is a variation which exacerbates this
flaw.

This change replaces this jitter implementation with three options:

1. None
2. Full
3. Bounded

It also changes how 'maxiumum retry duration' is implemented. Before,
there was no information about how long the task had been retrying, so
there was no way to implement a correct 'maximum retry duration'.

This has been reimplemented to require a start time for a task when
setting a maxiumum retry duration.
  • Loading branch information
ThomWright committed Jul 4, 2023
1 parent c58f3cb commit 724e930
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 98 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.0] - 2023-??-??

### Changed

- [Breaking] Jitter algorithm changed from a variation of decorrelated jitter to either none, full, or bounded.
- [Breaking] Now requires a task start time when using a total retry duration.

## [0.1.2] - 2022-10-28

### Added

- `Debug` derived for `RetryDecision`

## [0.1.1] - 2021-10-18

### Security

- remove time v0.1 dependency

## [0.1.0] - 2021-08-11

### Added

- `ExponentialBackoff` policy.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A collection of plug-and-play retry policies for Rust projects.
Currently available algorithms:

- [`ExponentialBackoff`](https://docs.rs/retry-policies/latest/retry_policies/policies/struct.ExponentialBackoff.html),
with decorrelated jitter.
with configurable jitter.

## How to install

Expand All @@ -19,7 +19,7 @@ Add `retry-policies` to your dependencies
```toml
[dependencies]
# ...
retry-policies = "0.1.2"
retry-policies = "0.2.0"
```

#### License
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
pub mod policies;
mod retry_policy;

pub use retry_policy::{RetryDecision, RetryPolicy};
pub use retry_policy::{Jitter, RetryDecision, RetryPolicy};
Loading

0 comments on commit 724e930

Please sign in to comment.