-
Notifications
You must be signed in to change notification settings - Fork 2k
/
ICustomStorageInterface.cs
31 lines (28 loc) · 1.38 KB
/
ICustomStorageInterface.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Orleans.EventSourcing.CustomStorage
{
/// <summary>
/// The storage interface exposed by grains that want to use the CustomStorage log-consistency provider
/// <typeparam name="TState">The type for the state of the grain.</typeparam>
/// <typeparam name="TDelta">The type for delta objects that represent updates to the state.</typeparam>
/// </summary>
public interface ICustomStorageInterface<TState, TDelta>
{
/// <summary>
/// Reads the current state and version from storage
/// (note that the state object may be mutated by the provider, so it must not be shared).
/// </summary>
/// <returns>the version number and a state object.</returns>
Task<KeyValuePair<int,TState>> ReadStateFromStorage();
/// <summary>
/// Applies the given array of deltas to storage, and returns true, if the version in storage matches the expected version.
/// Otherwise, does nothing and returns false. If successful, the version of storage must be increased by the number of deltas.
/// </summary>
/// <returns>true if the deltas were applied, false otherwise</returns>
Task<bool> ApplyUpdatesToStorage(IReadOnlyList<TDelta> updates, int expectedversion);
}
}