Table of Contents

Class CommandExecutor<TReq, TResp>

Namespace
Azure.Iot.Operations.Protocol.RPC
Assembly
Azure.Iot.Operations.Protocol.dll
public abstract class CommandExecutor<TReq, TResp> : IAsyncDisposable where TReq : class where TResp : class

Type Parameters

TReq
TResp
Inheritance
CommandExecutor<TReq, TResp>
Implements
Derived
Inherited Members

Constructors

CommandExecutor(ApplicationContext, IMqttPubSubClient, string, IPayloadSerializer)

public CommandExecutor(ApplicationContext applicationContext, IMqttPubSubClient mqttClient, string commandName, IPayloadSerializer serializer)

Parameters

applicationContext ApplicationContext
mqttClient IMqttPubSubClient
commandName string
serializer IPayloadSerializer

Properties

CacheTtl

The cache time-to-live that will be used for reusing a previously computed response for duplicate or equivalent idempotent command requests.

public TimeSpan CacheTtl { get; init; }

Property Value

TimeSpan

Remarks

Idempotent commands will cache the response of duplicate requests until the maximum of cache time-to-live or the command request expiration. Idempotent commands will cache the response of equivalent requests until the cache time-to-live. The cache could be cleared before the time-to-live expires if the cost-weighted benefit is too low and the cache is under size pressure.

Two requests are considered to be duplicate when the requests have identical correlation ID. Two requests are considered to be equivalent when they have the same payload, parameters and topic, but different correlation ID.

ExecutionTimeout

public TimeSpan ExecutionTimeout { get; set; }

Property Value

TimeSpan

ExecutorId

public string? ExecutorId { get; init; }

Property Value

string

IsIdempotent

public bool IsIdempotent { get; init; }

Property Value

bool

OnCommandReceived

public required Func<ExtendedRequest<TReq>, CancellationToken, Task<ExtendedResponse<TResp>>> OnCommandReceived { get; set; }

Property Value

Func<ExtendedRequest<TReq>, CancellationToken, Task<ExtendedResponse<TResp>>>

RequestTopicPattern

public string RequestTopicPattern { get; init; }

Property Value

string

ServiceGroupId

public string ServiceGroupId { get; init; }

Property Value

string

TopicNamespace

public string? TopicNamespace { get; set; }

Property Value

string

TopicTokenMap

The topic token replacement map that this executor will use by default. Generally, this will include the token values for topic tokens such as "executorId" which should be the same for the duration of this command executor's lifetime.

public Dictionary<string, string> TopicTokenMap { get; protected set; }

Property Value

Dictionary<string, string>

Remarks

Tokens replacement values can also be specified when starting the executor by specifying the additionalTopicToken map in StartAsync(int?, Dictionary<string, string>?, CancellationToken).

Methods

DisposeAsync()

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

public virtual ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

DisposeAsync(bool)

public virtual ValueTask DisposeAsync(bool disposing)

Parameters

disposing bool

Returns

ValueTask

DisposeAsyncCore(bool)

protected virtual ValueTask DisposeAsyncCore(bool disposing)

Parameters

disposing bool

Returns

ValueTask

StartAsync(int?, CancellationToken)

Begin accepting command invocations.

public Task StartAsync(int? preferredDispatchConcurrency = null, CancellationToken cancellationToken = default)

Parameters

preferredDispatchConcurrency int?

The dispatch concurrency count for the command response cache to use.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

StopAsync(CancellationToken)

public Task StopAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task