MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / store_and_run

Method store_and_run

src/task_runner.rs:82–96  ·  view source on GitHub ↗

Stores and executes a task inline, for use by `run` and `shell` commands. Unlike server-scheduled tasks (which are added to the queue as `Queued` and later picked up by the scheduler), `run` and `shell` execute tasks directly. This method persists the task as `Running` before execution so it appears in `tsk list` and can be used as a parent for task chaining. The `Running` status prevents the ser

(
        &self,
        task: &Task,
    )

Source from the content-addressed store, hash-verified

80 /// parent for task chaining. The `Running` status prevents the server scheduler from
81 /// picking it up.
82 pub async fn store_and_run(
83 &self,
84 task: &Task,
85 ) -> Result<TaskExecutionResult, TaskExecutionError> {
86 let mut stored_task = task.clone();
87 stored_task.status = TaskStatus::Running;
88 stored_task.started_at = Some(chrono::Utc::now());
89 if let Err(e) = self.task_storage.add_task(stored_task).await {
90 emit_or_print(
91 &self.event_sender,
92 ServerEvent::WarningMessage(format!("Error storing task: {e}")),
93 );
94 }
95 self.run_with_lifecycle(task).await
96 }
97
98 /// Execute a task from the queue with status updates.
99 ///

Callers 5

test_store_and_runFunction · 0.80
executeMethod · 0.80
executeMethod · 0.80

Calls 3

emit_or_printFunction · 0.85
add_taskMethod · 0.80
run_with_lifecycleMethod · 0.80

Tested by 3

test_store_and_runFunction · 0.64