pub struct InstanceRuntime { /* private fields */ }Expand description
Unique owner of every task. Cancelling shutdown or dropping this value aborts the supervisor, whose owned managers and JoinSets abort their tasks.
Implementations§
Source§impl InstanceRuntime
impl InstanceRuntime
Sourcepub fn handle(&self) -> RuntimeHandle
pub fn handle(&self) -> RuntimeHandle
Another clone of the runtime’s request and diagnostic handle.
Sourcepub fn spawn(
source: Arc<dyn SnapshotSource>,
allocator: Arc<dyn LeaseAllocator>,
sink: Arc<dyn UsageSink>,
clock: Arc<dyn Clock>,
config: InstanceRuntimeConfig,
) -> Result<(Self, RuntimeHandle), InstanceRuntimeConfigError>
pub fn spawn( source: Arc<dyn SnapshotSource>, allocator: Arc<dyn LeaseAllocator>, sink: Arc<dyn UsageSink>, clock: Arc<dyn Clock>, config: InstanceRuntimeConfig, ) -> Result<(Self, RuntimeHandle), InstanceRuntimeConfigError>
Validate config, then start the snapshot manager, the usage writer
and the supervisor that runs one lease manager per eligible account.
Returns the unique owner, which must be retained and shut down, and a
first RuntimeHandle.
source, allocator and sink may be the same backend. clock
supplies control-plane timestamps. Must be called within a Tokio
runtime. Nothing starts when validation fails.
§Errors
InstanceRuntimeConfigError for any configuration rule
InstanceRuntimeConfig::validate or a component’s spawn refuses.
Sourcepub async fn shutdown(self) -> Result<RuntimeShutdownReport, JoinError>
pub async fn shutdown(self) -> Result<RuntimeShutdownReport, JoinError>
Request shutdown (starting the total deadline if no one has yet) and
wait for the supervisor to finish it: stop discovery, pause refills,
drain the usage writer, stop the snapshot manager, then release every
account’s leases, all within
InstanceRuntimeConfig::shutdown_deadline. Stop the application’s
listeners and quiesce its request tasks alongside, bounded by the same
deadline. Cancelling this future aborts the supervisor.
§Errors
The supervisor task’s JoinError if it
panicked or was cancelled; its report is then unavailable.