googleapis / googleapis/google-cloud-cpp

Explicit options in the `*Stub` layer

Offen
#12,359 0 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @scotthart Auf GitHub ansehen
type: cleanup
Vorherrschende Sprache
C++
Sterne
659
Forks
462
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
89

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.