Azure / azure-storage-cpp

Microsoft Azure Storage Client Library for C++
http://azure.github.io/azure-storage-cpp
Apache License 2.0
132 stars 147 forks source link

Asynchronous notification of blob change #317

Closed gri6507 closed 4 years ago

gri6507 commented 4 years ago

Unless I am missing something in the API, there doesn't appear to be any methods to subscribe for asynchronous notifications of blob changes, either specific blob or any blob in a container.

Is my understanding correct?

Thank you!

Jinming-Hu commented 4 years ago

This cpp sdk is built on top of storage services REST APIs. Blob storage service doesn't provide notification mechanism, so cpp sdk cannot do anything either.

You can have a look at Azure functions, which might be useful to your requirements.

gri6507 commented 4 years ago

@JinmingHu-MSFT I understand that the REST API may not provide the functionality natively. However, C++ SDK can provide a relatively simple wrapper scheme to mimic such async functionality. For example,

void register_for_bob_change_notification(callback_fn* cb, const std::string &blob_path, unsigned int poll_interval)

The implementation of such a function would simply start a new thread which would poll for the requested blob path at the requested polling interval using the currently available API. When this polling loop detects that the blob md5 property changes or when the blob itself is no longer there, then the callback function would get issued.

Please consider this as a new feature request

Jinming-Hu commented 4 years ago

@gri6507 C++ SDK is pretty much just a wrapper of storage REST APIs. In this sense, it should not provide features/functions that storage REST APIs do not provide.

Plus the polling strategy is neither timely nor efficient. I don't think it's the proper way to do what you want. Please consider Azure functions, which is designed to do that.

Or maybe you can implement register_for_bob_change_notification in your code, using C++ sdk. Detect blob change by its etag property, which is updated everytime the blob's content or metadata is changed.

gri6507 commented 4 years ago

Thank you for the explanation and consideration. I will now consider this ticket closed