Skip to content

Commit

Permalink
Merge branch 'master' into non-static
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz authored Jul 23, 2024
2 parents 2449c10 + 85080a5 commit 709b68f
Show file tree
Hide file tree
Showing 62 changed files with 207 additions and 233 deletions.
169 changes: 63 additions & 106 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,60 @@ name: CI
on:
push:
branches:
- master
- master
pull_request: {}

env:
MSRV: 1.49.0
MSRV: 1.64.0

jobs:
check-stable:
# Run `cargo check` first to ensure that the pushed code at least compiles.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-features --all-targets
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Check
run: cargo check --workspace --all-features --all-targets

check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: cargo doc
working-directory: ${{ matrix.subcrate }}
env:
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links"
run: cargo doc --all-features --no-deps
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: cargo doc
working-directory: ${{ matrix.subcrate }}
env:
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links"
run: cargo doc --all-features --no-deps

check-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --all-targets --all-features --locked
toolchain: ${{ env.MSRV }}
- uses: actions/checkout@v4
- name: "install Rust ${{ env.MSRV }}"
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}
- name: "install Rust nightly"
uses: dtolnay/rust-toolchain@nightly
- name: Select minimal versions
run: cargo update -Z minimal-versions
- name: Check
run: |
rustup default ${{ env.MSRV }}
cargo check --all --all-targets --all-features --locked
cargo-hack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack check
working-directory: ${{ matrix.subcrate }}
run: cargo hack check --each-feature --no-dev-deps --workspace
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack check
working-directory: ${{ matrix.subcrate }}
run: cargo hack check --each-feature --no-dev-deps --workspace

test-versions:
# Test against the stable, beta, and nightly Rust toolchains on ubuntu-latest.
Expand All @@ -93,68 +70,48 @@ jobs:
matrix:
rust: [stable, beta, nightly]
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ matrix.rust }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features
- uses: actions/checkout@v4
- name: "install Rust ${{ matrix.rust }}"
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Run tests
run: cargo test --workspace --all-features

test-msrv:
needs: check-msrv
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: test
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-features --locked
toolchain: ${{ env.MSRV }}
- uses: actions/checkout@v4
- name: "install Rust ${{ env.MSRV }}"
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MSRV }}
- name: "install Rust nightly"
uses: dtolnay/rust-toolchain@nightly
- name: Select minimal versions
run: cargo update -Z minimal-versions
- name: test
run: |
rustup default ${{ env.MSRV }}
cargo check --workspace --all-features --locked
style:
needs: check-stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: rustfmt
run: cargo fmt --all -- --check

deny-check:
name: cargo-deny check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check
13 changes: 3 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,13 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Install nightly Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
profile: minimal
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --workspace --no-deps --all-features
# Tower uses nightly-only RustDoc features
toolchain: nightly
run: cargo doc --workspace --no-deps --all-features
env:
# Enable the RustDoc `#[doc(cfg(...))]` attribute.
RUSTDOCFLAGS: --cfg docsrs
Expand All @@ -36,4 +30,3 @@ jobs:
build_dir: target/doc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
if: github.repository_owner == 'tower-rs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: taiki-e/[email protected]
with:
prefix: "(tower)|(tower-[a-z]+)"
Expand Down
20 changes: 20 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,23 @@ members = [
"tower-service",
"tower-test",
]

