pub struct Runtime { /* private fields */ }Expand description
A composed kindling integration: a client (and durable-emit spooled client) over a daemon the runtime either started in-process or attached to.
Owns the embedded server task handle (when SpawnStrategy::Embedded), so
shutdown can stop it.
Dropping a Runtime without calling shutdown does
not stop an embedded daemon: the serve task was spawned onto the tokio
runtime and keeps running until the runtime itself shuts down (or the daemon
idles out). Call shutdown for deterministic teardown.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub async fn start(config: RuntimeConfig) -> Result<Self, RuntimeError>
pub async fn start(config: RuntimeConfig) -> Result<Self, RuntimeError>
Start the runtime: build a client for the configured socket and wire the
SpawnStrategy. Probes the daemon with a health call (which triggers
attach-or-spawn) so a started runtime is immediately usable.
Sourcepub fn client(&self) -> &Client
pub fn client(&self) -> &Client
Borrow the underlying daemon client for reads and non-spooled ops (health, retrieve, capsules, pins, …).
Sourcepub fn spooled_client(&self) -> &SpooledClient
pub fn spooled_client(&self) -> &SpooledClient
Borrow the durable-emit spooled client. Append through this for outage-resilient writes.
Sourcepub fn strategy(&self) -> &SpawnStrategy
pub fn strategy(&self) -> &SpawnStrategy
The SpawnStrategy this runtime was started with.
Sourcepub fn spawned_embedded_daemon(&self) -> bool
pub fn spawned_embedded_daemon(&self) -> bool
Whether this runtime started an embedded daemon (true) or attached to a
pre-existing one (false). Only meaningful for
SpawnStrategy::Embedded.
Sourcepub async fn shutdown(self) -> Result<(), RuntimeError>
pub async fn shutdown(self) -> Result<(), RuntimeError>
Stop the runtime, aborting the embedded daemon task if this runtime started one. Attached daemons (started elsewhere) are left running.