Expand description
The RpcServer — an axum JSON-RPC server bound to one transport surface.
A server serves ONE Surface on one socket:
RpcServerMode::Loopback— plain HTTP on loopback, ALL tiers reachable (the local admin / control surface; MUST bind a loopback address).RpcServerMode::PublicRead— HTTPS,Tier::PublicReadonly (browser / anonymous read tier).RpcServerMode::Peer— mTLS, the peer allowlist only (other DIG nodes).
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 viaRpcHandler::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; }).awaitStructs§
- RpcServer
- The JSON-RPC server.
Enums§
- RpcServer
Mode - How a server is deployed — surface + bind address + (for TLS surfaces) certs.