Skip to content

Commit

Permalink
Remove ServerBuilder::configure (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow authored Apr 27, 2021
1 parent 613b2be commit 8ad5f58
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 460 deletions.
4 changes: 4 additions & 0 deletions actix-server/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changes

## Unreleased - 2021-xx-xx
* Remove `config` module. `ServiceConfig`, `ServiceRuntime` public types are removed due to this change. [#349]
* Remove `ServerBuilder::configure` [#349]

[#349]: https://github.com/actix/actix-net/pull/349


## 2.0.0-beta.5 - 2021-04-20
Expand Down
27 changes: 0 additions & 27 deletions actix-server/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
use tokio::sync::oneshot;

use crate::accept::AcceptLoop;
use crate::config::{ConfiguredService, ServiceConfig};
use crate::server::{Server, ServerCommand};
use crate::service::{InternalServiceFactory, ServiceFactory, StreamNewService};
use crate::signals::{Signal, Signals};
Expand Down Expand Up @@ -149,32 +148,6 @@ impl ServerBuilder {
self
}

/// Execute external configuration as part of the server building process.
///
/// This function is useful for moving parts of configuration to a different module or
/// even library.
pub fn configure<F>(mut self, f: F) -> io::Result<ServerBuilder>
where
F: Fn(&mut ServiceConfig) -> io::Result<()>,
{
let mut cfg = ServiceConfig::new(self.threads, self.backlog);

f(&mut cfg)?;

if let Some(apply) = cfg.apply {
let mut srv = ConfiguredService::new(apply);
for (name, lst) in cfg.services {
let token = self.token.next();
srv.stream(token, name.clone(), lst.local_addr()?);
self.sockets.push((token, name, MioListener::Tcp(lst)));
}
self.services.push(Box::new(srv));
}
self.threads = cfg.threads;

Ok(self)
}

/// 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
Expand Down
287 changes: 0 additions & 287 deletions actix-server/src/config.rs

This file was deleted.

2 changes: 0 additions & 2 deletions actix-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

mod accept;
mod builder;
mod config;
mod server;
mod service;
mod signals;
Expand All @@ -16,7 +15,6 @@ mod waker_queue;
mod worker;

pub use self::builder::ServerBuilder;
pub use self::config::{ServiceConfig, ServiceRuntime};
pub use self::server::Server;
pub use self::service::ServiceFactory;
pub use self::test_server::TestServer;
Expand Down
6 changes: 3 additions & 3 deletions actix-server/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) trait InternalServiceFactory: Send {

fn clone_factory(&self) -> Box<dyn InternalServiceFactory>;

fn create(&self) -> LocalBoxFuture<'static, Result<Vec<(Token, BoxedServerService)>, ()>>;
fn create(&self) -> LocalBoxFuture<'static, Result<(Token, BoxedServerService), ()>>;
}

pub(crate) type BoxedServerService = Box<
Expand Down Expand Up @@ -131,14 +131,14 @@ where
})
}

fn create(&self) -> LocalBoxFuture<'static, Result<Vec<(Token, BoxedServerService)>, ()>> {
fn create(&self) -> LocalBoxFuture<'static, Result<(Token, BoxedServerService), ()>> {
let token = self.token;
let fut = self.inner.create().new_service(());
Box::pin(async move {
match fut.await {
Ok(inner) => {
let service = Box::new(StreamService::new(inner)) as _;
Ok(vec![(token, service)])
Ok((token, service))
}
Err(_) => Err(()),
}
Expand Down
Loading

0 comments on commit 8ad5f58

Please sign in to comment.