mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-23 22:51:07 +01:00
use actix deps instead of tokio
This commit is contained in:
parent
5efac449b1
commit
52d03fa18c
@ -43,7 +43,6 @@ futures = "0.3.1"
|
||||
http = { version = "0.1.17", optional = true }
|
||||
log = "0.4"
|
||||
tokio-net = "=0.2.0-alpha.6"
|
||||
tokio-executor = "=0.2.0-alpha.6"
|
||||
trust-dns-resolver = { version="0.18.0-alpha.1", default-features = false }
|
||||
|
||||
# openssl
|
||||
@ -60,4 +59,3 @@ webpki = { version = "0.21", optional = true }
|
||||
bytes = "0.4"
|
||||
actix-testing = { version="0.3.0-alpha.1" }
|
||||
actix-server-config = "0.3.0-alpha.1"
|
||||
tokio = "0.2.0-alpha.6"
|
||||
|
@ -36,7 +36,7 @@ pub use self::service::{ConnectService, ConnectServiceFactory, TcpConnectService
|
||||
|
||||
pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver {
|
||||
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
||||
tokio_executor::current_thread::spawn(bg);
|
||||
actix_rt::spawn(bg);
|
||||
resolver
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ pub(crate) fn get_default_resolver() -> AsyncResolver {
|
||||
};
|
||||
|
||||
let (resolver, bg) = AsyncResolver::new(cfg, opts);
|
||||
tokio_executor::current_thread::spawn(bg);
|
||||
actix_rt::spawn(bg);
|
||||
|
||||
Arbiter::set_item(DefaultResolver(resolver.clone()));
|
||||
resolver
|
||||
|
@ -48,7 +48,7 @@ async fn test_rustls_string() {
|
||||
assert_eq!(con.peer_addr().unwrap(), srv.addr());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[actix_rt::test]
|
||||
async fn test_static_str() {
|
||||
let srv = TestServer::with(|| {
|
||||
service_fn(|io: Io<tokio_net::tcp::TcpStream>| {
|
||||
|
@ -21,17 +21,15 @@ path = "src/lib.rs"
|
||||
actix-service = "1.0.0-alpha.1"
|
||||
actix-codec = "0.2.0-alpha.1"
|
||||
actix-utils = "0.5.0-alpha.1"
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
bytes = "0.4"
|
||||
either = "1.5.2"
|
||||
futures = "0.3.1"
|
||||
pin-project = "0.4.5"
|
||||
tokio-executor = "=0.2.0-alpha.6"
|
||||
log = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
actix-connect = "1.0.0-alpha.1"
|
||||
actix-testing = "0.3.0-alpha.1"
|
||||
actix-server-config = "0.3.0-alpha.1"
|
||||
tokio-net = "=0.2.0-alpha.6"
|
||||
tokio-timer = "=0.3.0-alpha.6"
|
||||
|
@ -279,22 +279,21 @@ where
|
||||
};
|
||||
|
||||
let mut cell = inner.clone();
|
||||
tokio_executor::current_thread::spawn(
|
||||
srv.call(Item::new(state.clone(), sink.clone(), item))
|
||||
.then(move |item| {
|
||||
let item = match item {
|
||||
Ok(Some(item)) => Ok(item),
|
||||
Ok(None) => return ready(()),
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
unsafe {
|
||||
let inner = cell.get_mut();
|
||||
inner.buf.push_back(item);
|
||||
inner.task.wake();
|
||||
}
|
||||
ready(())
|
||||
}),
|
||||
);
|
||||
actix_rt::spawn(srv.call(Item::new(state.clone(), sink.clone(), item)).then(
|
||||
move |item| {
|
||||
let item = match item {
|
||||
Ok(Some(item)) => Ok(item),
|
||||
Ok(None) => return ready(()),
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
unsafe {
|
||||
let inner = cell.get_mut();
|
||||
inner.buf.push_back(item);
|
||||
inner.task.wake();
|
||||
}
|
||||
ready(())
|
||||
},
|
||||
));
|
||||
}
|
||||
Poll::Pending => return false,
|
||||
Poll::Ready(Err(err)) => {
|
||||
|
@ -3,12 +3,12 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_codec::BytesCodec;
|
||||
use actix_rt::time::delay_for;
|
||||
use actix_server_config::Io;
|
||||
use actix_service::{apply_fn_factory, service_fn, Service};
|
||||
use actix_testing::TestServer;
|
||||
use futures::future::ok;
|
||||
use tokio_net::tcp::TcpStream;
|
||||
use tokio_timer::delay_for;
|
||||
|
||||
use actix_ioframe::{Builder, Connect};
|
||||
|
||||
|
@ -22,7 +22,7 @@ openssl = ["tokio-openssl"]
|
||||
rustls = ["tokio-rustls"]
|
||||
|
||||
[dependencies]
|
||||
tokio-io = "=0.2.0-alpha.6"
|
||||
actix-codec = "0.2.0-alpha.1"
|
||||
tokio-net = { version = "=0.2.0-alpha.6", features = ["tcp", "uds"] }
|
||||
tokio-openssl = { version = "0.4.0-alpha.6", optional = true }
|
||||
#tokio-rustls = { version = "0.12.0-alpha.8", optional = true }
|
||||
|
@ -5,7 +5,7 @@ use std::net::SocketAddr;
|
||||
use std::rc::Rc;
|
||||
use std::{fmt, io, net, ops, time};
|
||||
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use tokio_net::tcp::TcpStream;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -24,12 +24,13 @@ path = "src/lib.rs"
|
||||
default = []
|
||||
nativetls = ["native-tls", "tokio-tls"]
|
||||
openssl = ["open-ssl", "tokio-openssl", "actix-server-config/openssl"]
|
||||
#rustls = ["rust-tls", "tokio-rustls", "webpki", "webpki-roots", "actix-server-config/rustls"]
|
||||
rustls = ["rust-tls", "tokio-rustls", "webpki", "webpki-roots", "actix-server-config/rustls"]
|
||||
|
||||
[dependencies]
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
actix-service = "1.0.0-alpha.1"
|
||||
actix-server-config = "0.3.0-alpha.1"
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
actix-codec = "0.2.0-alpha.1"
|
||||
|
||||
log = "0.4"
|
||||
num_cpus = "1.0"
|
||||
@ -37,11 +38,7 @@ mio = "0.6.19"
|
||||
net2 = "0.2"
|
||||
futures = "0.3.1"
|
||||
slab = "0.4"
|
||||
|
||||
tokio = "0.2.0-alpha.6"
|
||||
tokio-io = "0.2.0-alpha.6"
|
||||
tokio-net = { version = "0.2.0-alpha.6", features = ["signal", "tcp", "uds"] }
|
||||
tokio-timer = "0.3.0-alpha.6"
|
||||
|
||||
# unix domain sockets
|
||||
mio-uds = { version = "0.6.7" }
|
||||
|
@ -2,11 +2,11 @@ use std::sync::mpsc as sync_mpsc;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{io, thread};
|
||||
|
||||
use actix_rt::time::delay;
|
||||
use actix_rt::System;
|
||||
use futures::FutureExt;
|
||||
use log::{error, info};
|
||||
use slab::Slab;
|
||||
use tokio_timer::delay;
|
||||
|
||||
use crate::server::Server;
|
||||
use crate::socket::{SocketAddr, SocketListener, StdListener};
|
||||
|
@ -3,7 +3,7 @@ use std::task::{Context, Poll};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{io, mem, net};
|
||||
|
||||
use actix_rt::{spawn, Arbiter, System};
|
||||
use actix_rt::{spawn, time::delay, Arbiter, System};
|
||||
use futures::channel::mpsc::{unbounded, UnboundedReceiver};
|
||||
use futures::future::ready;
|
||||
use futures::stream::FuturesUnordered;
|
||||
@ -12,7 +12,6 @@ use log::{error, info};
|
||||
use net2::TcpBuilder;
|
||||
use num_cpus;
|
||||
use tokio_net::tcp::TcpStream;
|
||||
use tokio_timer::delay;
|
||||
|
||||
use crate::accept::{AcceptLoop, AcceptNotify, Command};
|
||||
use crate::config::{ConfiguredService, ServiceConfig};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{fmt, io, net};
|
||||
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use tokio_net::driver::Handle;
|
||||
use tokio_net::tcp::TcpStream;
|
||||
|
||||
|
@ -2,10 +2,10 @@ use std::convert::Infallible;
|
||||
use std::marker::PhantomData;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{self, FutureExt as _, LocalBoxFuture, TryFutureExt as _};
|
||||
use native_tls::Error;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use tokio_tls::{TlsAcceptor, TlsStream};
|
||||
|
||||
use crate::counter::Counter;
|
||||
|
@ -3,10 +3,10 @@ use std::marker::PhantomData;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use open_ssl::ssl::SslAcceptor;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_openssl::{HandshakeError, SslStream};
|
||||
|
||||
use crate::counter::{Counter, CounterGuard};
|
||||
|
@ -5,10 +5,10 @@ use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, Ready};
|
||||
use rust_tls::ServerConfig;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_rustls::{server::TlsStream, Accept, TlsAcceptor};
|
||||
|
||||
use crate::counter::{Counter, CounterGuard};
|
||||
|
@ -4,13 +4,13 @@ use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
use std::{mem, time};
|
||||
|
||||
use actix_rt::time::{delay, Delay};
|
||||
use actix_rt::{spawn, Arbiter};
|
||||
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use futures::channel::oneshot;
|
||||
use futures::future::{join_all, LocalBoxFuture, MapOk};
|
||||
use futures::{Future, FutureExt, Stream, TryFutureExt};
|
||||
use log::{error, info, trace};
|
||||
use tokio_timer::{delay, Delay};
|
||||
|
||||
use crate::accept::AcceptNotify;
|
||||
use crate::counter::Counter;
|
||||
|
@ -19,14 +19,10 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
actix-service = "1.0.0-alpha.1"
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
actix-codec = "0.2.0-alpha.1"
|
||||
bytes = "0.4"
|
||||
either = "1.5.2"
|
||||
futures = "0.3.1"
|
||||
pin-project = "0.4.5"
|
||||
tokio-timer = "0.3.0-alpha.6"
|
||||
tokio-executor = { version="=0.2.0-alpha.6", features=["current-thread"] }
|
||||
log = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1.0.0-alpha.1"
|
||||
|
@ -287,7 +287,7 @@ where
|
||||
inner.task.wake();
|
||||
ready(())
|
||||
});
|
||||
tokio_executor::current_thread::spawn(fut);
|
||||
actix_rt::spawn(fut);
|
||||
}
|
||||
Poll::Pending => return false,
|
||||
Poll::Ready(Err(err)) => {
|
||||
|
@ -131,7 +131,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn call(&mut self, _: ()) -> Self::Future {
|
||||
tokio_timer::delay_for(self.0)
|
||||
actix_rt::time::delay_for(self.0)
|
||||
.then(|_| ok::<_, ()>(()))
|
||||
.boxed_local()
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use actix_rt::time::{delay, Delay};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, Ready};
|
||||
use tokio_timer::{delay, Delay};
|
||||
|
||||
use super::time::{LowResTime, LowResTimeService};
|
||||
|
||||
|
@ -174,7 +174,7 @@ where
|
||||
|
||||
let task = self.task.clone();
|
||||
let fut = self.service.call(request);
|
||||
tokio_executor::current_thread::spawn(async move {
|
||||
actix_rt::spawn(async move {
|
||||
let res = fut.await;
|
||||
task.wake();
|
||||
let _ = tx1.send(res);
|
||||
@ -252,7 +252,7 @@ mod tests {
|
||||
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
||||
|
||||
// dispatcher do this
|
||||
tokio_timer::delay_for(Duration::from_millis(100)).await;
|
||||
actix_rt::time::delay_for(Duration::from_millis(100)).await;
|
||||
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
||||
|
||||
assert_eq!(res1.await.unwrap(), 1);
|
||||
|
@ -2,9 +2,9 @@ use std::convert::Infallible;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::{self, Duration, Instant};
|
||||
|
||||
use actix_rt::time::delay_for;
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, ready, FutureExt, Ready};
|
||||
use tokio_timer::delay_for;
|
||||
|
||||
use super::cell::Cell;
|
||||
|
||||
@ -79,7 +79,7 @@ impl LowResTimeService {
|
||||
b.resolution
|
||||
};
|
||||
|
||||
tokio_executor::current_thread::spawn(delay_for(interval).then(move |_| {
|
||||
actix_rt::spawn(delay_for(interval).then(move |_| {
|
||||
inner.get_mut().current.take();
|
||||
ready(())
|
||||
}));
|
||||
@ -144,7 +144,7 @@ impl SystemTimeService {
|
||||
b.resolution
|
||||
};
|
||||
|
||||
tokio_executor::current_thread::spawn(delay_for(interval).then(move |_| {
|
||||
actix_rt::spawn(delay_for(interval).then(move |_| {
|
||||
inner.get_mut().current.take();
|
||||
ready(())
|
||||
}));
|
||||
|
@ -8,9 +8,9 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::{fmt, time};
|
||||
|
||||
use actix_rt::time::{delay_for, Delay};
|
||||
use actix_service::{IntoService, Service, Transform};
|
||||
use futures::future::{ok, Ready};
|
||||
use tokio_timer::{clock, delay, Delay};
|
||||
|
||||
/// Applies a timeout to requests.
|
||||
#[derive(Debug)]
|
||||
@ -138,7 +138,7 @@ where
|
||||
fn call(&mut self, request: S::Request) -> Self::Future {
|
||||
TimeoutServiceResponse {
|
||||
fut: self.service.call(request),
|
||||
sleep: delay(clock::now() + self.timeout),
|
||||
sleep: delay_for(self.timeout),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,7 +198,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn call(&mut self, _: ()) -> Self::Future {
|
||||
tokio_timer::delay_for(self.0)
|
||||
actix_rt::time::delay_for(self.0)
|
||||
.then(|_| ok::<_, ()>(()))
|
||||
.boxed_local()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user