21.204. Interface ITaskTable

Namespace: ArmoniK.Core.Common.Storage
Assembly: ArmoniK.Core.Common.dll

Interface to manage tasks and their life cycle in the data base

public interface ITaskTable : IInitializable, IHealthCheckProvider

21.204.1. Implements

IInitializable, IHealthCheckProvider

21.204.2. 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)

21.204.3. Properties

21.204.3.1. Logger

Logger for class ITaskTable

ILogger Logger { get; }

21.204.3.1.1. Property Value

ILogger

21.204.3.2. PollingDelayMax

Upper bound delay between two data base accesses when active polling is employed to wait for a task status to change

TimeSpan PollingDelayMax { get; }

21.204.3.2.1. Property Value

TimeSpan

21.204.3.3. PollingDelayMin

Lower bound delay between two data base accesses when active polling is employed to wait for a task status to change

TimeSpan PollingDelayMin { get; }

21.204.3.3.1. Property Value

TimeSpan

21.204.4. Methods

21.204.4.1. BulkUpdateTasks(IEnumerable<(Expression<Func<TaskData, bool>> filter, UpdateDefinition<TaskData> updates)>, CancellationToken)

Updates in bulk tasks

Task<long> BulkUpdateTasks(IEnumerable<(Expression<Func<TaskData, bool>> filter, UpdateDefinition<TaskData> updates)> bulkUpdates, CancellationToken cancellationToken)

21.204.4.1.1. Parameters

bulkUpdates IEnumerable<(Expression<Func<TaskData, bool>> filter, UpdateDefinition<TaskData> updates)>

Enumeration of updates with the filter they apply on

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.204.4.1.2. Returns

Task<long>

The number of task matched

21.204.4.2. CountAllTasksAsync(TaskStatus, CancellationToken)

Count tasks matching a given status

Task<int> CountAllTasksAsync(TaskStatus status, CancellationToken cancellationToken = default)

21.204.4.2.1. Parameters

status TaskStatus

Status of the tasks to be counted

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.204.4.2.2. Returns

Task<int>

The number of tasks that matched the status

21.204.4.3. CountPartitionTasksAsync(CancellationToken)

Count tasks matching a given filter and group by partition and status

Task<IEnumerable<PartitionTaskStatusCount>> CountPartitionTasksAsync(CancellationToken cancellationToken = default)

21.204.4.3.1. Parameters

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.204.4.3.2. Returns

Task<IEnumerable<PartitionTaskStatusCount>>

The number of tasks that matched the filter grouped by partition and status

21.204.4.4. CountTasksAsync(Expression<Func<TaskData, bool>>, CancellationToken)

Count tasks matching a given filter

Task<IEnumerable<TaskStatusCount>> CountTasksAsync(Expression<Func<TaskData, bool>> filter, CancellationToken cancellationToken = default)

21.204.4.4.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

21.204.4.4.2. Returns

Task<IEnumerable<TaskStatusCount>>

The number of tasks that matched the filter

21.204.4.5. CreateTasks(IEnumerable<TaskData>, CancellationToken)

Inserts a collection of tasks in the data base

Task CreateTasks(IEnumerable<TaskData> tasks, CancellationToken cancellationToken = default)

21.204.4.5.1. Parameters

tasks IEnumerable<TaskData>

Collection of tasks to be inserted

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.204.4.5.2. Returns

Task

Task representing the asynchronous execution of the method

21.204.4.6. DeleteTaskAsync(string, CancellationToken)

Remove a task from the data base given its id

Task DeleteTaskAsync(string id, CancellationToken cancellationToken = default)

21.204.4.6.1. Parameters

id string

Id of the tasks to be deleted

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.204.4.6.2. Returns

Task

Task representing the asynchronous execution of the method

21.204.4.7. DeleteTasksAsync(string, CancellationToken)

Remove tasks from the data base given their session id

Task DeleteTasksAsync(string sessionId, CancellationToken cancellationToken = default)

21.204.4.7.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

21.204.4.7.2. Returns

Task

Task representing the asynchronous execution of the method

21.204.4.8. FindTasksAsync<T>(Expression<Func<TaskData, bool>>, Expression<Func<TaskData, T>>, CancellationToken)

Find all tasks matching the given filter and ordering

IAsyncEnumerable<T> FindTasksAsync<T>(Expression<Func<TaskData, bool>> filter, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)

21.204.4.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

21.204.4.8.2. Returns

IAsyncEnumerable<T>

Task metadata matching the request and total number of results without paging

21.204.4.8.3. Type Parameters

T

21.204.4.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

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)

21.204.4.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

21.204.4.9.2. Returns

Task<(IEnumerable<Application> applications, int totalCount)>

Collection of applications metadata matching the request and total number of results without paging

21.204.4.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

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)

21.204.4.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

21.204.4.10.2. Returns

Task<(IEnumerable<T> tasks, long totalCount)>

Collection of task metadata matching the request and total number of results without paging

21.204.4.10.3. Type Parameters

T

21.204.4.10.4. Remarks

If pageSize is 0, this function can be used to count the number of tasks satisfying the condition specified by filter

21.204.4.11. ReadTaskAsync<T>(string, Expression<Func<TaskData, T>>, CancellationToken)

Retrieves a task from the data base

Task<T> ReadTaskAsync<T>(string taskId, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)

21.204.4.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

21.204.4.11.2. Returns

Task<T>

Task metadata of the retrieved task

21.204.4.11.3. Type Parameters

T

21.204.4.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

IAsyncEnumerable<T> RemoveRemainingDataDependenciesAsync<T>(ICollection<string> taskIds, ICollection<string> dependenciesToRemove, Expression<Func<TaskData, T>> selector, CancellationToken cancellationToken = default)

21.204.4.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

21.204.4.12.2. Returns

IAsyncEnumerable<T>

Projected tasks that are ready after the dependencies removal

21.204.4.12.3. Type Parameters

T

21.204.4.13. UpdateManyTasks(Expression<Func<TaskData, bool>>, UpdateDefinition<TaskData>, CancellationToken)

Update the tasks matching the filter with the given new values

Task<long> UpdateManyTasks(Expression<Func<TaskData, bool>> filter, UpdateDefinition<TaskData> updates, CancellationToken cancellationToken = default)

21.204.4.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

21.204.4.13.2. Returns

Task<long>

The number of task matched

21.204.4.14. UpdateOneTask(string, Expression<Func<TaskData, bool>>?, UpdateDefinition<TaskData>, bool, CancellationToken)

Update one task with the given new values

Task<TaskData?> UpdateOneTask(string taskId, Expression<Func<TaskData, bool>>? filter, UpdateDefinition<TaskData> updates, bool before = false, CancellationToken cancellationToken = default)

21.204.4.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

21.204.4.14.2. Returns

Task<TaskData?>

The task metadata before the update or null if task not found