From 6e0fe7db2dcd737582b05673028d098ef9a0c58a Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 28 Mar 2019 05:16:43 -0700 Subject: [PATCH] use actix-threadpool for blocking calls --- Cargo.toml | 3 ++- src/error.rs | 8 ++++---- src/lib.rs | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 63a607e2..5a75e9ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,11 +70,12 @@ actix-codec = "0.1.1" actix-service = "0.3.4" actix-utils = "0.3.4" actix-router = "0.1.0" -actix-rt = "0.2.1" +actix-rt = "0.2.2" actix-web-codegen = { path="actix-web-codegen" } actix-http = { path = "actix-http", features=["fail"] } actix-server = "0.4.1" actix-server-config = "0.1.0" +actix-threadpool = "0.1.0" awc = { path = "awc", optional = true } bytes = "0.4" diff --git a/src/error.rs b/src/error.rs index f7610d50..984b46e0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -37,11 +37,11 @@ pub enum BlockingError { impl ResponseError for BlockingError {} -impl From> for BlockingError { - fn from(err: actix_rt::blocking::BlockingError) -> Self { +impl From> for BlockingError { + fn from(err: actix_threadpool::BlockingError) -> Self { match err { - actix_rt::blocking::BlockingError::Error(e) => BlockingError::Error(e), - actix_rt::blocking::BlockingError::Canceled => BlockingError::Canceled, + actix_threadpool::BlockingError::Error(e) => BlockingError::Error(e), + actix_threadpool::BlockingError::Canceled => BlockingError::Canceled, } } } diff --git a/src/lib.rs b/src/lib.rs index d3d66c61..ec5a9e6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,6 @@ pub mod dev { pub mod web { //! Various types use actix_http::{http::Method, Response}; - use actix_rt::blocking; use futures::{Future, IntoFuture}; pub use actix_http::Response as HttpResponse; @@ -339,7 +338,7 @@ pub mod web { I: Send + 'static, E: Send + std::fmt::Debug + 'static, { - blocking::run(f).from_err() + actix_threadpool::run(f).from_err() } use actix_service::{fn_transform, Service, Transform};