Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Preview] Full Fidelity Change Feed: Adds new LatestVersion and AllVersionsAndDeletes to ChangeFeedMode #3596

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ internal ChangeFeedMode()
/// <returns>A <see cref="ChangeFeedMode"/> to receive incremental item changes.</returns>
public static ChangeFeedMode Incremental => ChangeFeedModeIncremental.Instance;

/// <summary>
/// Creates a <see cref="ChangeFeedMode"/> to receive latest version item changes.
/// </summary>
/// <remarks>
/// Latest version mode includes item creations and updates, not deletions.
/// </remarks>
/// <returns>A <see cref="ChangeFeedMode"/> to receive latest version item changes.</returns>
#if PREVIEW
public
#else
internal
#endif
static ChangeFeedMode LatestVersion => ChangeFeedModeIncremental.Instance;

/// <summary>
/// Creates a <see cref="ChangeFeedMode"/> to receive notifications for creations, deletes, as well as all intermediary snapshots for updates.
/// </summary>
Expand All @@ -49,6 +63,6 @@ internal ChangeFeedMode()
#else
internal
#endif
static ChangeFeedMode FullFidelity => ChangeFeedModeFullFidelity.Instance;
static ChangeFeedMode AllVersionsAndDeletes => ChangeFeedModeFullFidelity.Instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.Azure.Cosmos
using Newtonsoft.Json;

/// <summary>
/// The typed response that contains the current, previous, and metadata change feed resource when <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.FullFidelity"/>.
/// The typed response that contains the current, previous, and metadata change feed resource when <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>.
/// </summary>
/// <example>
/// <code>
Expand All @@ -19,7 +19,7 @@ namespace Microsoft.Azure.Cosmos
/// public string status { get; set; }
/// }
///
/// ChangeFeedMode changeFeedMode = ChangeFeedMode.FullFidelity;
/// ChangeFeedMode changeFeedMode = ChangeFeedMode.AllVersionsAndDeletes;
/// PartitionKey partitionKey = new PartitionKey(@"learning");
/// ChangeFeedStartFrom changeFeedStartFrom = ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(partitionKey));
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.Azure.Cosmos
using Newtonsoft.Json.Converters;

/// <summary>
/// The metadata of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.FullFidelity"/>.
/// The metadata of a change feed resource with <see cref="ChangeFeedMode"/> is initialized to <see cref="ChangeFeedMode.AllVersionsAndDeletes"/>.
/// </summary>
#if PREVIEW
public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.Azure.Cosmos
using System.Runtime.Serialization;

/// <summary>
/// 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"/>.
/// 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"/>.
/// </summary>
#if PREVIEW
public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Cosmos
/// <example>
/// 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
philipthomas-MSFT marked this conversation as resolved.
Show resolved Hide resolved
/// available for processing for 5 minutes before they vanish.
/// 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
/// 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
/// than the retention window (5 minutes in this sample) an error (Status Code 400) will be returned.
/// It would still be possible to process changes using <see cref="ChangeFeedMode.Incremental"/> mode even when configuring a full fidelity change
/// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public async Task ChangeFeedIteratorCore_WithFullFidelityReadFromBeginning()
// FF does not work with StartFromBeginning currently, capture error
FeedIterator<ToDoActivityWithMetadata> fullFidelityIterator = container.GetChangeFeedIterator<ToDoActivityWithMetadata>(
ChangeFeedStartFrom.Beginning(),
ChangeFeedMode.FullFidelity);
ChangeFeedMode.AllVersionsAndDeletes);

