mirror of https://github.com/dapr/dotnet-sdk.git
metadata, etag, options, etc are optional
This commit is contained in:
parent
6e6aadf779
commit
ea5dc12c5d
|
@ -67,6 +67,16 @@ namespace Dapr.Client
|
||||||
IReadOnlyDictionary<string, string> metadata = default,
|
IReadOnlyDictionary<string, string> metadata = default,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="storeName">The state store name.</param>
|
||||||
|
/// <param name="key">The state key.</param>
|
||||||
|
/// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param>
|
||||||
|
/// <typeparam name="TValue">The data type.</typeparam>
|
||||||
|
/// <returns>A <see cref="ValueTask" /> that will return the value when the operation has completed.</returns>
|
||||||
|
public abstract ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store.
|
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -78,6 +88,16 @@ namespace Dapr.Client
|
||||||
/// <returns>A <see cref="ValueTask" /> that will return the value when the operation has completed.</returns>
|
/// <returns>A <see cref="ValueTask" /> that will return the value when the operation has completed.</returns>
|
||||||
public abstract ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default);
|
public abstract ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store and an ETag.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TValue">The data type.</typeparam>
|
||||||
|
/// <param name="storeName">The state store name.</param>
|
||||||
|
/// <param name="key">The state key.</param>
|
||||||
|
/// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store and an ETag.
|
/// Gets the current value associated with the <paramref name="key" /> from the Dapr state store and an ETag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -89,6 +109,20 @@ namespace Dapr.Client
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default);
|
public abstract ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="StateEntry{T}" /> for the current value associated with the <paramref name="key" /> from
|
||||||
|
/// the Dapr state store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="storeName">The state store name.</param>
|
||||||
|
/// <param name="key">The state key.</param>
|
||||||
|
/// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param>
|
||||||
|
/// <typeparam name="TValue">The data type.</typeparam>
|
||||||
|
/// <returns>A <see cref="ValueTask" /> that will return the <see cref="StateEntry{T}" /> when the operation has completed.</returns>
|
||||||
|
public ValueTask<StateEntry<TValue>> GetStateEntryAsync<TValue>(string storeName, string key, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.GetStateEntryAsync<TValue>(storeName, key, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a <see cref="StateEntry{T}" /> for the current value associated with the <paramref name="key" /> from
|
/// Gets a <see cref="StateEntry{T}" /> for the current value associated with the <paramref name="key" /> from
|
||||||
/// the Dapr state store.
|
/// the Dapr state store.
|
||||||
|
@ -115,6 +149,18 @@ namespace Dapr.Client
|
||||||
return new StateEntry<TValue>(this, storeName, key, stateAndETag.Data, stateAndETag.ETag);
|
return new StateEntry<TValue>(this, storeName, key, stateAndETag.Data, stateAndETag.ETag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the provided <paramref name="value" /> associated with the provided <paramref name="key" /> to the Dapr state
|
||||||
|
/// store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="storeName">The state store name.</param>
|
||||||
|
/// <param name="key">The state key.</param>
|
||||||
|
/// <param name="value">The value to save.</param>
|
||||||
|
/// <param name="cancellationToken">A <see cref="CancellationToken" /> that can be used to cancel the operation.</param>
|
||||||
|
/// <typeparam name="TValue">The data type.</typeparam>
|
||||||
|
/// <returns>A <see cref="ValueTask" /> that will complete when the operation has completed.</returns>
|
||||||
|
public abstract ValueTask SaveStateAsync<TValue>(string storeName, string key, TValue value, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the provided <paramref name="value" /> associated with the provided <paramref name="key" /> to the Dapr state
|
/// Saves the provided <paramref name="value" /> associated with the provided <paramref name="key" /> to the Dapr state
|
||||||
/// store.
|
/// store.
|
||||||
|
@ -137,6 +183,15 @@ namespace Dapr.Client
|
||||||
StateRequestOptions stateRequestOptions,
|
StateRequestOptions stateRequestOptions,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <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="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.</returns>
|
||||||
|
public abstract ValueTask DeleteStateAsync(string storeName, string key, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the value associated with the provided <paramref name="key" /> in the Dapr state store.
|
/// Deletes the value associated with the provided <paramref name="key" /> in the Dapr state store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -207,6 +207,12 @@ namespace Dapr.Client
|
||||||
return JsonSerializer.Deserialize<TResponse>(responseData, this.jsonSerializerOptions);
|
return JsonSerializer.Deserialize<TResponse>(responseData, this.jsonSerializerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.GetStateAsync<TValue>(storeName, key, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override async ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default)
|
public override async ValueTask<TValue> GetStateAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
@ -233,6 +239,12 @@ namespace Dapr.Client
|
||||||
return JsonSerializer.Deserialize<TValue>(responseData, this.jsonSerializerOptions);
|
return JsonSerializer.Deserialize<TValue>(responseData, this.jsonSerializerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.GetStateAndETagAsync<TValue>(storeName, key, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override async ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default)
|
public override async ValueTask<StateAndETag<TValue>> GetStateAndETagAsync<TValue>(string storeName, string key, ConsistencyMode? consistencyMode = default, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
@ -260,6 +272,12 @@ namespace Dapr.Client
|
||||||
return new StateAndETag<TValue>(deserialized, response.Etag);
|
return new StateAndETag<TValue>(deserialized, response.Etag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ValueTask SaveStateAsync<TValue>(string storeName, string key, TValue value, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.SaveStateAsync<TValue>(storeName, key, value, null, null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override async ValueTask SaveStateAsync<TValue>(
|
public override async ValueTask SaveStateAsync<TValue>(
|
||||||
string storeName,
|
string storeName,
|
||||||
|
@ -319,6 +337,12 @@ namespace Dapr.Client
|
||||||
await client.SaveStateAsync(saveStateEnvelope, callOptions);
|
await client.SaveStateAsync(saveStateEnvelope, callOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ValueTask DeleteStateAsync(string storeName, string key, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.DeleteStateAsync(storeName, key, null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override async ValueTask DeleteStateAsync(string storeName, string key, string etag, StateOptions stateOptions = default, CancellationToken cancellationToken = default)
|
public override async ValueTask DeleteStateAsync(string storeName, string key, string etag, StateOptions stateOptions = default, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace Dapr
|
||||||
/// <param name="etag">The etag.</param>
|
/// <param name="etag">The etag.</param>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Application code should not need to create instances of <see cref="StateEntry{T}" />. Use
|
/// Application code should not need to create instances of <see cref="StateEntry{T}" />. Use
|
||||||
|
/// <see cref="Dapr.Client.DaprClient.GetStateEntryAsync{TValue}(string, string, ConsistencyMode?, CancellationToken)" /> to access
|
||||||
/// state entries.
|
/// state entries.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public StateEntry(DaprClient client, string storeName, string key, TValue value, string etag)
|
public StateEntry(DaprClient client, string storeName, string key, TValue value, string etag)
|
||||||
|
@ -77,6 +78,16 @@ namespace Dapr
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ETag { get; }
|
public string ETag { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the entry associated with <see cref="Key" /> in the state store.
|
||||||
|
/// </summary>
|
||||||
|
/// <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.</returns>
|
||||||
|
public ValueTask DeleteAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.DeleteAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the entry associated with <see cref="Key" /> in the state store.
|
/// Deletes the entry associated with <see cref="Key" /> in the state store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -89,6 +100,16 @@ namespace Dapr
|
||||||
return this.client.DeleteStateAsync(this.StoreName, this.Key, null, stateOptions, cancellationToken);
|
return this.client.DeleteStateAsync(this.StoreName, this.Key, null, stateOptions, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the current value of <see cref="Value" /> to the state store.
|
||||||
|
/// </summary>
|
||||||
|
/// <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.</returns>
|
||||||
|
public ValueTask SaveAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.SaveAsync(null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the current value of <see cref="Value" /> to the state store.
|
/// Saves the current value of <see cref="Value" /> to the state store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -102,6 +123,16 @@ namespace Dapr
|
||||||
return this.client.SaveStateAsync(this.StoreName, this.Key, this.Value, null, metadata, stateRequestOptions, cancellationToken);
|
return this.client.SaveStateAsync(this.StoreName, this.Key, this.Value, null, metadata, stateRequestOptions, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the current value of <see cref="Value" /> to the state store.
|
||||||
|
/// </summary>
|
||||||
|
/// <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.</returns>
|
||||||
|
public ValueTask<bool> TrySaveAsync(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return this.TrySaveAsync(null, null, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the current value of <see cref="Value" /> to the state store.
|
/// Saves the current value of <see cref="Value" /> to the state store.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue