23.25. Class TaskTable

Namespace: ArmoniK.Core.Adapters.Memory
Assembly: ArmoniK.Core.Adapters.Memory.dll

public class TaskTable : ITaskTable, IInitializable, IHealthCheckProvider

23.25.1. Inheritance

objectTaskTable

23.25.2. Implements

ITaskTable, IInitializable, IHealthCheckProvider

23.25.3. Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

23.25.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.25.5. Constructors

23.25.5.1. TaskTable(ConcurrentDictionary<string, TaskData>, ConcurrentDictionary<string, ConcurrentQueue<string>>, ILogger<TaskTable>)

public TaskTable(ConcurrentDictionary<string, TaskData> task2TaskData, ConcurrentDictionary<string, ConcurrentQueue<string>> session2TaskId, ILogger<TaskTable> logger)

23.25.5.1.1. Parameters

task2TaskData ConcurrentDictionary<string, TaskData>

session2TaskId ConcurrentDictionary<string, ConcurrentQueue<string>>

logger ILogger<TaskTable>

23.25.6. Properties

23.25.6.1. Logger

Logger for class ITaskTable

public ILogger Logger { get; set; }

23.25.6.1.1. Property Value

ILogger

23.25.6.2. 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.25.6.2.1. Property Value

TimeSpan

23.25.6.3. 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.25.6.3.1. Property Value

TimeSpan

23.25.7. Methods

23.25.7.1. Check(HealthCheckTag)

Checks the status of a class for the given health check type.

public Task<HealthCheckResult> Check(HealthCheckTag tag)

23.25.7.1.1. Parameters

tag HealthCheckTag

Health check for which the class has to answer.

23.25.7.1.2. Returns

Task<HealthCheckResult>

The result of the check containing the status of the class for the health check type.

23.25.7.2. CountAllTasksAsync(TaskStatus, CancellationToken)

Count tasks matching a given status

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

23.25.7.2.1. Parameters

status TaskStatus

Status of the tasks to be counted

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.2.2. Returns

Task<int>

The number of tasks that matched the status

23.25.7.3. CountPartitionTasksAsync(CancellationToken)

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

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

23.25.7.3.1. Parameters

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.3.2. Returns

Task<IEnumerable<PartitionTaskStatusCount>>

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

23.25.7.4. 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.25.7.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

23.25.7.4.2. Returns

Task<IEnumerable<TaskStatusCount>>

The number of tasks that matched the filter

23.25.7.5. CreateTasks(IEnumerable<TaskData>, CancellationToken)

Inserts a collection of tasks in the data base

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

23.25.7.5.1. Parameters

tasks IEnumerable<TaskData>

Collection of tasks to be inserted

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.5.2. Returns

Task

Task representing the asynchronous execution of the method

23.25.7.6. DeleteTaskAsync(string, CancellationToken)

Remove a task from the database given its id

public Task DeleteTaskAsync(string id, CancellationToken cancellationToken = default)

23.25.7.6.1. Parameters

id string

Id of the tasks to be deleted

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.6.2. Returns

Task

Task representing the asynchronous execution of the method

23.25.7.7. DeleteTasksAsync(string, CancellationToken)

Remove tasks from the database given their session id

public Task DeleteTasksAsync(string sessionId, CancellationToken cancellationToken = default)

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

23.25.7.7.2. Returns

Task

Task representing the asynchronous execution of the method

23.25.7.8. DeleteTasksAsync(ICollection<string>, CancellationToken)

Remove tasks from the database given their ids

public Task DeleteTasksAsync(ICollection<string> taskIds, CancellationToken cancellationToken = default)

23.25.7.8.1. Parameters

taskIds ICollection<string>

Ids of the tasks to be deleted

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.8.2. Returns

Task

Task representing the asynchronous execution of the method

23.25.7.8.3. Remarks

Does not throw if the task does not exist.

23.25.7.9. 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.25.7.9.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.25.7.9.2. Returns

IAsyncEnumerable<T>

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

23.25.7.9.3. Type Parameters

T

23.25.7.10. Init(CancellationToken)

Executes an initialization process for the class

public Task Init(CancellationToken cancellationToken)

23.25.7.10.1. Parameters

cancellationToken CancellationToken

Token used to cancel the execution of the method

23.25.7.10.2. Returns

Task

Task representing the asynchronous execution of the method

23.25.7.11. 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.25.7.11.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.25.7.11.2. Returns

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

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

23.25.7.12. 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.25.7.12.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.25.7.12.2. Returns

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

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

23.25.7.12.3. Type Parameters

T

23.25.7.12.4. Remarks

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

23.25.7.13. 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.25.7.13.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.25.7.13.2. Returns

Task<T>

Task metadata of the retrieved task

23.25.7.13.3. Type Parameters

T

23.25.7.14. 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.25.7.14.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.25.7.14.2. Returns

IAsyncEnumerable<T>

Projected tasks that are ready after the dependencies removal

23.25.7.14.3. Type Parameters

T

23.25.7.15. 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.25.7.15.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.25.7.15.2. Returns

Task<long>

The number of task matched

23.25.7.16. 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.25.7.16.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.25.7.16.2. Returns

Task<TaskData?>

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