pub struct SidecarHandle {
pub port: u16,
pub shutdown_tx: Sender<()>,
pub server_join: JoinHandle<()>,
pub token_stats: Arc<TokenStats>,
}Expand description
Handle returned by spawn_sidecar. Dropping this or sending on shutdown_tx
gracefully stops the background axum server and cleans up port/PID files.
Prefer shutdown_and_join().await over a bare shutdown_tx.send(()): the
helper awaits the server task’s completion so the listener is fully dropped
before the caller proceeds. This matters in tests where rapid teardown +
rebind cycles must not race a still-open listener.
Fields§
§port: u16The ephemeral port the sidecar bound to.
shutdown_tx: Sender<()>Send () on this channel to initiate graceful shutdown.
server_join: JoinHandle<()>Join handle for the spawned axum-serve task. Awaiting this after sending
on shutdown_tx guarantees the listener has been dropped.
token_stats: Arc<TokenStats>Shared token stats for the sidecar session.
Pass this Arc to SymForgeServer::new() so the health tool can report savings.
Implementations§
Source§impl SidecarHandle
impl SidecarHandle
Sourcepub async fn shutdown_and_join(self)
pub async fn shutdown_and_join(self)
Signal graceful shutdown and await server-task completion.
Consumes the handle; the listener and port/PID files are fully released
by the time this returns. Tests should prefer this over a bare
shutdown_tx.send(()) followed by an arbitrary sleep.
Auto Trait Implementations§
impl Freeze for SidecarHandle
impl !RefUnwindSafe for SidecarHandle
impl Send for SidecarHandle
impl Sync for SidecarHandle
impl Unpin for SidecarHandle
impl UnsafeUnpin for SidecarHandle
impl !UnwindSafe for SidecarHandle
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more