Skip to main content

Crate polyc_host

Crate polyc_host 

Source
Expand description

Generic dedicated-thread bridge between the tokio control plane and a Commonware-runtime-backed durable store.

Built slice by slice against the invariants every host migration (PersonaHost, EventLogHost) depends on:

  • INV-H1: dropping a HostHandle never deadlocks — the command sender is dropped before the dedicated thread is joined.
  • INV-H2: an eager Body::open failure surfaces as spawn_host’s Err, before any command can be sent — never as a silently-empty host.
  • INV-H3: a lazy Body::open (returns Ok(()) immediately) followed by a command that fails inside Body::handle never crashes the command loop.
  • INV-H4: a command already queued on the channel when shutdown.cancel() fires is still processed by the post-cancellation drain, not lost.
  • INV-H5: Body::on_drain_complete fires strictly after the drain has run every command it queued.
  • INV-H6: a caller-supplied (Sender, Receiver) pair (spawn_host_with_channel) drives the exact same ready handshake/loop/drain/on_drain_complete/Drop machinery as an internally-created one (spawn_host) — the only difference is who constructs the channel. EventLogHost’s 4 shards need this: every shard’s Sender must exist and be handed to every OTHER shard’s Body before any shard’s thread starts (a chicken-and-egg an internally-built channel can’t resolve), so the caller builds all its channels up front and hands each shard its own (Sender, Receiver) pair.

Structs§

Closed
The dedicated host has shut down; a call could not be served.
HostHandle
Handle to a durable host running on its dedicated Commonware-runtime thread.
HostOptions
Configuration for one dedicated host thread.

Enums§

SpawnError
Error starting a dedicated host thread.

Traits§

Body
Per-host behavior plugged into the generic dedicated-thread bridge.

Functions§

call
Send one command carrying a fresh oneshot ack, and await the reply.
spawn_host
Spawn a dedicated Commonware-runtime thread hosting body, rooted at opts.storage_dir, and returns once the thread has reported readiness.
spawn_host_with_channel
Spawn a dedicated Commonware-runtime thread hosting body, using a caller-supplied (Sender, Receiver) pair instead of one spawn_host creates internally (INV-H6).