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
applicationContextApplicationContextmqttClientIMqttPubSubClient
Methods
DeleteAsync(StateStoreKey, StateStoreDeleteRequestOptions?, TimeSpan?, CancellationToken)
Delete the provided key from the State Store.
public virtual Task<IStateStoreDeleteResponse> DeleteAsync(StateStoreKey key, StateStoreDeleteRequestOptions? options = null, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)
Parameters
keyStateStoreKeyThe key to delete from the State Store.
optionsStateStoreDeleteRequestOptionsThe optional parameters for this request. OnlyDeleteIfValueEquals allows for conditional deletion.
requestTimeoutTimeSpan?The request timeout.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IStateStoreDeleteResponse>
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
disposingbool
Returns
DisposeAsyncCore(bool)
protected virtual ValueTask DisposeAsyncCore(bool disposing)
Parameters
disposingbool
Returns
GetAsync(StateStoreKey, TimeSpan?, CancellationToken)
Get the value of a key from the State Store.
public virtual Task<IStateStoreGetResponse> GetAsync(StateStoreKey key, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)
Parameters
keyStateStoreKeyThe key to get the value of.
requestTimeoutTimeSpan?The optional timeout for this request.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IStateStoreGetResponse>
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
keyStateStoreKeyThe key to receive notifications about.
requestTimeoutTimeSpan?The optional timeout for this request.
cancellationTokenCancellationTokenCancellation token.
Returns
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<IStateStoreSetResponse> SetAsync(StateStoreKey key, StateStoreValue value, StateStoreSetRequestOptions? options = null, TimeSpan? requestTimeout = null, CancellationToken cancellationToken = default)
Parameters
keyStateStoreKeyThe key to set in the State Store.
valueStateStoreValueThe value to assign
keyin the State Store.optionsStateStoreSetRequestOptionsThe parameters for this request including the key and value to use. Condition allows for conditional setting/overwriting of values.
requestTimeoutTimeSpan?The optional timeout for this request.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IStateStoreSetResponse>
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
keyStateStoreKeyThe key to stop receiving events about.
requestTimeoutTimeSpan?The optional timeout for this request.
cancellationTokenCancellationTokenCancellation token.
Returns
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