Skip to main content

WorkflowDriver

Trait WorkflowDriver 

Source
pub trait WorkflowDriver: Send + Sync {
    // Required methods
    fn spawn_task<'life0, 'async_trait>(
        &'life0 self,
        request: TaskRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SpawnedTask, DriverError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_all(&self);
    fn budget(&self) -> BudgetSnapshot;
    fn progress(&self, event: ProgressEvent);
}
Expand description

Host-side executor for a Workflow run.

Implementations must be cheap to call from the VM thread: spawn_task admits the task and returns immediately (fire-and-forget spawn — never await the child inline), while budget, progress, and cancel_all are synchronous. cancel_all must be idempotent; it is invoked when the script errors, when the run future is dropped, and once more never hurts.

Required Methods§

Source

fn spawn_task<'life0, 'async_trait>( &'life0 self, request: TaskRequest, ) -> Pin<Box<dyn Future<Output = Result<SpawnedTask, DriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Admit and start one task. Errors surface as a JS throw on the corresponding task() call.

Source

fn cancel_all(&self)

Cancel every in-flight task belonging to this run. Idempotent.

Source

fn budget(&self) -> BudgetSnapshot

Current snapshot of the run’s shared token pool.

Source

fn progress(&self, event: ProgressEvent)

Receive a script progress event (ordered, synchronous).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§