Class TaskHandler

Namespace: ArmoniK.Api.Worker.Worker
Assembly: ArmoniK.Api.Worker.dll

Task handler that unifies task execution and calls to the Agent

public class TaskHandler : ITaskHandler, IAsyncDisposable

Inheritance

objectTaskHandler

Implements

ITaskHandler, IAsyncDisposable

Inherited Members

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

Constructors

TaskHandler(ProcessRequest, AgentClient, ILoggerFactory, CancellationToken)

Instantiate task handler that unifies task execution and calls to the Agent

public TaskHandler(ProcessRequest processRequest, Agent.AgentClient client, ILoggerFactory loggerFactory, CancellationToken cancellationToken)

Parameters

processRequest ProcessRequest

Task execution request

client Agent.AgentClient

Client to the agent

loggerFactory ILoggerFactory

Logger factory used to create loggers

cancellationToken CancellationToken

Token used to cancel the execution of the method

Exceptions

InvalidOperationException

when payload is not found

Properties

Configuration

The configuration parameters for the interaction with ArmoniK.

public Configuration Configuration { get; }

Property Value

Configuration

DataDependencies

The data required to compute the task

public IReadOnlyDictionary<string, byte[]> DataDependencies { get; }

Property Value

IReadOnlyDictionary<string, byte[]>

ExpectedResults

Lists the result that should be provided or delegated by this task.

public IList<string> ExpectedResults { get; }

Property Value

IList<string>

Payload

The data provided when submitting the task.

public byte[] Payload { get; }

Property Value

byte[]

SessionId

Id of the session this task belongs to.

public string SessionId { get; }

Property Value

string

TaskId

Id of the task being processed.

public string TaskId { get; }

Property Value

string

TaskOptions

List of options provided when submitting the task.

public TaskOptions TaskOptions { get; }

Property Value

TaskOptions

Token

Communication token used to identify requests

public string Token { get; }

Property Value

string

Methods

CreateResultsAsync(IEnumerable<ResultCreate>, CancellationToken?)

Create results from metadata and data in an unique request

public Task<CreateResultsResponse> CreateResultsAsync(IEnumerable<CreateResultsRequest.Types.ResultCreate> results, CancellationToken? cancellationToken = null)

Parameters

results IEnumerable<CreateResultsRequest.Types.ResultCreate>

The results to create

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<CreateResultsResponse>

The task submission response

CreateResultsMetaDataAsync(IEnumerable<ResultCreate>, CancellationToken?)

Create results metadata

public Task<CreateResultsMetaDataResponse> CreateResultsMetaDataAsync(IEnumerable<CreateResultsMetaDataRequest.Types.ResultCreate> results, CancellationToken? cancellationToken = null)

Parameters

results IEnumerable<CreateResultsMetaDataRequest.Types.ResultCreate>

The collection of results to be created

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<CreateResultsMetaDataResponse>

The result creation response

CreateTasksAsync(IEnumerable<TaskRequest>, TaskOptions?, CancellationToken?)

This method allows to create subtasks.

public Task<CreateTaskReply> CreateTasksAsync(IEnumerable<TaskRequest> tasks, TaskOptions? taskOptions = null, CancellationToken? cancellationToken = null)

Parameters

tasks IEnumerable<TaskRequest>

Lists the tasks to submit

taskOptions TaskOptions?

The task options. If no value is provided, will use the default session options

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<CreateTaskReply>

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

RequestCommonData(string, CancellationToken?)

NOT IMPLEMENTED This method is used to retrieve data provided when creating the session.

public Task<byte[]> RequestCommonData(string key, CancellationToken? cancellationToken = null)

Parameters

key string

The da ta key identifier

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<byte[]>

RequestDirectData(string, CancellationToken?)

NOT IMPLEMENTED This method is used to retrieve data directly from the submission client.

public Task<byte[]> RequestDirectData(string key, CancellationToken? cancellationToken = null)

Parameters

key string

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<byte[]>

RequestResource(string, CancellationToken?)

NOT IMPLEMENTED This method is used to retrieve data available system-wide.

public Task<byte[]> RequestResource(string key, CancellationToken? cancellationToken = null)

Parameters

key string

The data key identifier

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<byte[]>

SendResult(string, byte[], CancellationToken?)

Send the results computed by the task

public Task SendResult(string key, byte[] data, CancellationToken? cancellationToken = null)

Parameters

key string

The key identifier of the result.

data byte[]

The data corresponding to the result

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task

SubmitTasksAsync(IEnumerable<TaskCreation>, TaskOptions?, CancellationToken?)

Submit tasks with existing payloads (results)

public Task<SubmitTasksResponse> SubmitTasksAsync(IEnumerable<SubmitTasksRequest.Types.TaskCreation> taskCreations, TaskOptions? submissionTaskOptions, CancellationToken? cancellationToken = null)

Parameters

taskCreations IEnumerable<SubmitTasksRequest.Types.TaskCreation>

The requests to create tasks

submissionTaskOptions TaskOptions?

optional tasks for the whole submission

cancellationToken CancellationToken?

Token used to cancel the execution of the method. If null, the cancellation token of the task handler is used

Returns

Task<SubmitTasksResponse>

The task submission response