Skip to content

Commit 73c9e08

Browse files
add new LatestVersion changefeed mode that has same behavior as Incremental; renamed FullFidelity to AllVersionsAndDeletes (#3596)
1 parent 5c05fbb commit 73c9e08

File tree

8 files changed

+42
-18
lines changed

8 files changed

+42
-18
lines changed

Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedMode.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ internal ChangeFeedMode()
3131
/// <returns>A <see cref="ChangeFeedMode"/> to receive incremental item changes.</returns>
3232
public static ChangeFeedMode Incremental => ChangeFeedModeIncremental.Instance;
3333

34+
/// <summary>
35+
/// Creates a <see cref="ChangeFeedMode"/> to receive latest version item changes.
36+
/// </summary>
37+
/// <remarks>
38+
/// Latest version mode includes item creations and updates, not deletions.
39+
/// </remarks>
40+
/// <returns>A <see cref="ChangeFeedMode"/> to receive latest version item changes.</returns>
41+
#if PREVIEW
42+
public
43+
#else
44+
internal
45+
#endif
46+
static ChangeFeedMode LatestVersion => ChangeFeedModeIncremental.Instance;
47+
3448
/// <summary>
3549
/// Creates a <see cref="ChangeFeedMode"/> to receive notifications for creations, deletes, as well as all intermediary snapshots for updates.
3650
/// </summary>
@@ -49,6 +63,6 @@ internal ChangeFeedMode()
4963
#else
5064
internal
5165
#endif
52-
static ChangeFeedMode FullFidelity => ChangeFeedModeFullFidelity.Instance;
66+
static ChangeFeedMode AllVersionsAndDeletes => ChangeFeedModeFullFidelity.Instance;
5367
}
5468
}

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/ChangeFeedItemChange{T}.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.Azure.Cosmos
77
using Newtonsoft.Json;
88

99
/// <summary>
10-
/// The typed response that contains the current, previous, and metadata change feed resource when <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.FullFidelity"/>.
10+
/// The typed response that contains the current, previous, and metadata change feed resource when <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>.
1111
/// </summary>
1212
/// <example>
1313
/// <code>
@@ -19,7 +19,7 @@ namespace Microsoft.Azure.Cosmos
1919
/// public string status { get; set; }
2020
/// }
2121
///
22-
/// ChangeFeedMode changeFeedMode = ChangeFeedMode.FullFidelity;
22+
/// ChangeFeedMode changeFeedMode = ChangeFeedMode.AllVersionsAndDeletes;
2323
/// PartitionKey partitionKey = new PartitionKey(@"learning");
2424
/// ChangeFeedStartFrom changeFeedStartFrom = ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(partitionKey));
2525
///

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/ChangeFeedMetadata.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Microsoft.Azure.Cosmos
1010
using Newtonsoft.Json.Converters;
1111

1212
/// <summary>
13-
/// The metadata of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.FullFidelity"/>.
13+
/// The metadata of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>.
1414
/// </summary>
1515
#if PREVIEW
1616
public

Microsoft.Azure.Cosmos/src/Resource/FullFidelity/ChangeFeedOperationType.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Microsoft.Azure.Cosmos
77
using System.Runtime.Serialization;
88

99
/// <summary>
10-
/// The operation type of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.FullFidelity"/>. Upsert operations will yield <see cref="Create"/> or <see cref="Replace"/>.
10+
/// The operation type of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>. Upsert operations will yield <see cref="Create"/> or <see cref="Replace"/>.
1111
/// </summary>
1212
#if PREVIEW
1313
public