[workspace.dependencies]
futures = "0.3.22"
futures-core = "0.3.22"
futures-util = { version = "0.3.22", default-features = false }
hdrhistogram = { version = "7.0", default-features = false }
http = "0.2"
indexmap = "2.0.2"
lazy_static = "1.4.0"
pin-project-lite = "0.2.7"
quickcheck = "1"
rand = "0.8"
slab = "0.4"
sync_wrapper = "0.1.1"
tokio = "1.6.2"
tokio-stream = "0.1.0"
tokio-test = "0.4"
tokio-util = { version = "0.7.0", default-features = false }
tracing = { version = "0.1.2", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pattern. If your protocol is entirely stream based, Tower may not be a good fit.

Tower will keep a rolling MSRV (minimum supported Rust version) policy of **at
least** 6 months. When increasing the MSRV, the new Rust version must have been
released at least six months ago. The current MSRV is 1.49.0.
released at least six months ago. The current MSRV is 1.64.0.

## Getting Started

Expand Down
1 change: 0 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
vulnerability = "deny"
unmaintained = "warn"
notice = "warn"
ignore = ["RUSTSEC-2020-0159"]

[licenses]
unlicensed = "deny"
Expand Down
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ edition = "2018"
# [dependencies] instead.
[dev-dependencies]
tower = { version = "0.4", path = "../tower", features = ["full"] }
tower-service = "0.3"
tower-service = "0.3"
tokio = { version = "1.0", features = ["full"] }
rand = "0.8"
pin-project = "1.0"
futures = "0.3"
futures = "0.3.22"
tracing = "0.1"
tracing-subscriber = "0.2"
hdrhistogram = "7"
Expand Down
6 changes: 3 additions & 3 deletions guides/building-a-middleware-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ means we can combine multiple errors type into one. That has the following
advantages:

1. Our error handling is less fragile since changing the order middleware are
applied in wont change the final error type.
applied in won't change the final error type.
2. The error type now has a constant size regardless how many middleware we've
applied.
3. Extracting the error no longer requires a big `match` but can instead be done
Expand All @@ -412,7 +412,7 @@ For our `Timeout` middleware that means we need to create a struct that
implements `std::error::Error` such that we can convert it into a `Box<dyn
std::error::Error + Send + Sync>`. We also have to require that the inner
service's error type implements `Into<Box<dyn std::error::Error + Send +
Sync>>`. Luckily most errors automatically satisfies that so it wont require
Sync>>`. Luckily most errors automatically satisfies that so it won't require
users to write any additional code. We're using `Into` for the trait bound
rather than `From` as recommend by the [standard
library](https://doc.rust-lang.org/stable/std/convert/trait.From.html).
Expand Down Expand Up @@ -521,7 +521,7 @@ where

## Conclusion

Thats it! We've now successfully implemented the `Timeout` middleware as it
That's it! We've now successfully implemented the `Timeout` middleware as it
exists in Tower today.

Our final implementation is:
Expand Down
2 changes: 1 addition & 1 deletion tower-layer/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Identity {

impl Identity {
/// Create a new [`Identity`] value
pub fn new() -> Identity {
pub const fn new() -> Identity {
Identity { _p: () }
}
}
Expand Down
2 changes: 1 addition & 1 deletion tower-layer/src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Stack<Inner, Outer> {

impl<Inner, Outer> Stack<Inner, Outer> {
/// Create a new `Stack`.
pub fn new(inner: Inner, outer: Outer) -> Self {
pub const fn new(inner: Inner, outer: Outer) -> Self {
Stack { inner, outer }
}
}
Expand Down
6 changes: 3 additions & 3 deletions tower-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ edition = "2018"
[dependencies]

[dev-dependencies]
http = "0.2"
http = { workspace = true }
tower-layer = { version = "0.3", path = "../tower-layer" }
tokio = { version = "1", features = ["macros", "time"] }
futures = "0.3"
tokio = { workspace = true, features = ["macros", "time"] }
futures = { workspace = true }
4 changes: 2 additions & 2 deletions tower-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ use std::task::{Context, Poll};
/// }
///
/// impl<T> Timeout<T> {
/// pub fn new(inner: T, timeout: Duration) -> Timeout<T> {
/// pub const fn new(inner: T, timeout: Duration) -> Timeout<T> {
/// Timeout {
/// inner,
/// timeout
Expand Down Expand Up @@ -204,7 +204,7 @@ use std::task::{Context, Poll};
/// pub struct TimeoutLayer(Duration);
///
/// impl TimeoutLayer {
/// pub fn new(delay: Duration) -> Self {
/// pub const fn new(delay: Duration) -> Self {
/// TimeoutLayer(delay)
/// }
/// }
Expand Down
10 changes: 5 additions & 5 deletions tower-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ categories = ["asynchronous", "network-programming"]
edition = "2018"

[dependencies]
futures-util = { version = "0.3", default-features = false }
tokio = { version = "1.0", features = ["sync"] }
tokio-test = "0.4"
futures-util = { workspace = true }
tokio = { workspace = true, features = ["sync"] }
tokio-test = { workspace = true }
tower-layer = { version = "0.3", path = "../tower-layer" }
tower-service = { version = "0.3", path = "../tower-service" }
pin-project-lite = "0.2"
pin-project-lite = { workspace = true }

[dev-dependencies]
tokio = { version = "1.0", features = ["macros"] }
tokio = { workspace = true, features = ["macros"] }
Loading

0 comments on commit 709b68f

Please sign in to comment.