Skip to content

Migrate Firestore to the v1 protocol #2200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ for text_proto_file in "${text_protos_dir}"/*; do
echo "${file_content}" \
| "${SRCROOT}/Pods/!ProtoCompiler/protoc" \
-I"${SRCROOT}/../../Firestore/Protos/protos" \
--encode=google.firestore.v1beta1."${message_type}" \
google/firestore/v1beta1/document.proto > "${binary_protos_dir}/${file_name}"
--encode=google.firestore.v1."${message_type}" \
google/firestore/v1/document.proto > "${binary_protos_dir}/${file_name}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(github won't let me comment on files not in the PR.)

Check out https://github.com/firebase/firebase-ios-sdk/blob/wilhuff/v1/Firestore/core/src/firebase/firestore/model/field_path.cc#L82 for a missed instance of v1beta1. It's a pretty stale comment, since it refers to moving to v1beta1 rather than away from it. The bug it references has been fixed (1y+ ago)

Fixing the code here is outside the scope of this PR, so this could be deferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just wasn't cleaned up. I've removed the stale comments.

done
10 changes: 5 additions & 5 deletions Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#import "Firestore/Protos/objc/firestore/local/MaybeDocument.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Target.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Local/FSTQueryData.h"
Expand Down
6 changes: 3 additions & 3 deletions Firestore/Example/Tests/Model/FSTFieldValueTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ - (void)testWrapsBooleans {
};

