21.242. Class TaskTableExtensions

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

Provides extension methods for to manage and update the lifecycle and metadata of tasks in storage. Includes utilities for ending, cancelling, finalizing, acquiring, releasing, retrying, and bulk updating tasks, as well as retrieving task status and outputs.

public static class TaskTableExtensions

21.242.1. Inheritance

objectTaskTableExtensions

21.242.2. Inherited Members

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

21.242.3. Methods

21.242.3.1. AcquireTask(ITaskTable, TaskData, CancellationToken)

Acquire the task to process it on the current agent

public static Task<TaskData> AcquireTask(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)

21.242.3.1.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskData TaskData

Metadata of the task to acquire

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.1.2. Returns

Task<TaskData>

Metadata of the task we try to acquire

21.242.3.1.3. Remarks

Updates:

  • : New status of the task

  • : Identifier (Ip) that will be used to reach the pod if another pod tries to acquire the task

  • : Hostname of the pollster

  • : Date when the message from the queue storage is received

  • : Date when the task is acquired

21.242.3.2. BulkUpdateTasks(ITaskTable, IEnumerable<(string taskId, UpdateDefinition<TaskData> updates)>, CancellationToken)

Updates in bulk tasks

public static Task<long> BulkUpdateTasks(this ITaskTable taskTable, IEnumerable<(string taskId, UpdateDefinition<TaskData> updates)> bulkUpdates, CancellationToken cancellationToken)

21.242.3.2.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

bulkUpdates IEnumerable<(string taskId, UpdateDefinition<TaskData> updates)>

Enumeration of updates with the taskId they apply on

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.2.2. Returns

Task<long>

The number of task matched

21.242.3.3. CancelSessionAsync(ITaskTable, string, CancellationToken)

Cancels all tasks in a given session

public static Task CancelSessionAsync(this ITaskTable taskTable, string sessionId, CancellationToken cancellationToken = default)

21.242.3.3.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

sessionId string

Id of the target session

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.3.2. Returns

Task

Task representing the asynchronous execution of the method

21.242.3.4. CancelTaskAsync(ITaskTable, ICollection<string>, CancellationToken)

Cancels all the given tasks that are not in a final status

public static Task<long> CancelTaskAsync(this ITaskTable taskTable, ICollection<string> taskIds, CancellationToken cancellationToken = default)

21.242.3.4.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskIds ICollection<string>

Collection of task ids

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.4.2. Returns

Task<long>

The number of task matched

21.242.3.5. EndTaskAsync(ITaskTable, TaskData, TaskStatus, string?, CancellationToken)

Change the status of the task to canceled

public static Task<TaskData> EndTaskAsync(this ITaskTable taskTable, TaskData taskData, TaskStatus status, string? errorMessage = null, CancellationToken cancellationToken = default)

21.242.3.5.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskData TaskData

Metadata of the task to tag as succeeded

status TaskStatus

The status to set

errorMessage string?

The error message in case of error

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.5.2. Returns

Task<TaskData>

Task representing the asynchronous execution of the method

21.242.3.5.3. Remarks

Updates:

  • : New status of the task

  • : Date when the task ends

  • : Duration between the creation and the end of the task

  • : Duration between the start and the end of the task

  • : Output of the task

21.242.3.6. FinalizeTaskCreation(ITaskTable, ICollection<string>, bool, CancellationToken)

Tag a collection of tasks as submitted

public static Task<long> FinalizeTaskCreation(this ITaskTable taskTable, ICollection<string> taskIds, bool paused = false, CancellationToken cancellationToken = default)

21.242.3.6.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskIds ICollection<string>

Task ids whose creation will be finalized

paused bool

If the tasks should be paused (usually because the session is paused)

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.6.2. Returns

Task<long>

The number of tagged tasks by the function

21.242.3.7. GetParentTaskIds(ITaskTable, string, CancellationToken)

Get expected parent’s ids of a task given its id

public static Task<IList<string>> GetParentTaskIds(this ITaskTable taskTable, string taskId, CancellationToken cancellationToken = default)

