21.234. Class TaskTableExtensions
Namespace: ArmoniK.Core.Common.Storage
Assembly: ArmoniK.Core.Common.dll
public static class TaskTableExtensions
21.234.1. Inheritance
21.234.2. Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
21.234.3. Methods
21.234.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.234.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.234.3.1.2. Returns
Metadata of the task we try to acquire
21.234.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.234.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.234.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.234.3.2.2. Returns
The number of task matched
21.234.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.234.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.234.3.3.2. Returns
Task representing the asynchronous execution of the method
21.234.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.234.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.234.3.4.2. Returns
The number of task matched
21.234.3.5. 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.234.3.5.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.234.3.5.2. Returns
The number of tagged tasks by the function
21.234.3.6. 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.234.3.6.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.234.3.6.2. Returns
The parent’s ids
21.234.3.7. GetTaskOutput(ITaskTable, string, CancellationToken)
Retrieve a task’s output
public static Task<Output> GetTaskOutput(this ITaskTable taskTable, string taskId, CancellationToken cancellationToken = default)
21.234.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.234.3.7.2. Returns
Task’s output
21.234.3.8. 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.234.3.8.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.234.3.8.2. Returns
IAsyncEnumerable<TaskIdStatus>
Reply status metadata
21.234.3.9. 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.234.3.9.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.234.3.9.2. Returns
Reply status metadata
21.234.3.10. 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.234.3.10.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.234.3.10.2. Returns
IAsyncEnumerable<(string taskId, IEnumerable<string> expectedOutputKeys)>
The expected output keys
21.234.3.11. 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.234.3.11.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.234.3.11.2. Returns
Task metadata of the retrieved task
21.234.3.12. 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.234.3.12.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.234.3.12.2. Returns
Metadata of the task we try to release
21.234.3.12.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.234.3.13. 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.234.3.13.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.234.3.13.2. Returns
The id of the freshly created task
21.234.3.14. SetTaskCanceledAsync(ITaskTable, TaskData, CancellationToken)
Change the status of the task to canceled
public static Task SetTaskCanceledAsync(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)
21.234.3.14.1. Parameters
taskTable ITaskTable
Interface to manage tasks lifecycle
taskData TaskData
Metadata of the task to tag as succeeded
cancellationToken CancellationToken
Token used to cancel the execution of the method
21.234.3.14.2. Returns
Task representing the asynchronous execution of the method
21.234.3.14.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.234.3.15. SetTaskErrorAsync(ITaskTable, TaskData, string, CancellationToken)
Tag a task as errored and populate its output with an error message
public static Task<bool> SetTaskErrorAsync(this ITaskTable taskTable, TaskData taskData, string errorDetail, CancellationToken cancellationToken = default)
21.234.3.15.1. Parameters
taskTable ITaskTable
Interface to manage tasks lifecycle
taskData TaskData
Metadata of the task to mark as errored
errorDetail string
Error message to be inserted in task’s output
cancellationToken CancellationToken
Token used to cancel the execution of the method
21.234.3.15.2. Returns
A boolean representing whether the status has been updated
21.234.3.15.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.234.3.16. SetTaskRetryAsync(ITaskTable, TaskData, string, CancellationToken)
Change the status of the task to retry
public static Task<bool> SetTaskRetryAsync(this ITaskTable taskTable, TaskData taskData, string errorDetail, CancellationToken cancellationToken = default)
21.234.3.16.1. Parameters
taskTable ITaskTable
Interface to manage tasks lifecycle
taskData TaskData
Metadata of the task to tag as succeeded
errorDetail string
Error message to be inserted in task’s output
cancellationToken CancellationToken
Token used to cancel the execution of the method
21.234.3.16.2. Returns
A boolean representing whether the status has been updated
21.234.3.16.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.234.3.17. SetTaskSuccessAsync(ITaskTable, TaskData, CancellationToken)
Change the status of the task to succeeded
public static Task SetTaskSuccessAsync(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)
21.234.3.17.1. Parameters
taskTable ITaskTable
Interface to manage tasks lifecycle
taskData TaskData
Metadata of the task to tag as succeeded
cancellationToken CancellationToken
Token used to cancel the execution of the method
21.234.3.17.2. Returns
Task representing the asynchronous execution of the method
21.234.3.17.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.234.3.18. SetTaskTimeoutAsync(ITaskTable, TaskData, Output, CancellationToken)
Change the status of the task to retry
public static Task<bool> SetTaskTimeoutAsync(this ITaskTable taskTable, TaskData taskData, Output output, CancellationToken cancellationToken = default)
21.234.3.18.1. Parameters
taskTable ITaskTable
Interface to manage tasks lifecycle
taskData TaskData
Metadata of the task to tag as succeeded
output Output
Task Output
cancellationToken CancellationToken
Token used to cancel the execution of the method
21.234.3.18.2. Returns
A boolean representing whether the status has been updated
21.234.3.18.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.234.3.19. StartTask(ITaskTable, TaskData, CancellationToken)
Update a task status to TaskStatus.Processing
public static Task StartTask(this ITaskTable taskTable, TaskData taskData, CancellationToken cancellationToken = default)
21.234.3.19.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.234.3.19.2. Returns
Task representing the asynchronous execution of the method
21.234.3.19.3. Remarks
Updates:
: New status of the task : Date when the task starts : Date TTL on the pod