1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-02 14:26:43 +00:00

deprecate start_incoming

This commit is contained in:
Nikolay Kim 2018-09-28 08:45:49 -07:00
parent fc5088b55e
commit 0f1c80ccc6
3 changed files with 63 additions and 61 deletions

View file

@ -51,7 +51,7 @@ type SslConnector = Arc<ClientConfig>;
feature = "ssl", feature = "ssl",
feature = "tls", feature = "tls",
feature = "rust-tls", feature = "rust-tls",
)))] ),))]
type SslConnector = (); type SslConnector = ();
use server::IoStream; use server::IoStream;
@ -290,7 +290,7 @@ impl Default for ClientConnector {
feature = "ssl", feature = "ssl",
feature = "tls", feature = "tls",
feature = "rust-tls", feature = "rust-tls",
)))] ),))]
{ {
() ()
} }

View file

@ -1,6 +1,7 @@
use std::net::{Shutdown, SocketAddr}; use std::net::{Shutdown, SocketAddr};
use std::{io, ptr, time}; use std::{io, ptr, time};
use actix::Message;
use bytes::{Buf, BufMut, BytesMut}; use bytes::{Buf, BufMut, BytesMut};
use futures::{Async, Future, Poll}; use futures::{Async, Future, Poll};
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
@ -282,6 +283,10 @@ where
io: T, io: T,
} }
impl<T: AsyncRead + AsyncWrite + 'static> Message for WrapperStream<T> {
type Result = ();
}
impl<T> WrapperStream<T> impl<T> WrapperStream<T>
where where
T: AsyncRead + AsyncWrite + 'static, T: AsyncRead + AsyncWrite + 'static,

View file

@ -1,11 +1,13 @@
use std::{io, mem, net}; use std::{io, mem, net};
use actix::{Addr, System}; use actix::{Actor, Addr, Arbiter, AsyncContext, Context, Handler, System};
use actix_net::server::Server; use actix_net::server::Server;
use actix_net::ssl; use actix_net::ssl;
use futures::Stream;
use net2::TcpBuilder; use net2::TcpBuilder;
use num_cpus; use num_cpus;
use tokio_io::{AsyncRead, AsyncWrite};
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
use native_tls::TlsAcceptor; use native_tls::TlsAcceptor;
@ -17,8 +19,10 @@ use openssl::ssl::SslAcceptorBuilder;
use rustls::ServerConfig; use rustls::ServerConfig;
use super::acceptor::{AcceptorServiceFactory, DefaultAcceptor}; use super::acceptor::{AcceptorServiceFactory, DefaultAcceptor};
use super::builder::DefaultPipelineFactory; use super::builder::{DefaultPipelineFactory, HttpServiceBuilder, ServiceProvider};
use super::builder::{HttpServiceBuilder, ServiceProvider}; use super::channel::{HttpChannel, WrapperStream};
use super::handler::HttpHandler;
use super::settings::{ServerSettings, WorkerSettings};
use super::{IntoHttpHandler, KeepAlive}; use super::{IntoHttpHandler, KeepAlive};
struct Socket { struct Socket {
@ -520,67 +524,60 @@ impl<H: IntoHttpHandler, F: Fn() -> H + Send + Clone> HttpServer<H, F> {
} }
} }
// impl<H: IntoHttpHandler> HttpServer<H> { impl<H, F> HttpServer<H, F>
// /// Start listening for incoming connections from a stream. where
// /// H: IntoHttpHandler,
// /// This method uses only one thread for handling incoming connections. F: Fn() -> H + Send + Clone,
// pub fn start_incoming<T, S>(self, stream: S, secure: bool) {
// where #[doc(hidden)]
// S: Stream<Item = T, Error = io::Error> + Send + 'static, #[deprecated(since = "0.7.8")]
// T: AsyncRead + AsyncWrite + Send + 'static, /// Start listening for incoming connections from a stream.
// { ///
// // set server settings /// This method uses only one thread for handling incoming connections.
// let addr: net::SocketAddr = "127.0.0.1:8080".parse().unwrap(); pub fn start_incoming<T, S>(self, stream: S, secure: bool)
// let srv_settings = ServerSettings::new(Some(addr), &self.host, secure); where
// let apps: Vec<_> = (*self.factory)() S: Stream<Item = T, Error = io::Error> + 'static,
// .into_iter() T: AsyncRead + AsyncWrite + 'static,
// .map(|h| h.into_handler()) {
// .collect(); // set server settings
// let settings = WorkerSettings::create( let addr: net::SocketAddr = "127.0.0.1:8080".parse().unwrap();
// apps, let apps = (self.factory)().into_handler();
// self.keep_alive, let settings = WorkerSettings::new(
// srv_settings, apps,
// ); self.keep_alive,
self.client_timeout as u64,
ServerSettings::new(Some(addr), &self.host, secure),
);
// // start server // start server
// HttpIncoming::create(move |ctx| { HttpIncoming::create(move |ctx| {
// ctx.add_message_stream(stream.map_err(|_| ()).map(move |t| Conn { ctx.add_message_stream(
// io: WrapperStream::new(t), stream.map_err(|_| ()).map(move |t| WrapperStream::new(t)),
// handler: Token::new(0), );
// token: Token::new(0), HttpIncoming { settings }
// peer: None, });
// })); }
// HttpIncoming { settings } }
// });
// }
// }
// struct HttpIncoming<H: HttpHandler> { struct HttpIncoming<H: HttpHandler> {
// settings: Rc<WorkerSettings<H>>, settings: WorkerSettings<H>,
// } }
// impl<H> Actor for HttpIncoming<H> impl<H: HttpHandler> Actor for HttpIncoming<H> {
// where type Context = Context<Self>;
// H: HttpHandler, }
// {
// type Context = Context<Self>;
// }
// impl<T, H> Handler<Conn<T>> for HttpIncoming<H> impl<T, H> Handler<WrapperStream<T>> for HttpIncoming<H>
// where where
// T: IoStream, T: AsyncRead + AsyncWrite,
// H: HttpHandler, H: HttpHandler,
// { {
// type Result = (); type Result = ();
// fn handle(&mut self, msg: Conn<T>, _: &mut Context<Self>) -> Self::Result { fn handle(&mut self, msg: WrapperStream<T>, _: &mut Context<Self>) -> Self::Result {
// spawn(HttpChannel::new( Arbiter::spawn(HttpChannel::new(self.settings.clone(), msg, None));
// Rc::clone(&self.settings), }
// msg.io, }
// msg.peer,
// ));
// }
// }
fn create_tcp_listener( fn create_tcp_listener(
addr: net::SocketAddr, backlog: i32, addr: net::SocketAddr, backlog: i32,