pub struct Builder<RpcMiddleware> { /* private fields */ }Expand description
Builder to configure and create a JSON-RPC server
Implementations§
Source§impl<RpcMiddleware> Builder<RpcMiddleware>
impl<RpcMiddleware> Builder<RpcMiddleware>
Sourcepub const fn max_request_body_size(self, size: u32) -> Self
pub const fn max_request_body_size(self, size: u32) -> Self
Set the maximum size of a request body in bytes. Default is 10 MiB.
Sourcepub const fn max_response_body_size(self, size: u32) -> Self
pub const fn max_response_body_size(self, size: u32) -> Self
Set the maximum size of a response body in bytes. Default is 10 MiB.
Sourcepub const fn max_connections(self, max: u32) -> Self
pub const fn max_connections(self, max: u32) -> Self
Set the maximum number of connections allowed. Default is 100.
Sourcepub const fn max_subscriptions_per_connection(self, max: u32) -> Self
pub const fn max_subscriptions_per_connection(self, max: u32) -> Self
Set the maximum number of subscriptions per connection. Default is 1024.
Sourcepub fn custom_tokio_runtime(self, rt: Handle) -> Self
pub fn custom_tokio_runtime(self, rt: Handle) -> Self
Configure a custom [tokio::runtime::Handle] to run the server on.
Default: [tokio::spawn]
Sourcepub fn set_ipc_socket_permissions(self, permissions: Option<String>) -> Self
pub fn set_ipc_socket_permissions(self, permissions: Option<String>) -> Self
Sets the permissions for the IPC socket file.
On Unix, accepts an octal mode up to 0o7777 with an optional 0o prefix. Invalid modes or
failures to apply them cause IpcServer::start to return an error. This includes
platforms that do not support setting socket permissions before binding. None uses the
system’s umask. Ignored on non-Unix platforms.
Sourcepub fn set_id_provider<I: IdProvider + 'static>(self, id_provider: I) -> Self
pub fn set_id_provider<I: IdProvider + 'static>(self, id_provider: I) -> Self
Configure custom subscription ID provider for the server to use
to when getting new subscription calls.
You may choose static dispatch or dynamic dispatch because
IdProvider is implemented for Box<T>.
Default: [RandomIntegerIdProvider].
§Examples
use jsonrpsee::server::RandomStringIdProvider;
use reth_ipc::server::Builder;
// static dispatch
let builder1 = Builder::default().set_id_provider(RandomStringIdProvider::new(16));
// or dynamic dispatch
let builder2 = Builder::default().set_id_provider(Box::new(RandomStringIdProvider::new(16)));Sourcepub fn set_rpc_middleware<T>(
self,
rpc_middleware: RpcServiceBuilder<T>,
) -> Builder<T>
pub fn set_rpc_middleware<T>( self, rpc_middleware: RpcServiceBuilder<T>, ) -> Builder<T>
Enable middleware that is invoked on every JSON-RPC call.
The middleware itself is very similar to the tower middleware but
it has a different service trait which takes &self instead &mut self
which means that you can’t use built-in middleware from tower.
Another consequence of &self is that you must wrap any of the middleware state in
a type which is Send and provides interior mutability such Arc<Mutex>.
The builder itself exposes a similar API as the [tower::ServiceBuilder]
where it is possible to compose layers to the middleware.
Trait Implementations§
Auto Trait Implementations§
impl<RpcMiddleware> !RefUnwindSafe for Builder<RpcMiddleware>
impl<RpcMiddleware> !UnwindSafe for Builder<RpcMiddleware>
impl<RpcMiddleware> Freeze for Builder<RpcMiddleware>where
RpcServiceBuilder<RpcMiddleware>: Freeze,
impl<RpcMiddleware> Send for Builder<RpcMiddleware>where
RpcServiceBuilder<RpcMiddleware>: Send,
impl<RpcMiddleware> Sync for Builder<RpcMiddleware>where
RpcServiceBuilder<RpcMiddleware>: Sync,
impl<RpcMiddleware> Unpin for Builder<RpcMiddleware>where
RpcServiceBuilder<RpcMiddleware>: Unpin,
impl<RpcMiddleware> UnsafeUnpin for Builder<RpcMiddleware>where
RpcServiceBuilder<RpcMiddleware>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.