-
Notifications
You must be signed in to change notification settings - Fork 42
Exposing new constructor to blob_client. #54
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
base: master
Are you sure you want to change the base?
Conversation
src/blob/blob_client.cpp
Outdated
| properties.metadata.push_back(std::make_pair(iter->first.substr(constants::header_ms_meta_prefix_size), iter->second)); | ||
| properties.metadata.emplace_back(header.first.substr(constants::header_ms_meta_prefix_size), header.second); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is duplicated with get_blob_properties, it would be better to abstract the logic and make it a function, for future use in file service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@katmsft I'm not sure I agree with you. Since this piece of code is processing properties and metadata. Properties for file/blob container/blob might be different. So I think it's also okay to leave it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best solution for this is to use a transform_if algorithm, but it is not in the STL.
I agree that we should eliminate duplication, but where do I put this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JinmingHu-MSFT You are absolutely right about the properties being different. What I was suggesting was the logic of extracting metadata from the headers. This is universal for blob/container/file/share/directory, potentially there will be 5 places that shares the same code logic.
@AlexandreBaiao I think it would be nice to have it in util.h so that if in the future file service is supported in CPPLite, it can be also called when extracting the metadata.
include/retry.h
Outdated
| { | ||
| public: | ||
|
|
||
| retry_policy(const int maximum_retries = 3, const std::chrono::seconds base_timeout = std::chrono::seconds{10}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the maximum_retries and base_timeout a reference to a constant variable defined in constant.dat.
This way it is easier for the customer to find where to change them by modifying the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please re-check
include/blob/blob_client.h
Outdated
|
|
||
| blob_client(std::shared_ptr<storage_account> account, | ||
| std::shared_ptr<executor_context> context, | ||
| std::shared_ptr<CurlEasyClient> client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::shared_ptr client [](start = 20, length = 38)
client should be internal logic that is not exposed to customers. Please make the 3rd argument int max_concurrency instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the ctor with client for future tests and to join all the ctor logics in to one flow, however it is private so the customer will not use it.
Please recheck and share your thoughts.
katmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
katmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for the contribution! Exception for the last minor comments other parts looks fine by me. Please resolve it and we can proceed to validate/merge the PR :)
This method has potential 5 places to be reused accordingly with @katmsft and should be placed in a general place accessible by all the code that needs it.
katmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Exposing a new constructor to blob_client in order to be able to allow a dependency injection pattern in the class.
Also, simplifying the retry logic.
Modernizing some parts of the code.
And adding const correctness in the container_property class.