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

Method run_with_lifecycle

src/task_runner.rs:121–162  ·  view source on GitHub ↗

Execute a task in a Docker container and update storage with the result. Callers are responsible for getting the task into storage and setting the initial Running state before calling this method. This method handles: - Agent validation and warmup - Docker image management and container execution - Repository changes and git operations - Task completion notifications - Updating task storage to Co

(
        &self,
        task: &Task,
    )

Source from the content-addressed store, hash-verified

119 /// - Task completion notifications
120 /// - Updating task storage to Complete or Failed
121 async fn run_with_lifecycle(
122 &self,
123 task: &Task,
124 ) -> Result<TaskExecutionResult, TaskExecutionError> {
125 let result = self.run_in_container(task).await;
126 match &result {
127 Ok(exec_result) => {
128 self.ctx.notification_client().notify_task_complete(
129 &task.name,
130 true,
131 Some(&exec_result.message),
132 );
133 if let Err(e) = self
134 .task_storage
135 .mark_complete(&task.id, &exec_result.branch_name)
136 .await
137 {
138 emit_or_print(
139 &self.event_sender,
140 ServerEvent::WarningMessage(format!("Error updating task status: {e}")),
141 );
142 }
143 }
144 Err(e) => {
145 self.ctx.notification_client().notify_task_complete(
146 &task.name,
147 false,
148 Some(&e.message),
149 );
150 if let Err(storage_err) = self.task_storage.mark_failed(&task.id, &e.message).await
151 {
152 emit_or_print(
153 &self.event_sender,
154 ServerEvent::WarningMessage(format!(
155 "Error updating task status: {storage_err}"
156 )),
157 );
158 }
159 }
160 }
161 result
162 }
163
164 /// Run a task in a Docker container.
165 ///

Callers 2

store_and_runMethod · 0.80
run_queuedMethod · 0.80

Calls 6

emit_or_printFunction · 0.85
run_in_containerMethod · 0.80
notify_task_completeMethod · 0.80
notification_clientMethod · 0.80
mark_completeMethod · 0.80
mark_failedMethod · 0.80

Tested by

no test coverage detected