Skip to main content

DrainArgs

Struct DrainArgs 

Source
pub struct DrainArgs {
    pub admin_url: Option<String>,
    pub config: Option<PathBuf>,
    pub json: bool,
    pub timeout_ms: u64,
    pub wait: bool,
    pub wait_timeout_secs: NonZeroU64,
    pub wait_poll_ms: NonZeroU64,
}
Expand description

decdn node drain — trigger graceful shutdown of the running node via admin_v1_drain (issue #244, adr/appendix-local-admin-http.md). Fires the same runtime shutdown path as SIGTERM without needing the process PID.

Without --wait, the command is fire-and-forget: it returns drain_initiated=true as soon as the trigger lands and the admin server begins its early-stop sequence (metrics, then admin, both before router.shutdown). The connection will close before the node fully exits — observe completion via process exit (systemd/K8s) or decdn node health until ECONNREFUSED.

Pass --wait (issue #604) to opt the runtime into keeping the admin server alive through router.shutdown and have the CLI poll admin_v1_health.in_flight_streams until it reaches 0 (or the wait budget expires). On a clean drain the command returns success once the count is zero; on overrun it prints drain_timeout=true in_flight_streams=N to stderr and exits non-zero so operator scripts can fail closed during a stuck rolling upgrade.

Fields§

§admin_url: Option<String>

Base URL of the node’s admin HTTP surface. See health --admin-url for resolution precedence (flag → env → config → default).

§config: Option<PathBuf>

Path to the TOML config file used to derive the admin URL when --admin-url / DECDN_ADMIN_URL are unset.

§json: bool

Emit the admin response as JSON instead of a one-line confirmation.

§timeout_ms: u64

Roundtrip timeout in milliseconds for each individual RPC (the initial drain call and each poll under --wait).

§wait: bool

Block until all in-flight client streams complete (or the wait budget expires) before returning. Opt-in seam for #604: when set, the server keeps admin alive through router.shutdown so the CLI can poll admin_v1_health.in_flight_streams to observe completion. Without it, the original SIGTERM-equivalent ordering applies.

§wait_timeout_secs: NonZeroU64

Wall-clock budget (seconds) for the --wait polling loop. On overrun the CLI exits non-zero and prints drain_timeout=true. Ignored without --wait. Default 30s covers the runtime’s 15s SHUTDOWN_DEADLINE plus typical settle time. NonZeroU64 so clap rejects 0 at parse time — a zero-second budget would deadline-overrun on the first iteration with no signal of why.

§wait_poll_ms: NonZeroU64

Cadence (milliseconds) at which --wait polls admin_v1_health. Lower values converge faster on short drains; higher values reduce admin churn on long ones. Ignored without --wait. NonZeroU64 so clap rejects 0 at parse time — a zero-millisecond poll interval would spin a busy loop against the loopback admin port.

Trait Implementations§

Source§

impl Args for DrainArgs

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl Debug for DrainArgs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for DrainArgs

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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