Skip to main content

EggressHandle

Struct EggressHandle 

Source
pub struct EggressHandle { /* private fields */ }
Expand description

Handle to a running eggress service.

Provides access to bound addresses, status, metrics, reload, and shutdown. Dropping the handle cancels the shutdown token, initiating graceful shutdown.

§Thread ownership

The handle owns exactly one of two mutually exclusive thread models:

Async path (start()):

  • A Tokio blocking-pool thread runs the startup sequence and then blocks on run_result.join() for the lifetime of the service.
  • A dedicated OS thread ("eggress-embed-rt") owns ServiceSupervisor::run().
  • _runtime_task wraps the blocking task’s JoinHandle as a Tokio task.

Blocking path (start_blocking()):

  • An outer OS thread ("eggress-embed-rt") handles startup, sends results through a channel, and terminates.
  • An inner OS thread ("eggress-embed-run") owns ServiceSupervisor::run().
  • _run_handle holds the inner thread’s JoinHandle directly.

§Drop behavior

Dropping the handle cancels the shutdown token and performs a best-effort join: the blocking path joins the run thread directly; the async path creates a throwaway Tokio runtime and awaits the task with a 5-second timeout. Explicit shutdown() or shutdown_blocking() is preferred to guarantee orderly teardown.

Implementations§

Source§

impl EggressHandle

Source

pub fn bound_addresses(&self) -> BoundAddresses

Get the addresses the service is listening on.

Source

pub fn status(&self) -> ServiceStatus

Get the current service status.

Source

pub fn metrics_text(&self) -> Result<String, EggressError>

Render Prometheus metrics text.

Source

pub fn reload_toml_str( &self, input: &str, ) -> Result<ReloadOutcome, EggressError>

Reload configuration from a TOML string.

Returns the outcome of the reload attempt. On success, the generation is incremented. On rejection, the old configuration remains active.

Source

pub fn reload_toml_file( &self, path: impl AsRef<Path>, ) -> Result<ReloadOutcome, EggressError>

Reload configuration from a file.

Source

pub async fn shutdown(self) -> Result<(), EggressError>

Initiate graceful shutdown.

Source

pub fn shutdown_blocking(self) -> Result<(), EggressError>

Initiate graceful shutdown (blocking).

Trait Implementations§

Source§

impl Drop for EggressHandle

Source§

fn drop(&mut self)

Cancel the shutdown token and best-effort join the supervisor.

This is a fallback for callers who do not call shutdown() explicitly. The async path creates a throwaway Tokio runtime to await the task with a 5-second timeout; if the timeout expires, the task is abandoned. Prefer explicit shutdown() or shutdown_blocking() for guaranteed orderly teardown.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more