Table of Contents

Class StateStore

Namespace
GroupeIsa.Neos.ClusterCommunication.DistributedStore
Assembly
GroupeIsa.Neos.ClusterCommunication.dll

Represents a distributed state store.

public class StateStore : IStateStore
Inheritance
StateStore
Implements
Inherited Members

Constructors

StateStore(DaprClient)

Initializes a new instance of the StateStore class.

public StateStore(DaprClient daprClient)

Parameters

daprClient DaprClient

The dapr client.

Methods

DeleteBulkStateAsync(IReadOnlyList<BulkStateStoreItem>, CancellationToken)

Deletes a list of items from the state store.

public Task DeleteBulkStateAsync(IReadOnlyList<BulkStateStoreItem> items, CancellationToken cancellationToken = default)

Parameters

items IReadOnlyList<BulkStateStoreItem>

The list of items to delete.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task that will complete when the operation has completed.

DeleteStateAsync(string, StateStoreConsistency, StateStoreConcurrency, CancellationToken)

Deletes the value associated with the provided key in the state store.

public Task DeleteStateAsync(string key, StateStoreConsistency stateStoreConsistency = StateStoreConsistency.Strong, StateStoreConcurrency stateStoreConcurrency = StateStoreConcurrency.LastWrite, CancellationToken cancellationToken = default)

Parameters

key string

The state key.

stateStoreConsistency StateStoreConsistency

A StateStoreConsistency.

stateStoreConcurrency StateStoreConcurrency

The concurrency mode StateStoreConcurrency.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task that will complete when the operation has completed.

GetStateAsync<TValue>(string, StateStoreConsistency, CancellationToken)

Gets the current value associated with the key from the state store.

public Task<(TValue? Value, string ETag)> GetStateAsync<TValue>(string key, StateStoreConsistency stateStoreConsistency = StateStoreConsistency.Strong, CancellationToken cancellationToken = default)

Parameters

key string

The state key.

stateStoreConsistency StateStoreConsistency

The consistency mode StateStoreConsistency.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<(TValue Value, string ETag)>

A Task<TResult> that will return the value when the operation has completed.

Type Parameters

TValue

The data type of the value to read.

QueryStateAsync<TValue>(StateStoreQuery, IReadOnlyCollection<string>?, CancellationToken)

Queries the specified statestore with the given query. The query is a object representation of the query.

public Task<StateStoreQueryResult<TValue>> QueryStateAsync<TValue>(StateStoreQuery query, IReadOnlyCollection<string>? indexes = null, CancellationToken cancellationToken = default)

Parameters

query StateStoreQuery

The query StateStoreQuery.

indexes IReadOnlyCollection<string>

The list of indexes to be searched.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<StateStoreQueryResult<TValue>>

A StateStoreQueryResult<TValue> that may be paginated, use PaginationToken to continue the query.

Type Parameters

TValue

The data type of the value to read.

SaveBulkStateAsync<TValue>(IReadOnlyList<BulkStateStoreItem<TValue>>, CancellationToken)

Saves a list of items to the state store.

public Task SaveBulkStateAsync<TValue>(IReadOnlyList<BulkStateStoreItem<TValue>> items, CancellationToken cancellationToken = default)

Parameters

items IReadOnlyList<BulkStateStoreItem<TValue>>

The list of items to save.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task that will complete when the operation has completed.

Type Parameters

TValue

The type of the data that will be JSON serialized and stored in the state store.

SaveStateAsync<TValue>(string, TValue, StateStoreConsistency, StateStoreConcurrency, CancellationToken)

Saves the provided value associated with the provided key to the state store. store.

public Task SaveStateAsync<TValue>(string key, TValue value, StateStoreConsistency stateStoreConsistency = StateStoreConsistency.Strong, StateStoreConcurrency stateStoreConcurrency = StateStoreConcurrency.LastWrite, CancellationToken cancellationToken = default)

Parameters

key string

The state key.

value TValue

The data that will be JSON serialized and stored in the state store.

stateStoreConsistency StateStoreConsistency

The consistency mode StateStoreConsistency.

stateStoreConcurrency StateStoreConcurrency

The concurrency mode StateStoreConcurrency.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task that will complete when the operation has completed.

Type Parameters

TValue

The type of the data that will be JSON serialized and stored in the state store.

TrySaveStateAsync<TValue>(string, TValue, string, StateStoreConsistency, StateStoreConcurrency, CancellationToken)

Tries to save the statevalue associated with the providedkey using the etag to the state store.

public Task<bool> TrySaveStateAsync<TValue>(string key, TValue value, string etag, StateStoreConsistency stateStoreConsistency = StateStoreConsistency.Strong, StateStoreConcurrency stateStoreConcurrency = StateStoreConcurrency.LastWrite, CancellationToken cancellationToken = default)

Parameters

key string

The state key.

value TValue

The data that will be JSON serialized and stored in the state store.

etag string

The etag.

stateStoreConsistency StateStoreConsistency

The consistency mode StateStoreConsistency.

stateStoreConcurrency StateStoreConcurrency

The concurrency mode StateStoreConcurrency.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<bool>

A Task that will complete when the operation has completed.

Type Parameters

TValue

The type of the data that will be JSON serialized and stored in the state store.