googleapis / googleapis/google-cloud-cpp

Explicit options in the `*Stub` layer

Abierto
#12,359 0 comentarios 0 reacciones 1 asignado Reclamado por @scotthart Ver en GitHub
type: cleanup
Lenguaje dominante
C++
Estrellas
659
Forks
462
Merge medio
1 d 2 h
PR fusionados (30 d)
89

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.