-
Notifications
You must be signed in to change notification settings - Fork 154
Remove final keyword for RetryPolicy so that storage SDK can inherit from it
#5530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9057184
Update policy.hpp
Jinming-Hu 0b5f23d
add storage retry policy
Jinming-Hu e737df6
clang-format
Jinming-Hu 3ae250b
virtual destructor
Jinming-Hu d732886
Remove unused header
Jinming-Hu 88861ce
update
Jinming-Hu 5e4965e
construct pipeline
Jinming-Hu f7535a4
fix
Jinming-Hu 77df2c1
Add include header
Jinming-Hu ec00985
fix build error
Jinming-Hu 50cb16c
fix
Jinming-Hu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
sdk/storage/azure-storage-common/inc/azure/storage/common/internal/storage_retry_policy.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <azure/core/http/policies/policy.hpp> | ||
|
|
||
| namespace Azure { namespace Storage { namespace _internal { | ||
|
|
||
| class StorageRetryPolicy final : public Core::Http::Policies::_internal::RetryPolicy { | ||
| public: | ||
| explicit StorageRetryPolicy(Core::Http::Policies::RetryOptions options) | ||
| : RetryPolicy(std::move(options)) | ||
| { | ||
| } | ||
| ~StorageRetryPolicy() override {} | ||
|
|
||
| protected: | ||
| bool ShouldRetryOnResponse( | ||
| const Core::Http::RawResponse& response, | ||
| const Core::Http::Policies::RetryOptions& retryOptions, | ||
| int32_t attempt, | ||
| std::chrono::milliseconds& retryAfter, | ||
| double jitterFactor = -1) const override; | ||
| }; | ||
|
|
||
| }}} // namespace Azure::Storage::_internal |
44 changes: 44 additions & 0 deletions
44
sdk/storage/azure-storage-common/src/storage_retry_policy.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #include "azure/storage/common/internal/storage_retry_policy.hpp" | ||
|
|
||
| namespace Azure { namespace Storage { namespace _internal { | ||
|
|
||
| bool StorageRetryPolicy::ShouldRetryOnResponse( | ||
| const Core::Http::RawResponse& response, | ||
| const Core::Http::Policies::RetryOptions& retryOptions, | ||
| int32_t attempt, | ||
| std::chrono::milliseconds& retryAfter, | ||
| double jitterFactor) const | ||
| { | ||
| bool ret = RetryPolicy::ShouldRetryOnResponse( | ||
| response, retryOptions, attempt, retryAfter, jitterFactor); | ||
| if (ret) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| if (attempt > retryOptions.MaxRetries) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if (static_cast<std::underlying_type_t<Core::Http::HttpStatusCode>>(response.GetStatusCode()) | ||
| >= 400) | ||
| { | ||
| const auto& headers = response.GetHeaders(); | ||
| auto ite = headers.find("x-ms-copy-source-status-code"); | ||
|
Jinming-Hu marked this conversation as resolved.
|
||
| if (ite != headers.end()) | ||
| { | ||
| auto innerStatusCode = static_cast<Core::Http::HttpStatusCode>(std::stoi(ite->second)); | ||
| if (retryOptions.StatusCodes.find(innerStatusCode) != retryOptions.StatusCodes.end()) | ||
| { | ||
| return true; | ||
| } | ||
|
Jinming-Hu marked this conversation as resolved.
|
||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| }}} // namespace Azure::Storage::_internal | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.