throttle-net 1.0.0

General-purpose outbound throttling and resilience for Rust: multi-algorithm rate limiting, multi-dimensional and cost-aware limits, adaptive throttling, circuit breakers, and jittered backoff/retry. The outbound companion to rate-net.
Documentation
name: CI

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: [main, dev]

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  test:
    name: Test (${{ matrix.os }} / ${{ matrix.rust }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [stable, "1.85"]
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: Format
        run: cargo fmt --all -- --check
      - name: Clippy
        run: cargo clippy --all-targets --all-features -- -D warnings
      - name: Test
        run: cargo test --all-features
      - name: Doc
        run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: "-D warnings"

  runtimes:
    name: Runtimes (smol + no_std core)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - name: Clippy (smol backend)
        run: cargo clippy --no-default-features --features smol --all-targets -- -D warnings
      - name: Test (smol backend)
        run: cargo test --no-default-features --features smol
      - name: Build no_std core
        run: cargo build --no-default-features
      - name: Clippy (no default features)
        run: cargo clippy --no-default-features --all-targets -- -D warnings

  loom:
    name: Loom (concurrency model check)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Loom
        run: cargo test --test loom_throttle --no-default-features --features adaptive --release
        env:
          RUSTFLAGS: "--cfg throttle_loom"
          LOOM_MAX_PREEMPTIONS: "3"

  fuzz:
    name: Fuzz (smoke)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - name: Install cargo-fuzz
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-fuzz
      # cargo-fuzz manages its own RUSTFLAGS (sanitizer instrumentation); clear
      # the workflow-wide `-D warnings` so it does not fight the fuzz build.
      # Pin the fuzz target to the gnu triple: the prebuilt cargo-fuzz binary is
      # musl-static, so it would otherwise default the fuzz target to musl, whose
      # std/core the nightly toolchain does not ship ("can't find crate for core").
      - name: Fuzz parse_retry_after (30s)
        run: cargo +nightly fuzz run retry_after --target x86_64-unknown-linux-gnu -- -max_total_time=30
        env:
          RUSTFLAGS: ""
      - name: Fuzz provider headers (30s)
        run: cargo +nightly fuzz run provider_headers --target x86_64-unknown-linux-gnu -- -max_total_time=30
        env:
          RUSTFLAGS: ""

  security:
    name: Security (audit + deny)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Install cargo-audit and cargo-deny
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit,cargo-deny
      - name: Audit
        run: cargo audit
      - name: Deny
        run: cargo deny check