Skip to content

[Cosmos] Prime metadata caches#3852

Closed
simorenoh wants to merge 2 commits intorelease/azure_data_cosmos-previewsfrom
prime-caches
Closed

[Cosmos] Prime metadata caches#3852
simorenoh wants to merge 2 commits intorelease/azure_data_cosmos-previewsfrom
prime-caches

Conversation

@simorenoh
Copy link
Copy Markdown
Member

Prime account properties, container properties, and partition key range caches
eagerly so the first data-plane operation doesn't incur unexpected latency from
cold cache population.

Fixes #3793

Changes

Cache priming in build() (cosmos_client_builder.rs):

  • Call refresh_location(false) during build() to eagerly fetch account
    properties and populate regional endpoints before the first operation.
  • This also triggers the PPAF callback, configuring partition-level failover
    flags immediately.

Cache priming in container_client() (container_client.rs, database_client.rs):

  • ContainerClient::new() eagerly fetches container properties and partition
    key ranges at construction time.
  • Exposes partition_key_definition() and container_rid() accessors on
    ContainerClient since the data is already available after priming.
  • DatabaseClient::container_client() now returns azure_core::Result<ContainerClient>
    since construction makes fallible HTTP calls.

Signature change propagation (examples, tests, native FFI):

  • All container_client() call sites updated with ? to handle the new
    Result return type across examples, emulator tests, and the native
    FFI wrapper.

Other Changes

  • Builder tests now use the fault injection framework to mock the HTTP call
    instead of a #[cfg(test)] transport override.

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.

1 participant