Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 15 additions & 30 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,34 @@ name: Lint & Test
on:
pull_request:
types: [opened, edited, reopened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install Cargo
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo index
uses: actions/cache@v1
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.platform }}-v2

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Clippy Install
uses: dtolnay/rust-toolchain@clippy

- name: Lint
uses: actions-rs/clippy@master
with:
args: --all-features --all-targets
run: cargo clippy --all-features --all-targets --tests

- name: Test
run: cargo test --all-features
run: cargo test --all-features
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "backoff-rs"
version = "0.1.0"
edition = "2018"
edition = "2024"
authors = ["Dean Karn <[email protected]>"]
description = "Backoff provides the base components for implementing backoff and retry operations."
keywords = [
Expand All @@ -15,4 +15,4 @@ repository = "https://github.com/rust-playground/backoff-rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.8.4"
rand = "0.9.0"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Exponential {
/// returns the calculated backoff duration for backoff and retries based on the attempt.
pub fn duration(&self, attempt: usize) -> Duration {
let nanoseconds = (self.factor.powi(attempt as i32) * self.interval
+ rand::thread_rng().gen_range(0.0..=self.jitter)) as u64;
+ rand::rng().random_range(0.0..=self.jitter)) as u64;
match self.max {
Some(max) if nanoseconds > max => Duration::from_nanos(max),
_ => Duration::from_nanos(nanoseconds),
Expand Down