CosmosException cosmosException = await Assert.ThrowsExceptionAsync<CosmosException>(() => fullFidelityIterator.ReadNextAsync());
Assert.AreEqual(HttpStatusCode.BadRequest, cosmosException.StatusCode, "Full Fidelity Change Feed does not work with StartFromBeginning currently.");
philipthomas-MSFT marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -829,7 +829,7 @@ private async Task ValidateChangeFeedIteratorCore_WithQuery(
// FF does not work with StartFromBeginning currently, so we capture an initial continuation.
FeedIterator<ChangeFeedItemChange<Document>> fullFidelityIterator = container.GetChangeFeedIteratorWithQuery<ChangeFeedItemChange<Document>>(
ChangeFeedStartFrom.Now(),
ChangeFeedMode.FullFidelity,
ChangeFeedMode.AllVersionsAndDeletes,
querySpec,
null);

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

fullFidelityIterator = container.GetChangeFeedIteratorWithQuery<ChangeFeedItemChange<Document>>(
ChangeFeedStartFrom.ContinuationToken(initialContinuation),
ChangeFeedMode.FullFidelity,
ChangeFeedMode.AllVersionsAndDeletes,
querySpec,
null);
detectedEvents = 0;
Expand Down Expand Up @@ -927,7 +927,7 @@ public async Task ChangeFeedIteratorCore_FeedRange_FromPartitionKey_VerifyingWir
string otherId = Guid.NewGuid().ToString();

PartitionKey partitionKey = new PartitionKey(id);
ChangeFeedMode changeFeedMode = ChangeFeedMode.FullFidelity;
ChangeFeedMode changeFeedMode = ChangeFeedMode.AllVersionsAndDeletes;
ChangeFeedStartFrom changeFeedStartFrom = ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(partitionKey));

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

using (FeedIterator<ChangeFeedItemChange<Item>> feedIterator = container.GetChangeFeedIterator<ChangeFeedItemChange<Item>>(
changeFeedStartFrom: ChangeFeedStartFrom.Now(),
changeFeedMode: ChangeFeedMode.FullFidelity))
changeFeedMode: ChangeFeedMode.AllVersionsAndDeletes))
{
string continuation = null;
while (feedIterator.HasMoreResults)
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public async Task ChangeFeedIteratorCore_FeedRange_FromPartitionKey_Dynamic_Veri
string otherId = Guid.NewGuid().ToString();
using (FeedIterator<dynamic> feedIterator = container.GetChangeFeedIterator<dynamic>(
changeFeedStartFrom: ChangeFeedStartFrom.Now(FeedRange.FromPartitionKey(new PartitionKey(id))),
changeFeedMode: ChangeFeedMode.FullFidelity))
changeFeedMode: ChangeFeedMode.AllVersionsAndDeletes))
{
string continuation = null;
while (feedIterator.HasMoreResults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public async Task MonadicChangeFeedAsync_ChangeFeedMode_FullFidelity()

await networkAttachedDocumentContainer.MonadicChangeFeedAsync(
feedRangeState: new FeedRangeState<ChangeFeedState>(new FeedRangePartitionKeyRange("0"), ChangeFeedState.Beginning()),
changeFeedPaginationOptions: new ChangeFeedPaginationOptions(ChangeFeedMode.FullFidelity, pageSizeHint: 10),
changeFeedPaginationOptions: new ChangeFeedPaginationOptions(ChangeFeedMode.AllVersionsAndDeletes, pageSizeHint: 10),
trace: NoOpTrace.Singleton,
cancellationToken: default);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,25 @@
"Microsoft.Azure.Cosmos.ChangeFeedMode;System.Object;IsAbstract:True;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Microsoft.Azure.Cosmos.ChangeFeedMode FullFidelity": {
"Microsoft.Azure.Cosmos.ChangeFeedMode AllVersionsAndDeletes": {
"Type": "Property",
"Attributes": [],
"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;"
"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;"
},
"Microsoft.Azure.Cosmos.ChangeFeedMode get_FullFidelity()": {
"Microsoft.Azure.Cosmos.ChangeFeedMode LatestVersion": {
"Type": "Property",
"Attributes": [],
"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;"
},
"Microsoft.Azure.Cosmos.ChangeFeedMode get_AllVersionsAndDeletes()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_AllVersionsAndDeletes();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.ChangeFeedMode get_LatestVersion()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_FullFidelity();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedMode get_LatestVersion();IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
Expand Down