Table of Contents

Class StateStoreClient

Namespace
Azure.Iot.Operations.Services.StateStore
Assembly
Azure.Iot.Operations.Services.dll

A client for interacting with the Akri MQ distributed state store.

public class StateStoreClient : IStateStoreClient, IAsyncDisposable
Inheritance
StateStoreClient
Implements
Inherited Members

Constructors

StateStoreClient(ApplicationContext, IMqttPubSubClient)

public StateStoreClient(ApplicationContext applicationContext, IMqttPubSubClient mqttClient)

Parameters

applicationContext ApplicationContext
mqttClient IMqttPubSubClient

Methods

DeleteAsync(StateStoreKey, StateStoreDeleteRequestOptions?, TimeSpan?, CancellationToken)

Delete the provided key from the State Store.

public virtual Task<StateStoreDeleteResponse> DeleteAsync(StateStoreKey key, StateStoreDeleteRequestOptions? options = null, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)

Parameters

key StateStoreKey

The key to delete from the State Store.

options StateStoreDeleteRequestOptions

The optional parameters for this request. OnlyDeleteIfValueEquals allows for conditional deletion.

requestTimeout TimeSpan?

The request timeout.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<StateStoreDeleteResponse>

The details of the service response.

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.

DisposeAsync(bool)

public ValueTask DisposeAsync(bool disposing)

Parameters

disposing bool

Returns

ValueTask

DisposeAsyncCore(bool)

protected virtual ValueTask DisposeAsyncCore(bool disposing)

Parameters

disposing bool

Returns

ValueTask

GetAsync(StateStoreKey, TimeSpan?, CancellationToken)

Get the value of a key from the State Store.

public virtual Task<StateStoreGetResponse> GetAsync(StateStoreKey key, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)

Parameters

key StateStoreKey

The key to get the value of.

requestTimeout TimeSpan?

The optional timeout for this request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<StateStoreGetResponse>

The service response containing the current value of the key in the State Store.

ObserveAsync(StateStoreKey, TimeSpan?, CancellationToken)

Begin receiving events each time the provided key is updated, deleted, or created. Events will be delivered via KeyChangeMessageReceivedAsync.

public virtual Task ObserveAsync(StateStoreKey key, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)

Parameters

key StateStoreKey

The key to receive notifications about.

requestTimeout TimeSpan?

The optional timeout for this request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This method does not support using wildcard characters to subscribe to multiple keys at once.

SetAsync(StateStoreKey, StateStoreValue, StateStoreSetRequestOptions?, TimeSpan?, CancellationToken)

Set the value of a key in the State Store.

public virtual Task<StateStoreSetResponse> SetAsync(StateStoreKey key, StateStoreValue value, StateStoreSetRequestOptions? options = null, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)

Parameters

key StateStoreKey

The key to set in the State Store.

value StateStoreValue

The value to assign key in the State Store.

options StateStoreSetRequestOptions

The parameters for this request including the key and value to use. Condition allows for conditional setting/overwriting of values.

requestTimeout TimeSpan?

The optional timeout for this request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<StateStoreSetResponse>

The service response detailing if the operation succeeded and (optionally) the previous value of this key.

UnobserveAsync(StateStoreKey, TimeSpan?, CancellationToken)

Stop receiving events each time the provided key is updated, created, or deleted.

public virtual Task UnobserveAsync(StateStoreKey key, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)

Parameters

key StateStoreKey

The key to stop receiving events about.

requestTimeout TimeSpan?

The optional timeout for this request.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

This method does not support using wildcard characters to unsubscribe from multiple keys at once.

Events

KeyChangeMessageReceivedAsync

The event that executes each time an observed key is changed.

public event Func<object?, KeyChangeMessageReceivedEventArgs, Task>? KeyChangeMessageReceivedAsync

Event Type

Func<object, KeyChangeMessageReceivedEventArgs, Task>