1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 20:12:58 +01:00

add constraint

This commit is contained in:
Nikolay Kim 2019-03-12 16:48:29 -07:00
parent a3c4637372
commit 0fdac38307

View File

@ -2,6 +2,7 @@ use std::time::Duration;
use std::{io, mem, net}; use std::{io, mem, net};
use actix_rt::{spawn, Arbiter, System}; use actix_rt::{spawn, Arbiter, System};
use actix_service::NewService;
use futures::future::{lazy, ok}; use futures::future::{lazy, ok};
use futures::stream::futures_unordered; use futures::stream::futures_unordered;
use futures::sync::mpsc::{unbounded, UnboundedReceiver}; use futures::sync::mpsc::{unbounded, UnboundedReceiver};
@ -9,6 +10,7 @@ use futures::{Async, Future, Poll, Stream};
use log::{error, info}; use log::{error, info};
use net2::TcpBuilder; use net2::TcpBuilder;
use num_cpus; use num_cpus;
use tokio_tcp::TcpStream;
use tokio_timer::sleep; use tokio_timer::sleep;
use crate::accept::{AcceptLoop, AcceptNotify, Command}; use crate::accept::{AcceptLoop, AcceptNotify, Command};
@ -17,7 +19,7 @@ use crate::service_config::{ConfiguredService, ServiceConfig};
use crate::services::{InternalServiceFactory, ServiceFactory, StreamNewService}; use crate::services::{InternalServiceFactory, ServiceFactory, StreamNewService};
use crate::signals::{Signal, Signals}; use crate::signals::{Signal, Signals};
use crate::worker::{self, Worker, WorkerAvailability, WorkerClient}; use crate::worker::{self, Worker, WorkerAvailability, WorkerClient};
use crate::{ssl, Token}; use crate::{ssl, Io, ServerConfig, Token};
/// Server builder /// Server builder
pub struct ServerBuilder { pub struct ServerBuilder {
@ -164,6 +166,7 @@ impl ServerBuilder {
pub fn bind<F, U, N: AsRef<str>>(mut self, name: N, addr: U, factory: F) -> io::Result<Self> pub fn bind<F, U, N: AsRef<str>>(mut self, name: N, addr: U, factory: F) -> io::Result<Self>
where where
F: ServiceFactory, F: ServiceFactory,
F::NewService: NewService<ServerConfig, Request = Io<TcpStream>>,
U: net::ToSocketAddrs, U: net::ToSocketAddrs,
{ {
let sockets = bind_addr(addr, self.backlog)?; let sockets = bind_addr(addr, self.backlog)?;