1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 22:51:07 +01:00

rename StreamServiceFactory to ServiceFactory

This commit is contained in:
Nikolay Kim 2019-03-04 14:31:46 -08:00
parent 82930de8e7
commit 9f25fdf929
4 changed files with 21 additions and 9 deletions

View File

@ -1,5 +1,14 @@
# Changes
## [0.3.1] - 2019-03-xx
### Changed
* Rename `StreamServiceFactory` to `ServiceFactory`
* Deprecate `StreamServiceFactory`
## [0.3.0] - 2019-03-02
### Changed

View File

@ -14,7 +14,7 @@ use tokio_timer::sleep;
use crate::accept::{AcceptLoop, AcceptNotify, Command};
use crate::config::{ConfiguredService, ServiceConfig};
use crate::server::{Server, ServerCommand};
use crate::services::{InternalServiceFactory, StreamNewService, StreamServiceFactory};
use crate::services::{InternalServiceFactory, ServiceFactory, StreamNewService};
use crate::signals::{Signal, Signals};
use crate::worker::{self, Worker, WorkerAvailability, WorkerClient};
use crate::Token;
@ -137,7 +137,7 @@ impl ServerBuilder {
/// Add new service to the server.
pub fn bind<F, U, N: AsRef<str>>(mut self, name: N, addr: U, factory: F) -> io::Result<Self>
where
F: StreamServiceFactory,
F: ServiceFactory,
U: net::ToSocketAddrs,
{
let sockets = bind_addr(addr)?;
@ -163,7 +163,7 @@ impl ServerBuilder {
factory: F,
) -> Self
where
F: StreamServiceFactory,
F: ServiceFactory,
{
let token = self.token.next();
self.services.push(StreamNewService::create(

View File

@ -13,7 +13,10 @@ mod worker;
pub use self::builder::ServerBuilder;
pub use self::config::{ServiceConfig, ServiceRuntime};
pub use self::server::Server;
pub use self::services::StreamServiceFactory;
pub use self::services::ServiceFactory;
#[doc(hidden)]
pub use self::services::ServiceFactory as StreamServiceFactory;
/// Socket id token
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View File

@ -22,7 +22,7 @@ pub(crate) enum ServerMessage {
ForceShutdown,
}
pub trait StreamServiceFactory: Send + Clone + 'static {
pub trait ServiceFactory: Send + Clone + 'static {
type NewService: NewService<Request = TcpStream>;
fn create(&self) -> Self::NewService;
@ -92,7 +92,7 @@ where
}
}
pub(crate) struct StreamNewService<F: StreamServiceFactory> {
pub(crate) struct StreamNewService<F: ServiceFactory> {
name: String,
inner: F,
token: Token,
@ -100,7 +100,7 @@ pub(crate) struct StreamNewService<F: StreamServiceFactory> {
impl<F> StreamNewService<F>
where
F: StreamServiceFactory,
F: ServiceFactory,
{
pub(crate) fn create(name: String, token: Token, inner: F) -> Box<InternalServiceFactory> {
Box::new(Self { name, token, inner })
@ -109,7 +109,7 @@ where
impl<F> InternalServiceFactory for StreamNewService<F>
where
F: StreamServiceFactory,
F: ServiceFactory,
{
fn name(&self, _: Token) -> &str {
&self.name
@ -152,7 +152,7 @@ impl InternalServiceFactory for Box<InternalServiceFactory> {
}
}
impl<F, T> StreamServiceFactory for F
impl<F, T> ServiceFactory for F
where
F: Fn() -> T + Send + Clone + 'static,
T: NewService<Request = TcpStream>,