googleapis / googleapis/google-cloud-cpp

Explicit options in the `*Stub` layer

Aperta
#12,359 0 commenti 0 reazioni 1 assegnatario Rivendicata da @scotthart Vedi su GitHub
type: cleanup
Lingua principale
C++
Stelle
659
Fork
462
Merge medio
1g 2h
PR unite (30g)
89

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.