@@ -8,32 +8,80 @@ public partial class KurrentDBClient {
8
8
/// </summary>
9
9
/// <param name="streamName">The name of the stream to tombstone.</param>
10
10
/// <param name="expectedState">The expected <see cref="StreamState"/> of the stream being deleted.</param>
11
- /// <param name="deadline"></param>
12
- /// <param name="userCredentials">The optional <see cref="UserCredentials"/> to perform operation with.</param>
11
+ /// <param name="options">Optional settings for the tombstone operation, e.g. deadline, user credentials etc.</param>
13
12
/// <param name="cancellationToken">The optional <see cref="System.Threading.CancellationToken"/>.</param>
14
13
/// <returns></returns>
15
14
public Task < DeleteResult > TombstoneAsync (
16
15
string streamName ,
17
16
StreamState expectedState ,
18
- TimeSpan ? deadline = null ,
19
- UserCredentials ? userCredentials = null ,
20
- CancellationToken cancellationToken = default ) => TombstoneInternal ( new TombstoneReq {
21
- Options = new TombstoneReq . Types . Options {
22
- StreamIdentifier = streamName
23
- }
24
- } . WithAnyStreamRevision ( expectedState ) , deadline , userCredentials , cancellationToken ) ;
17
+ TombstoneOptions ? options = null ,
18
+ CancellationToken cancellationToken = default
19
+ ) =>
20
+ TombstoneInternal (
21
+ new TombstoneReq {
22
+ Options = new TombstoneReq . Types . Options {
23
+ StreamIdentifier = streamName
24
+ }
25
+ } . WithAnyStreamRevision ( expectedState ) ,
26
+ options ,
27
+ cancellationToken
28
+ ) ;
25
29
26
- private async Task < DeleteResult > TombstoneInternal ( TombstoneReq request , TimeSpan ? deadline ,
27
- UserCredentials ? userCredentials , CancellationToken cancellationToken ) {
30
+ async Task < DeleteResult > TombstoneInternal (
31
+ TombstoneReq request ,
32
+ TombstoneOptions ? options ,
33
+ CancellationToken cancellationToken
34
+ ) {
28
35
_log . LogDebug ( "Tombstoning stream {streamName}." , request . Options . StreamIdentifier ) ;
29
36
30
37
var channelInfo = await GetChannelInfo ( cancellationToken ) . ConfigureAwait ( false ) ;
31
- using var call = new EventStore . Client . Streams . Streams . StreamsClient (
32
- channelInfo . CallInvoker ) . TombstoneAsync ( request ,
33
- KurrentDBCallOptions . CreateNonStreaming ( Settings , deadline , userCredentials , cancellationToken ) ) ;
38
+ using var call = new Streams . StreamsClient ( channelInfo . CallInvoker ) . TombstoneAsync (
39
+ request ,
40
+ KurrentDBCallOptions . CreateNonStreaming (
41
+ Settings ,
42
+ options ? . Deadline ,
43
+ options ? . UserCredentials ,
44
+ cancellationToken
45
+ )
46
+ ) ;
47
+
34
48
var result = await call . ResponseAsync . ConfigureAwait ( false ) ;
35
49
36
50
return new DeleteResult ( new Position ( result . Position . CommitPosition , result . Position . PreparePosition ) ) ;
37
51
}
38
52
}
53
+
54
+ [ Obsolete ( "Those extensions may be removed in the future versions" , false ) ]
55
+ public static class ObsoleteKurrentDBClientTombstoneExtensions {
56
+ /// <summary>
57
+ /// Tombstones a stream asynchronously. Note: Tombstoned streams can never be recreated.
58
+ /// </summary>
59
+ /// <param name="dbClient"></param>
60
+ /// <param name="streamName">The name of the stream to tombstone.</param>
61
+ /// <param name="expectedState">The expected <see cref="StreamState"/> of the stream being deleted.</param>
62
+ /// <param name="deadline"></param>
63
+ /// <param name="userCredentials">The optional <see cref="UserCredentials"/> to perform operation with.</param>
64
+ /// <param name="cancellationToken">The optional <see cref="System.Threading.CancellationToken"/>.</param>
65
+ /// <returns></returns>
66
+ [ Obsolete (
67
+ "This method may be removed in future releases. Use the overload with TombstoneOptions parameter" ,
68
+ false
69
+ ) ]
70
+ public static Task < DeleteResult > TombstoneAsync (
71
+ KurrentDBClient dbClient ,
72
+ string streamName ,
73
+ StreamState expectedState ,
74
+ TimeSpan ? deadline = null ,
75
+ UserCredentials ? userCredentials = null ,
76
+ CancellationToken cancellationToken = default
77
+ ) =>
78
+ dbClient . TombstoneAsync (
79
+ streamName ,
80
+ expectedState ,
81
+ new TombstoneOptions { Deadline = deadline , UserCredentials = userCredentials } ,
82
+ cancellationToken
83
+ ) ;
84
+ }
85
+
86
+ public class TombstoneOptions : OperationOptions ;
39
87
}
0 commit comments