Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional Methods w/ CancellationToken to IStorage #9279

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CosmosGrainStorageOptions : CosmosOptions
public int InitStage { get; set; } = DEFAULT_INIT_STAGE;

/// <summary>
/// Gets or sets a value indicating whether state should be deleted when <see cref="IStorage.ClearStateAsync"/> is called.
/// Gets or sets a value indicating whether state should be deleted when <see cref="IStorage.ClearStateAsync()"/> is called.
Chris-Eckhardt marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public bool DeleteStateOnClear { get; set; }

Expand Down
38 changes: 38 additions & 0 deletions src/Orleans.Core.Abstractions/Core/IStorage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading;
using System.Threading.Tasks;

namespace Orleans.Core
Expand Down Expand Up @@ -53,6 +54,43 @@ public interface IStorage
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task ReadStateAsync();

/// <summary>
/// (Optional) Clears the grain state.
/// </summary>
/// <param name="cancellationToken"></param>
/// <remarks>
/// This will usually mean the state record is deleted from backing store, but the specific behavior is defined by the storage provider instance configured for this grain.
/// If the Etag does not match what is present in the backing store, then this operation will fail; Set <see cref="Etag"/> to <see langword="null"/> to indicate "always delete".
/// </remarks>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task ClearStateAsync(CancellationToken cancellationToken) => ClearStateAsync();

/// <summary>
/// (Optional) Writes grain state to storage.
/// </summary>
/// <param name="cancellationToken"></param>
/// <remarks>
/// If the Etag does not match what is present in the backing store, then this operation will fail; Set <see cref="Etag"/> to <see langword="null"/> to indicate "always delete".
/// </remarks>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task WriteStateAsync(CancellationToken cancellationToken) => WriteStateAsync();

/// <summary>
/// (Optional) Reads grain state from storage.
/// </summary>
/// <param name="cancellationToken"></param>
/// <remarks>
/// Any previous contents of the grain state data will be overwritten.
/// </remarks>
/// <returns>
/// A <see cref="Task"/> representing the operation.
/// </returns>
Task ReadStateAsync(CancellationToken cancellationToken) => ReadStateAsync();
}

/// <summary>
Expand Down
Loading