pub struct ServiceHandler { /* private fields */ }Expand description
Handle for managing a running service: grpc or http.
This handle provides control over a running service, allowing you to:
- Wait for the service to start accepting connections
- Signal graceful shutdown
- Wait for the service to fully stop
- Check if the service task has completed
The handle uses a cancellation token for graceful shutdown and provides async methods for coordinating server lifecycle events.
Implementations§
Source§impl ServiceHandler
impl ServiceHandler
Sourcepub async fn wait_for_start(&mut self) -> Result<()>
pub async fn wait_for_start(&mut self) -> Result<()>
Waits for the server to start accepting connections.
This method blocks until the server has successfully bound to its configured address and is ready to accept gRPC requests.
§Panics
Panics if called more than once, as the start signal is consumed.
Sourcepub async fn wait_for_stop(self) -> Result<()>
pub async fn wait_for_stop(self) -> Result<()>
Waits for the server to completely stop.
This method consumes the handle and blocks until the server task
has finished executing. Use this after calling shutdown() to
ensure clean termination.
§Panics
Panics if the server task panicked during execution.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Signals the server to begin graceful shutdown.
This method triggers the shutdown process but does not wait for
completion. Use wait_for_stop() to wait for the server to fully stop.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Checks if the server task has completed.
Returns true if the server has finished running, either due to
shutdown or an error condition.
Auto Trait Implementations§
impl Freeze for ServiceHandler
impl !RefUnwindSafe for ServiceHandler
impl Send for ServiceHandler
impl Sync for ServiceHandler
impl Unpin for ServiceHandler
impl !UnwindSafe for ServiceHandler
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
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>
T in a tonic::Request