diff --git a/src/connector.rs b/src/connector.rs index 5752228c..786e4762 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -2,7 +2,7 @@ use std::collections::VecDeque; use std::io; use std::net::SocketAddr; -use futures::{Async, Future, Poll}; +use futures::{Async, Future, Poll, future::ok}; use tokio; use tokio_tcp::{ConnectFuture, TcpStream}; use tower_service::Service; @@ -47,6 +47,18 @@ impl Connector { Connector { resolver } } + + pub fn new_service() -> impl Future { + ok(Connector::new()) + } +} + +impl Clone for Connector { + fn clone(&self) -> Self { + Connector { + resolver: self.resolver.clone(), + } + } } impl Service for Connector { diff --git a/src/service/fn_service.rs b/src/service/fn_service.rs index 021c2203..28a7df8e 100644 --- a/src/service/fn_service.rs +++ b/src/service/fn_service.rs @@ -34,6 +34,21 @@ where } } +impl Clone for FnService +where + F: Fn(Req) -> Fut + Clone, + Fut: IntoFuture, +{ + fn clone(&self) -> Self { + FnService { + f: self.f.clone(), + req: marker::PhantomData, + resp: marker::PhantomData, + err: marker::PhantomData, + } + } +} + impl Service for FnService where F: Fn(Req) -> Fut,