Skip to content

Commit

Permalink
util: Remove ServiceExt::ready (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn authored Jan 5, 2021
1 parent 3bdaae9 commit b7a7c28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 56 deletions.
8 changes: 5 additions & 3 deletions tower/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added `MakeService::into_service` and `MakeService::as_service` for
converting `MakeService`s into `Service`s.
- Make `ServiceBuilder::service` take `self` by reference rather than by value.

### Changed

- All middleware `tower-*` crates were merged into `tower` and placed
behind feature flags.
- All middleware `tower-*` crates were merged into `tower` and placed
behind feature flags.
- Make `ServiceBuilder::service` take `self` by reference rather than by value.

### Removed

- Remove `ServiceExt::ready`.

# 0.3.1 (January 17, 2020)

- Allow opting out of tracing/log (#410).
Expand Down
12 changes: 1 addition & 11 deletions tower/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use self::{
map_result::{MapResult, MapResultLayer},
oneshot::Oneshot,
optional::Optional,
ready::{Ready, ReadyAnd, ReadyOneshot},
ready::{ReadyAnd, ReadyOneshot},
service_fn::{service_fn, ServiceFn},
then::{Then, ThenLayer},
try_map_request::{TryMapRequest, TryMapRequestLayer},
Expand Down Expand Up @@ -55,16 +55,6 @@ pub mod future {
/// An extension trait for `Service`s that provides a variety of convenient
/// adapters
pub trait ServiceExt<Request>: tower_service::Service<Request> {
/// Resolves when the service is ready to accept a request.
#[deprecated(since = "0.3.1", note = "prefer `ready_and` which yields the service")]
fn ready(&mut self) -> Ready<'_, Self, Request>
where
Self: Sized,
{
#[allow(deprecated)]
Ready::new(self)
}

/// Yields a mutable reference to the service when it is ready to accept a request.
fn ready_and(&mut self) -> ReadyAnd<'_, Self, Request>
where
Expand Down
42 changes: 0 additions & 42 deletions tower/src/util/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,45 +97,3 @@ where
f.debug_tuple("ReadyAnd").field(&self.0).finish()
}
}

// ==== deprecated `Ready` that is just `ReadyAnd` with a unit return type.

/// A future that resolves when a `Service` is ready to accept a request.
///
/// `Ready` values are produced by `ServiceExt::ready`.
pub struct Ready<'a, T, Request>(ReadyAnd<'a, T, Request>);

// Safety: This is safe for the same reason that the impl for ReadyOneshot is safe.
impl<'a, T, Request> Unpin for Ready<'a, T, Request> {}

impl<'a, T, Request> Ready<'a, T, Request>
where
T: Service<Request>,
{
#[allow(missing_docs)]
#[deprecated(since = "0.3.1", note = "prefer `ReadyAnd` which yields the service")]
pub fn new(service: &'a mut T) -> Self {
Self(ReadyAnd::new(service))
}
}

impl<'a, T, Request> Future for Ready<'a, T, Request>
where
T: Service<Request>,
{
type Output = Result<(), T::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let _ = ready!(Pin::new(&mut self.0).poll(cx));
Poll::Ready(Ok(()))
}
}

impl<'a, T, Request> fmt::Debug for Ready<'a, T, Request>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Ready").field(&self.0).finish()
}
}

0 comments on commit b7a7c28

Please sign in to comment.