Commit b592daf
authored
Cosmos: Adds
## Description:
This PR is introducing `GlobalEndpointManager`, `ClientRetryPolicy`,
`LocationCache` and `AccountProperties` to support cross-regional
routing in the rust SDK. Some of the key design decisions are
highlighted below:
- We used [Moka ](https://docs.rs/moka/latest/moka/)as a caching library
which supports thread safe access of the cached data and uses LRFU based
cache eviction mechanism.
- The cache refresh has been done on a TTL (time to live) model, where
each incoming request has the opportunity to refresh `AccountProperties`
and `LocationCache`, if the TTL expires or `force_refresh` is passed as
`True`.
- We haven't took the background refresh route yet, since we will need
to be a little careful and optimized for the rust bg task management.
However, our long term goal is to refresh the cache in the background,
so that we do not penalize an incoming request to refresh the cache.
The below flow diagram depicts the entire component interactions to
better understand how the request will be made.
## Flow Diagram:
```mermaid
sequenceDiagram
participant J as ContainerClient
participant A as CosmosPipeline
participant B as RetryHandler
participant C as ClientRetryPolicy
participant D as Core Pipeline <br> send_raw <br> through delegate
participant E as GlobalEndpointManager
participant F as LocationCache
J-->>A: 1. send(CosmosRequest)
A->>B: 2. send<Sender, Fut>()
loop Retry Iterations with force-refresh flag = false/ true
B->>C: 3. before_send_request(request)
C->>E: 4. refresh_location_async() <br> Refresh Cache only when TTL Expires OR <br> force_refresh is requested. <br><br> NO-OP when either of the above is false.
E->>E: 5. get_database_account() <br> Fetch Account Properties <br> from Gateway.
E->>F: 6. on_database_account_read() <br> Refresh Location Cache
C->>E: 7. resolve_service_endpoint() <br> Fetch and set the next endpoint in <br> CosmosRequest to route request.
B->>D: 8. Call sender delegate(request)
B->>C: 9. Invoke should_retry(result)
B->>B: 10. RetryAfter <br> (TimeSpan.Zero)
end
B->>J: 11. Return result if No Retry
```
## Closing issues
Fixes #3175GlobalEndpointManager, ClientRetryPolicy and LocationCache To Support Cross-Regional Routing (#3348)1 parent ba4ca41 commit b592daf
File tree
25 files changed
+3293
-328
lines changed- eng/dict
- sdk/cosmos
- azure_data_cosmos
- src
- clients
- handler
- models
- options
- pipeline
- query
- retry_policies
- routing
25 files changed
+3293
-328
lines changedSome 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 | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
Lines changed: 26 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
69 | 70 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
| |||
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
114 | | - | |
115 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
116 | 114 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 115 | + | |
122 | 116 | | |
123 | 117 | | |
124 | 118 | | |
| |||
181 | 175 | | |
182 | 176 | | |
183 | 177 | | |
184 | | - | |
185 | | - | |
| 178 | + | |
| 179 | + | |
186 | 180 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 181 | + | |
192 | 182 | | |
193 | 183 | | |
194 | 184 | | |
| |||
264 | 254 | | |
265 | 255 | | |
266 | 256 | | |
267 | | - | |
268 | | - | |
| 257 | + | |
269 | 258 | | |
270 | 259 | | |
271 | 260 | | |
272 | 261 | | |
273 | 262 | | |
274 | 263 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 264 | + | |
280 | 265 | | |
281 | 266 | | |
282 | 267 | | |
| |||
354 | 339 | | |
355 | 340 | | |
356 | 341 | | |
357 | | - | |
358 | | - | |
| 342 | + | |
359 | 343 | | |
360 | 344 | | |
361 | 345 | | |
362 | 346 | | |
363 | 347 | | |
364 | 348 | | |
365 | | - | |
| 349 | + | |
366 | 350 | | |
367 | 351 | | |
368 | 352 | | |
| |||
441 | 425 | | |
442 | 426 | | |
443 | 427 | | |
444 | | - | |
445 | | - | |
| 428 | + | |
446 | 429 | | |
447 | 430 | | |
448 | 431 | | |
449 | 432 | | |
450 | 433 | | |
451 | 434 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 435 | + | |
457 | 436 | | |
458 | 437 | | |
459 | 438 | | |
| |||
499 | 478 | | |
500 | 479 | | |
501 | 480 | | |
502 | | - | |
503 | | - | |
| 481 | + | |
504 | 482 | | |
505 | 483 | | |
506 | 484 | | |
507 | 485 | | |
508 | 486 | | |
509 | | - | |
| 487 | + | |
510 | 488 | | |
511 | 489 | | |
512 | 490 | | |
| |||
538 | 516 | | |
539 | 517 | | |
540 | 518 | | |
541 | | - | |
542 | | - | |
543 | | - | |
| 519 | + | |
544 | 520 | | |
545 | 521 | | |
546 | 522 | | |
547 | 523 | | |
548 | 524 | | |
549 | | - | |
| 525 | + | |
550 | 526 | | |
551 | 527 | | |
552 | 528 | | |
| |||
614 | 590 | | |
615 | 591 | | |
616 | 592 | | |
617 | | - | |
618 | | - | |
| 593 | + | |
619 | 594 | | |
620 | 595 | | |
621 | 596 | | |
622 | 597 | | |
623 | 598 | | |
624 | 599 | | |
625 | | - | |
| 600 | + | |
626 | 601 | | |
627 | 602 | | |
628 | 603 | | |
| |||
0 commit comments