Skip to content
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

CPPLite initial commit #1

Merged
merged 8 commits into from
Sep 10, 2018
Merged

CPPLite initial commit #1

merged 8 commits into from
Sep 10, 2018

Conversation

katmsft
Copy link
Member

@katmsft katmsft commented Aug 17, 2018

No description provided.

@vinjiang
Copy link
Member

@JasonYang-MSFT , can you CR?

include/common.h Outdated
virtual iterator_base end() = 0;
};

class my_iterator : public my_iterator_base {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my_iterator [](start = 14, length = 11)

Check whether it is used or not. If not, we can remove it, otherwise we need a better naming.

DAT(http_post, "POST")
DAT(http_put, "PUT")

DAT(default_endpoint_suffix, ".core.windows.net")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_endpoint_suffix [](start = 4, length = 23)

Besides default suffix, does other environment supported or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it requires the user to specify the endpoint and it has to be the form of "account.blob.endpoint".

include/constants.h Outdated Show resolved Hide resolved

//AZURE_STORAGE_API void build_request(const storage_account &a, const get_blob_request_base &r, http_base &h);

class blob_property
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blob_property [](start = 14, length = 13)

We should move blob_property to a common header file instead of a request_base.h

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This item is recorded, and can be fix in the future. This refinement is not going to break the customer and is not critical enough to address in the initial release.

// blob_type m_type;
// azure::storage::lease_status m_lease_status;
// azure::storage::lease_state m_lease_state;
// azure::storage::lease_duration m_lease_duration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those value should be necessary properties for blob, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the logic of parsing them is not yet finished, and it will be done if requested by customer.

namespace microsoft_azure {
namespace storage {

void append_block_request_base::build_request(const storage_account &a, http_base &h) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a [](start = 77, length = 1)

I think we should use more meaningful names than 'a', 'h', 'r'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a refinement that can be done in the future, which does not introduce breaking changes.

url.append_path(r.container()).append_path(r.blob());

url.add_query(constants::query_comp, constants::query_comp_appendblock);
add_optional_query(url, constants::query_timeout, r.timeout());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r.timeout() [](start = 62, length = 11)

timeout() is always 0. So there is no way to set request time out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is already recorded in the missing feature.

add_optional_content_md5(h, headers, r.content_md5());
add_access_condition_headers(h, headers, r);

add_ms_header(h, headers, constants::header_ms_client_request_id, r.ms_client_request_id(), true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ms_client_request_id [](start = 80, length = 20)

request id always empty too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is already recorded in the missing feature.

} while (!marker.empty());

return results;
}*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is marked out, we can remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

h.set_url(url.to_string());

storage_headers headers;
//add_access_condition_headers(h, headers, r);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//add_access_condition_headers(h, headers, r); [](start = 12, length = 46)

Is access condition in scope?

If it is in scope but not ready yet, we can add a TODO flag here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it is currently not in scope, it is recorded in the missing feature.

… list container, renamed to list_container_segmented.
class create_container_request_base : public blob_request_base
{
public:
enum class blob_public_access {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ [](start = 37, length = 2)

'{'


virtual std::string container() const = 0;

virtual blob_public_access ms_blob_public_access() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ [](start = 64, length = 2)

'{'

return blob_public_access::unspecified;
}

//virtual std::map<std::string, std::string> ms_meta() const {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//virtual std::map<std::string, std::string> ms_meta() const {}; [](start = 8, length = 64)

Remove it or make a TODO here.

.gitignore Outdated
*.dylib

# Executables
*.exe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be .exe if this change is to support Linux only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this will be modified.


project(azurestoragelite)

option(BUILD_TESTS "Build test codes" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this make BUILD_TESTS always OFF?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, when user specifies -DBUILD_TESTS=true, tests will be build.

"inheritEnvironments": [ "linux-x64" ],
"variables": [
{
"name": "BUILD_TESTS",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this overwrite option(BUILD_TESTS "Build test codes" OFF)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is develop only environment, so this should always build tests.

README.md Outdated
# Contributing
## About

The Azure Storage Client Library for C++ allows you to build applications against Microsoft Azure Storage's blob service. This is a minimum dependency version that provide basic object storage. For an overview of Azure Storage, see [Introduction to Microsoft Azure Storage](http://azure.microsoft.com/en-us/documentation/articles/storage-introduction/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Storage Client Library for C++ (Lite)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give a quick link here for customer wants to use tqf and other blob's missing feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both comments are valid, this will be modified in the next commit.

README.md Outdated
azure::storage_lite::blob_client client(storage_account, connection_count);

// Start using
auto outcome = client.create_container("YOUR_CONTAINER_NAME");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no wait happened here, the sample program will exit, maybe before sending requests to the server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, added .get() to get the result.

class storage_request_base
{
public:
virtual std::string ms_client_request_id() const { return std::string(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to create request id for each request for debug purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid improvement, but is beyond the scope of this release. Added todo tag to track.

url.add_optional_query(constant::query_timeout, (r.timeout() != std::numeric_limits<unsigned long long>::max() ? std::to_string(r.timeout()) : std::string()));
h.set_url(url.to_string());

details::add_optional_header(h, constant::header_content_encoding, r.content_encoding());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These headers are not needed for get blob metadata, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true, this should be used with set blob metadata or set blob properties. Added todo tag to move it when implementing those APIs.

url.add_optional_query(constant::query_timeout, (r.timeout() != std::numeric_limits<unsigned long long>::max() ? std::to_string(r.timeout()) : std::string()));
h.set_url(url.to_string());

details::add_optional_header(h, constant::header_content_encoding, r.content_encoding());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check the headers and create items for mising headers.
For example, copy source, copy progress, incremental copy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is in todo list, and should be removed from cmakelist.

namespace storage_lite {
namespace experimental {

struct query_entities_request_base : table_request_base {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If table is not in the scope, it is better to remove from this release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is in todo list, and should be removed from cmakelist.

template<typename Request, typename Http>
struct storage_request_processor<Request, Http, std::enable_if_t<std::is_base_of<set_blob_metadata_request, std::remove_reference_t<Request>>::value>> {
static inline void process(Request &&r, Http &&h) {
//static_assert(std::is_same<decltype(r.use_https()), decltype(r.get_blob_request::use_https())>::value, "get_blob_request::use_https != Request::use_https");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is in todo list, and should be removed from cmakelist.

};

template<>
inline list_containers_response xml_parser_base::parse_response<list_containers_response>(const std::string &xml) const\
Copy link
Member

@JasonYang-MSFT JasonYang-MSFT Sep 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'\'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed \


namespace azure { namespace storage_lite {

namespace {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extran name space?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is to avoid namespace clash for helper functions.


http->set_output_stream(storage_ostream(os));

const auto response = async_executor<void>::submit(m_account, request, http, m_context).get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the request changed from async to sync then return with async.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but there is no plan to change it at the moment. The initial release will leave it as is.


auto request = std::make_shared<get_container_property_request>(container);

auto response = async_executor<void>::submit(m_account, request, http, m_context).get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, async to sync too. Think about to add the post process as a function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also noted as TODO and to be refined in the future.

return storage_outcome<container_property>(containerProperty);
}

std::future<storage_outcome<list_containers_response>> blob_client::list_containers_segmented(const std::string &prefix, const std::string& continuation_token, const int max_result, bool include_metadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list_containers_response, the name should align with list blobs segmented.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, already modified.

/// </summary>
/// <param name="account">An existing <see cref="azure::storage_lite::storage_account" /> object.</param>
/// <param name="size">An int value indicates the maximum concurrency expected during execute requests against the service.</param>
blob_client(std::shared_ptr<storage_account> account, int size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size is actually the maximun concurrency value, consider to change the name. Also you can try to add a default value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good proposal for the optimized concurrency count, but I have already changed the naming. Any thoughts?

{
const auto &r = *this;

h.set_absolute_timeout(30L);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those timeouts are magic values, we should find a way to allow setting max execution time, request time out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added todo for future enhancement.


size_t CurlEasyRequest::header_callback(char *buffer, size_t size, size_t nitems, void *userdata)
{
CurlEasyRequest::MY_TYPE *p = static_cast<CurlEasyRequest::MY_TYPE *>(userdata);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to have a better name than "MY_TYPE".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to REQUEST_TYPE.


inline void add_ms_header(http_base &h, storage_headers &headers, const std::string &name, const std::string &value, bool optional = false)
{
if (!optional || !value.empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a required header is missing, it will still proceed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a required header is missing, it means that the header must be added with an empty value. The function will proceed to add it to the headers and proceed.


inline void add_ms_header(http_base &h, storage_headers &headers, const std::string &name, unsigned long long value, bool optional = false)
{
if (!optional || !value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!value is not align with other place I saw the definition of not set unsigned long long value. In some place, it is using max value of unsigned long long.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, now changed it to compare with max value of unsigned long long.

string_to_sign.append(headers.content_length).append("\n");
string_to_sign.append(headers.content_md5).append("\n");
string_to_sign.append(headers.content_type).append("\n");
string_to_sign.append("\n"); // Date
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Date is not in string to sign?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are only using x-ms-date, so Date header will always be empty.

Copy link
Member

@JasonYang-MSFT JasonYang-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, first release is mostly release as it is in blob fuse. As long as we mark out the missing features, covered basic functionalities, fixed the coding style and well documented, I think it is OK to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants