pub struct RpcServer { /* private fields */ }Available on crate feature
server only.Expand description
Convenient type alias for ZusServerManager
This is the main RPC server type for hosting services.
§Example
use zus_rs::{RpcServer, prelude::*};
use bytes::Bytes;
use std::sync::Arc;
struct MyService;
#[async_trait]
impl Service for MyService {
fn service_name(&self) -> &str { "MyService" }
async fn do_work(
&self,
method: &str,
params: Bytes,
_ctx: zus_rpc_server::RequestContext,
) -> zus_common::Result<Bytes> {
Ok(params)
}
}
let mut server = RpcServer::new("0.0.0.0".to_string(), 9527);
server.register_service(Arc::new(MyService));
server.start().await?;ZUS Server Manager (replacing Java’s ZusServerManager)
Implementations§
Source§impl ZusServerManager
impl ZusServerManager
pub fn new(address: String, port: u16) -> ZusServerManager
pub fn with_max_connections(self, max: usize) -> ZusServerManager
pub fn register_service(&mut self, service: Arc<dyn Service>)
pub fn with_zoo_client(self, zoo_client: Arc<ZusZooClient>) -> ZusServerManager
Sourcepub fn get_statistics(&self, service_name: &str) -> Option<ServiceStatistics>
pub fn get_statistics(&self, service_name: &str) -> Option<ServiceStatistics>
Get statistics for a specific service
Sourcepub fn get_all_statistics(&self) -> HashMap<String, ServiceStatistics>
pub fn get_all_statistics(&self) -> HashMap<String, ServiceStatistics>
Get statistics for all registered services
Sourcepub fn reset_statistics(&self, service_name: &str)
pub fn reset_statistics(&self, service_name: &str)
Reset statistics for a specific service
Sourcepub fn reset_all_statistics(&self)
pub fn reset_all_statistics(&self)
Reset statistics for all services
Auto Trait Implementations§
impl Freeze for ZusServerManager
impl !RefUnwindSafe for ZusServerManager
impl Send for ZusServerManager
impl Sync for ZusServerManager
impl Unpin for ZusServerManager
impl !UnwindSafe for ZusServerManager
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request