firebase / firebase/firebase-cpp-sdk

[Bug] Fix Document.Get behavior to send unary gRPC request instead of setting up a Listen stream for Document updates

Ouverte
#1,700 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
api: firestore new type: question
Langage dominant
C++
Étoiles
326
Forks
137
Merge moyen
3 j 9 h
PR mergées (30 j)
5

Description

### [REQUIRED] Please fill in the following fields:

* Pre-built SDK from the [website](https://firebase.google.com/download/cpp) or open-source from this repo: _____
* Firebase C++ SDK version: [unity-v11.8.0](https://github.com/firebase/firebase-cpp-sdk/releases/tag/unity-v11.8.0) onwards
* Problematic Firebase Component: Firestore Database API
* Other Firebase Components in use: N/A
* Platform you are using the C++ SDK on: Linux (but exists on all platforms)
* Platform you are targeting: desktop

### [REQUIRED] Please describe the issue here:

The Firestore C++ Mobile SDK API implementation for DocumentReference.Get() is sub-optimal. Instead a sending a single gRPC request for Firestore.GetDocument, it opens a Firestore.Listen stream to listen for DocumentSnapshots and serves the first snapshot as response to the Get() call.

At minimum, this has latency impact - cost of setting up and tearing down a Listen stream is higher and using it to only read first version of the DocumentSnapshot, the cost is not amortized. Arguably, this may even be construed as incorrect behavior if one were to look at the network messages generated by these calls by this implementation as it deviates from the intent of the Firestore API.

#### Steps to reproduce:

Have you been able to reproduce this issue with just the [Firebase C++ quickstarts](https://github.com/firebase/quickstart-cpp) ?
What's the issue repro rate? (eg 100%, 1/5 etc)

*100%. Using the DocumentReference.Get() API.*

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

#### Relevant Code:

https://github.com/firebase/firebase-cpp-sdk/blob/5fead53b4e57ed355c40dd313634a91dd51c3671/firestore/src/main/document_reference_main.cc#L59

```
// Get should send a unary RPC - not a Streaming Listen RPC
Future DocumentReferenceInternal::Get(Source source) {
auto promise =
promise_factory_.CreatePromise(AsyncApis::kGet);
auto listener = ListenerWithPromise(promise);
reference_.GetDocument(ToCoreApi(source), std::move(listener));
return promise.future();
}
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez dans firestore/src/main/document_reference_main.cc, au niveau de DocumentReferenceInternal::Get, et suivez l’implémentation de l’API Firestore référencée. Vérifiez comment GetDocument et le chemin Listen sont sélectionnés, puis vérifiez que Get() utilise une requête unaire et renvoie toujours le premier DocumentSnapshot attendu sans ouvrir de flux Listen.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp, grpc
Domaine
backend-api-design, databases
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.