/// <summary> /// Tries to delete the the state associated with the provided <paramref name="key" /> using the /// <paramref name="etag"/> from the Dapr state. State store implementation will allow the delete only if the attached ETag matches with the latest ETag in the state store. /// </summary> /// <param name="storeName">The state store name.</param> /// <param name="key">The state key.</param> /// <param name="etag">An ETag.</param> /// <param name="stateOptions">A <see cref="StateOptions" />.</param> /// <param name="metadata">An key/value pair that may be consumed by the state store. This depends on the state store used.</param> /// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param> /// <returns>A <see cref="ValueTask" /> that will complete when the operation has completed. If the wrapped value is true the operation suceeded.</returns> public abstract ValueTask <bool> TryDeleteStateAsync( string storeName, string key, string etag, StateOptions stateOptions = default, Dictionary <string, string> metadata = default, CancellationToken cancellationToken = default);
/// <summary> /// Saves the provided <paramref name="value" /> associated with the provided <paramref name="key" /> to the Dapr state /// store. /// </summary> /// <param name="storeName">The name of the state store.</param> /// <param name="key">The state key.</param> /// <param name="value">The value to save.</param> /// <param name="stateOptions">Options for performing save state operation.</param> /// <param name="metadata">An key/value pair that may be consumed by the state store. This is dependent on the type of state store used.</param> /// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param> /// <typeparam name="TValue">The data type of the value to save.</typeparam> /// <returns>A <see cref="ValueTask" /> that will complete when the operation has completed.</returns> public abstract Task SaveStateAsync <TValue>( string storeName, string key, TValue value, StateOptions stateOptions = default, Dictionary <string, string> metadata = default, CancellationToken cancellationToken = default);
/// <summary> /// Initializes a new instance of the <see cref="BulkStateItem"/> class. /// </summary> /// <param name="key">The state key.</param> /// <param name="etag">The ETag.</param> /// <param name="stateOptions">The stateOptions.</param> /// <param name="metadata">The metadata.</param> public BulkDeleteStateItem(string key, string etag, StateOptions stateOptions = default, IReadOnlyDictionary <string, string> metadata = default) { this.Key = key; this.ETag = etag; StateOptions = stateOptions; Metadata = metadata; }
/// <summary> /// Deletes the value associated with the provided <paramref name="key" /> in the Dapr state store. /// </summary> /// <param name="storeName">The state store name.</param> /// <param name="key">The state key.</param> /// <param name="stateOptions">A <see cref="StateOptions" />.</param> /// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param> /// <returns>A <see cref="Task" /> that will complete when the operation has completed.</returns> public abstract Task DeleteStateAsync( string storeName, string key, StateOptions stateOptions = default, CancellationToken cancellationToken = default);
/// <summary> /// Initializes a new instance of the <see cref="StateTransactionRequest"/> class. /// </summary> /// <param name="key">The state key.</param> /// <param name="value">The serialized state value.</param> /// <param name="operationType">The operation type.</param> /// <param name="etag">The etag (optional).</param> /// <param name="metadata">Additional key value pairs for the state (optional).</param> /// <param name="options">State options (optional).</param> public StateTransactionRequest(string key, byte[] value, StateOperationType operationType, string etag = default, IReadOnlyDictionary <string, string> metadata = default, StateOptions options = default) { ArgumentVerifier.ThrowIfNull(key, nameof(key)); this.Key = key; this.Value = value; this.OperationType = operationType; this.ETag = etag; this.Metadata = metadata; this.Options = options; }
public override async Task <bool> TrySaveStateAsync <TValue>(string storeName, string key, TValue value, string etag, StateOptions stateOptions = null, IReadOnlyDictionary <string, string> metadata = null, CancellationToken cancellationToken = default) { await SaveStateAsync <TValue>(storeName, key, value, stateOptions, metadata, cancellationToken); return(true); }