- (void)testNormalizesNaNs {
// NOTE: With v1beta1 query semantics, it's no longer as important that our NaN representation
// matches the backend, since all NaNs are defined to sort as equal, but we preserve the
// normalization and this test regardless for now.
// NOTE: With v1 query semantics, it's no longer as important that our NaN representation matches
// the backend, since all NaNs are defined to sort as equal, but we preserve the normalization and
// this test regardless for now.

// We use a canonical NaN bit pattern that's common for both Java and Objective-C. Specifically:
// - sign: 0
Expand Down
10 changes: 5 additions & 5 deletions Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

#import "Firestore/Protos/objc/firestore/local/MaybeDocument.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/rpc/Status.pbobjc.h"
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"
#import "Firestore/Source/API/FIRFieldValue+Internal.h"
Expand Down
2 changes: 1 addition & 1 deletion Firestore/Source/Local/FSTLocalSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Serializer for values stored in the LocalStore.
*
* Note that FSTLocalSerializer currently delegates to the serializer for the Firestore v1beta1 RPC
* Note that FSTLocalSerializer currently delegates to the serializer for the Firestore v1 RPC
* protocol to save implementation time and code duplication. We'll need to revisit this when the
* RPC protocol we use diverges from local storage.
*/
Expand Down
7 changes: 3 additions & 4 deletions Firestore/Source/Local/FSTLocalSerializer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import "Firestore/Protos/objc/firestore/local/MaybeDocument.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Target.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Document.pbobjc.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTDocument.h"
Expand Down Expand Up @@ -103,9 +103,8 @@ - (FSTMaybeDocument *)decodedMaybeDocument:(FSTPBMaybeDocument *)proto {
}

/**
* Encodes a Document for local storage. This differs from the v1beta1 RPC serializer for
* Documents in that it preserves the updateTime, which is considered an output only value by the
* server.
* Encodes a Document for local storage. This differs from the v1 RPC serializer for Documents in
* that it preserves the updateTime, which is considered an output only value by the server.
*/
- (GCFSDocument *)encodedDocument:(FSTDocument *)document {
FSTSerializerBeta *remoteSerializer = self.remoteSerializer;
Expand Down
10 changes: 5 additions & 5 deletions Firestore/Source/Remote/FSTSerializerBeta.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include <utility>
#include <vector>

#import "Firestore/Protos/objc/google/firestore/v1beta1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1beta1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Common.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Document.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Query.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Write.pbobjc.h"
#import "Firestore/Protos/objc/google/rpc/Status.pbobjc.h"
#import "Firestore/Protos/objc/google/type/Latlng.pbobjc.h"

Expand Down
12 changes: 6 additions & 6 deletions Firestore/core/src/firebase/firestore/local/local_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "Firestore/Protos/nanopb/firestore/local/maybe_document.nanopb.h"
#include "Firestore/Protos/nanopb/firestore/local/target.nanopb.h"
#include "Firestore/Protos/nanopb/google/firestore/v1beta1/document.nanopb.h"
#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h"
#include "Firestore/core/src/firebase/firestore/core/query.h"
#include "Firestore/core/src/firebase/firestore/model/field_value.h"
#include "Firestore/core/src/firebase/firestore/model/no_document.h"
Expand Down Expand Up @@ -113,22 +113,22 @@ std::unique_ptr<MaybeDocument> LocalSerializer::DecodeMaybeDocument(
void LocalSerializer::EncodeDocument(Writer* writer,
const Document& doc) const {
// Encode Document.name
writer->WriteTag({PB_WT_STRING, google_firestore_v1beta1_Document_name_tag});
writer->WriteTag({PB_WT_STRING, google_firestore_v1_Document_name_tag});
writer->WriteString(rpc_serializer_.EncodeKey(doc.key()));

// Encode Document.fields (unless it's empty)
const ObjectValue& object_value = doc.data().object_value();
if (!object_value.internal_value.empty()) {
rpc_serializer_.EncodeObjectMap(
writer, object_value.internal_value,
google_firestore_v1beta1_Document_fields_tag,
google_firestore_v1beta1_Document_FieldsEntry_key_tag,
google_firestore_v1beta1_Document_FieldsEntry_value_tag);
google_firestore_v1_Document_fields_tag,
google_firestore_v1_Document_FieldsEntry_key_tag,
google_firestore_v1_Document_FieldsEntry_value_tag);
}

// Encode Document.update_time
writer->WriteTag(
{PB_WT_STRING, google_firestore_v1beta1_Document_update_time_tag});
{PB_WT_STRING, google_firestore_v1_Document_update_time_tag});
writer->WriteNestedMessage([&](Writer* writer) {
rpc_serializer_.EncodeVersion(writer, doc.version());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ namespace local {
* @brief Serializer for values stored in the LocalStore.
*
* Note that local::LocalSerializer currently delegates to the
* remote::Serializer (for the Firestore v1beta1 RPC protocol) to save
* implementation time and code duplication. We'll need to revisit this when the
* RPC protocol we use diverges from local storage.
* remote::Serializer (for the Firestore v1 RPC protocol) to save implementation
* time and code duplication. We'll need to revisit this when the RPC protocol
* we use diverges from local storage.
*/
class LocalSerializer {
public:
Expand Down Expand Up @@ -104,7 +104,7 @@ class LocalSerializer {

private:
/**
* Encodes a Document for local storage. This differs from the v1beta1 RPC
* Encodes a Document for local storage. This differs from the v1 RPC
* serializer for Documents in that it preserves the updateTime, which is
* considered an output only value by the server.
*/
Expand Down
2 changes: 1 addition & 1 deletion Firestore/core/src/firebase/firestore/nanopb/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "Firestore/core/src/firebase/firestore/nanopb/reader.h"

#include "Firestore/Protos/nanopb/google/firestore/v1beta1/document.nanopb.h"
#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h"

namespace firebase {
namespace firestore {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/core/src/firebase/firestore/nanopb/tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace nanopb {
* field_number is one of the field tags that nanopb generates based off of
* the proto messages. They're typically named in the format:
* <parentNameSpace>_<childNameSpace>_<message>_<field>_tag, e.g.
* google_firestore_v1beta1_Document_name_tag.
* google_firestore_v1_Document_name_tag.
*/
struct Tag {
Tag() {
Expand Down
2 changes: 1 addition & 1 deletion Firestore/core/src/firebase/firestore/nanopb/writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "Firestore/core/src/firebase/firestore/nanopb/writer.h"

#include "Firestore/Protos/nanopb/google/firestore/v1beta1/document.nanopb.h"
#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h"
#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"

namespace firebase {
Expand Down
5 changes: 2 additions & 3 deletions Firestore/core/src/firebase/firestore/remote/datastore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@

namespace {

const auto kRpcNameCommit = "/google.firestore.v1beta1.Firestore/Commit";
const auto kRpcNameLookup =
"/google.firestore.v1beta1.Firestore/BatchGetDocuments";
const auto kRpcNameCommit = "/google.firestore.v1.Firestore/Commit";
const auto kRpcNameLookup = "/google.firestore.v1.Firestore/BatchGetDocuments";

std::unique_ptr<Executor> CreateExecutor() {
auto queue = dispatch_queue_create("com.google.firebase.firestore.rpc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "Firestore/core/src/firebase/firestore/util/status.h"
#include "grpcpp/support/byte_buffer.h"

#import "Firestore/Protos/objc/google/firestore/v1beta1/Firestore.pbobjc.h"
#import "Firestore/Protos/objc/google/firestore/v1/Firestore.pbobjc.h"
#import "Firestore/Source/Core/FSTTypes.h"
#import "Firestore/Source/Local/FSTQueryData.h"
#import "Firestore/Source/Model/FSTMutation.h"
Expand Down
Loading