Skip to main content

Module completion_task

Module completion_task 

Source
Expand description

PH7.6 — the per-plugin actor bridge for completion sources.

The completion analogue of picker_task.rs: a dedicated async task owns the plugin’s Store<PluginState> for life (the Store is !Sync), a CompletionCall crosses an mpsc channel with a oneshot reply, and the Send + Sync CompletionClient serializes calls onto the single-consumer loop. PluginHost::spawn_completion_source instantiates the completion-source-plugin world under the plugin’s grant and returns (CompletionClient, CompletionActor); the caller drives CompletionActor::run on its multi-thread runtime (the lib owns no runtime).

The picker and completion actors are near-identical; a third guest-backed Arc<dyn> adapter (grammar, PH7.7) is the rule-of-three trigger to generalise the loop over the bindings type. Until then this duplicates the ~50-line shape and reuses the shared arm_store / new_store / build_plugin_wasi primitives.

Re-exports§

pub use crate::lattice::plugin_host::types::CompletionSourceSpec;
pub use crate::lattice::plugin_host::types::GenerateContext;
pub use crate::lattice::plugin_host::types::RawCandidate;

Structs§

CompletionActor
The per-plugin actor: owns the Store + completion bindings for the plugin’s life and serves calls off the channel until every CompletionClient drops.
CompletionClient
The Send + Sync handle the WasmCompletionSource adapter holds. Cloning is cheap (an mpsc Sender clone); every clone talks to the same actor / Store, so calls serialize on the single-consumer loop.