Take CPU pool as dependency for State
This commit is contained in:
parent
6fb1062376
commit
320ec98d65
2 changed files with 5 additions and 3 deletions
|
@ -54,7 +54,9 @@ fn core_main() -> Result<(), Box<std::error::Error>> {
|
||||||
.unwrap_or(8080);
|
.unwrap_or(8080);
|
||||||
|
|
||||||
let db_pool = db::create_pool(db_file)?;
|
let db_pool = db::create_pool(db_file)?;
|
||||||
let state = state::State::new(db_pool);
|
let cpu_pool = futures_cpupool::CpuPool::new_num_cpus();
|
||||||
|
|
||||||
|
let state = state::State::new(db_pool, cpu_pool);
|
||||||
|
|
||||||
let server =
|
let server =
|
||||||
hyper::server::Http::new()
|
hyper::server::Http::new()
|
||||||
|
|
|
@ -18,10 +18,10 @@ pub struct State {
|
||||||
pub type Error = Box<std::error::Error + Send + Sync>;
|
pub type Error = Box<std::error::Error + Send + Sync>;
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn new(connection_pool: Pool<ConnectionManager<SqliteConnection>>) -> State {
|
pub fn new(connection_pool: Pool<ConnectionManager<SqliteConnection>>, cpu_pool: futures_cpupool::CpuPool) -> State {
|
||||||
State {
|
State {
|
||||||
connection_pool,
|
connection_pool,
|
||||||
cpu_pool: futures_cpupool::CpuPool::new_num_cpus(),
|
cpu_pool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue