googleapis / googleapis/google-cloud-cpp
Support idempotency token for Storage client
- Langage dominant
- C++
- Étoiles
- 659
- Forks
- 462
- Merge moyen
- 1 j 2 h
- PR mergées (30 j)
- 89
Description
The GCS API supports (or soon will support) an idempotency token header. The header allows GCS to detect if a request is a duplicate, and returns the same value for duplicate requests.
To implement this we need to:
- Create the unique id in the `RetryClient`
- The decorators below `RetryClient` need to accept a new "context" field on each function
- The gRPC and REST-based implementations need to consume this field and send it to the service as a header.
It is time to split the `RawClient` stack in two, like we do for all the other libraries. The `*Connection` stack will be used for mocks and to implement the retry loop. The typical function will look like so:
```cc
virtual StatusOr GetBucketMetadata(
GetBucketMetadataRequest const& request) = 0;
```
The `*Stub` will implement logging, tracing, and actually sending the data to the service, the typical function will look like so:
```cc
virtual StatusOr GetBucketMetadata(
rest_internal::RestContext& context,
Options const& options,
GetBucketMetadataRequest const& request) = 0;
```
Note how the options are passed explicitly and not tunneled via `CurrentOptions`. Also note that the "context" object is REST-based. We can change both over time, as the classes in the `*Stub` hierarchy are not needed for mocking.
----
Java implemented this in:
https://github.com/googleapis/java-storage/pull/2027
Internally, the design doc is [go/gcs-client-idem-token](http://goto.google.com/gcs-client-idem-token)
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par suivre les implémentations de RetryClient, RawClient, gRPC et REST mentionnées dans l’issue. Examinez la séparation des stacks *Connection et *Stub, notamment le passage de context et des Options explicites. Le travail est terminé lorsque le token est créé, propagé à travers les deux implémentations et envoyé comme en-tête de service, tout en préservant les comportements de mocking et de retry.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- cpp, gcp, grpc
- Domaine
- api, backend-api-design, cloud
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100