pub struct ProcessWorkDriver { /* private fields */ }Expand description
Registry and run handle for process work owned outside
LashCore.
The registry non-terminal rows are the durable work queue. Hosts drive that
queue explicitly by calling claim_and_run_pending
on each relevant event. Cross-process idempotency belongs to the registry
claim; there is no core-owned polling loop.
Implementations§
Source§impl ProcessWorkDriver
impl ProcessWorkDriver
pub fn new( registry: Arc<dyn ProcessRegistry>, run_handle: Arc<dyn ProcessRunHandle>, ) -> Self
Sourcepub fn new_with_sink(
registry: Arc<dyn ProcessRegistry>,
run_handle: Arc<dyn ProcessRunHandle>,
sink: Option<Arc<dyn ProcessEventSink>>,
) -> Self
pub fn new_with_sink( registry: Arc<dyn ProcessRegistry>, run_handle: Arc<dyn ProcessRunHandle>, sink: Option<Arc<dyn ProcessEventSink>>, ) -> Self
Like new, but installs a host-facing
ProcessEventSink on the registry decorator this driver wraps.
The sink receives every appended event, best-effort, after its durable
write — see ProcessEventSink for the freshness-not-truth contract.
pub fn from_watched( registry: Arc<dyn ProcessRegistry>, hub: ProcessChangeHub, run_handle: Arc<dyn ProcessRunHandle>, ) -> Self
pub fn with_attach(self, attach: Arc<dyn ProcessAttach>) -> Self
pub fn inline( registry: Arc<dyn ProcessRegistry>, worker: DurableProcessWorker, ) -> Self
pub fn process_registry(&self) -> Arc<dyn ProcessRegistry> ⓘ
pub fn change_hub(&self) -> ProcessChangeHub
pub fn awaiter(&self) -> ProcessAwaiter
Sourcepub async fn await_terminal(
&self,
process_id: &str,
) -> Result<ProcessAwaitOutput, PluginError>
pub async fn await_terminal( &self, process_id: &str, ) -> Result<ProcessAwaitOutput, PluginError>
Wait for process_id to reach a terminal state and return its outcome.
This is the one way to wait on a started work item (ADR 0016): never a
raw registry poll loop. The mechanism matches the deployment — an
engine-native durable promise when a ProcessAttach is installed
(Restate ingress attach), otherwise the in-process change hub plus
bounded backoff point reads. An already-terminal process returns
immediately.
Callers must bound the wait themselves: a process that never terminates
would otherwise pin the caller forever. Wrap it in
tokio::time::timeout.
use std::time::Duration;
use lash_core::{PluginError, ProcessWorkDriver};
async fn wait(driver: &ProcessWorkDriver, process_id: &str) -> Result<(), PluginError> {
match tokio::time::timeout(Duration::from_secs(30), driver.await_terminal(process_id)).await {
Ok(Ok(output)) => {
// Terminal outcome (success / failure / cancelled). To reconcile
// the full event history, read `events_after(process_id, 0)`.
let _ = output;
Ok(())
}
Ok(Err(err)) => Err(err), // e.g. unknown process, or an attach error
Err(_elapsed) => Ok(()), // bound exceeded; retry or surface to the caller
}
}Sourcepub async fn await_event(
&self,
process_id: &str,
event_type: &str,
after_sequence: u64,
) -> Result<ProcessEvent, PluginError>
pub async fn await_event( &self, process_id: &str, event_type: &str, after_sequence: u64, ) -> Result<ProcessEvent, PluginError>
Wait for the first event of event_type on process_id with a sequence
greater than after_sequence, returning it once it appears.
Like await_terminal this rides the awaiter’s
hub-plus-backoff point reads rather than a store poll loop, and callers
bound the wait with tokio::time::timeout. Historical events already
past after_sequence resolve immediately. This waits on a non-terminal
milestone; for completion use await_terminal.
pub async fn claim_and_run_pending( &self, reason: &str, ) -> Result<(), PluginError>
Trait Implementations§
Source§impl Clone for ProcessWorkDriver
impl Clone for ProcessWorkDriver
Source§fn clone(&self) -> ProcessWorkDriver
fn clone(&self) -> ProcessWorkDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more