Commit c739c17
feat(core): implement exponential polling strategy (Azure#27017)
* feat(core): implement exponential polling strategy
1. add `IOperationPollingStrategy` and 2 implementation
1.1 `ConstantPollingStrategy` is for constant polling interval
1.2 `ExponentialPollingStrategy` is for exponential polling interval starting from 1 second up to 32 seconds
2. refactor `OperationInternalBase` and `OperationInternalOfT`:
2.1 replace `DefaultPollingInterval` with `PollingStrategy`
2.2 override implementation of `WaitForCompletionResponseAsync` and `WaitForCompletionAsync`, use interval from `PollingStrategy.PollingInterval`
3. add unit test cases, and update project build dependencies
part of Azure#26922
* update according to review comments
1. change interface `IOperationPollingStrategy` to abstract class `OperationPollingStrategy`
1.1 move common logic of `GetServerDelay` into `OperationPollingStrategy`
1.2 change `PollingInterval` to `GetNextWait(response)` to be more specific and fit the new logic
2. change polling sequence of `ExponentialPollingStrategy` to `1, 1, 1, 2, 4 ... 32`
3. consolidate polling logic into `OperationInternalBase.PollingResponseAsync`
4. change implementation of `TestLroOperation.cs` to get rid of dependency on `OperationInternals` which is located in `autorest.csharp`
4.1 I can restore the dependency by doing the similar change like `OperationInternalBase`, but that could be overkill, so I choose a simple change.
5. update test cases and build dependency
* split polling strategy logic according to review comments
1. add two polling strategy implementation: `ZeroPollingStrategy` and `RetryAfterPollingStrategy`
1.1 `ZeroPollingStrategy` is for testing purpose (e.g play back test recordings)
1.2 `RetryAfterPollingStrategy` is used when detecting the server side support `retry-after` header, and corresponding logic is removed from `ConstantPollingStrategy` and `ExponentialPollingStrategy`.
2. change constructor of `OperationInternalBase` and its subclasses
2.1 add a polling strategy parameter
2.2 change polling strategy initialization logic, now it will"
2.2.1 first check if there is any `retry-after` header, if so then adopt `RetryAfterPollingStrategy`
2.2.2 then adopt the passed-in polling strategy
2.2.3 fall back to `ConstantPollingStrategy` if none is adopted
2.3 change the interval detemination logic of `WaitForCompletionResponseAsync(TimeSpan, CancellationToken)`. Now we adopt the max value of the passed-in interval and the interval determined by polling strategy.
3. update test cases and build dependencies
* update according to review comments
1. move `OperationInternalBase.ChoosePollingStrategy()` to `OperationPollingStrategy` class
2. make `OperationInternalBase.PollingStrategy` private and update test cases
3. update polling strategy implementation
3.1. `ConstantPollingStrategy` will return max value of initial constant interval and the passed-in interval
3.2. `ZeroPollingStrategy` will always return 0
3.3. `ExponentialPollingStrategy` will always return sequence value
3.4. `RetryAfterPollingStrategy1 will return max value of retry-after and passed-in interval
3.5. update test cases
4. add back `OperationInternalBase.DefaultPollInterval`
5. move some common logic into `OperationPollingStrategy`
* implement `OperationPoller`
1. add `OperationPoller` and `OperationPoller<T>` as the common polling logic implementation
2. replace the polling logic in `OperationInternalBase`, `Operation` and `OperationOfT`.
3. update build dependencies
* wip refactor
* remove unused delegate
* temp - add back polling interval
* renames to represent this is a delay strategy and separate from operations which can be used in many places
* renaming polling param
* more minor refactoring
* comment change
* updates for non T in test framework
* update test cases
* fix zero interval for test recording playback
1. fix a type comparison error when using project reference (lro.BaseType.BaseType is from `Operation` in `Azure.ResourceManager`, not `Azure.Core`)
2. unify the zero interval polling logic, since we've dumped the special zero interval handling in `Operation.GetServerDelay`
* add files to make autorest changes
* tweak to code for autorest
* update dataplance csproj files
* missed a couple csproj files
* add new files to common lro includes
* update common lro files
* fix folder for shared files
* remove duplicate compiles
* update 2 more duplicate compiles
* address comments from Azure/autorest.csharp#2000
* update who owns defaulting
* Update AutoRest C# version to 3.0.0-beta.20220302.4
* fix polling strategy tests
* update latest autorest.csharp 3.0.0-beta.20220303.1
* disable some operation internal tests
those tests are not working, because we no longer override `OperationInternalBase.WaitAsync`
* update OperationInterceptor.cs
1. more precise reflection on the generic types
2. update `RecordedTestBaseTest`
2.1 update `CustomOperation` due to polling architecture change
2.2 update `WaitForCompletionDoesntWaitDuringPlayback` since in playback mode, `CustomOperation.WaitForCompletionAsync` won't be called. Instead, it's intercepted. So we need to use `DateTimeOffset` to check the interval.
* update to tests
* update so interceptor works with true or false scenarios for no wait in mgmt plane
* fix failure in `TestResourceOperationOrResponseOfT`
Move exception throwing into `UpdateStatus` and `UpdateStatusAsync`, since the `WaitForXXX` operation will be intercepted and delegate to `OperatonPoller`.
* fix test timeout in `Azure.Communication.PhoneNumbers`
1. add `InstrumentOperation` before `operation.WaitForXXX`
2. remove the zero timespan in playback mode, since the operation interceptor will poll by zero timespan
* update api for sync wait methods
* update to translation LRO to not prefecth first page
* regen desktopvirtualization
* add back in cancellation token forwarding
* add pr comments
Co-authored-by: m-nash <prognash@gmail.com>
Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com>1 parent 9593bbe commit c739c17
File tree
132 files changed
+2005
-520
lines changed- eng
- sdk
- appconfiguration/Azure.ResourceManager.AppConfiguration/src/Generated/LongRunningOperation
- azurestackhci/Azure.ResourceManager.StackHCI/src/Generated/LongRunningOperation
- cdn/Azure.ResourceManager.Cdn/src/Generated/LongRunningOperation
- communication
- Azure.Communication.PhoneNumbers
- api
- src/Generated
- tests/samples
- Azure.ResourceManager.Communication/src/Generated/LongRunningOperation
- compute/Azure.ResourceManager.Compute/src/Generated/LongRunningOperation
- connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/src/Generated/LongRunningOperation
- core
- Azure.Core.Experimental/src
- Azure.Core.TestFramework/src
- Instrumentation
- Azure.Core
- src
- tests
- TestClients
- cosmosdb/Azure.ResourceManager.CosmosDB/src/Generated/LongRunningOperation
- desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/src/Generated/LongRunningOperation
- deviceupdate/Azure.ResourceManager.DeviceUpdate/src/Generated/LongRunningOperation
- edgeorder/Azure.ResourceManager.EdgeOrder/src/Generated/LongRunningOperation
- eventhub/Azure.ResourceManager.EventHubs/src/Generated/LongRunningOperation
- extendedlocation/Azure.ResourceManager.ExtendedLocation/src/Generated/LongRunningOperation
- keyvault/Azure.ResourceManager.KeyVault/src/Generated/LongRunningOperation
- network/Azure.ResourceManager.Network/src/Generated/LongRunningOperation
- resourcemanager/Azure.ResourceManager/src
- Common/Generated/LongRunningOperation
- ManagementGroup/Generated/LongRunningOperation
- Resources/Generated/LongRunningOperation
- resources/Azure.ResourceManager.Resources/src/Generated/LongRunningOperation
- servicebus/Azure.ResourceManager.ServiceBus/src/Generated/LongRunningOperation
- sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation
- storagepool/Azure.ResourceManager.StoragePool/src/Generated/LongRunningOperation
- storage/Azure.ResourceManager.Storage/src/Generated/LongRunningOperation
- synapse/Azure.Analytics.Synapse.Artifacts
- api
- src/Generated
- translation/Azure.AI.Translation.Document/tests
- webpubsub/Azure.ResourceManager.WebPubSub/src/Generated/LongRunningOperation
- websites/Azure.ResourceManager.AppService/src/Generated/LongRunningOperation
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
132 files changed
+2005
-520
lines changedLines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 45 | | |
52 | 46 | | |
53 | 47 | | |
| |||
232 | 226 | | |
233 | 227 | | |
234 | 228 | | |
235 | | - | |
| 229 | + | |
236 | 230 | | |
237 | 231 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
| |||
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
220 | 230 | | |
221 | 231 | | |
222 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| |||
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
| 202 | + | |
| 203 | + | |
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| |||
0 commit comments