Skip to main content

Module admin

Module admin 

Source
Expand description

Loopback-only admin JSON-RPC server (appendix-local-admin-http.md).

Wire types (the AdminRpc trait, DTOs, error codes, parse_hash_arg) live in decdn_common::admin so the user-facing decdn CLI can speak the generated client without dragging in the daemon’s runtime dependencies. This module keeps the server-side implementation: AdminState, the AdminRpcImpl that backs the trait against the live cache and runtime handles, and the bind/serve helpers the runtime calls during start-up and graceful shutdown.

Re-exports§

pub use crate::handlers::client::LaneActivityClock;

Structs§

AdminRpcImpl
Concrete server implementation backed by the live AdminState.
AdminState
Shared state for admin RPC handlers.
BuyerPoolHandle
The buyer pool store handle admin_v1_pools reads, wrapped so AdminState keeps its Debug derive. An Arc clone of the store the buy loop already writes through, so attaching it adds read access, not new ownership.
DhtStatusHandles
Read-only DHT subsystem handles the admin_v1_status handler snapshots (issue #741). Each shared-state field is an Arc clone of state the runtime already owns and shares with the DHT handler / refresh / republish tasks (plus the Copy refresh_interval), so attaching this to AdminState adds no new ownership — only read access. Bundled into one struct so the AdminState constructor stays a single optional argument rather than five positional ones.
DrainTrigger
One-shot trigger that lets admin_v1_drain wake the runtime’s main select loop and request graceful shutdown (issue #244). Modelled on tokio::sync::Notify so the RPC handler can fire-and-return without blocking on the runtime’s shutdown latency. The runtime awaits wait in its select loop; firing twice is a no-op (the second notify_one coalesces, same as Notify).
LaneStatusHandles
Read-only lane handles the admin_v1_lanes handler snapshots (issue #749). Each is an Arc clone of state the runtime already owns and shares with the cdn/client/v1 handler and the settlement service, so attaching this to AdminState adds read access, not new ownership. Bundled into one struct so the with_lanes builder stays a single argument.
ReloadHook
Pair of values needed by admin_v1_reload: the runtime’s reload state (the same Arc the SIGHUP arm holds in runtime::run’s select loop) and the path to the config file the operator started with. Bundled so AdminState can carry “both or neither” as a single Option, matching the runtime’s “no path → no reload” invariant.
SlashStatusHandles
Read-only slash-detection handle the admin_v1_slashes handler snapshots (#1032). The shared in-memory store is populated by the slash watcher; the admin surface only reads it. Bundled into a struct so the with_slash_detection builder stays a single argument (and to leave room for future fields without churning the signature).

Functions§

bind
Bind the admin listener. Kept synchronous-at-startup so port conflicts fail fast rather than deep inside the runtime task graph.
serve
Serve admin RPC methods on listener until shutdown fires.