21.242.3.7.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskId string

Id of the target task

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.7.2. Returns

Task<IList<string>>

The parent’s ids

21.242.3.8. GetTaskOutput(ITaskTable, string, CancellationToken)

Retrieve a task’s output

public static Task<Output> GetTaskOutput(this ITaskTable taskTable, string taskId, CancellationToken cancellationToken = default)

21.242.3.8.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskId string

Id of the target task

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.8.2. Returns

Task<Output>

Task’s output

21.242.3.9. GetTaskStatus(ITaskTable, IEnumerable<string>, CancellationToken)

Get reply status metadata of a task given its id

public static IAsyncEnumerable<TaskIdStatus> GetTaskStatus(this ITaskTable taskTable, IEnumerable<string> taskIds, CancellationToken cancellationToken = default)

21.242.3.9.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskIds IEnumerable<string>

Ids of the target tasks

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.9.2. Returns

IAsyncEnumerable<TaskIdStatus>

Reply status metadata

21.242.3.10. GetTaskStatus(ITaskTable, string, CancellationToken)

Get reply status metadata of a task given its id

public static Task<TaskStatus> GetTaskStatus(this ITaskTable taskTable, string taskId, CancellationToken cancellationToken = default)

21.242.3.10.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskId string

Id of the target task

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.10.2. Returns

Task<TaskStatus>

Reply status metadata

21.242.3.11. GetTasksExpectedOutputKeys(ITaskTable, IEnumerable<string>, CancellationToken)

Get expected output keys of tasks given their ids

public static IAsyncEnumerable<(string taskId, IEnumerable<string> expectedOutputKeys)> GetTasksExpectedOutputKeys(this ITaskTable taskTable, IEnumerable<string> taskIds, CancellationToken cancellationToken = default)

21.242.3.11.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskIds IEnumerable<string>

Collection of task ids

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.11.2. Returns

IAsyncEnumerable<(string taskId, IEnumerable<string> expectedOutputKeys)>

The expected output keys

21.242.3.12. ReadTaskAsync(ITaskTable, string, CancellationToken)

Retrieves a task from the data base

public static Task<TaskData> ReadTaskAsync(this ITaskTable taskTable, string taskId, CancellationToken cancellationToken = default)

21.242.3.12.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskId string

Id of the task to read

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.12.2. Returns

Task<TaskData>

Task metadata of the retrieved task

21.242.3.13. ReleaseTask(ITaskTable, TaskData, bool, CancellationToken)

Release the task from the current agent

public static Task<TaskData> ReleaseTask(this ITaskTable taskTable, TaskData taskData, bool paused = false, CancellationToken cancellationToken = default)

21.242.3.13.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskData TaskData

Metadata of the task to release

paused bool

If task should be paused

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.13.2. Returns

Task<TaskData>

Metadata of the task we try to release

21.242.3.13.3. Remarks

Updates:

  • : New status of the task

  • : Identifier (Ip) that will be used to reach the pod if another pod tries to acquire the task

  • : Hostname of the pollster

  • : Date when the message from the queue storage is received

  • : Date when the task is acquired

21.242.3.14. RetryTask(ITaskTable, TaskData, CancellationToken)

Retry a task identified by its meta data

public static Task<string> RetryTask(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)

21.242.3.14.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskData TaskData

Task metadata of the task to retry

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.14.2. Returns

Task<string>

The id of the freshly created task

21.242.3.15. StartTask(ITaskTable, TaskData, CancellationToken)

Update a task status to TaskStatus.Processing

public static Task StartTask(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)

21.242.3.15.1. Parameters

taskTable ITaskTable

Interface to manage tasks lifecycle

taskData TaskData

Metadata of the task to start

cancellationToken CancellationToken

Token used to cancel the execution of the method

21.242.3.15.2. Returns

Task

Task representing the asynchronous execution of the method

21.242.3.15.3. Remarks

Updates:

  • : New status of the task

  • : Date when the task starts

  • : Date TTL on the pod