Struct sc_rpc_server::middleware::RpcMiddleware
source · pub struct RpcMiddleware { /* private fields */ }
Expand description
Middleware for RPC calls
Implementations§
source§impl RpcMiddleware
impl RpcMiddleware
sourcepub fn new(metrics: RpcMetrics, transport_label: &'static str) -> Self
pub fn new(metrics: RpcMetrics, transport_label: &'static str) -> Self
Create a new RpcMiddleware
with the provided RpcMetrics
.
Trait Implementations§
source§impl Clone for RpcMiddleware
impl Clone for RpcMiddleware
source§fn clone(&self) -> RpcMiddleware
fn clone(&self) -> RpcMiddleware
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl HttpMiddleware for RpcMiddleware
impl HttpMiddleware for RpcMiddleware
§type Instant = Instant
type Instant = Instant
Intended to carry timestamp of a request, for example
std::time::Instant
. How the middleware
measures time, if at all, is entirely up to the implementation. Read moresource§fn on_request(
&self,
_remote_addr: SocketAddr,
_headers: &Headers
) -> Self::Instant
fn on_request(
&self,
_remote_addr: SocketAddr,
_headers: &Headers
) -> Self::Instant
Called when a new JSON-RPC request comes to the server.
source§fn on_call(&self, name: &str, params: Params<'_>, kind: MethodKind)
fn on_call(&self, name: &str, params: Params<'_>, kind: MethodKind)
Called on each JSON-RPC method call, batch requests will trigger
on_call
multiple times.source§fn on_result(&self, name: &str, success: bool, started_at: Self::Instant)
fn on_result(&self, name: &str, success: bool, started_at: Self::Instant)
Called on each JSON-RPC method completion, batch requests will trigger
on_result
multiple times.source§fn on_response(&self, _result: &str, started_at: Self::Instant)
fn on_response(&self, _result: &str, started_at: Self::Instant)
Called once the JSON-RPC request is finished and response is sent to the output buffer.
source§impl WsMiddleware for RpcMiddleware
impl WsMiddleware for RpcMiddleware
§type Instant = Instant
type Instant = Instant
Intended to carry timestamp of a request, for example
std::time::Instant
. How the middleware
measures time, if at all, is entirely up to the implementation. Read moresource§fn on_connect(&self, _remote_addr: SocketAddr, _headers: &Headers)
fn on_connect(&self, _remote_addr: SocketAddr, _headers: &Headers)
Called when a new client connects
source§fn on_request(&self) -> Self::Instant
fn on_request(&self) -> Self::Instant
Called when a new JSON-RPC request comes to the server.
source§fn on_call(&self, name: &str, params: Params<'_>, kind: MethodKind)
fn on_call(&self, name: &str, params: Params<'_>, kind: MethodKind)
Called on each JSON-RPC method call, batch requests will trigger
on_call
multiple times.source§fn on_result(&self, name: &str, success: bool, started_at: Self::Instant)
fn on_result(&self, name: &str, success: bool, started_at: Self::Instant)
Called on each JSON-RPC method completion, batch requests will trigger
on_result
multiple times.source§fn on_response(&self, _result: &str, started_at: Self::Instant)
fn on_response(&self, _result: &str, started_at: Self::Instant)
Called once the JSON-RPC request is finished and response is sent to the output buffer.
source§fn on_disconnect(&self, _remote_addr: SocketAddr)
fn on_disconnect(&self, _remote_addr: SocketAddr)
Called when a client disconnects