forked from kurrent-io/KurrentDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIEventStoreConnection.cs
627 lines (579 loc) · 40.3 KB
/
IEventStoreConnection.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EventStore.ClientAPI.Internal;
using EventStore.ClientAPI.SystemData;
namespace EventStore.ClientAPI
{
/// <summary>
/// Maintains a full duplex connection to the EventStore
/// </summary>
/// <remarks>
/// An <see cref="IEventStoreConnection"/> operates quite differently than say a SqlConnection. Normally
/// when using an <see cref="IEventStoreConnection"/> you want to keep the connection open for a much longer of time than
/// when you use a SqlConnection. If you prefer the usage pattern of using(new Connection()) .. then you would likely
/// want to create a FlyWeight on top of the <see cref="EventStoreConnection"/>.
///
/// Another difference is that with the <see cref="IEventStoreConnection"/> all operations are handled in a full async manner
/// (even if you call the synchronous behaviors). Many threads can use an <see cref="IEventStoreConnection"/> at the same
/// time or a single thread can make many asynchronous requests. To get the most performance out of the connection
/// it is generally recommended to use it in this way.
/// </remarks>
public interface IEventStoreConnection : IDisposable
{
/// <summary>
/// Gets the name of this connection. A connection name can be used for disambiguation
/// in log files.
/// </summary>
string ConnectionName { get; }
/// <summary>
/// Connects the <see cref="IEventStoreConnection"/> asynchronously to a destination
/// </summary>
/// <returns>A <see cref="Task"/> that can be waited upon.</returns>
Task ConnectAsync();
/// <summary>
/// Closes this <see cref="IEventStoreConnection"/>
/// </summary>
void Close();
/// <summary>
/// Deletes a stream from the Event Store asynchronously
/// </summary>
/// <param name="stream">The name of the stream to delete.</param>
/// <param name="expectedVersion">The expected version that the streams should have when being deleted. <see cref="ExpectedVersion"/></param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="Task"/> that can be awaited upon by the caller.</returns>
Task<DeleteResult> DeleteStreamAsync(string stream, long expectedVersion, UserCredentials userCredentials = null);
/// <summary>
/// Deletes a stream from the Event Store asynchronously
/// </summary>
/// <param name="stream">The name of the stream to delete.</param>
/// <param name="expectedVersion">The expected version that the streams should have when being deleted. <see cref="ExpectedVersion"/></param>
/// <param name="hardDelete">Indicator for tombstoning vs soft-deleting the stream. Tombstoned streams can never be recreated. Soft-deleted streams
/// can be written to again, but the EventNumber sequence will not start from 0.</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="Task"/> that can be awaited upon by the caller.</returns>
Task<DeleteResult> DeleteStreamAsync(string stream, long expectedVersion, bool hardDelete, UserCredentials userCredentials = null);
/// <summary>
/// Appends Events asynchronously to a stream.
/// </summary>
/// <remarks>
/// When appending events to a stream the <see cref="ExpectedVersion"/> choice can
/// make a very large difference in the observed behavior. For example, if no stream exists
/// and ExpectedVersion.Any is used, a new stream will be implicitly created when appending.
///
/// There are also differences in idempotency between different types of calls.
/// If you specify an ExpectedVersion aside from ExpectedVersion.Any the Event Store
/// will give you an idempotency guarantee. If using ExpectedVersion.Any the Event Store
/// will do its best to provide idempotency but does not guarantee idempotency
/// </remarks>
/// <param name="stream">The name of the stream to append events to</param>
/// <param name="expectedVersion">The <see cref="ExpectedVersion"/> of the stream to append to</param>
/// <param name="events">The events to append to the stream</param>
Task<WriteResult> AppendToStreamAsync(string stream, long expectedVersion, params EventData[] events);
/// <summary>
/// Appends Events asynchronously to a stream.
/// </summary>
/// <remarks>
/// When appending events to a stream the <see cref="ExpectedVersion"/> choice can
/// make a very large difference in the observed behavior. For example, if no stream exists
/// and ExpectedVersion.Any is used, a new stream will be implicitly created when appending.
///
/// There are also differences in idempotency between different types of calls.
/// If you specify an ExpectedVersion aside from ExpectedVersion.Any the Event Store
/// will give you an idempotency guarantee. If using ExpectedVersion.Any the Event Store
/// will do its best to provide idempotency but does not guarantee idempotency
/// </remarks>
/// <param name="stream">The name of the stream to append events to</param>
/// <param name="expectedVersion">The <see cref="ExpectedVersion"/> of the stream to append to</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <param name="events">The events to append to the stream</param>
Task<WriteResult> AppendToStreamAsync(string stream, long expectedVersion, UserCredentials userCredentials, params EventData[] events);
/// <summary>
/// Appends Events asynchronously to a stream.
/// </summary>
/// <remarks>
/// When appending events to a stream the <see cref="ExpectedVersion"/> choice can
/// make a very large difference in the observed behavior. For example, if no stream exists
/// and ExpectedVersion.Any is used, a new stream will be implicitly created when appending.
///
/// There are also differences in idempotency between different types of calls.
/// If you specify an ExpectedVersion aside from ExpectedVersion.Any the Event Store
/// will give you an idempotency guarantee. If using ExpectedVersion.Any the Event Store
/// will do its best to provide idempotency but does not guarantee idempotency
/// </remarks>
/// <param name="stream">The name of the stream to append events to</param>
/// <param name="expectedVersion">The <see cref="ExpectedVersion"/> of the stream to append to</param>
/// <param name="events">The events to append to the stream</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
Task<WriteResult> AppendToStreamAsync(string stream, long expectedVersion, IEnumerable<EventData> events, UserCredentials userCredentials = null);
/// <summary>
/// Appends Events asynchronously to a stream if the stream version matches the <paramref name="expectedVersion"/>.
/// </summary>
/// <remarks>
/// When appending events to a stream the <see cref="ExpectedVersion"/> choice can
/// make a very large difference in the observed behavior. For example, if no stream exists
/// and ExpectedVersion.Any is used, a new stream will be implicitly created when appending.
///
/// There are also differences in idempotency between different types of calls.
/// If you specify an ExpectedVersion aside from ExpectedVersion.Any the Event Store
/// will give you an idempotency guarantee. If using ExpectedVersion.Any the Event Store
/// will do its best to provide idempotency but does not guarantee idempotency
/// </remarks>
/// <param name="stream">The name of the stream to append events to</param>
/// <param name="expectedVersion">The <see cref="ExpectedVersion"/> of the stream to append to</param>
/// <param name="events">The events to append to the stream</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>If the operation succeeded and, if not, the reason for failure (which can be either stream version mismatch or trying to write to a deleted stream)</returns>
Task<ConditionalWriteResult> ConditionalAppendToStreamAsync(string stream, long expectedVersion, IEnumerable<EventData> events, UserCredentials userCredentials = null);
/// <summary>
/// Starts a transaction in the event store on a given stream asynchronously
/// </summary>
/// <remarks>
/// A <see cref="EventStoreTransaction"/> allows the calling of multiple writes with multiple
/// round trips over long periods of time between the caller and the event store. This method
/// is only available through the TCP interface and no equivalent exists for the RESTful interface.
/// </remarks>
/// <param name="stream">The stream to start a transaction on</param>
/// <param name="expectedVersion">The expected version of the stream at the time of starting the transaction</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A task the caller can use to control the operation.</returns>
Task<EventStoreTransaction> StartTransactionAsync(string stream, long expectedVersion, UserCredentials userCredentials = null);
/// <summary>
/// Continues transaction by provided transaction ID.
/// </summary>
/// <remarks>
/// A <see cref="EventStoreTransaction"/> allows the calling of multiple writes with multiple
/// round trips over long periods of time between the caller and the event store. This method
/// is only available through the TCP interface and no equivalent exists for the RESTful interface.
/// </remarks>
/// <param name="transactionId">The transaction ID that needs to be continued.</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns><see cref="EventStoreTransaction"/> object.</returns>
EventStoreTransaction ContinueTransaction(long transactionId, UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously reads a single event from a stream.
/// </summary>
/// <param name="stream">The stream to read from</param>
/// <param name="eventNumber">The event number to read, <see cref="StreamPosition">StreamPosition.End</see> to read the last event in the stream</param>
/// <param name="resolveLinkTos">Whether to resolve LinkTo events automatically</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="Task<EventReadResult>"/> containing the results of the read operation</returns>
Task<EventReadResult> ReadEventAsync(string stream, long eventNumber, bool resolveLinkTos, UserCredentials userCredentials = null);
/// <summary>
/// Reads count Events from an Event Stream forwards (e.g. oldest to newest) starting from position start
/// </summary>
/// <param name="stream">The stream to read from</param>
/// <param name="start">The starting point to read from</param>
/// <param name="count">The count of items to read</param>
/// <param name="resolveLinkTos">Whether to resolve LinkTo events automatically</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="Task<StreamEventsSlice>"/> containing the results of the read operation</returns>
Task<StreamEventsSlice> ReadStreamEventsForwardAsync(string stream, long start, int count, bool resolveLinkTos, UserCredentials userCredentials = null);
/// <summary>
/// Reads count events from an Event Stream backwards (e.g. newest to oldest) from position asynchronously
/// </summary>
/// <param name="stream">The Event Stream to read from</param>
/// <param name="start">The position to start reading from</param>
/// <param name="count">The count to read from the position</param>
/// <param name="resolveLinkTos">Whether to resolve LinkTo events automatically</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>An <see cref="Task<StreamEventsSlice>"/> containing the results of the read operation</returns>
Task<StreamEventsSlice> ReadStreamEventsBackwardAsync(string stream, long start, int count, bool resolveLinkTos, UserCredentials userCredentials = null);
/// <summary>
/// Reads All Events in the node forward asynchronously (e.g. beginning to end)
/// </summary>
/// <param name="position">The position to start reading from</param>
/// <param name="maxCount">The maximum count to read</param>
/// <param name="resolveLinkTos">Whether to resolve LinkTo events automatically</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="AllEventsSlice"/> containing the records read</returns>
Task<AllEventsSlice> ReadAllEventsForwardAsync(Position position, int maxCount, bool resolveLinkTos, UserCredentials userCredentials = null);
/// <summary>
/// Reads All Events in the node backwards (e.g. end to beginning)
/// </summary>
/// <param name="position">The position to start reading from</param>
/// <param name="maxCount">The maximum count to read</param>
/// <param name="resolveLinkTos">Whether to resolve Link events automatically</param>
/// <param name="userCredentials">The optional user credentials to perform operation with.</param>
/// <returns>A <see cref="AllEventsSlice"/> containing the records read</returns>
Task<AllEventsSlice> ReadAllEventsBackwardAsync(Position position, int maxCount, bool resolveLinkTos, UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously subscribes to a single event stream. New events
/// written to the stream while the subscription is active will be
/// pushed to the client.
/// </summary>
/// <param name="stream">The stream to subscribe to</param>
/// <param name="resolveLinkTos">Whether to resolve Link events automatically</param>
/// <param name="eventAppeared">An action invoked when a new event is received over the subscription</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
Task<EventStoreSubscription> SubscribeToStreamAsync(
string stream,
bool resolveLinkTos,
Action<EventStoreSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null);
/// <summary>
/// Subscribes to a single event stream. Existing events from
/// lastCheckpoint onwards are read from the stream
/// and presented to the user of <see cref="EventStoreCatchUpSubscription"/>
/// as if they had been pushed.
///
/// Once the end of the stream is read the subscription is
/// transparently (to the user) switched to push new events as
/// they are written.
///
/// The action liveProcessingStarted is called when the
/// <see cref="EventStoreCatchUpSubscription"/> switches from the reading
/// phase to the live subscription phase.
/// </summary>
/// <param name="stream">The stream to subscribe to</param>
/// <param name="lastCheckpoint">The event number from which to start.
///
/// To receive all events in the stream, use <see cref="StreamCheckpoint.StreamStart" />.
/// If events have already been received and resubscription from the same point
/// is desired, use the event number of the last event processed which
/// appeared on the subscription.
///
/// NOTE: Using <see cref="StreamPosition.Start" /> here will result in missing
/// the first event in the stream.</param>
/// <param name="resolveLinkTos">Whether to resolve Link events automatically</param>
/// <param name="eventAppeared">An action invoked when an event is received over the subscription</param>
/// <param name="liveProcessingStarted">An action invoked when the subscription switches to newly-pushed events</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="readBatchSize">The batch size to use during the read phase</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
[Obsolete("This method will be obsoleted in the next major version please switch to the overload with a settings object")]
EventStoreStreamCatchUpSubscription SubscribeToStreamFrom(
string stream,
long? lastCheckpoint,
bool resolveLinkTos,
Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreCatchUpSubscription> liveProcessingStarted = null,
Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null,
int readBatchSize = 500);
/// <summary>
/// Subscribes to a single event stream. Existing events from
/// lastCheckpoint onwards are read from the stream
/// and presented to the user of <see cref="EventStoreCatchUpSubscription"/>
/// as if they had been pushed.
///
/// Once the end of the stream is read the subscription is
/// transparently (to the user) switched to push new events as
/// they are written.
///
/// The action liveProcessingStarted is called when the
/// <see cref="EventStoreCatchUpSubscription"/> switches from the reading
/// phase to the live subscription phase.
/// </summary>
/// <param name="stream">The stream to subscribe to</param>
/// <param name="lastCheckpoint">The event number from which to start.
///
/// To receive all events in the stream, use <see cref="StreamCheckpoint.StreamStart" />.
/// If events have already been received and resubscription from the same point
/// is desired, use the event number of the last event processed which
/// appeared on the subscription.
///
/// NOTE: Using <see cref="StreamPosition.Start" /> here will result in missing
/// the first event in the stream.</param>
/// <param name="eventAppeared">An action invoked when an event is received over the subscription</param>
/// <param name="liveProcessingStarted">An action invoked when the subscription switches to newly-pushed events</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="settings">The <see cref="CatchUpSubscriptionSettings"/> for the subscription</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
EventStoreStreamCatchUpSubscription SubscribeToStreamFrom(
string stream,
long? lastCheckpoint,
CatchUpSubscriptionSettings settings,
Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreCatchUpSubscription> liveProcessingStarted = null,
Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously subscribes to all events in the Event Store. New
/// events written to the stream while the subscription is active
/// will be pushed to the client.
/// </summary>
/// <param name="resolveLinkTos">Whether to resolve Link events automatically</param>
/// <param name="eventAppeared">An action invoked when a new event is received over the subscription</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
Task<EventStoreSubscription> SubscribeToAllAsync(
bool resolveLinkTos,
Action<EventStoreSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null);
/// <summary>
/// Subscribes to a persistent subscription(competing consumer) on event store
/// </summary>
/// <param name="groupName">The subscription group to connect to</param>
/// <param name="stream">The stream to subscribe to</param>
/// <param name="eventAppeared">An action invoked when an event appears</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="bufferSize">The buffer size to use for the persistent subscription</param>
/// <param name="autoAck">Whether the subscription should automatically acknowledge messages processed.
/// If not set the receiver is required to explicitly acknowledge messages through the subscription.</param>
/// <remarks>This will connect you to a persistent subscription group for a stream. The subscription group
/// must first be created with CreatePersistentSubscriptionAsync many connections
/// can connect to the same group and they will be treated as competing consumers within the group.
/// If one connection dies work will be balanced across the rest of the consumers in the group. If
/// you attempt to connect to a group that does not exist you will be given an exception.
/// </remarks>
/// <returns>An <see cref="EventStorePersistentSubscriptionBase"/> representing the subscription</returns>
EventStorePersistentSubscriptionBase ConnectToPersistentSubscription(
string stream,
string groupName,
Action<EventStorePersistentSubscriptionBase, ResolvedEvent> eventAppeared,
Action<EventStorePersistentSubscriptionBase, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null,
int bufferSize = 10,
bool autoAck = true);
/// <summary>
/// Asynchronously subscribes to a persistent subscription(competing consumer) on event store
/// </summary>
/// <param name="groupName">The subscription group to connect to</param>
/// <param name="stream">The stream to subscribe to</param>
/// <param name="eventAppeared">An action invoked when an event appears</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="bufferSize">The buffer size to use for the persistent subscription</param>
/// <param name="autoAck">Whether the subscription should automatically acknowledge messages processed.
/// If not set the receiver is required to explicitly acknowledge messages through the subscription.</param>
/// <remarks>This will connect you to a persistent subscription group for a stream. The subscription group
/// must first be created with CreatePersistentSubscriptionAsync many connections
/// can connect to the same group and they will be treated as competing consumers within the group.
/// If one connection dies work will be balanced across the rest of the consumers in the group. If
/// you attempt to connect to a group that does not exist you will be given an exception.
/// </remarks>
/// <returns>An <see cref="EventStorePersistentSubscriptionBase"/> representing the subscription</returns>
Task<EventStorePersistentSubscriptionBase> ConnectToPersistentSubscriptionAsync(
string stream,
string groupName,
Action<EventStorePersistentSubscriptionBase, ResolvedEvent> eventAppeared,
Action<EventStorePersistentSubscriptionBase, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null,
int bufferSize = 10,
bool autoAck = true);
/*
/// <summary>
/// Subscribes a persistent subscription (competing consumer) to all events in the event store
/// </summary>
/// <param name="groupName">The subscription group to connect to</param>
/// <param name="eventAppeared">An action invoked when an event appears</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="bufferSize">The buffer size to use for the persistent subscription</param>
/// <param name="autoAck">Whether the subscription should automatically acknowledge messages processed.
/// If not set the receiver is required to explicitly acknowledge messages through the subscription.</param>
/// <remarks>This will connect you to a persistent subscription group for all events. The subscription group
/// must first be created with CreatePersistentSubscriptionAsync many connections
/// can connect to the same group and they will be treated as competing consumers within the group.
/// If one connection dies work will be balanced across the rest of the consumers in the group. If
/// you attempt to connect to a group that does not exist you will be given an exception.
/// </remarks>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
EventStorePersistentSubscription ConnectToPersistentSubscriptionForAll(
string groupName,
Action<EventStorePersistentSubscription, ResolvedEvent> eventAppeared,
Action<EventStorePersistentSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null,
int? bufferSize = null,
bool autoAck = true);
*/
/// <summary>
/// Subscribes to all events. Existing events from lastCheckpoint
/// onwards are read from the Event Store and presented to the user of
/// <see cref="EventStoreCatchUpSubscription"/> as if they had been pushed.
///
/// Once the end of the stream is read the subscription is
/// transparently (to the user) switched to push new events as
/// they are written.
///
/// The action liveProcessingStarted is called when the
/// <see cref="EventStoreCatchUpSubscription"/> switches from the reading
/// phase to the live subscription phase.
/// </summary>
/// <param name="lastCheckpoint">The position from which to start.
///
/// To receive all events in the database, use <see cref="AllCheckpoint.AllStart" />.
/// If events have already been received and resubscription from the same point
/// is desired, use the position representing the last event processed which
/// appeared on the subscription.
///
/// NOTE: Using <see cref="Position.Start" /> here will result in missing
/// the first event in the stream.</param>
/// <param name="resolveLinkTos">Whether to resolve Link events automatically</param>
/// <param name="eventAppeared">An action invoked when an event is received over the subscription</param>
/// <param name="liveProcessingStarted">An action invoked when the subscription switches to newly-pushed events</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="readBatchSize">The batch size to use during the read phase</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
[Obsolete("This overload will be removed in the next major release please use the overload with a settings object")]
EventStoreAllCatchUpSubscription SubscribeToAllFrom(
Position? lastCheckpoint,
bool resolveLinkTos,
Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreCatchUpSubscription> liveProcessingStarted = null,
Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null,
int readBatchSize = 500);
/// <summary>
/// Subscribes to a all events. Existing events from lastCheckpoint
/// onwards are read from the Event Store and presented to the user of
/// <see cref="EventStoreCatchUpSubscription"/> as if they had been pushed.
///
/// Once the end of the stream is read the subscription is
/// transparently (to the user) switched to push new events as
/// they are written.
///
/// The action liveProcessingStarted is called when the
/// <see cref="EventStoreCatchUpSubscription"/> switches from the reading
/// phase to the live subscription phase.
/// </summary>
/// <param name="lastCheckpoint">The position from which to start.
///
/// To receive all events in the database, use <see cref="AllCheckpoint.AllStart" />.
/// If events have already been received and resubscription from the same point
/// is desired, use the position representing the last event processed which
/// appeared on the subscription.
///
/// NOTE: Using <see cref="Position.Start" /> here will result in missing
/// the first event in the stream.</param>
/// <param name="eventAppeared">An action invoked when an event is received over the subscription</param>
/// <param name="liveProcessingStarted">An action invoked when the subscription switches to newly-pushed events</param>
/// <param name="subscriptionDropped">An action invoked if the subscription is dropped</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <param name="settings">The <see cref="CatchUpSubscriptionSettings"/> for the subscription</param>
/// <returns>An <see cref="EventStoreSubscription"/> representing the subscription</returns>
EventStoreAllCatchUpSubscription SubscribeToAllFrom(
Position? lastCheckpoint,
CatchUpSubscriptionSettings settings,
Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared,
Action<EventStoreCatchUpSubscription> liveProcessingStarted = null,
Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,
UserCredentials userCredentials = null);
/*
/// <summary>
/// Asynchronously create a persistent subscription group for all events
/// </summary>
/// <param name="groupName">The name of the group to create</param>
/// <param name="settings">The <see cref="PersistentSubscriptionSettings"></see> for the subscription</param>
/// /// <param name="credentials">The credentials to be used for this operation.</param>
/// <returns>A <see cref="PersistentSubscriptionCreateResult"/>.</returns>
Task<PersistentSubscriptionCreateResult> CreatePersistentSubscriptionForAllAsync(string groupName, PersistentSubscriptionSettings settings, UserCredentials credentials);
*/
/// <summary>
/// Asynchronously update a persistent subscription group on a stream
/// </summary>
/// <param name="stream">The name of the stream to create the persistent subscription on</param>
/// <param name="groupName">The name of the group to create</param>
/// <param name="settings">The <see cref="PersistentSubscriptionSettings"></see> for the subscription</param>
/// <param name="credentials">The credentials to be used for this operation.</param>
/// <returns>A <see cref="PersistentSubscriptionCreateResult"/>.</returns>
Task UpdatePersistentSubscriptionAsync(string stream, string groupName, PersistentSubscriptionSettings settings, UserCredentials credentials);
/// <summary>
/// Asynchronously create a persistent subscription group on a stream
/// </summary>
/// <param name="stream">The name of the stream to create the persistent subscription on</param>
/// <param name="groupName">The name of the group to create</param>
/// <param name="settings">The <see cref="PersistentSubscriptionSettings"></see> for the subscription</param>
/// <param name="credentials">The credentials to be used for this operation.</param>
/// <returns>A <see cref="PersistentSubscriptionCreateResult"/>.</returns>
Task CreatePersistentSubscriptionAsync(string stream, string groupName, PersistentSubscriptionSettings settings, UserCredentials credentials);
/// <summary>
/// Asynchronously delete a persistent subscription group on a stream
/// </summary>
/// <param name="stream">The name of the stream to delete the persistent subscription on</param>
/// <param name="groupName">The name of the group to delete</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <returns>A <see cref="PersistentSubscriptionDeleteResult"/>.</returns>
Task DeletePersistentSubscriptionAsync(string stream, string groupName, UserCredentials userCredentials = null);
/*
/// <summary>
/// Asynchronously delete a persistent subscription group for all events
/// </summary>
/// <param name="groupName">The name of the group to delete</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <returns>A <see cref="PersistentSubscriptionDeleteResult"/>.</returns>
Task<PersistentSubscriptionDeleteResult> DeletePersistentSubscriptionForAllAsync(string groupName, UserCredentials userCredentials = null);
*/
/// <summary>
/// Asynchronously sets the metadata for a stream.
/// </summary>
/// <param name="stream">The name of the stream for which to set metadata.</param>
/// <param name="expectedMetastreamVersion">The expected version for the write to the metadata stream.</param>
/// <param name="metadata">A <see cref="StreamMetadata"/> representing the new metadata.</param>
/// <param name="userCredentials">User credentials to use for the operation</param>
/// <returns>A <see cref="WriteResult"/>.</returns>
Task<WriteResult> SetStreamMetadataAsync(string stream, long expectedMetastreamVersion, StreamMetadata metadata, UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously sets the metadata for a stream.
/// </summary>
/// <param name="stream">The name of the stream for which to set metadata.</param>
/// <param name="expectedMetastreamVersion">The expected version for the write to the metadata stream.</param>
/// <param name="metadata">A byte array representing the new metadata.</param>
/// <param name="userCredentials">User credentials to use for the operation.</param>
/// <returns>A <see cref="WriteResult"/>.</returns>
Task<WriteResult> SetStreamMetadataAsync(string stream, long expectedMetastreamVersion, byte[] metadata, UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously reads the metadata for a stream and converts the metadata into a <see cref="StreamMetadata"/>.
/// </summary>
/// <param name="stream">The name of the stream for which to read metadata.</param>
/// <param name="userCredentials">User credentials to use for the operation.</param>
/// <returns>A <see cref="StreamMetadataResult"/> representing the result of the operation.</returns>
Task<StreamMetadataResult> GetStreamMetadataAsync(string stream, UserCredentials userCredentials = null);
/// <summary>
/// Asynchronously reads the metadata for a stream as a byte array.
/// </summary>
/// <param name="stream">The name of the stream for which to read metadata.</param>
/// <param name="userCredentials">User credentials to use for the operation.</param>
/// <returns>A <see cref="StreamMetadataResult"/> representing the result of the operation.</returns>
Task<RawStreamMetadataResult> GetStreamMetadataAsRawBytesAsync(string stream, UserCredentials userCredentials = null);
/// <summary>
/// Sets the global settings for the server or cluster to which the <see cref="IEventStoreConnection"/>
/// is connected.
/// </summary>
/// <param name="settings">The <see cref="SystemSettings"/> to apply.</param>
/// <param name="userCredentials">User credentials to use for the operation.</param>
Task SetSystemSettingsAsync(SystemSettings settings, UserCredentials userCredentials = null);
/// <summary>
/// Fired when an <see cref="IEventStoreConnection"/> connects to an Event Store server.
/// </summary>
event EventHandler<ClientConnectionEventArgs> Connected;
/// <summary>
/// Fired when an <see cref="IEventStoreConnection"/> is disconnected from an Event Store server
/// by some means other than by calling the <see cref="Close"/> method.
/// </summary>
event EventHandler<ClientConnectionEventArgs> Disconnected;
/// <summary>
/// Fired when an <see cref="IEventStoreConnection"/> is attempting to reconnect to an Event Store
/// server following a disconnection.
/// </summary>
event EventHandler<ClientReconnectingEventArgs> Reconnecting;
/// <summary>
/// Fired when an <see cref="IEventStoreConnection"/> is closed either using the <see cref="Close"/>
/// method, or when reconnection limits are reached without a successful connection being established.
/// </summary>
event EventHandler<ClientClosedEventArgs> Closed;
/// <summary>
/// Fired when an error is thrown on an <see cref="IEventStoreConnection"/>.
/// </summary>
event EventHandler<ClientErrorEventArgs> ErrorOccurred;
/// <summary>
/// Fired when a client fails to authenticate to an Event Store server.
/// </summary>
event EventHandler<ClientAuthenticationFailedEventArgs> AuthenticationFailed;
/// <summary>
/// A <see cref="ConnectionSettings"/> object is an immutable representation of the settings for an
/// <see cref="IEventStoreConnection"/>.
/// </summary>
ConnectionSettings Settings { get; }
}
}