Update tower-reconnect to std::future (#333)
This bumps tower-reconnect to 0.3.0-alpha.1 It also makes the tower-make version consistent
This commit is contained in:
parent
adca66cf74
commit
9691d0d379
|
@ -11,7 +11,7 @@ members = [
|
|||
"tower-limit",
|
||||
"tower-load",
|
||||
"tower-load-shed",
|
||||
# "tower-reconnect",
|
||||
"tower-reconnect",
|
||||
"tower-retry",
|
||||
"tower-service",
|
||||
# "tower-spawn-ready",
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# 0.3.0-alpha.1
|
||||
|
||||
- Bump version to match all the other crates with `std::future`
|
||||
|
||||
# 0.1.0-alpha.2 (August 30, 2019)
|
||||
|
||||
- Update `tokio-io` to `alpha.4`
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
[package]
|
||||
name = "tower-make"
|
||||
version = "0.1.0-alpha.2"
|
||||
version = "0.3.0-alpha.1"
|
||||
authors = ["Tower Maintainers <team@tower-rs.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/tower-rs/tower"
|
||||
homepage = "https://github.com/tower-rs/tower"
|
||||
documentation = "https://docs.rs/tower-make/0.1.0-alpha.2"
|
||||
documentation = "https://docs.rs/tower-make/0.3.0-alpha.1"
|
||||
description = """
|
||||
Trait aliases for Services that produce specific types of Responses.
|
||||
"""
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![doc(html_root_url = "https://docs.rs/tower-make/0.1.0-alpha.2")]
|
||||
#![doc(html_root_url = "https://docs.rs/tower-make/0.3.0-alpha.1")]
|
||||
#![deny(rust_2018_idioms)]
|
||||
|
||||
//! Trait aliases for Services that produce specific types of Responses.
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# 0.3.0-alpha.1
|
||||
|
||||
- Move to `std::future`
|
||||
|
||||
# 0.1.0 (unreleased)
|
||||
|
||||
- Initial release
|
||||
|
|
|
@ -8,13 +8,13 @@ name = "tower-reconnect"
|
|||
# - README.md
|
||||
# - Update CHANGELOG.md.
|
||||
# - Create "v0.1.x" git tag.
|
||||
version = "0.1.0"
|
||||
version = "0.3.0-alpha.1"
|
||||
authors = ["Tower Maintainers <team@tower-rs.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/tower-rs/tower"
|
||||
homepage = "https://github.com/tower-rs/tower"
|
||||
documentation = "https://docs.rs/tower-reconnect/0.1.0"
|
||||
documentation = "https://docs.rs/tower-reconnect/0.3.0-alpha.1"
|
||||
description = """
|
||||
Automatically recreate a new `Service` instance when an error is encountered.
|
||||
"""
|
||||
|
@ -24,6 +24,6 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
log = "0.4.1"
|
||||
futures = "0.1.26"
|
||||
tower-service = "0.2.0"
|
||||
tower-util = "0.1.0"
|
||||
tower-service = "0.3.0-alpha.1"
|
||||
tower-make = { version = "0.3.0-alpha.1", path = "../tower-make" }
|
||||
pin-project = "0.4.0-alpha.10"
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
use crate::Error;
|
||||
use futures::{Future, Poll};
|
||||
use pin_project::pin_project;
|
||||
use std::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
#[pin_project]
|
||||
pub struct ResponseFuture<F> {
|
||||
#[pin]
|
||||
inner: F,
|
||||
}
|
||||
|
||||
|
@ -11,15 +18,14 @@ impl<F> ResponseFuture<F> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> Future for ResponseFuture<F>
|
||||
impl<F, T, E> Future for ResponseFuture<F>
|
||||
where
|
||||
F: Future,
|
||||
F::Error: Into<Error>,
|
||||
F: Future<Output = Result<T, E>>,
|
||||
E: Into<Error>,
|
||||
{
|
||||
type Item = F::Item;
|
||||
type Error = Error;
|
||||
type Output = Result<T, Error>;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
self.inner.poll().map_err(Into::into)
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
self.project().inner.poll(cx).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
#![doc(html_root_url = "https://docs.rs/tower-load-shed/0.1.0")]
|
||||
#![doc(html_root_url = "https://docs.rs/tower-reconnect/0.3.0-alpha.1")]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![allow(elided_lifetimes_in_paths)]
|
||||
|
||||
pub mod future;
|
||||
|
||||
use crate::future::ResponseFuture;
|
||||
use futures::{Async, Future, Poll};
|
||||
use log::trace;
|
||||
use std::fmt;
|
||||
use std::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
use tower_make::MakeService;
|
||||
use tower_service::Service;
|
||||
use tower_util::MakeService;
|
||||
|
||||
pub struct Reconnect<M, Target>
|
||||
where
|
||||
|
@ -52,6 +56,7 @@ impl<M, Target, S, Request> Service<Request> for Reconnect<M, Target>
|
|||
where
|
||||
M: Service<Target, Response = S>,
|
||||
S: Service<Request>,
|
||||
M::Future: Unpin,
|
||||
Error: From<M::Error> + From<S::Error>,
|
||||
Target: Clone,
|
||||
{
|
||||
|
@ -59,7 +64,7 @@ where
|
|||
type Error = Error;
|
||||
type Future = ResponseFuture<S::Future>;
|
||||
|
||||
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
|
||||
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||
let ret;
|
||||
let mut state;
|
||||
|
||||
|
@ -67,11 +72,11 @@ where
|
|||
match self.state {
|
||||
State::Idle => {
|
||||
trace!("poll_ready; idle");
|
||||
match self.mk_service.poll_ready()? {
|
||||
Async::Ready(()) => (),
|
||||
Async::NotReady => {
|
||||
match self.mk_service.poll_ready(cx) {
|
||||
Poll::Ready(r) => r?,
|
||||
Poll::Pending => {
|
||||
trace!("poll_ready; MakeService not ready");
|
||||
return Ok(Async::NotReady);
|
||||
return Poll::Pending;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,15 +86,15 @@ where
|
|||
}
|
||||
State::Connecting(ref mut f) => {
|
||||
trace!("poll_ready; connecting");
|
||||
match f.poll() {
|
||||
Ok(Async::Ready(service)) => {
|
||||
match Pin::new(f).poll(cx) {
|
||||
Poll::Ready(Ok(service)) => {
|
||||
state = State::Connected(service);
|
||||
}
|
||||
Ok(Async::NotReady) => {
|
||||
Poll::Pending => {
|
||||
trace!("poll_ready; not ready");
|
||||
return Ok(Async::NotReady);
|
||||
return Poll::Pending;
|
||||
}
|
||||
Err(e) => {
|
||||
Poll::Ready(Err(e)) => {
|
||||
trace!("poll_ready; error");
|
||||
state = State::Idle;
|
||||
ret = Err(e.into());
|
||||
|
@ -99,16 +104,16 @@ where
|
|||
}
|
||||
State::Connected(ref mut inner) => {
|
||||
trace!("poll_ready; connected");
|
||||
match inner.poll_ready() {
|
||||
Ok(Async::Ready(_)) => {
|
||||
match inner.poll_ready(cx) {
|
||||
Poll::Ready(Ok(())) => {
|
||||
trace!("poll_ready; ready");
|
||||
return Ok(Async::Ready(()));
|
||||
return Poll::Ready(Ok(()));
|
||||
}
|
||||
Ok(Async::NotReady) => {
|
||||
Poll::Pending => {
|
||||
trace!("poll_ready; not ready");
|
||||
return Ok(Async::NotReady);
|
||||
return Poll::Pending;
|
||||
}
|
||||
Err(_) => {
|
||||
Poll::Ready(Err(_)) => {
|
||||
trace!("poll_ready; error");
|
||||
state = State::Idle;
|
||||
}
|
||||
|
@ -120,7 +125,7 @@ where
|
|||
}
|
||||
|
||||
self.state = state;
|
||||
ret
|
||||
Poll::Ready(ret)
|
||||
}
|
||||
|
||||
fn call(&mut self, request: Request) -> Self::Future {
|
||||
|
|
Loading…
Reference in New Issue