Microsoft.Azure.Cosmos/src/Resource/Settings/ChangeFeedPolicy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.Azure.Cosmos
1616
/// <example>
1717
/// The example below creates a new container with a custom change feed policy for full fidelity change feed with a retention window of 5 minutes - so intermediary snapshots of changes as well as deleted documents would be
1818
/// available for processing for 5 minutes before they vanish.
19-
/// Processing the change feed with <see cref="ChangeFeedMode.FullFidelity"/> will only be able within this retention window - if you attempt to process a change feed after more
19+
/// Processing the change feed with <see cref="ChangeFeedMode.AllVersionsAndDeletes"/> will only be able within this retention window - if you attempt to process a change feed after more
2020
/// than the retention window (5 minutes in this sample) an error (Status Code 400) will be returned.
2121
/// It would still be possible to process changes using <see cref="ChangeFeedMode.Incremental"/> mode even when configuring a full fidelity change
2222
/// feed policy with retention window on the container and when using Incremental mode it doesn't matter whether your are out of the retention window or not.

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/FeedToken/ChangeFeedIteratorCoreTests.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ public async Task ChangeFeedIteratorCore_WithFullFidelityReadFromBeginning()
788788
// FF does not work with StartFromBeginning currently, capture error
789789
FeedIterator<ToDoActivityWithMetadata> fullFidelityIterator = container.GetChangeFeedIterator<ToDoActivityWithMetadata>(
790790
ChangeFeedStartFrom.Beginning(),
791-
ChangeFeedMode.FullFidelity);
791+
ChangeFeedMode.AllVersionsAndDeletes);
792792

