Commit f3c5db5
Cosmos: rework driver options to use new macro and model (#3990)
This pull request refactors the runtime options resolution logic in the
Cosmos DB Rust SDK, introduces a new `RuntimeOptionsView` for layered
option resolution, and updates documentation and tests to match the new
approach. The changes simplify how runtime options are merged and
accessed, improve clarity in the codebase, and ensure consistent
behavior across driver, runtime, operation, and environment layers.
### Runtime Options Resolution Refactor
* Replaced the `effective_runtime_options` method with
`runtime_options_view`, which constructs a `RuntimeOptionsView` for
resolving options across operation, driver, runtime, and environment
layers. The view provides prioritized access to option values and
replaces manual merging.
(`sdk/cosmos/azure_data_cosmos_driver/src/driver/cosmos_driver.rs`)
[[1]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L695-L734)
[[2]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L825-R801)
* Removed fields and logic related to default retry counts
(`default_max_failover_retries`, `default_max_session_retries`) from
`CosmosDriver`, as these are now resolved through the new view.
(`sdk/cosmos/azure_data_cosmos_driver/src/driver/cosmos_driver.rs`)
[[1]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L59-L62)
[[2]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L580-L607)
### Documentation Updates
* Updated configuration documentation to clarify the movement of
`custom_headers` from multiple option types to `CosmosAccountOptions`,
and explained its best-effort nature and intended use.
(`sdk/cosmos/azure_data_cosmos/docs/ConfigurationOptions.md`)
[[1]](diffhunk://#diff-a8765df6c0f13087ea693bf4ac61c1394eda3e421df8acbf41c0e9d655b4e384R262)
[[2]](diffhunk://#diff-a8765df6c0f13087ea693bf4ac61c1394eda3e421df8acbf41c0e9d655b4e384L492-R497)
[[3]](diffhunk://#diff-a8765df6c0f13087ea693bf4ac61c1394eda3e421df8acbf41c0e9d655b4e384L534-R537)
### Test and Builder API Updates
* Refactored tests to use `RuntimeOptionsBuilder` instead of the
previous builder pattern, and updated assertions to match the new
options access pattern.
(`sdk/cosmos/azure_data_cosmos_driver/src/driver/cosmos_driver.rs`)
[[1]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1036-R1004)
[[2]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1157-R1132)
[[3]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1173-R1146)
[[4]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1183-R1157)
[[5]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1321-R1309)
[[6]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1350-R1319)
[[7]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1361-R1330)
[[8]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1371-R1352)
[[9]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1392-R1361)
[[10]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L1407-R1379)
### Dependency and Import Changes
* Added `azure_data_cosmos_macros` as a dependency in workspace and main
`Cargo.toml` files. (`Cargo.toml`,
`sdk/cosmos/azure_data_cosmos_driver/Cargo.toml`)
[[1]](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R101)
[[2]](diffhunk://#diff-e88ccd29a5723513603d930d833d57bdb20427e8b1a20c3bbc48acecc2bd464bR24)
* Updated imports to include `RuntimeOptionsView` and remove unused or
obsolete items.
(`sdk/cosmos/azure_data_cosmos_driver/src/driver/cosmos_driver.rs`,
`sdk/cosmos/azure_data_cosmos_driver/src/driver/runtime.rs`)
[[1]](diffhunk://#diff-aae0ab9b30a5bf993d0a37d58a3f916f85391d6aeb72e334e2e9ea5d1ea18a54L17-R17)
[[2]](diffhunk://#diff-63386f335ae60cf8f9101b469999e1e136da6b574066ac6892d8b6855c949dfdL20-R21)
These changes make option resolution more robust and maintainable, and
clarify the intended usage of custom headers and runtime configuration
throughout the SDK.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 9cd7b33 commit f3c5db5
13 files changed
Lines changed: 312 additions & 588 deletions
File tree
- sdk/cosmos
- azure_data_cosmos_driver
- src
- driver
- pipeline
- options
- tests/framework
- azure_data_cosmos/docs
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
| |||
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
492 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
493 | 496 | | |
494 | | - | |
| 497 | + | |
495 | 498 | | |
496 | 499 | | |
497 | 500 | | |
| |||
531 | 534 | | |
532 | 535 | | |
533 | 536 | | |
534 | | - | |
| 537 | + | |
535 | 538 | | |
536 | 539 | | |
537 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
0 commit comments