Class DefaultTaskRepository
java.lang.Object
com.alibaba.cloud.ai.graph.agent.tools.task.DefaultTaskRepository
- All Implemented Interfaces:
TaskRepository
Default implementation of TaskRepository using a thread pool for background execution.
- Author:
- Spring AI Alibaba
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a repository with a default cached thread pool executor.DefaultTaskRepository(ExecutorService executor) Create a repository with a custom executor service.DefaultTaskRepository(ExecutorService executor, boolean ownsExecutor) Internal constructor for specifying executor ownership. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all tasks from the repository.voidRemove completed tasks from the repository.Get a background task by its ID.Add a new background task to the repository.voidremoveTask(String taskId) Remove a background task from the repository.voidshutdown()Shutdown the executor service if this repository owns it.
-
Constructor Details
-
DefaultTaskRepository
public DefaultTaskRepository()Create a repository with a default cached thread pool executor. -
DefaultTaskRepository
Create a repository with a custom executor service. -
DefaultTaskRepository
Internal constructor for specifying executor ownership.
-
-
Method Details
-
getTask
Description copied from interface:TaskRepositoryGet a background task by its ID.- Specified by:
getTaskin interfaceTaskRepository- Parameters:
taskId- the task identifier- Returns:
- the background task, or null if not found
-
putTask
Description copied from interface:TaskRepositoryAdd a new background task to the repository.- Specified by:
putTaskin interfaceTaskRepository- Parameters:
taskId- the task identifiertaskExecution- the supplier that executes the task and returns its output- Returns:
- the created background task
-
removeTask
Description copied from interface:TaskRepositoryRemove a background task from the repository.- Specified by:
removeTaskin interfaceTaskRepository- Parameters:
taskId- the task identifier
-
clear
public void clear()Description copied from interface:TaskRepositoryClear all tasks from the repository.- Specified by:
clearin interfaceTaskRepository
-
clearCompletedTasks
public void clearCompletedTasks()Remove completed tasks from the repository. -
shutdown
public void shutdown()Shutdown the executor service if this repository owns it.
-