mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-30 18:34:36 +01:00
log acctor init errors
This commit is contained in:
parent
f2d42e5e77
commit
e95babf8d3
@ -60,8 +60,8 @@ flate2-rust = ["flate2/rust_backend"]
|
||||
|
||||
[dependencies]
|
||||
actix = "0.7.0"
|
||||
#actix-net = { git="https://github.com/actix/actix-net.git" }
|
||||
actix-net = { path = "../actix-net" }
|
||||
actix-net = { git="https://github.com/actix/actix-net.git" }
|
||||
#actix-net = { path = "../actix-net" }
|
||||
|
||||
base64 = "0.9"
|
||||
bitflags = "1.0"
|
||||
|
@ -51,7 +51,7 @@ type SslConnector = Arc<ClientConfig>;
|
||||
feature = "ssl",
|
||||
feature = "tls",
|
||||
feature = "rust-tls",
|
||||
)))]
|
||||
),))]
|
||||
type SslConnector = ();
|
||||
|
||||
use server::IoStream;
|
||||
@ -290,7 +290,7 @@ impl Default for ClientConnector {
|
||||
feature = "ssl",
|
||||
feature = "tls",
|
||||
feature = "rust-tls",
|
||||
)))]
|
||||
),))]
|
||||
{
|
||||
()
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::net;
|
||||
use std::time::Duration;
|
||||
use std::{fmt, net};
|
||||
|
||||
use actix_net::server::ServerMessage;
|
||||
use actix_net::service::{NewService, Service};
|
||||
@ -27,6 +27,7 @@ where
|
||||
F: Fn() -> T + Send + Clone + 'static,
|
||||
T::Response: IoStream + Send,
|
||||
T: NewService<Request = TcpStream>,
|
||||
T::InitError: fmt::Debug,
|
||||
{
|
||||
type Io = T::Response;
|
||||
type NewService = T;
|
||||
@ -84,6 +85,7 @@ pub(crate) struct TcpAcceptor<T> {
|
||||
impl<T, E> TcpAcceptor<T>
|
||||
where
|
||||
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
||||
T::InitError: fmt::Debug,
|
||||
{
|
||||
pub(crate) fn new(inner: T) -> Self {
|
||||
TcpAcceptor { inner }
|
||||
@ -93,6 +95,7 @@ where
|
||||
impl<T, E> NewService for TcpAcceptor<T>
|
||||
where
|
||||
T: NewService<Request = TcpStream, Error = AcceptorError<E>>,
|
||||
T::InitError: fmt::Debug,
|
||||
{
|
||||
type Request = net::TcpStream;
|
||||
type Response = T::Response;
|
||||
@ -111,6 +114,7 @@ where
|
||||
pub(crate) struct TcpAcceptorResponse<T>
|
||||
where
|
||||
T: NewService<Request = TcpStream>,
|
||||
T::InitError: fmt::Debug,
|
||||
{
|
||||
fut: T::Future,
|
||||
}
|
||||
@ -118,16 +122,21 @@ where
|
||||
impl<T> Future for TcpAcceptorResponse<T>
|
||||
where
|
||||
T: NewService<Request = TcpStream>,
|
||||
T::InitError: fmt::Debug,
|
||||
{
|
||||
type Item = TcpAcceptorService<T::Service>;
|
||||
type Error = T::InitError;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
match self.fut.poll()? {
|
||||
Async::NotReady => Ok(Async::NotReady),
|
||||
Async::Ready(service) => {
|
||||
match self.fut.poll() {
|
||||
Ok(Async::NotReady) => Ok(Async::NotReady),
|
||||
Ok(Async::Ready(service)) => {
|
||||
Ok(Async::Ready(TcpAcceptorService { inner: service }))
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Can not create accetor service: {:?}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::net;
|
||||
use std::{fmt, net};
|
||||
|
||||
use actix_net::either::Either;
|
||||
use actix_net::server::{Server, ServiceFactory};
|
||||
@ -37,6 +37,7 @@ where
|
||||
F: Fn() -> H + Send + Clone + 'static,
|
||||
H: IntoHttpHandler,
|
||||
A: AcceptorServiceFactory,
|
||||
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
||||
{
|
||||
/// Create http service builder
|
||||
@ -58,6 +59,7 @@ where
|
||||
pub fn acceptor<A1>(self, acceptor: A1) -> HttpServiceBuilder<F, H, A1, P>
|
||||
where
|
||||
A1: AcceptorServiceFactory,
|
||||
<A1::NewService as NewService>::InitError: fmt::Debug,
|
||||
{
|
||||
HttpServiceBuilder {
|
||||
acceptor,
|
||||
@ -153,6 +155,7 @@ impl<F, H, A, P> ServiceProvider for HttpServiceBuilder<F, H, A, P>
|
||||
where
|
||||
F: Fn() -> H + Send + Clone + 'static,
|
||||
A: AcceptorServiceFactory,
|
||||
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||
P: HttpPipelineFactory<H::Handler, Io = A::Io>,
|
||||
H: IntoHttpHandler,
|
||||
{
|
||||
|
@ -1,7 +1,8 @@
|
||||
use std::{io, mem, net};
|
||||
use std::{fmt, io, mem, net};
|
||||
|
||||
use actix::{Addr, System};
|
||||
use actix_net::server::Server;
|
||||
use actix_net::service::NewService;
|
||||
use actix_net::ssl;
|
||||
|
||||
use net2::TcpBuilder;
|
||||
@ -233,6 +234,7 @@ where
|
||||
pub(crate) fn listen_with<A>(mut self, lst: net::TcpListener, acceptor: A) -> Self
|
||||
where
|
||||
A: AcceptorServiceFactory,
|
||||
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||
{
|
||||
let addr = lst.local_addr().unwrap();
|
||||
self.sockets.push(Socket {
|
||||
@ -254,7 +256,7 @@ where
|
||||
///
|
||||
/// HttpServer does not change any configuration for TcpListener,
|
||||
/// it needs to be configured before passing it to listen() method.
|
||||
pub fn listen_tls(mut self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self {
|
||||
pub fn listen_tls(self, lst: net::TcpListener, acceptor: TlsAcceptor) -> Self {
|
||||
use actix_net::service::NewServiceExt;
|
||||
|
||||
self.listen_with(lst, move || {
|
||||
@ -288,7 +290,7 @@ where
|
||||
/// Use listener for accepting incoming tls connection requests
|
||||
///
|
||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||
pub fn listen_rustls(mut self, lst: net::TcpListener, config: ServerConfig) -> Self {
|
||||
pub fn listen_rustls(self, lst: net::TcpListener, config: ServerConfig) -> Self {
|
||||
use super::{RustlsAcceptor, ServerFlags};
|
||||
use actix_net::service::NewServiceExt;
|
||||
|
||||
@ -324,6 +326,7 @@ where
|
||||
where
|
||||
S: net::ToSocketAddrs,
|
||||
A: AcceptorServiceFactory,
|
||||
<A::NewService as NewService>::InitError: fmt::Debug,
|
||||
{
|
||||
let sockets = self.bind2(addr)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user