Interface ITaskHandler

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

Higher level interface to implement to create tasks and populate results

[PublicAPI]
public interface ITaskHandler : IAsyncDisposable

Implements

IAsyncDisposable

Properties

Configuration

The configuration parameters for the interaction with ArmoniK.

Configuration Configuration { get; }

Property Value

Configuration

DataDependencies

The data required to compute the task

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

Property Value

IReadOnlyDictionary<string, byte[]>

ExpectedResults

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

IList<string> ExpectedResults { get; }

Property Value

IList<string>

Payload

The data provided when submitting the task.

byte[] Payload { get; }

Property Value

byte[]

SessionId

Id of the session this task belongs to.

string SessionId { get; }

Property Value

string

TaskId

Id of the task being processed.

string TaskId { get; }

Property Value

string

TaskOptions

List of options provided when submitting the task.

TaskOptions TaskOptions { get; }

Property Value

TaskOptions

Methods

CreateResultsAsync(IEnumerable<ResultCreate>, CancellationToken?)

Create results from metadata and data in an unique request

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

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.

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>

RequestCommonData(string, CancellationToken?)

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

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.

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.

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

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)

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