Option to disable keep alive for JSON-RPC http transport (#9848)
* Keep alive jsonrpc CLI option. * Update to latest json-rpc. * Keep alive flag.
This commit is contained in:
@@ -137,6 +137,7 @@ pub fn start_http<M, S, H, T>(
|
||||
extractor: T,
|
||||
threads: usize,
|
||||
max_payload: usize,
|
||||
keep_alive: bool,
|
||||
) -> ::std::io::Result<HttpServer> where
|
||||
M: jsonrpc_core::Metadata,
|
||||
S: jsonrpc_core::Middleware<M>,
|
||||
@@ -145,6 +146,7 @@ pub fn start_http<M, S, H, T>(
|
||||
{
|
||||
let extractor = http_common::MetaExtractor::new(extractor);
|
||||
Ok(http::ServerBuilder::with_meta_extractor(handler, extractor)
|
||||
.keep_alive(keep_alive)
|
||||
.threads(threads)
|
||||
.cors(cors_domains.into())
|
||||
.allowed_hosts(allowed_hosts.into())
|
||||
@@ -163,6 +165,7 @@ pub fn start_http_with_middleware<M, S, H, T, R>(
|
||||
middleware: R,
|
||||
threads: usize,
|
||||
max_payload: usize,
|
||||
keep_alive: bool,
|
||||
) -> ::std::io::Result<HttpServer> where
|
||||
M: jsonrpc_core::Metadata,
|
||||
S: jsonrpc_core::Middleware<M>,
|
||||
@@ -172,6 +175,7 @@ pub fn start_http_with_middleware<M, S, H, T, R>(
|
||||
{
|
||||
let extractor = http_common::MetaExtractor::new(extractor);
|
||||
Ok(http::ServerBuilder::with_meta_extractor(handler, extractor)
|
||||
.keep_alive(keep_alive)
|
||||
.threads(threads)
|
||||
.cors(cors_domains.into())
|
||||
.allowed_hosts(allowed_hosts.into())
|
||||
|
||||
@@ -40,6 +40,7 @@ fn serve(handler: Option<MetaIoHandler<Metadata>>) -> Server<HttpServer> {
|
||||
},
|
||||
1,
|
||||
5,
|
||||
false,
|
||||
).unwrap())
|
||||
}
|
||||
|
||||
|
||||
@@ -218,9 +218,10 @@ impl<M: core::Middleware<Metadata>> WsDispatcher<M> {
|
||||
|
||||
impl<M: core::Middleware<Metadata>> core::Middleware<Metadata> for WsDispatcher<M> {
|
||||
type Future = Either<
|
||||
core::FutureRpcResult<M::Future>,
|
||||
core::FutureRpcResult<M::Future, M::CallFuture>,
|
||||
core::FutureResponse,
|
||||
>;
|
||||
type CallFuture = core::middleware::NoopCallFuture;
|
||||
|
||||
fn on_request<F, X>(&self, request: core::Request, meta: Metadata, process: F)
|
||||
-> Either<Self::Future, X>
|
||||
|
||||
@@ -205,6 +205,7 @@ impl<T: ActivityNotifier> Middleware<T> {
|
||||
|
||||
impl<M: core::Metadata, T: ActivityNotifier> core::Middleware<M> for Middleware<T> {
|
||||
type Future = core::FutureResponse;
|
||||
type CallFuture = core::middleware::NoopCallFuture;
|
||||
|
||||
fn on_request<F, X>(&self, request: core::Request, meta: M, process: F) -> Either<Self::Future, X> where
|
||||
F: FnOnce(core::Request, M) -> X,
|
||||
|
||||
Reference in New Issue
Block a user