feat(common): a generic long-running operation#6804
Conversation
Long-running operations [aip/151] are used for API methods that take a significant amount of time to complete (think minutes, maybe an hour). The gRPC API returns a "promise" object, represented by the `google::longrunning::Operation` proto, and the application (or client library) should periodically poll this object until it is "done". In the C++ client libraries we represent these long-running operations by a member function that returns `future<StatusOr<ReturnType>>`. This PR introduces a generic function to implement these member functions. It first starts the operation using an asynchronous retry loop, and then starts an asynchronous loop to poll the operation until it completes. The promise can complete with an error, which is represented by a `google::cloud::Status` object, or with success and some `ReturnType` value. The application may also configure the "polling policy", which may stop the polling even though the operation has not completed. A future PR will change the generated libraries to use this function. With some work we could change the Spanner library to use it too, without the need to launch detached threads to poll the results. With substantial work we could change the Bigtable library to use it too. [aip/151]: https://google.aip.dev/151
|
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
|
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
Codecov Report
@@ Coverage Diff @@
## main #6804 +/- ##
========================================
Coverage 95.50% 95.51%
========================================
Files 1257 1262 +5
Lines 112769 113105 +336
========================================
+ Hits 107704 108032 +328
- Misses 5065 5073 +8
Continue to review full report at Codecov.
|
|
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
|
PTAL |
|
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
devjgm
left a comment
There was a problem hiding this comment.
A couple comments/questions, but I don't think any of mine were blockers.
|
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
Long-running operations aip/151 are used for API methods that take a
significant amount of time to complete (think minutes, maybe an hour).
The gRPC API returns a "promise" object, represented by the
google::longrunning::Operationproto, and the application (or clientlibrary) should periodically poll this object until it is "done".
In the C++ client libraries we represent these long-running operations
by a member function that returns
future<StatusOr<ReturnType>>. ThisPR introduces a generic function to implement these member functions. It
first starts the operation using an asynchronous retry loop, and then
starts an asynchronous loop to poll the operation until it completes.
The promise can complete with an error, which is represented by a
google::cloud::Statusobject, or with success and someReturnTypevalue. The application may also configure the "polling policy", which
may stop the polling even though the operation has not completed.
A future PR will change the generated libraries to use this function.
With some work we could change the Spanner library to use it too,
without the need to launch detached threads to poll the results. With
substantial work we could change the Bigtable library to use it too.
Part of the work for #5934, for #4038, and for #6821
This change is