pub struct BackgroundTaskManager { /* private fields */ }Expand description
Manager for background tasks with disk persistence
Implementations§
Source§impl BackgroundTaskManager
impl BackgroundTaskManager
Sourcepub async fn new(tasks_dir: &Path) -> Result<Self>
pub async fn new(tasks_dir: &Path) -> Result<Self>
Create a new background task manager.
The tasks_dir is where task JSON files are persisted.
If the directory doesn’t exist, it will be created.
On creation, it loads any existing tasks from disk.
Sourcepub async fn from_config(config: &RuntimeConfig) -> Result<Self>
pub async fn from_config(config: &RuntimeConfig) -> Result<Self>
Create from runtime config — uses workdir/tasks/ as the tasks directory
Sourcepub async fn submit(
&self,
prompt: String,
system_prompt: String,
) -> Result<String>
pub async fn submit( &self, prompt: String, system_prompt: String, ) -> Result<String>
Submit a new background task and return its ID. The task is persisted immediately and will be executed in the background.
Sourcepub async fn execute(
&self,
task_id: &str,
llm: Arc<dyn LLMProviderTrait>,
) -> Result<String>
pub async fn execute( &self, task_id: &str, llm: Arc<dyn LLMProviderTrait>, ) -> Result<String>
Execute a background task with the given LLM client. Updates the task status to Running, runs the agent loop, and saves the result.
Sourcepub async fn status(&self, task_id: &str) -> Result<TaskStatus>
pub async fn status(&self, task_id: &str) -> Result<TaskStatus>
Get the current status of a task
Sourcepub async fn get_task(&self, task_id: &str) -> Result<BackgroundTask>
pub async fn get_task(&self, task_id: &str) -> Result<BackgroundTask>
Get the full task details
Sourcepub async fn list_tasks(&self) -> Vec<BackgroundTask>
pub async fn list_tasks(&self) -> Vec<BackgroundTask>
List all tasks with their status
Sourcepub async fn resume_incomplete(&self) -> Vec<String>
pub async fn resume_incomplete(&self) -> Vec<String>
Resume all incomplete tasks (Pending or Running) from disk. Returns the list of task IDs that need execution.
Trait Implementations§
Source§impl Clone for BackgroundTaskManager
impl Clone for BackgroundTaskManager
Source§fn clone(&self) -> BackgroundTaskManager
fn clone(&self) -> BackgroundTaskManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for BackgroundTaskManager
impl !UnwindSafe for BackgroundTaskManager
impl Freeze for BackgroundTaskManager
impl Send for BackgroundTaskManager
impl Sync for BackgroundTaskManager
impl Unpin for BackgroundTaskManager
impl UnsafeUnpin for BackgroundTaskManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request