Skip to content

Add change feed pull model support#3649

Closed
Pilchie wants to merge 11 commits intoAzure:release/azure_data_cosmos-previewsfrom
Pilchie:feature/change-feed-pull-model-3458
Closed

Add change feed pull model support#3649
Pilchie wants to merge 11 commits intoAzure:release/azure_data_cosmos-previewsfrom
Pilchie:feature/change-feed-pull-model-3458

Conversation

@Pilchie
Copy link
Copy Markdown
Member

@Pilchie Pilchie commented Feb 2, 2026

Implement change feed pull model for azure_data_cosmos crate with V2 support for partition splits and merges.

New public APIs:

  • ContainerClient::query_items_change_feed() -> FeedPager
  • ContainerClient::read_feed_ranges() -> Vec

New types:

  • change_feed::FeedRange - Serializable feed range for persistence
  • change_feed::ChangeFeedStartFrom - Beginning, Now, or PointInTime
  • change_feed::ChangeFeedMode - LatestVersion or AllVersionsAndDeletes
  • QueryChangeFeedOptions - Options for change feed queries
  • ReadFeedRangesOptions - Options for reading feed ranges

Internal infrastructure:

  • Continuation token serialization/deserialization
  • Composite continuation tokens with split/merge handling
  • Change feed state machine for tracking position

Fixes #3458

@github-actions github-actions bot added the Cosmos The azure_cosmos crate label Feb 2, 2026
@Pilchie Pilchie force-pushed the feature/change-feed-pull-model-3458 branch from f4362d6 to e92439e Compare February 25, 2026 23:49
@Pilchie Pilchie changed the base branch from main to release/azure_data_cosmos-previews February 26, 2026 22:06
@Pilchie Pilchie force-pushed the feature/change-feed-pull-model-3458 branch 2 times, most recently from 139f991 to 3e9bd2a Compare March 3, 2026 19:26
analogrelay and others added 5 commits March 3, 2026 11:42
We need to do a release ASAP for a customer need, and we're depending on
unreleased code in azure_core. This PR reverts that temporarily and
moves our dependency from path-based to depending on the released
versions of core libraries (0.32).

I'll open a follow-up PR after this is released to go back to
referencing the live code, so that we can release again after the next
Core release wave.
Implement change feed pull model for azure_data_cosmos crate with V2
support for partition splits and merges.

New public APIs:
- ContainerClient::query_items_change_feed<T>() -> FeedPager<T>
- ContainerClient::read_feed_ranges() -> Vec<FeedRange>

New types:
- change_feed::FeedRange - Serializable feed range for persistence
- change_feed::ChangeFeedStartFrom - Beginning, Now, or PointInTime
- change_feed::ChangeFeedMode - LatestVersion or AllVersionsAndDeletes
- QueryChangeFeedOptions - Options for change feed queries
- ReadFeedRangesOptions - Options for reading feed ranges

Internal infrastructure:
- Continuation token serialization/deserialization
- Composite continuation tokens with split/merge handling
- Change feed state machine for tracking position

Fixes Azure#3458
Remove leftover conflict markers in the cosmos Cargo.toml after rebasing onto release/azure_data_cosmos-previews, and refresh Cargo.lock to match the dependency set (azure_core workspace + base64).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The method on ChangeFeedStartFromInternal was never called,
causing a dead_code warning treated as error in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pin azure_core to version 0.32.0 with default-features = false
instead of inheriting the workspace version (0.33.0), which was
incorrectly merged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Pilchie Pilchie force-pushed the feature/change-feed-pull-model-3458 branch from 3e9bd2a to bf4d1e1 Compare March 3, 2026 19:46
@Pilchie Pilchie force-pushed the feature/change-feed-pull-model-3458 branch from bf4d1e1 to 089c9b7 Compare March 3, 2026 21:52
Pilchie and others added 5 commits March 3, 2026 16:15
Update cosmos_change_feed.rs to use correct public APIs:
- Use azure_core::Uuid instead of uuid crate
- Use ContainerProperties::new() instead of struct literal
- Use QueryChangeFeedOptions builder methods instead of
  private field access
- Add .await on async container_client() calls
- Pass None for run_with_shared_db options parameter
- Use FeedItemIterator as Stream<Item=Result<T>> directly
- Handle Result from FeedRange::to_string_representation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The change feed request was passing None for PipelineSendOptions,
causing 304 (Not Modified) responses to be treated as errors.
Now passes SUCCESS_CODES to accept 304 and returns Ok(None) to
cleanly end the change feed stream when no more changes exist.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rewrite query_items_change_feed to use ChangeFeedState for
multi-partition round-robin instead of hardcoded pk_range_id 0.
Read the etag response header for change feed continuation
instead of x-ms-continuation.

- Make query_items_change_feed async to resolve partition key
  ranges upfront via the partition key range cache
- Expose continuation tokens on every FeedPage so callers can
  save and resume via with_continuation_token()
- Wire up with_feed_range() for scoped/parallel processing
- Add FeedRange::for_full_range() factory
- Validate AllVersionsAndDeletes requires ChangeFeedStartFrom::Now
- Add ETAG constant for change feed response headers
- Remove old single-partition send_change_feed_request from pipeline
- Delete unused scaffolding (test-only constructors, unused fields)

Add 9 new emulator tests covering event counting, continuation
token resume, fromNow, fromPointInTime, small page size, full
range, parallel feed ranges, and mode restriction validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@analogrelay
Copy link
Copy Markdown
Member

This is going to be different in the driver world, so I'm going to close it for now, we can keep the code around in your fork branch!

@github-project-automation github-project-automation bot moved this from Todo to Done in CosmosDB Go/Rust Crew Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cosmos The azure_cosmos crate

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Change feed pull model support For Cosmos DB NoSQL SDK

2 participants