From 7674109b28776695827374f607c033d845fb84d9 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Thu, 18 Nov 2021 20:40:01 +0100 Subject: [PATCH] tower: prepare to release 0.4.11 (#618) * tower: prepare to release 0.4.11 Added - **util**: Add `CloneBoxService` which is a `Clone + Send` boxed `Service` ([#615]) - **util**: Add `ServiceExt::boxed` and `ServiceExt::clone_boxed` for applying the `BoxService` and `CloneBoxService` middleware ([#616]) - **builder**: Add `ServiceBuilder::boxed` and `ServiceBuilder::clone_boxed` for applying `BoxService` and `CloneBoxService` layers ([#616]) Fixed - **balance**: Remove redundant `Req: Clone` bound from `Clone` impls for `MakeBalance`, and `MakeBalanceLayer` ([#607]) - **balance**: Remove redundant `Req: Debug` bound from `Debug` impls for `MakeBalance`, `MakeFuture`, `Balance`, and `Pool` ([#607]) - **ready-cache**: Remove redundant `Req: Debug` bound from `Debug` impl for `ReadyCache` ([#607]) - **steer**: Remove redundant `Req: Debug` bound from `Debug` impl for `Steer` ([#607]) - **util**: Remove redundant `F: Clone` bound from `ServiceExt::map_request` ([#607]) - **docs**: Fix `doc(cfg(...))` attributes of `PeakEwmaDiscover`, and `PendingRequestsDiscover` ([#610]) - **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService` ([#617]) - **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService` ([#617]) [#607]: https://github.com/tower-rs/tower/pull/607 [#610]: https://github.com/tower-rs/tower/pull/610 [#616]: https://github.com/tower-rs/tower/pull/616 [#617]: https://github.com/tower-rs/tower/pull/617 [#615]: https://github.com/tower-rs/tower/pull/615 * sorting * Rename `CloneBoxService` to `BoxCloneService` * formatting * also update changelog --- tower/CHANGELOG.md | 26 ++++++++++++------- tower/Cargo.toml | 4 +-- tower/src/builder/mod.rs | 20 +++++++------- tower/src/lib.rs | 2 +- tower/src/util/boxed/sync.rs | 2 +- .../util/{clone_boxed.rs => boxed_clone.rs} | 26 +++++++++---------- tower/src/util/mod.rs | 20 +++++++------- 7 files changed, 54 insertions(+), 46 deletions(-) rename tower/src/util/{clone_boxed.rs => boxed_clone.rs} (79%) diff --git a/tower/CHANGELOG.md b/tower/CHANGELOG.md index 634641c53..5aa08345a 100644 --- a/tower/CHANGELOG.md +++ b/tower/CHANGELOG.md @@ -7,16 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased -- **util**: Add `CloneBoxService` which is a `Clone + Send` boxed `Service`. -- **util:** Add `ServiceExt::boxed` and `ServiceExt::clone_boxed` for applying the - `BoxService` and `CloneBoxService` middleware. -- **builder:** Add `ServiceBuilder::boxed` and `ServiceBuilder::clone_boxed` for - applying `BoxService` and `CloneBoxService` layers. -- **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService`. -- **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService`. +- None. + +# 0.4.11 (November 18, 2021) + +### Added + +- **util**: Add `BoxCloneService` which is a `Clone + Send` boxed `Service` ([#615]) +- **util**: Add `ServiceExt::boxed` and `ServiceExt::boxed_clone` for applying the + `BoxService` and `BoxCloneService` middleware ([#616]) +- **builder**: Add `ServiceBuilder::boxed` and `ServiceBuilder::boxed_clone` for + applying `BoxService` and `BoxCloneService` layers ([#616]) ### Fixed +- **util**: Remove redundant `F: Clone` bound from `ServiceExt::map_request` ([#607]) +- **util**: Remove unnecessary `Debug` bounds from `impl Debug for BoxService` ([#617]) +- **util**: Remove unnecessary `Debug` bounds from `impl Debug for UnsyncBoxService` ([#617]) - **balance**: Remove redundant `Req: Clone` bound from `Clone` impls for `MakeBalance`, and `MakeBalanceLayer` ([#607]) - **balance**: Remove redundant `Req: Debug` bound from `Debug` impls @@ -25,13 +32,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 for `ReadyCache` ([#607]) - **steer**: Remove redundant `Req: Debug` bound from `Debug` impl for `Steer` ([#607]) -- **util**: Remove redundant `F: Clone` bound - from `ServiceExt::map_request` ([#607]) - **docs**: Fix `doc(cfg(...))` attributes of `PeakEwmaDiscover`, and `PendingRequestsDiscover` ([#610]) [#607]: https://github.com/tower-rs/tower/pull/607 [#610]: https://github.com/tower-rs/tower/pull/610 +[#615]: https://github.com/tower-rs/tower/pull/615 +[#616]: https://github.com/tower-rs/tower/pull/616 +[#617]: https://github.com/tower-rs/tower/pull/617 # 0.4.10 (October 19, 2021) diff --git a/tower/Cargo.toml b/tower/Cargo.toml index ae2def913..237becfdf 100644 --- a/tower/Cargo.toml +++ b/tower/Cargo.toml @@ -8,13 +8,13 @@ name = "tower" # - README.md # - Update CHANGELOG.md. # - Create "vX.X.X" git tag. -version = "0.4.10" +version = "0.4.11" authors = ["Tower Maintainers "] license = "MIT" readme = "README.md" repository = "https://github.com/tower-rs/tower" homepage = "https://github.com/tower-rs/tower" -documentation = "https://docs.rs/tower/0.4.10" +documentation = "https://docs.rs/tower/0.4.11" description = """ Tower is a library of modular and reusable components for building robust clients and servers. diff --git a/tower/src/builder/mod.rs b/tower/src/builder/mod.rs index 5d24ac705..50f961254 100644 --- a/tower/src/builder/mod.rs +++ b/tower/src/builder/mod.rs @@ -745,17 +745,17 @@ impl ServiceBuilder { self.layer(crate::util::BoxService::layer()) } - /// This wraps the inner service with the [`Layer`] returned by [`CloneBoxService::layer()`]. + /// This wraps the inner service with the [`Layer`] returned by [`BoxCloneService::layer()`]. /// /// This is similar to the [`boxed`] method, but it requires that `Self` implement /// [`Clone`], and the returned boxed service implements [`Clone`]. /// - /// See [`CloneBoxService`] for more details. + /// See [`BoxCloneService`] for more details. /// /// # Example /// /// ``` - /// use tower::{Service, ServiceBuilder, BoxError, util::CloneBoxService}; + /// use tower::{Service, ServiceBuilder, BoxError, util::BoxCloneService}; /// use std::time::Duration; /// # /// # struct Request; @@ -764,8 +764,8 @@ impl ServiceBuilder { /// # fn new() -> Self { Self } /// # } /// - /// let service: CloneBoxService = ServiceBuilder::new() - /// .clone_boxed() + /// let service: BoxCloneService = ServiceBuilder::new() + /// .boxed_clone() /// .load_shed() /// .concurrency_limit(64) /// .timeout(Duration::from_secs(10)) @@ -780,19 +780,19 @@ impl ServiceBuilder { /// # where S: Service { svc } /// ``` /// - /// [`CloneBoxService::layer()`]: crate::util::CloneBoxService::layer() - /// [`CloneBoxService`]: crate::util::CloneBoxService + /// [`BoxCloneService::layer()`]: crate::util::BoxCloneService::layer() + /// [`BoxCloneService`]: crate::util::BoxCloneService /// [`boxed`]: Self::boxed #[cfg(feature = "util")] #[cfg_attr(docsrs, doc(cfg(feature = "util")))] - pub fn clone_boxed( + pub fn boxed_clone( self, ) -> ServiceBuilder< Stack< tower_layer::LayerFn< fn( L::Service, - ) -> crate::util::CloneBoxService< + ) -> crate::util::BoxCloneService< R, >::Response, >::Error, @@ -806,7 +806,7 @@ impl ServiceBuilder { L::Service: Service + Clone + Send + 'static, >::Future: Send + 'static, { - self.layer(crate::util::CloneBoxService::layer()) + self.layer(crate::util::BoxCloneService::layer()) } } diff --git a/tower/src/lib.rs b/tower/src/lib.rs index e3c65c455..cf390baae 100644 --- a/tower/src/lib.rs +++ b/tower/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/tower/0.4.10")] +#![doc(html_root_url = "https://docs.rs/tower/0.4.11")] #![warn( missing_debug_implementations, missing_docs, diff --git a/tower/src/util/boxed/sync.rs b/tower/src/util/boxed/sync.rs index ef092405c..8c02fb4e2 100644 --- a/tower/src/util/boxed/sync.rs +++ b/tower/src/util/boxed/sync.rs @@ -16,7 +16,7 @@ use std::{ /// response future to be [`Send`]. /// /// If you need a boxed [`Service`] that implements [`Clone`] consider using -/// [`CloneBoxService`](crate::util::CloneBoxService). +/// [`BoxCloneService`](crate::util::BoxCloneService). /// /// See module level documentation for more details. pub struct BoxService { diff --git a/tower/src/util/clone_boxed.rs b/tower/src/util/boxed_clone.rs similarity index 79% rename from tower/src/util/clone_boxed.rs rename to tower/src/util/boxed_clone.rs index 9468e7715..1209fd2ef 100644 --- a/tower/src/util/clone_boxed.rs +++ b/tower/src/util/boxed_clone.rs @@ -9,7 +9,7 @@ use tower_service::Service; /// A [`Clone`] + [`Send`] boxed [`Service`]. /// -/// [`CloneBoxService`] turns a service into a trait object, allowing the +/// [`BoxCloneService`] turns a service into a trait object, allowing the /// response future type to be dynamic, and allowing the service to be cloned. /// /// This is similar to [`BoxService`](super::BoxService) except the resulting @@ -18,7 +18,7 @@ use tower_service::Service; /// # Example /// /// ``` -/// use tower::{Service, ServiceBuilder, BoxError, util::CloneBoxService}; +/// use tower::{Service, ServiceBuilder, BoxError, util::BoxCloneService}; /// use std::time::Duration; /// # /// # struct Request; @@ -45,8 +45,8 @@ use tower_service::Service; /// }); /// # let service = assert_service(service); /// -/// // `CloneBoxService` will erase the type so it's nameable -/// let service: CloneBoxService = CloneBoxService::new(service); +/// // `BoxCloneService` will erase the type so it's nameable +/// let service: BoxCloneService = BoxCloneService::new(service); /// # let service = assert_service(service); /// /// // And we can still clone the service @@ -55,25 +55,25 @@ use tower_service::Service; /// # fn assert_service(svc: S) -> S /// # where S: Service { svc } /// ``` -pub struct CloneBoxService( +pub struct BoxCloneService( Box< dyn CloneService>> + Send, >, ); -impl CloneBoxService { - /// Create a new `CloneBoxService`. +impl BoxCloneService { + /// Create a new `BoxCloneService`. pub fn new(inner: S) -> Self where S: Service + Clone + Send + 'static, S::Future: Send + 'static, { let inner = inner.map_future(|f| Box::pin(f) as _); - CloneBoxService(Box::new(inner)) + BoxCloneService(Box::new(inner)) } - /// Returns a [`Layer`] for wrapping a [`Service`] in a [`CloneBoxService`] + /// Returns a [`Layer`] for wrapping a [`Service`] in a [`BoxCloneService`] /// middleware. /// /// [`Layer`]: crate::Layer @@ -86,7 +86,7 @@ impl CloneBoxService { } } -impl Service for CloneBoxService { +impl Service for BoxCloneService { type Response = U; type Error = E; type Future = BoxFuture<'static, Result>; @@ -102,7 +102,7 @@ impl Service for CloneBoxService { } } -impl Clone for CloneBoxService { +impl Clone for BoxCloneService { fn clone(&self) -> Self { Self(self.0.clone_box()) } @@ -129,8 +129,8 @@ where } } -impl fmt::Debug for CloneBoxService { +impl fmt::Debug for BoxCloneService { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("CloneBoxService").finish() + fmt.debug_struct("BoxCloneService").finish() } } diff --git a/tower/src/util/mod.rs b/tower/src/util/mod.rs index 446cacc47..129c9d7ab 100644 --- a/tower/src/util/mod.rs +++ b/tower/src/util/mod.rs @@ -2,8 +2,8 @@ mod and_then; mod boxed; +mod boxed_clone; mod call_all; -mod clone_boxed; mod either; mod future_service; @@ -23,7 +23,7 @@ mod then; pub use self::{ and_then::{AndThen, AndThenLayer}, boxed::{BoxLayer, BoxService, UnsyncBoxService}, - clone_boxed::CloneBoxService, + boxed_clone::BoxCloneService, either::Either, future_service::{future_service, FutureService}, map_err::{MapErr, MapErrLayer}, @@ -958,7 +958,7 @@ pub trait ServiceExt: tower_service::Service { /// /// See [`BoxService`] for more details. /// - /// If `Self` implements the [`Clone`] trait, the [`clone_boxed`] method + /// If `Self` implements the [`Clone`] trait, the [`boxed_clone`] method /// can be used instead, to produce a boxed service which will also /// implement [`Clone`]. /// @@ -993,7 +993,7 @@ pub trait ServiceExt: tower_service::Service { /// ``` /// /// [`Service`]: crate::Service - /// [`clone_boxed`]: Self::clone_boxed + /// [`boxed_clone`]: Self::boxed_clone fn boxed(self) -> BoxService where Self: Sized + Send + 'static, @@ -1006,12 +1006,12 @@ pub trait ServiceExt: tower_service::Service { /// /// This is similar to the [`boxed`] method, but it requires that `Self` implement /// [`Clone`], and the returned boxed service implements [`Clone`]. - /// See [`CloneBoxService`] for more details. + /// See [`BoxCloneService`] for more details. /// /// # Example /// /// ``` - /// use tower::{Service, ServiceExt, BoxError, service_fn, util::CloneBoxService}; + /// use tower::{Service, ServiceExt, BoxError, service_fn, util::BoxCloneService}; /// # /// # struct Request; /// # struct Response; @@ -1023,7 +1023,7 @@ pub trait ServiceExt: tower_service::Service { /// Ok::<_, BoxError>(Response::new()) /// }); /// - /// let service: CloneBoxService = service + /// let service: BoxCloneService = service /// .map_request(|req| { /// println!("received request"); /// req @@ -1032,7 +1032,7 @@ pub trait ServiceExt: tower_service::Service { /// println!("response produced"); /// res /// }) - /// .clone_boxed(); + /// .boxed_clone(); /// /// // The boxed service can still be cloned. /// service.clone(); @@ -1043,12 +1043,12 @@ pub trait ServiceExt: tower_service::Service { /// /// [`Service`]: crate::Service /// [`boxed`]: Self::boxed - fn clone_boxed(self) -> CloneBoxService + fn boxed_clone(self) -> BoxCloneService where Self: Clone + Sized + Send + 'static, Self::Future: Send + 'static, { - CloneBoxService::new(self) + BoxCloneService::new(self) } }