pub struct RpcServer { /* private fields */ }Expand description
Builds configured Tonic server routers.
Implementations§
Source§impl RpcServer
impl RpcServer
Sourcepub fn new(config: RpcServerConfig) -> Self
pub fn new(config: RpcServerConfig) -> Self
Examples found in repository?
examples/echo_server.rs (lines 76-80)
74async fn main() -> Result<(), Box<dyn std::error::Error>> {
75 let address: SocketAddr = "[::1]:50051".parse()?;
76 let server = RpcServer::new(
77 RpcServerConfig::new(address)
78 .with_request_timeout(Duration::from_secs(10))
79 .with_concurrency_limit(1_024),
80 );
81 let (mut reporter, health_service) = health_reporter();
82 reporter.set_serving::<EchoServer<EchoService>>().await;
83
84 server
85 .router()
86 .add_service(health_service)
87 .add_service(EchoServer::new(EchoService))
88 .serve(server.config().address())
89 .await?;
90 Ok(())
91}pub fn try_new(config: RpcServerConfig) -> Result<Self, RpcConfigError>
Sourcepub fn config(&self) -> &RpcServerConfig
pub fn config(&self) -> &RpcServerConfig
Examples found in repository?
examples/echo_server.rs (line 88)
74async fn main() -> Result<(), Box<dyn std::error::Error>> {
75 let address: SocketAddr = "[::1]:50051".parse()?;
76 let server = RpcServer::new(
77 RpcServerConfig::new(address)
78 .with_request_timeout(Duration::from_secs(10))
79 .with_concurrency_limit(1_024),
80 );
81 let (mut reporter, health_service) = health_reporter();
82 reporter.set_serving::<EchoServer<EchoService>>().await;
83
84 server
85 .router()
86 .add_service(health_service)
87 .add_service(EchoServer::new(EchoService))
88 .serve(server.config().address())
89 .await?;
90 Ok(())
91}Sourcepub fn router(&self) -> Server
pub fn router(&self) -> Server
Returns a Tonic server builder with the configured timeout and load limits.
Examples found in repository?
examples/echo_server.rs (line 85)
74async fn main() -> Result<(), Box<dyn std::error::Error>> {
75 let address: SocketAddr = "[::1]:50051".parse()?;
76 let server = RpcServer::new(
77 RpcServerConfig::new(address)
78 .with_request_timeout(Duration::from_secs(10))
79 .with_concurrency_limit(1_024),
80 );
81 let (mut reporter, health_service) = health_reporter();
82 reporter.set_serving::<EchoServer<EchoService>>().await;
83
84 server
85 .router()
86 .add_service(health_service)
87 .add_service(EchoServer::new(EchoService))
88 .serve(server.config().address())
89 .await?;
90 Ok(())
91}Sourcepub async fn serve_with_shutdown<F>(
&self,
router: Router,
signal: F,
) -> Result<(), RpcServerError>
pub async fn serve_with_shutdown<F>( &self, router: Router, signal: F, ) -> Result<(), RpcServerError>
Serves an assembled Tonic router and bounds draining after the shutdown signal fires.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RpcServer
impl RefUnwindSafe for RpcServer
impl Send for RpcServer
impl Sync for RpcServer
impl Unpin for RpcServer
impl UnsafeUnpin for RpcServer
impl UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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::RequestSource§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