googleapis / googleapis/google-cloud-cpp

Explicit options in the `*Stub` layer

オープン
#12,359 コメント 0 件 リアクション 0 件 担当者 1 名 @scotthart が担当を希望しています GitHub で見る
type: cleanup
主要言語
C++
スター
659
フォーク
462
平均マージ
1日 2時間
マージ済み PR(30日)
89

説明

We pass `Options` parameters from the `*Client` to the `*Connection` layer via a thread local variable[^1]. We should not use this after the `*Connection` layer. All the `*Stub` decorators should receive an explicit `Options const&` parameter.

Roughly speaking we need to do this:

- [x] Change the `MakeTracedSleeper()` to consume an explicit `Options const&` parameter.
- [x] Add `RetryLoop` overloads that consume an explicit `Options const&` parameter.
- [x] Add `RestRetryLoop` overloads that consume an explicit `Options const&` parameter.
- [x] Add `AsyncRetryLoop` overloads that consume an explicit `Options const&` parameter.
- [x] Add `AsyncRestRetryLoop` overloads that consume an explicit `Options const&` parameter.
- [x] Add `LogWrapper` overloads that consume an explicit `Options const&` parameter.
- [x] Add a `AsyncLongRunningOperation` overload that consumes an explicit `Options const&` parameter.
- [x] Support explicit options in pagination ranges.

These overloads could be based on the type of the functor. We can use `std::enable_if` and `std::is_invocable` to remove the variants that cannot use explicit parameters.

- Then we can change the generator to emit all the gRPC-based stubs with an extra `Options const&` parameter.
- We will need to change all the unit tests for golden files at the same time.
- We will need to change any hand-written code that uses the generated `*Stub` classes at the same time.

We can break down this work further:

- [x] Change LROs to use explicit options
- [x] Change streaming read RPCs to use explicit options
- [x] Change streaming write RPCs to use explicit options
- [x] Change bidir streaming RPCs to use explicit options
- [x] Change async streaming read RPCs to use explicit options
- [x] Change async streaming write RPCs to use explicit options
- [x] Change async RPCs returning `Status` to use explicit options
- [x] Change async RPCs returning `StatusOr` to use explicit options
- [x] Change sync RPCs returning `Status` to use explicit options
- [x] Change sync RPCs returning `StatusOr` to use explicit options

The REST-based stubs should not need changes because the `Options` are already provided in the `RestContext&` parameter. Though we need to think about the non-constness of this parameter, i.e., we do want it to remain non-const, but maybe we cannot trust its `options()` function to carry the original options all the way through.

[^1]: We do this because changing the API to `*Connection` would be breaking, and we don't want a massive breaking change like modifying all these APIs.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。