793793
CosmosException cosmosException = await Assert.ThrowsExceptionAsync<CosmosException>(() => fullFidelityIterator.ReadNextAsync());
794794
Assert.AreEqual(HttpStatusCode.BadRequest, cosmosException.StatusCode, "Full Fidelity Change Feed does not work with StartFromBeginning currently.");
@@ -829,7 +829,7 @@ private async Task ValidateChangeFeedIteratorCore_WithQuery(
829829
// FF does not work with StartFromBeginning currently, so we capture an initial continuation.
830830
FeedIterator<ChangeFeedItemChange<Document>> fullFidelityIterator = container.GetChangeFeedIteratorWithQuery<ChangeFeedItemChange<Document>>(
831831
ChangeFeedStartFrom.Now(),
832-
ChangeFeedMode.FullFidelity,
832+
ChangeFeedMode.AllVersionsAndDeletes,
833833
querySpec,
834834
null);
835835

@@ -862,7 +862,7 @@ private async Task ValidateChangeFeedIteratorCore_WithQuery(
862862
// Resume Change Feed and verify we pickup the events where documents matches the query
863863
fullFidelityIterator = container.GetChangeFeedIteratorWithQuery<ChangeFeedItemChange<Document>>(
864864
ChangeFeedStartFrom.ContinuationToken(initialContinuation),
865-
ChangeFeedMode.FullFidelity,
865+
ChangeFeedMode.AllVersionsAndDeletes,
866866
querySpec,
867867
null);
868868
int detectedEvents = 0;
@@ -891,7 +891,7 @@ private async Task ValidateChangeFeedIteratorCore_WithQuery(
891891

892892
fullFidelityIterator = container.GetChangeFeedIteratorWithQuery<ChangeFeedItemChange<Document>>(
893893
ChangeFeedStartFrom.ContinuationToken(initialContinuation),
894-
ChangeFeedMode.FullFidelity,
894+
ChangeFeedMode.AllVersionsAndDeletes,
895895
querySpec,
896896
null);
897897
detectedEvents = 0;
@@ -927,7 +927,7 @@ public async Task ChangeFeedIteratorCore_FeedRange_FromPartitionKey_VerifyingWir
927927
string otherId = Guid.NewGuid().ToString();
928928

929929
PartitionKey partitionKey = new PartitionKey(id);
930-
ChangeFeedMode changeFeedMode = ChangeFeedMode.FullFidelity;
930+
ChangeFeedMode changeFeedMode = ChangeFeedMode.AllVersionsAndDeletes;
931931
ChangeFeedStartFrom changeFeedStartFrom = ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(partitionKey));
932932

933933
using (FeedIterator<ChangeFeedItemChange<Item>> feedIterator = container.GetChangeFeedIterator<ChangeFeedItemChange<Item>>(
@@ -1017,7 +1017,7 @@ public async Task ChangeFeedIteratorCore_FeedRange_VerifyingWireFormatTests()
10171017

10181018
using (FeedIterator<ChangeFeedItemChange<Item>> feedIterator = container.GetChangeFeedIterator<ChangeFeedItemChange<Item>>(
10191019
changeFeedStartFrom: ChangeFeedStartFrom.Now(),
1020-
changeFeedMode: ChangeFeedMode.FullFidelity))
1020+
changeFeedMode: ChangeFeedMode.AllVersionsAndDeletes))
10211021
{
10221022
string continuation = null;
10231023
while (feedIterator.HasMoreResults)
@@ -1124,7 +1124,7 @@ public async Task ChangeFeedIteratorCore_FeedRange_FromPartitionKey_Dynamic_Veri
11241124
string otherId = Guid.NewGuid().ToString();
11251125
using (FeedIterator<dynamic> feedIterator = container.GetChangeFeedIterator<dynamic>(
11261126
changeFeedStartFrom: ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(new PartitionKey(id))),
1127-
changeFeedMode: ChangeFeedMode.FullFidelity))
1127+
changeFeedMode: ChangeFeedMode.AllVersionsAndDeletes))
11281128
{
11291129
string continuation = null;
11301130
while (feedIterator.HasMoreResults)

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/NetworkAttachedDocumentContainerTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task MonadicChangeFeedAsync_ChangeFeedMode_FullFidelity()
144144

145145
await networkAttachedDocumentContainer.MonadicChangeFeedAsync(
146146
feedRangeState: new FeedRangeState<ChangeFeedState>(new FeedRangePartitionKeyRange("0"), ChangeFeedState.Beginning()),
147-
changeFeedPaginationOptions: new ChangeFeedPaginationOptions(ChangeFeedMode.FullFidelity, pageSizeHint: 10),
147+
changeFeedPaginationOptions: new ChangeFeedPaginationOptions(ChangeFeedMode.AllVersionsAndDeletes, pageSizeHint: 10),
148148
trace: NoOpTrace.Singleton,
149149
cancellationToken: default);
150150

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json

+14-4
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,25 @@
160160
"Microsoft.Azure.Cosmos.ChangeFeedMode;System.Object;IsAbstract:True;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
161161
"Subclasses": {},
162162
"Members": {
163-
"Microsoft.Azure.Cosmos.ChangeFeedMode FullFidelity": {
163+
"Microsoft.Azure.Cosmos.ChangeFeedMode AllVersionsAndDeletes": {
164164
"Type": "Property",
165165
"Attributes": [],
166-
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode FullFidelity;CanRead:True;CanWrite:False;Microsoft.Azure.Cosmos.ChangeFeedMode get_FullFidelity();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
166+
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode AllVersionsAndDeletes;CanRead:True;CanWrite:False;Microsoft.Azure.Cosmos.ChangeFeedMode get_AllVersionsAndDeletes();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
167167
},
168-
"Microsoft.Azure.Cosmos.ChangeFeedMode get_FullFidelity()": {
168+
"Microsoft.Azure.Cosmos.ChangeFeedMode LatestVersion": {
169+
"Type": "Property",
170+
"Attributes": [],
171+
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode LatestVersion;CanRead:True;CanWrite:False;Microsoft.Azure.Cosmos.ChangeFeedMode get_LatestVersion();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
172+
},
173+
"Microsoft.Azure.Cosmos.ChangeFeedMode get_AllVersionsAndDeletes()": {
174+
"Type": "Method",
175+
"Attributes": [],
176+
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_AllVersionsAndDeletes();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
177+
},
178+
"Microsoft.Azure.Cosmos.ChangeFeedMode get_LatestVersion()": {
169179
"Type": "Method",
170180
"Attributes": [],
171-
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_FullFidelity();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
181+
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_LatestVersion();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
172182
}
173183
},
174184
"NestedTypes": {}

0 commit comments

Comments
 (0)