23.57. Class TaskTable
Namespace: ArmoniK.Core.Adapters.MongoDB
Assembly: ArmoniK.Core.Adapters.MongoDB.dll
Interface to manage tasks and their life cycle in the data base
public class TaskTable : BaseTable<TaskData, TaskDataModelMapping>, ITaskTable, IInitializable, IHealthCheckProvider
23.57.1. Inheritance
object ← BaseTable<TaskData, TaskDataModelMapping> ← TaskTable
23.57.2. Implements
ITaskTable, IInitializable, IHealthCheckProvider
23.57.3. Inherited Members
BaseTable<TaskData, TaskDataModelMapping>.Logger, BaseTable<TaskData, TaskDataModelMapping>.Init(CancellationToken), BaseTable<TaskData, TaskDataModelMapping>.Check(HealthCheckTag), BaseTable<TaskData, TaskDataModelMapping>.GetCollection(), BaseTable<TaskData, TaskDataModelMapping>.GetReadCollection(), BaseTable<TaskData, TaskDataModelMapping>.StartActivity(string), BaseTable<TaskData, TaskDataModelMapping>.GetSession(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
23.57.4. Extension Methods
TaskTableExtensions.AcquireTask(ITaskTable, TaskData, CancellationToken), TaskTableExtensions.BulkUpdateTasks(ITaskTable, IEnumerable<(string taskId, UpdateDefinition<TaskData> updates)>, CancellationToken), TaskTableExtensions.CancelSessionAsync(ITaskTable, string, CancellationToken), TaskTableExtensions.CancelTaskAsync(ITaskTable, ICollection<string>, CancellationToken), TaskTableExt.CancelTasks(ITaskTable, TaskFilter, CancellationToken), TaskTableExt.CountTasksAsync(ITaskTable, TaskFilter, CancellationToken), TaskTableExtensions.EndTaskAsync(ITaskTable, TaskData, TaskStatus, string?, CancellationToken), TaskTableExtensions.FinalizeTaskCreation(ITaskTable, ICollection<string>, bool, CancellationToken), TaskTableExtensions.GetParentTaskIds(ITaskTable, string, CancellationToken), TaskTableExtensions.GetTaskOutput(ITaskTable, string, CancellationToken), TaskTableExtensions.GetTaskStatus(ITaskTable, IEnumerable<string>, CancellationToken), TaskTableExtensions.GetTaskStatus(ITaskTable, string, CancellationToken), TaskTableExtensions.GetTasksExpectedOutputKeys(ITaskTable, IEnumerable<string>, CancellationToken), TaskTableExt.ListTasksAsync(ITaskTable, TaskFilter, CancellationToken), TaskTableExtensions.ReadTaskAsync(ITaskTable, string, CancellationToken), TaskTableExtensions.ReleaseTask(ITaskTable, TaskData, bool, CancellationToken), TaskTableExtensions.RetryTask(ITaskTable, TaskData, CancellationToken), TaskTableExtensions.StartTask(ITaskTable, TaskData, CancellationToken), TaskTableExt.UpdateAllTaskStatusAsync(ITaskTable, TaskFilter, TaskStatus, CancellationToken)
23.57.5. Constructors
23.57.5.1. TaskTable(SessionProvider, MongoCollectionProvider<TaskData, TaskDataModelMapping>, ActivitySource, ILogger<TaskTable>)
public TaskTable(SessionProvider sessionProvider, MongoCollectionProvider<TaskData, TaskDataModelMapping> taskCollectionProvider, ActivitySource activitySource, ILogger<TaskTable> logger)
23.57.5.1.1. Parameters
sessionProvider SessionProvider
taskCollectionProvider MongoCollectionProvider<TaskData, TaskDataModelMapping>
activitySource ActivitySource
23.57.6. Properties
23.57.6.1. PollingDelayMax
Upper bound delay between two data base accesses when active polling is employed to wait for a task status to change
public TimeSpan PollingDelayMax { get; set; }
23.57.6.1.1. Property Value
23.57.6.2. PollingDelayMin
Lower bound delay between two data base accesses when active polling is employed to wait for a task status to change
public TimeSpan PollingDelayMin { get; set; }
23.57.6.2.1. Property Value
23.57.6.3. Secondary
Table targeting a secondary server for read operations
public ITaskTable Secondary { get; }
23.57.6.3.1. Property Value
23.57.7. Methods
23.57.7.1. CountAllTasksAsync(TaskStatus, CancellationToken)
Count tasks matching a given status
public Task<int> CountAllTasksAsync(TaskStatus status, CancellationToken cancellationToken = default)
23.57.7.1.1. Parameters
status TaskStatus
Status of the tasks to be counted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.1.2. Returns
The number of tasks that matched the status
23.57.7.2. CountPartitionTasksAsync(CancellationToken)
Count tasks matching a given filter and group by partition and status
public Task<IEnumerable<PartitionTaskStatusCount>> CountPartitionTasksAsync(CancellationToken cancellationToken = default)
23.57.7.2.1. Parameters
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.2.2. Returns
Task<IEnumerable<PartitionTaskStatusCount>>
The number of tasks that matched the filter grouped by partition and status
23.57.7.3. CountTasksAsync(Expression<Func<TaskData, bool>>, CancellationToken)
Count tasks matching a given filter
public Task<IEnumerable<TaskStatusCount>> CountTasksAsync(Expression<Func<TaskData, bool>> filter, CancellationToken cancellationToken = default)
23.57.7.3.1. Parameters
filter Expression<Func<TaskData, bool>>
Filter expression describing the tasks to be counted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.3.2. Returns
Task<IEnumerable<TaskStatusCount>>
The number of tasks that matched the filter
23.57.7.4. CreateTasks(IEnumerable<TaskData>, CancellationToken)
Inserts a collection of tasks in the data base
public Task CreateTasks(IEnumerable<TaskData> tasks, CancellationToken cancellationToken = default)
23.57.7.4.1. Parameters
tasks IEnumerable<TaskData>
Collection of tasks to be inserted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.4.2. Returns
Task representing the asynchronous execution of the method
23.57.7.5. DeleteTaskAsync(string, CancellationToken)
Remove a task from the database given its id
public Task DeleteTaskAsync(string id, CancellationToken cancellationToken = default)
23.57.7.5.1. Parameters
id string
Id of the tasks to be deleted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.5.2. Returns
Task representing the asynchronous execution of the method
23.57.7.6. DeleteTasksAsync(string, CancellationToken)
Remove tasks from the database given their session id
public Task DeleteTasksAsync(string sessionId, CancellationToken cancellationToken = default)
23.57.7.6.1. Parameters
sessionId string
Id of the session from which tasks should be deleted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.6.2. Returns
Task representing the asynchronous execution of the method
23.57.7.7. DeleteTasksAsync(ICollection<string>, CancellationToken)
Remove tasks from the database given their ids
public Task DeleteTasksAsync(ICollection<string> taskIds, CancellationToken cancellationToken = default)
23.57.7.7.1. Parameters
taskIds ICollection<string>
Ids of the tasks to be deleted
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.7.2. Returns
Task representing the asynchronous execution of the method
23.57.7.7.3. Remarks
Does not throw if the task does not exist.
23.57.7.8. FindTasksAsync<T>(Expression<Func<TaskData, bool>>, Expression<Func<TaskData, T>>, CancellationToken)
Find all tasks matching the given filter and ordering
public IAsyncEnumerable<T> FindTasksAsync<T>(Expression<Func<TaskData, bool>> filter, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)
23.57.7.8.1. Parameters
filter Expression<Func<TaskData, bool>>
Filter to select tasks
selector Expression<Func<TaskData, T>>
Expression to select part of the returned task data
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.8.2. Returns
Task metadata matching the request and total number of results without paging
23.57.7.8.3. Type Parameters
T
23.57.7.9. ListApplicationsAsync(Expression<Func<TaskData, bool>>, ICollection<Expression<Func<Application, object?>>>, bool, int, int, CancellationToken)
List all applications extracted from task metadata matching the given filter and ordering
public Task<(IEnumerable<Application> applications, int totalCount)> ListApplicationsAsync(Expression<Func<TaskData, bool>> filter, ICollection<Expression<Func<Application, object?>>> orderFields, bool ascOrder, int page, int pageSize, CancellationToken cancellationToken = default)
23.57.7.9.1. Parameters
filter Expression<Func<TaskData, bool>>
Filter to select tasks
orderFields ICollection<Expression<Func<Application, object?>>>
Select the fields that will be used to order the tasks
ascOrder bool
Is the order ascending
page int
The page of results to retrieve
pageSize int
The number of results pages
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.9.2. Returns
Task<(IEnumerable<Application> applications, int totalCount)>
Collection of applications metadata matching the request and total number of results without paging
23.57.7.10. ListTasksAsync<T>(Expression<Func<TaskData, bool>>, Expression<Func<TaskData, object?>>, Expression<Func<TaskData, T>>, bool, int, int, CancellationToken)
List all tasks matching the given filter and ordering
public Task<(IEnumerable<T> tasks, long totalCount)> ListTasksAsync<T>(Expression<Func<TaskData, bool>> filter, Expression<Func<TaskData, object?>> orderField, Expression<Func<TaskData, T>> selector, bool ascOrder, int page, int pageSize, CancellationToken cancellationToken = default)
23.57.7.10.1. Parameters
filter Expression<Func<TaskData, bool>>
Filter to select tasks
orderField Expression<Func<TaskData, object?>>
Select the field that will be used to order the tasks
selector Expression<Func<TaskData, T>>
Expression to select part of the returned task data
ascOrder bool
Is the order ascending
page int
The page of results to retrieve
pageSize int
The number of results pages
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.10.2. Returns
Task<(IEnumerable<T> tasks, long totalCount)>
Collection of task metadata matching the request and total number of results without paging
23.57.7.10.3. Type Parameters
T
23.57.7.10.4. Remarks
If pageSize is 0, this function can be used to count the number of tasks
satisfying the condition specified by filter
23.57.7.11. ReadTaskAsync<T>(string, Expression<Func<TaskData, T>>, CancellationToken)
Retrieves a task from the data base
public Task<T> ReadTaskAsync<T>(string taskId, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)
23.57.7.11.1. Parameters
taskId string
Id of the task to read
selector Expression<Func<TaskData, T>>
Expression to select part of the returned task data
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.11.2. Returns
Task<T>
Task metadata of the retrieved task
23.57.7.11.3. Type Parameters
T
23.57.7.12. RemoveRemainingDataDependenciesAsync<T>(ICollection<string>, ICollection<string>, Expression<Func<TaskData, T>>, CancellationToken)
Remove data dependencies from remaining data dependencies, and returns tasks that are ready
public IAsyncEnumerable<T> RemoveRemainingDataDependenciesAsync<T>(ICollection<string> taskIds, ICollection<string> dependenciesToRemove, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)
23.57.7.12.1. Parameters
taskIds ICollection<string>
Tasks
dependenciesToRemove ICollection<string>
Dependencies
selector Expression<Func<TaskData, T>>
Expression to select part of the returned task data
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.12.2. Returns
Projected tasks that are ready after the dependencies removal
23.57.7.12.3. Type Parameters
T
23.57.7.13. UpdateManyTasks(Expression<Func<TaskData, bool>>, UpdateDefinition<TaskData>, CancellationToken)
Update the tasks matching the filter with the given new values
public Task<long> UpdateManyTasks(Expression<Func<TaskData, bool>> filter, UpdateDefinition<TaskData> updates, CancellationToken cancellationToken = default)
23.57.7.13.1. Parameters
filter Expression<Func<TaskData, bool>>
Filter to select the tasks to update
updates UpdateDefinition<TaskData>
Collection of fields to update and their new value
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.13.2. Returns
The number of task matched
23.57.7.14. UpdateOneTask(string, Expression<Func<TaskData, bool>>?, UpdateDefinition<TaskData>, bool, CancellationToken)
Update one task with the given new values
public Task<TaskData?> UpdateOneTask(string taskId, Expression<Func<TaskData, bool>>? filter, UpdateDefinition<TaskData> updates, bool before, CancellationToken cancellationToken = default)
23.57.7.14.1. Parameters
taskId string
Id of the tasks to be updated
filter Expression<Func<TaskData, bool>>?
Additional filter on the task
updates UpdateDefinition<TaskData>
Collection of fields to update and their new value
before bool
Whether to return metadata before update
cancellationToken CancellationToken
Token used to cancel the execution of the method
23.57.7.14.2. Returns
The task metadata before the update or null if task not found