forked from SQLStreamStore/SQLStreamStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIStreamStore.cs
More file actions
121 lines (117 loc) · 5.8 KB
/
Copy pathIStreamStore.cs
File metadata and controls
121 lines (117 loc) · 5.8 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
namespace SqlStreamStore
{
using System;
using System.Threading;
using System.Threading.Tasks;
using SqlStreamStore.Streams;
public interface IStreamStore : IReadonlyStreamStore
{
/// <summary>
/// Appends a collection of messages to a stream.
/// </summary>
/// <remarks>
/// Idempotency and concurrency handling is dependent on the choice of expected version and the messages
/// to append.
///
/// 1. When expectedVersion = ExpectedVersion.NoStream and the stream already exists and the collection of
/// message IDs are not already in the stream, then <see cref="WrongExpectedVersionException"/> is
/// throw.
/// 2. When expectedVersion = ExpectedVersion.Any and the collection of messages IDs don't exist in the
/// stream, then they are appended
/// 3. When expectedVersion = ExpectedVersion.Any and the collection of messages IDs exist in the stream,
/// then idempotency is applied and nothing happens.
/// 4. When expectedVersion = ExpectedVersion.Any and of the collection of messages Ids some exist in the
/// stream and some don't then a <see cref="WrongExpectedVersionException"/> will be throwm.
/// 5. When expectedVersion is specified and the stream current version does not match the
/// collection of message IDs are are checked against the stream in the correct position then the
/// operation is considered idempotent. Otherwise a <see cref="WrongExpectedVersionException"/> will be
/// throwm.
/// </remarks>
/// <param name="streamId">
/// The Stream Id of the stream to append the messages. Must not start with a '$'.
/// </param>
/// <param name="expectedVersion">
/// The version of the stream that is expected. This is used to control concurrency and idempotency
/// concerns. See <see cref="ExpectedVersion"/>.
/// </param>
/// <param name="messages">
/// The collection of messages to append.
/// </param>
/// <param name="cancellationToken">
/// The cancellation instruction.
/// </param>
/// <returns>A task representing the asynchronous operation.</returns>
Task AppendToStream(
string streamId,
int expectedVersion,
NewStreamMessage[] messages,
CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Hard deletes a stream and all of its messages. Deleting a stream will result in a '$stream-deleted'
/// message being appended to the '$deleted' stream. See <see cref="Deleted.StreamDeleted"/> for the
/// message structure.
/// </summary>
/// <param name="streamId">
/// The stream Id to delete.
/// </param>
/// <param name="expectedVersion">
/// The stream expected version. See <see cref="ExpectedVersion"/> for const values.
/// </param>
/// <param name="cancellationToken">
/// The cancellation instruction.
/// </param>
/// <returns>
/// A task representing the asynchronous operation.
/// </returns>
Task DeleteStream(
string streamId,
int expectedVersion = ExpectedVersion.Any,
CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Hard deletes a message from the stream. Deleting a message will result in a '$message-deleted'
/// message being appended to the '$deleted' stream. See <see cref="Deleted.MessageDeleted"/> for the
/// message structure.
/// </summary>
/// <param name="streamId">
/// The stream to delete.
/// </param>
/// <param name="messageId">
/// The message to delete. If the message doesn't exist then nothing happens.
/// </param>
/// <param name="cancellationToken">
/// The cancellation instruction.
/// </param>
/// <returns>
/// A task representing the asynchronous operation.
/// </returns>
Task DeleteMessage(
string streamId,
Guid messageId,
CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Sets the metadata for a stream.
/// </summary>
/// <param name="streamId">The stream Id to whose metadata is to be set.</param>
/// <param name="expectedStreamMetadataVersion">
/// The expected version number of the metadata stream to apply the metadata. Used for concurrency
/// handling. Default value is <see cref="ExpectedVersion.Any"/>. If specified and does not match
/// current version then <see cref="WrongExpectedVersionException"/> will be thrown.
/// </param>
/// <param name="maxAge">The max age of the messages in the stream in seconds.</param>
/// <param name="maxCount">The max count of messages in the stream.</param>
/// <param name="metadataJson">Custom meta data to associate with the stream.</param>
/// <param name="cancellationToken">
/// The cancellation instruction.
/// </param>
/// <returns>
/// A task representing the asynchronous operation.
/// </returns>
Task SetStreamMetadata(
string streamId,
int expectedStreamMetadataVersion = ExpectedVersion.Any,
int? maxAge = null,
int? maxCount = null,
string metadataJson = null,
CancellationToken cancellationToken = default(CancellationToken));
}
}