question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change Feed mode design

See original GitHub issue

Change Feed is introducing in preview shortly the Full Fidelity Change Feed.

The way to enable the retention on a container is defined in PR https://github.com/Azure/azure-cosmos-dotnet-v3/pull/2020.

Once retention has been enabled on a container, the user can consume the change feed in Full Fidelity mode, exposing deletes (within the retention period configured in the container).

The user can still consume Change Feed in the normal mode (Incremental) even if the retention is enabled, so they should be able to select one or the other when starting the Change Feed consumptions.

Because the continuations are valid for both modes, it is also possible to change the mode after capturing some previous continuation, so maintaining the mode as part of the continuation state is not really required.

Proposed API

Exposing a configuration on the ChangeFeedRequestOptions that allows the user to set the mode, similar to the page size hint:

public class ChangeFeedRequestOptions
{

        /// <summary>
        /// Gets or sets the desired mode on which to consume the Change Feed.
        /// </summary>
        /// <value>Default value is <see cref="ChangeFeedMode.Incremental"/>. </value>
        public ChangeFeedMode FeedMode { get; set; } = ChangeFeedRequestOptions.DefaultMode;

}

Following a similar model to StartFrom, the different modes can be implemented as abstract class implementations.

The user can then set the FeedMode to two different values:

  • Incremental (default): This is the default Change Feed, the current mode that surfaces creations and replaces.
  • Full Fidelity: Available if the container has a retention period defined.

Setting the FeedMode

Setting it to Incremental (the default):

ChangeFeedRequestOptions changeFeedRequestOptions = new ChangeFeedRequestOptions
            {
                FeedMode = ChangeFeedMode.Incremental()
            };

Setting it to Full Fidelity:

ChangeFeedRequestOptions changeFeedRequestOptions = new ChangeFeedRequestOptions
            {
                FeedMode = ChangeFeedMode.FullFidelity()
            };

And use it as part of the iterator:

FeedIterator feedIterator = container.GetChangeFeedStreamIterator(
        ChangeFeedStartFrom.Now(),
        new ChangeFeedRequestOptions()
       {
            FeedMode = ChangeFeedMode.FullFidelity(),
            PageSizeHint = 50
        });

The FeedMode implementation will define the A_IM header correctly to specify the desired mode.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ealsurcommented, Apr 12, 2022

@DmitryKhilyai, Full Fidelity is still in private preview. When the feature GAs we will certainly add Functions support, it is part of the roadmap.

2reactions
ealsurcommented, Dec 16, 2020

We could use an enum, thought it would be cleaner to have an abstract class, like :

public abstract class ChangeFeedMode
{
    internal abstract void Accept(RequestMessage requestMessage);
    public static ChangeFeedMode Incremental()
    {
        return ChangeFeedModeIncremental.Instance;
    }
    
    public static ChangeFeedMode FullFidelity()
    {
        return ChangeFeedModeFullFidelity.Instance;
    }
}

internal sealed class ChangeFeedModeIncremental : ChangeFeedMode
{
    internal override void Accept(RequestMessage requestMessage)
    {
        requestMessage.Headers.Add(HttpConstants.HttpHeaders.A_IM, HttpConstants.A_IMHeaderValues.IncrementalFeed);
    }
}

internal sealed class ChangeFeedModeFullFidelity : ChangeFeedMode
{
    internal override void Accept(RequestMessage requestMessage)
    {
        requestMessage.Headers.Add(HttpConstants.HttpHeaders.A_IM, HttpConstants.A_IMHeaderValues.FullFidelityFeed);
    }
}

So if we need to add more modes, we touch nothing else other than implementing a new type, instead of fishing where the value is and having a switch over an enum.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change feed modes in Azure Cosmos DB
Azure Cosmos DB offers two change feed modes. Each mode offers the same core functionality. Differences include the operations that are ...
Read more >
Feed Stream System Design: General Principles
This article describes the general framework behind a feed stream system and how its architecture is designed.
Read more >
Azure Cosmos DB Change Feed
Open a second terminal window and navigate to the ChangeFeedConsole folder · Start up your console app by running the following command in...
Read more >
Changes Feed
Changes Feed. Inspirational designs, illustrations, and graphic elements from the world's best designers. Want more inspiration? Browse our search results.
Read more >
How do I set the Printers [Feed Mode] inside of BarTender?
Answer · With your BarTender document open, go to "File > Print" · Click on the "Document Properties" button · Click the "Stock"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found