pub struct RpcServer {
pub server_id: String,
/* private fields */
}Expand description
The RPC server — holds method registrations and dispatches requests.
Fields§
§server_id: StringImplementations§
Source§impl RpcServer
impl RpcServer
Sourcepub fn new(server_id: impl Into<String>) -> Self
pub fn new(server_id: impl Into<String>) -> Self
Create a new RpcServer. For richer configuration, use RpcServer::builder.
Sourcepub fn builder() -> RpcServerBuilder
pub fn builder() -> RpcServerBuilder
Create a new builder.
pub fn protocol_name(&self) -> &str
pub fn describe_enabled(&self) -> bool
pub fn server_version(&self) -> &str
pub fn protocol_version(&self) -> &str
Sourcepub fn protocol_hash(&self) -> &str
pub fn protocol_hash(&self) -> &str
SHA-256 hex digest of the canonical describe payload. Computed lazily on first call and cached.
pub fn external_config(&self) -> Option<&Arc<ExternalLocationConfig>>
Sourcepub fn transport_kind(&self) -> Option<TransportKind>
pub fn transport_kind(&self) -> Option<TransportKind>
Currently-bound TransportKind,
or None before the framework has observed a transport. Set by
notify_transport.
Sourcepub fn transport_capabilities(&self) -> TransportCapabilities
pub fn transport_capabilities(&self) -> TransportCapabilities
Currently-advertised TransportCapabilities.
Empty (all-false) before a transport is bound and for transports
without extra capabilities.
Sourcepub fn notify_transport(&self, kind: TransportKind, caps: TransportCapabilities)
pub fn notify_transport(&self, kind: TransportKind, caps: TransportCapabilities)
Bind the server to a transport, firing on_serve_start once per
(kind, caps) combination. Subsequent calls with the same
combination are cheap no-ops (the common case where transport
glue invokes this on every request). A different combination
updates the bound state and re-fires the hook — matches the
Python _notify_transport contract.
Call this from each transport entry point:
- stdio / pipe
main: once beforeserve - Unix accept loop: once per process
- HTTP request handler: every request (idempotent)
Sourcepub fn register(&mut self, info: MethodInfo)
pub fn register(&mut self, info: MethodInfo)
Register a method described by a MethodInfo.
Sourcepub fn register_unary(
&mut self,
name: impl Into<String>,
result_schema: SchemaRef,
handler: impl Fn(&Request, &CallContext) -> Result<Option<RecordBatch>> + Send + Sync + 'static,
)
pub fn register_unary( &mut self, name: impl Into<String>, result_schema: SchemaRef, handler: impl Fn(&Request, &CallContext) -> Result<Option<RecordBatch>> + Send + Sync + 'static, )
Convenience wrapper for the old positional API — equivalent to
register(MethodInfo::unary(name, empty_schema(), result_schema, handler)).
Prefer MethodInfo::unary + RpcServer::register for new code.
Sourcepub fn register_stream(
&mut self,
name: impl Into<String>,
method_type: MethodType,
handler: impl Fn(&Request, &CallContext) -> Result<StreamResult> + Send + Sync + 'static,
)
pub fn register_stream( &mut self, name: impl Into<String>, method_type: MethodType, handler: impl Fn(&Request, &CallContext) -> Result<StreamResult> + Send + Sync + 'static, )
Convenience wrapper for the old positional API — equivalent to
register(MethodInfo::stream(name, method_type, empty_schema(), handler)).
Prefer MethodInfo::stream + RpcServer::register for new code.
pub fn method(&self, name: &str) -> Option<&MethodInfo>
pub fn methods(&self) -> &HashMap<String, MethodInfo>
pub fn method_names(&self) -> Vec<&str>
Sourcepub fn sorted_method_names(&self) -> Vec<&str>
pub fn sorted_method_names(&self) -> Vec<&str>
Method names sorted alphabetically. Preferred over methods().keys()
when order matters (introspection / describe / HTML rendering).
Sourcepub fn serve<R: Read, W: Write>(&self, r: R, w: W)
pub fn serve<R: Read, W: Write>(&self, r: R, w: W)
Run the serve loop over a single reader/writer pair (pipe or socket).
Reads are blocking with no timeout — a peer that opens the
connection and then stalls pins this thread until it sends data,
EOFs, or resets. stdio/pipe has no timeout API, so that transport
is trusted-peer-only (see also the SHM module docs). On a socket
transport, the caller owns the stream and should set a read
timeout (e.g. UnixStream::set_read_timeout) before handing it
here; a TimedOut/WouldBlock error then cleanly ends the
connection via the error path below.
Sourcepub fn serve_with_shutdown<R, W, F>(&self, r: R, w: W, shutdown: F)
pub fn serve_with_shutdown<R, W, F>(&self, r: R, w: W, shutdown: F)
Like [serve], but checks shutdown between requests and exits
cleanly when it returns true. Useful for daemonized pipe/unix
listeners that want to drain the in-flight request before exiting
on SIGTERM. Blocking reads still must terminate via EOF/peer-close
— this is an advisory signal checked at request boundaries.