pub struct RpcServer {
pub listener: TcpListener,
pub auth: Arc<Auth>,
pub handler: Arc<Handler>,
pub max_connections: usize,
pub idle_timeout: Duration,
}Expand description
Synchronous HTTP/1.1 JSON-RPC server.
Fields§
§listener: TcpListenerBound TCP listener.
auth: Arc<Auth>Shared authentication policy.
handler: Arc<Handler>Shared JSON-RPC handler.
max_connections: usizeMaximum concurrent worker connections.
idle_timeout: DurationIdle read timeout for each connection.
Implementations§
Source§impl RpcServer
impl RpcServer
Sourcepub fn bind<A: ToSocketAddrs>(
address: A,
auth: Arc<Auth>,
handler: Arc<Handler>,
max_connections: usize,
idle_timeout: Duration,
) -> Result<Self>
pub fn bind<A: ToSocketAddrs>( address: A, auth: Arc<Auth>, handler: Arc<Handler>, max_connections: usize, idle_timeout: Duration, ) -> Result<Self>
Binds a new RPC server.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local socket address.
Sourcepub fn serve(self) -> Result<()>
pub fn serve(self) -> Result<()>
Runs the accept loop. Each accepted connection is handled by one bounded worker thread.
Sourcepub fn serve_with_shutdown(self, shutdown: Arc<AtomicBool>) -> Result<()>
pub fn serve_with_shutdown(self, shutdown: Arc<AtomicBool>) -> Result<()>
Runs the accept loop until shutdown is set to true.
Polls non-blocking accept on a fixed cadence so the loop can observe
shutdown without parking on an open socket. Each accepted connection
is restored to blocking mode and handed to a bounded worker thread,
preserving the configured idle_timeout per connection.
Auto Trait Implementations§
impl !RefUnwindSafe for RpcServer
impl !UnwindSafe for RpcServer
impl Freeze for RpcServer
impl Send for RpcServer
impl Sync for RpcServer
impl Unpin for RpcServer
impl UnsafeUnpin for RpcServer
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more