Skip to content

Adding unknownDocument #1948

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 5 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
39 changes: 37 additions & 2 deletions Firestore/Protos/protos/firestore/local/maybe_document.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package firestore.client;
Expand All @@ -20,14 +34,35 @@ message NoDocument {
google.protobuf.Timestamp read_time = 2;
}

// Represents either an existing document or the explicitly known absence of a
// document.
// A message indicating that the document that is known to exist but its data
// is unknown.
message UnknownDocument {
// The name of the document that is known to exist, in the standard format:
// `projects/{project_id}/databases/{database_id}/documents/{document_path}`
string name = 1;

// The version at which we know the document exists.
google.protobuf.Timestamp version = 2;
}

// Represents either an existing document, the explicitly known absence of a
// document, or a document that is known to exist (at some version) but whose
// contents are unknown.
message MaybeDocument {
oneof document_type {
// Used if the document is known to not exist.
NoDocument no_document = 1;

// The document (if it exists).
google.firestore.v1beta1.Document document = 2;

// Used if the document is known to exist but its data is unknown.
UnknownDocument unknown_document = 3;
}

// `hasCommittedMutations` marks documents that were written to the remote
Copy link
Member

Choose a reason for hiding this comment

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

nit: consider fixing the name in the comment too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

// document store based on a write acknowledgment. These documents are
// potentially inconsistent with the backend's copy and use the write's
// commit version as their document version.
bool has_committed_mutations = 4;
}
14 changes: 14 additions & 0 deletions Firestore/Protos/protos/firestore/local/mutation.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

import "google/firestore/v1beta1/write.proto";
Expand Down
16 changes: 16 additions & 0 deletions Firestore/Protos/protos/firestore/local/target.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package firestore.client;
Expand All @@ -22,6 +36,7 @@ message Target {
// The last snapshot version received from the Watch Service for this target.
//
// This is the same value as TargetChange.read_time
// https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto#L734
Copy link
Member

Choose a reason for hiding this comment

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

I don't much care, but this comment could go stale and end up pointing to the wrong thing if firestore.proto is changed in the future.

Solutions:

  1. Nothing. If it changes, the reader will figure it out.
  2. Embed the commit hash in the url, i.e. https://github.com/googleapis/googleapis/blob/02111201c4752cdd0d7a5714ec6644f1d0297f51/google/firestore/v1beta1/firestore.proto#L734
  3. Omit "L734" and let the reader ctrl+f.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving as is, since this URL exists in the Android repo. I wanted both files to be the same

google.protobuf.Timestamp snapshot_version = 2;

// An opaque, server-assigned token that allows watching a query to be
Expand All @@ -38,6 +53,7 @@ message Target {
// the client should use the snapshot_version for its own purposes.
//
// This is the same value as TargetChange.resume_token
// https://github.com/googleapis/googleapis/blob/master/google/firestore/v1beta1/firestore.proto#L722
bytes resume_token = 3;

// A sequence number representing the last time this query was listened to,
Expand Down