mirror of
https://github.com/actix/actix-web.git
synced 2024-11-25 02:51:15 +00:00
allow configuring number of test server workers (#3069)
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
parent
b061f00421
commit
908fb2606e
2 changed files with 15 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Unreleased - 2023-xx-xx
|
||||
|
||||
- Add `TestServerConfig::workers()` setter method
|
||||
- Minimum supported Rust version (MSRV) is now 1.65 due to transitive `time` dependency.
|
||||
|
||||
## 0.1.1 - 2023-02-26
|
||||
|
|
|
@ -154,7 +154,10 @@ where
|
|||
let srv_cfg = cfg.clone();
|
||||
let timeout = cfg.client_request_timeout;
|
||||
|
||||
let builder = Server::build().workers(1).disable_signals().system_exit();
|
||||
let builder = Server::build()
|
||||
.workers(cfg.workers)
|
||||
.disable_signals()
|
||||
.system_exit();
|
||||
|
||||
let srv = match srv_cfg.stream {
|
||||
StreamType::Tcp => match srv_cfg.tp {
|
||||
|
@ -367,6 +370,7 @@ pub struct TestServerConfig {
|
|||
stream: StreamType,
|
||||
client_request_timeout: Duration,
|
||||
port: u16,
|
||||
workers: usize,
|
||||
}
|
||||
|
||||
impl Default for TestServerConfig {
|
||||
|
@ -383,6 +387,7 @@ impl TestServerConfig {
|
|||
stream: StreamType::Tcp,
|
||||
client_request_timeout: Duration::from_secs(5),
|
||||
port: 0,
|
||||
workers: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,6 +430,14 @@ impl TestServerConfig {
|
|||
self.port = port;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets number of workers in the test server process.
|
||||
///
|
||||
/// By default, the server boots with 1 worker
|
||||
pub fn workers(mut self, workers: usize) -> Self {
|
||||
self.workers = workers;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A basic HTTP server controller that simplifies the process of writing integration tests for
|
||||
|
|
Loading…
Reference in a new issue