Skip to main content

TaskHost

Trait TaskHost 

Source
pub trait TaskHost: Send + Sync {
    // Required methods
    fn caller_task_id(&self, lane: &str) -> Option<String>;
    fn task_lane(&self, task_id: &str) -> Option<String>;
    fn strategy(&self, definition: &str) -> Result<String, String>;
    fn tasks(&self) -> Result<Vec<Value>, String>;
    fn spawn(
        &self,
        request: &Value,
        parent: Option<&str>,
    ) -> Result<Value, String>;
    fn result(&self, task_id: &str) -> Result<Value, String>;
    fn cancel(&self, task_id: &str, reason: &str) -> Result<Value, String>;
    fn steer(&self, task_id: &str, message: &str) -> Result<bool, String>;
    fn now(&self) -> i64;

    // Provided methods
    fn usage(&self) -> Result<Option<Value>, String> { ... }
    fn pin_lane(&self, _lane: &str, _holder: &str) -> bool { ... }
    fn unpin_lane(&self, _lane: &str, _holder: &str) { ... }
}

Required Methods§

Source

fn caller_task_id(&self, lane: &str) -> Option<String>

Task that owns lane, or None for the root lane.

Source

fn task_lane(&self, task_id: &str) -> Option<String>

Lane a live task ran on, if any.

Source

fn strategy(&self, definition: &str) -> Result<String, String>

Execution strategy of a registered definition (“deterministic” | “predict” | “rlm”).

Source

fn tasks(&self) -> Result<Vec<Value>, String>

Every task of the session (NativeTask objects: id, parentId, definition, state, …).

Source

fn spawn(&self, request: &Value, parent: Option<&str>) -> Result<Value, String>

Admits request ({definition, input, model?, key?, timeoutMs?, lane?}) as a child of parent.

Source

fn result(&self, task_id: &str) -> Result<Value, String>

Blocks until the task’s durable terminal result (NativeResult).

Source

fn cancel(&self, task_id: &str, reason: &str) -> Result<Value, String>

Source

fn steer(&self, task_id: &str, message: &str) -> Result<bool, String>

Queues a steering message into a running task’s lane; false when it has no live lane.

Source

fn now(&self) -> i64

Provided Methods§

Source

fn usage(&self) -> Result<Option<Value>, String>

Usage status of the caller’s root.

Source

fn pin_lane(&self, _lane: &str, _holder: &str) -> bool

Keeps a lane’s Python kernel alive for holder; false when the host has no pool or no pin capacity left.

Source

fn unpin_lane(&self, _lane: &str, _holder: &str)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§