Skip to main content

Module server

Module server 

Source
Expand description

The RpcServer — an axum JSON-RPC server bound to one transport surface.

A server serves ONE Surface on one socket:

A DIG node typically runs a loopback control server plus a peer mTLS server (and, at the gateway, a public HTTPS read server) — each an independent RpcServer over the same RpcHandler.

§Routes

  • POST / — JSON-RPC dispatch (single request).
  • GET /healthz — liveness via RpcHandler::healthz.

§Graceful shutdown

serve takes any Future (a CancellationToken wait, a tokio::signal::ctrl_c(), a oneshot receiver); the server drains in-flight requests and returns when it resolves.

§Example

use std::sync::Arc;
use dig_rpc::{RpcServer, RpcServerMode, RpcHandler};
let node = Arc::new(Node);
let server = RpcServer::new(node, RpcServerMode::loopback("127.0.0.1:9778".parse().unwrap()));
server.serve(async move { let _ = stop.await; }).await

Structs§

RpcServer
The JSON-RPC server.

Enums§

RpcServerMode
How a server is deployed — surface + bind address + (for TLS surfaces) certs.