Skip to content

Commit

Permalink
add optional methods to IStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Eckhardt committed Jan 8, 2025
1 parent 59e1608 commit 42d2cae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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.
/// </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) => Task.CompletedTask;

/// <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) => Task.CompletedTask;

/// <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) => Task.CompletedTask;
}

/// <summary>
Expand Down

0 comments on commit 42d2cae

Please sign in to comment.