From 43e14818c4997fae12e8049d9149023d17f4a149 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 9 Dec 2018 10:15:49 -0800 Subject: [PATCH] migrate to actix-service crate --- Cargo.toml | 4 +--- actix-service/Cargo.toml | 2 +- src/cloneable.rs | 2 +- src/connector.rs | 3 +-- src/either.rs | 3 +-- src/framed.rs | 2 +- src/inflight.rs | 2 +- src/keepalive.rs | 2 +- src/resolver.rs | 3 +-- src/server/config.rs | 2 +- src/server/services.rs | 2 +- src/ssl/nativetls.rs | 2 +- src/ssl/openssl.rs | 2 +- src/ssl/rustls.rs | 2 +- src/stream.rs | 3 +-- src/time.rs | 2 +- src/timeout.rs | 3 +-- 17 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 90f7865b..0981dafc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,7 @@ cell = [] [dependencies] actix = "0.7.6" -# actix-service = "0.1" -actix-service = { path="./actix-service" } +actix-service = "0.1.1" log = "0.4" num_cpus = "1.0" @@ -66,7 +65,6 @@ tokio-tcp = "0.1" tokio-timer = "0.2" tokio-reactor = "0.1" tokio-current-thread = "0.1" -tower-service = { git = "https://github.com/tower-rs/tower.git" } trust-dns-proto = "^0.5.0" trust-dns-resolver = "^0.10.0" diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index d9900c4d..332d044a 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-service" -version = "0.1.0" +version = "0.1.1" authors = ["Nikolay Kim "] description = "Actix Service" keywords = ["network", "framework", "async", "futures"] diff --git a/src/cloneable.rs b/src/cloneable.rs index e367043a..cbce3e29 100644 --- a/src/cloneable.rs +++ b/src/cloneable.rs @@ -1,10 +1,10 @@ use std::marker::PhantomData; use std::rc::Rc; +use actix_service::Service; use futures::Poll; use super::cell::Cell; -use super::service::Service; /// Service that allows to turn non-clone service to a service with `Clone` impl pub struct CloneableService { diff --git a/src/connector.rs b/src/connector.rs index e1ede0e7..cebff826 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -4,15 +4,14 @@ use std::net::{IpAddr, SocketAddr}; use std::time::Duration; use std::{fmt, io}; +use actix_service::{NewService, Service}; use futures::future::{ok, Either, FutureResult}; use futures::{try_ready, Async, Future, Poll}; - use tokio_tcp::{ConnectFuture, TcpStream}; use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; use trust_dns_resolver::system_conf::read_system_conf; use super::resolver::{RequestHost, ResolveError, Resolver, ResolverFuture}; -use super::service::{NewService, Service}; /// Port of the request pub trait RequestPort { diff --git a/src/either.rs b/src/either.rs index d1baab0c..e5a23e49 100644 --- a/src/either.rs +++ b/src/either.rs @@ -1,8 +1,7 @@ //! Contains `Either` service and related types and functions. +use actix_service::{NewService, Service}; use futures::{future, try_ready, Async, Future, Poll}; -use super::service::{NewService, Service}; - /// Combine two different service types into a single type. /// /// Both services must be of the same request, response, and error types. diff --git a/src/framed.rs b/src/framed.rs index b66a5dc0..e6548920 100644 --- a/src/framed.rs +++ b/src/framed.rs @@ -3,6 +3,7 @@ use std::marker::PhantomData; use std::mem; use actix; +use actix_service::{IntoNewService, IntoService, NewService, Service}; use futures::future::{ok, FutureResult}; use futures::unsync::mpsc; use futures::{Async, AsyncSink, Future, Poll, Sink, Stream}; @@ -10,7 +11,6 @@ use tokio_codec::{Decoder, Encoder}; use tokio_io::{AsyncRead, AsyncWrite}; use crate::codec::Framed; -use crate::service::{IntoNewService, IntoService, NewService, Service}; type Request = ::Item; type Response = ::Item; diff --git a/src/inflight.rs b/src/inflight.rs index 9e1b35f2..d4751d05 100644 --- a/src/inflight.rs +++ b/src/inflight.rs @@ -1,7 +1,7 @@ +use actix_service::{IntoNewService, IntoService, NewService, Service}; use futures::{try_ready, Async, Future, Poll}; use super::counter::{Counter, CounterGuard}; -use super::service::{IntoNewService, IntoService, NewService, Service}; /// InFlight - new service for service that can limit number of in-flight /// async requests. diff --git a/src/keepalive.rs b/src/keepalive.rs index d3e31f33..4590c70e 100644 --- a/src/keepalive.rs +++ b/src/keepalive.rs @@ -1,11 +1,11 @@ use std::marker::PhantomData; use std::time::{Duration, Instant}; +use actix_service::{NewService, Service}; use futures::future::{ok, FutureResult}; use futures::{Async, Future, Poll}; use tokio_timer::Delay; -use super::service::{NewService, Service}; use super::time::{LowResTime, LowResTimeService}; use super::Never; diff --git a/src/resolver.rs b/src/resolver.rs index 0c87c78f..9c67a2c1 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -4,6 +4,7 @@ use std::net::IpAddr; use futures::{Async, Future, Poll}; +use actix_service::Service; use tokio_current_thread::spawn; use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; pub use trust_dns_resolver::error::ResolveError; @@ -11,8 +12,6 @@ use trust_dns_resolver::lookup_ip::LookupIpFuture; use trust_dns_resolver::system_conf::read_system_conf; use trust_dns_resolver::{AsyncResolver, Background}; -use super::service::Service; - /// Host name of the request pub trait RequestHost { fn host(&self) -> &str; diff --git a/src/server/config.rs b/src/server/config.rs index b48f89ea..4409bcf7 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -1,12 +1,12 @@ use std::collections::HashMap; use std::{fmt, io, net}; +use actix_service::{IntoNewService, NewService}; use futures::future::{join_all, Future}; use log::error; use tokio_tcp::TcpStream; use crate::counter::CounterGuard; -use crate::service::{IntoNewService, NewService}; use super::server::bind_addr; use super::services::{ diff --git a/src/server/services.rs b/src/server/services.rs index 24bde6c7..562914a0 100644 --- a/src/server/services.rs +++ b/src/server/services.rs @@ -1,6 +1,7 @@ use std::net; use std::time::Duration; +use actix_service::{NewService, Service}; use futures::future::{err, ok, FutureResult}; use futures::{Future, Poll}; use log::error; @@ -10,7 +11,6 @@ use tokio_tcp::TcpStream; use super::Token; use crate::counter::CounterGuard; -use crate::service::{NewService, Service}; /// Server message pub enum ServerMessage { diff --git a/src/ssl/nativetls.rs b/src/ssl/nativetls.rs index 03a661f1..a2c8c95d 100644 --- a/src/ssl/nativetls.rs +++ b/src/ssl/nativetls.rs @@ -1,13 +1,13 @@ use std::io; use std::marker::PhantomData; +use actix_service::{NewService, Service}; use futures::{future::ok, future::FutureResult, Async, Future, Poll}; use native_tls::{self, Error, HandshakeError, TlsAcceptor}; use tokio_io::{AsyncRead, AsyncWrite}; use super::MAX_CONN_COUNTER; use crate::counter::{Counter, CounterGuard}; -use crate::service::{NewService, Service}; /// Support `SSL` connections via native-tls package /// diff --git a/src/ssl/openssl.rs b/src/ssl/openssl.rs index 0cf14820..aea3f129 100644 --- a/src/ssl/openssl.rs +++ b/src/ssl/openssl.rs @@ -1,5 +1,6 @@ use std::marker::PhantomData; +use actix_service::{NewService, Service}; use futures::{future::ok, future::FutureResult, Async, Future, Poll}; use openssl::ssl::{Error, SslAcceptor, SslConnector}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -8,7 +9,6 @@ use tokio_openssl::{AcceptAsync, ConnectAsync, SslAcceptorExt, SslConnectorExt, use super::MAX_CONN_COUNTER; use crate::counter::{Counter, CounterGuard}; use crate::resolver::RequestHost; -use crate::service::{NewService, Service}; /// Support `SSL` connections via openssl package /// diff --git a/src/ssl/rustls.rs b/src/ssl/rustls.rs index b3140bcf..325e5dde 100644 --- a/src/ssl/rustls.rs +++ b/src/ssl/rustls.rs @@ -2,6 +2,7 @@ use std::io; use std::marker::PhantomData; use std::sync::Arc; +use actix_service::{NewService, Service}; use futures::{future::ok, future::FutureResult, Async, Future, Poll}; use rustls::{ServerConfig, ServerSession}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -9,7 +10,6 @@ use tokio_rustls::{Accept, TlsAcceptor, TlsStream}; use super::MAX_CONN_COUNTER; use crate::counter::{Counter, CounterGuard}; -use crate::service::{NewService, Service}; /// Support `SSL` connections via rustls package /// diff --git a/src/stream.rs b/src/stream.rs index c8067807..618575a6 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,11 +1,10 @@ use std::marker::PhantomData; +use actix_service::{IntoService, NewService, Service}; use futures::unsync::mpsc; use futures::{future, Async, Future, Poll, Stream}; use tokio_current_thread::spawn; -use super::service::{IntoService, NewService, Service}; - pub struct StreamDispatcher { stream: S, service: T, diff --git a/src/time.rs b/src/time.rs index 94f5f626..27e1d3a8 100644 --- a/src/time.rs +++ b/src/time.rs @@ -1,12 +1,12 @@ use std::time::{Duration, Instant}; +use actix_service::{NewService, Service}; use futures::future::{ok, FutureResult}; use futures::{Async, Future, Poll}; use tokio_current_thread::spawn; use tokio_timer::sleep; use super::cell::Cell; -use super::service::{NewService, Service}; use super::Never; #[derive(Clone, Debug)] diff --git a/src/timeout.rs b/src/timeout.rs index be5968ad..8a18b1ac 100644 --- a/src/timeout.rs +++ b/src/timeout.rs @@ -5,12 +5,11 @@ use std::fmt; use std::time::Duration; +use actix_service::{NewService, Service}; use futures::try_ready; use futures::{Async, Future, Poll}; use tokio_timer::{clock, Delay}; -use crate::service::{NewService, Service}; - /// Applies a timeout to requests. #[derive(Debug)] pub struct Timeout {