rpc-http-threads cli arg (#8890)

* Add optional `rpc-http-threads` cli arg

* Update `http::ServerBuilder`threads
This commit is contained in:
tgmichel
2021-06-08 13:18:57 +02:00
committed by GitHub
parent 74793a83a5
commit a4bfd40a1b
8 changed files with 27 additions and 1 deletions
+5 -1
View File
@@ -33,6 +33,9 @@ pub const MAX_PAYLOAD: usize = 15 * 1024 * 1024;
/// Default maximum number of connections for WS RPC servers.
const WS_MAX_CONNECTIONS: usize = 100;
/// Default thread pool size for RPC HTTP servers.
const HTTP_THREADS: usize = 4;
/// The RPC IoHandler containing all requested APIs.
pub type RpcHandler<T> = pubsub::PubSubHandler<T, RpcMiddleware>;
@@ -79,11 +82,12 @@ mod inner {
/// **Note**: Only available if `not(target_os = "unknown")`.
pub fn start_http<M: pubsub::PubSubMetadata + Default>(
addr: &std::net::SocketAddr,
thread_pool_size: Option<usize>,
cors: Option<&Vec<String>>,
io: RpcHandler<M>,
) -> io::Result<http::Server> {
http::ServerBuilder::new(io)
.threads(4)
.threads(thread_pool_size.unwrap_or(HTTP_THREADS))
.health_api(("/health", "system_health"))
.allowed_hosts(hosts_filtering(cors.is_some()))
.rest_api(if cors.is_some() {