target.proto 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2018 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package firestore.client;
  16. option java_multiple_files = true;
  17. option java_package = "com.google.firebase.firestore.proto";
  18. option objc_class_prefix = "FSTPB";
  19. import "google/firestore/v1/firestore.proto";
  20. import "google/protobuf/timestamp.proto";
  21. // A Target is a long-lived data structure representing a resumable listen on a
  22. // particular user query. While the query describes what to listen to, the
  23. // Target records data about when the results were last updated and enough
  24. // information to be able to resume listening later.
  25. message Target {
  26. // An auto-generated sequential numeric identifier for the target. This
  27. // serves as the identity of the target, and once assigned never changes.
  28. int32 target_id = 1;
  29. // The last snapshot version received from the Watch Service for this target.
  30. //
  31. // This is the same value as TargetChange.read_time
  32. // https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto#L734
  33. google.protobuf.Timestamp snapshot_version = 2;
  34. // An opaque, server-assigned token that allows watching a query to be
  35. // resumed after disconnecting without retransmitting all the data that
  36. // matches the query. The resume token essentially identifies a point in
  37. // time from which the server should resume sending results.
  38. //
  39. // This is related to the snapshot_version in that the resume_token
  40. // effectively also encodes that value, but the resume_token is opaque and
  41. // sometimes encodes additional information.
  42. //
  43. // A consequence of this is that the resume_token should be used when asking
  44. // the server to reason about where this client is in the watch stream, but
  45. // the client should use the snapshot_version for its own purposes.
  46. //
  47. // This is the same value as TargetChange.resume_token
  48. // https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto#L722
  49. bytes resume_token = 3;
  50. // A sequence number representing the last time this query was listened to,
  51. // used for garbage collection purposes.
  52. //
  53. // Conventionally this would be a timestamp value, but device-local clocks
  54. // are unreliable and they must be able to create new listens even while
  55. // disconnected. Instead this should be a monotonically increasing number
  56. // that's incremented on each listen call.
  57. //
  58. // This is different from the target_id since the target_id is an immutable
  59. // identifier assigned to the Target on first use while
  60. // last_listen_sequence_number is updated every time the query is listened
  61. // to.
  62. int64 last_listen_sequence_number = 4;
  63. // The server-side type of target to listen to.
  64. oneof target_type {
  65. // A target specified by a query.
  66. google.firestore.v1.Target.QueryTarget query = 5;
  67. // A target specified by a set of document names.
  68. google.firestore.v1.Target.DocumentsTarget documents = 6;
  69. }
  70. // Denotes the maximum snapshot version at which the associated query view
  71. // contained no limbo documents.
  72. google.protobuf.Timestamp last_limbo_free_snapshot_version = 7;
  73. }
  74. // Global state tracked across all Targets, tracked separately to avoid the
  75. // need for extra indexes.
  76. message TargetGlobal {
  77. // The highest numbered target id across all Targets.
  78. //
  79. // See Target.target_id.
  80. int32 highest_target_id = 1;
  81. // The highest numbered last_listen_sequence_number across all Targets.
  82. //
  83. // See Target.last_listen_sequence_number.
  84. int64 highest_listen_sequence_number = 2;
  85. // A global snapshot version representing the last consistent snapshot we
  86. // received from the backend. This is monotonically increasing and any
  87. // snapshots received from the backend prior to this version (e.g. for
  88. // targets resumed with a resume_token) should be suppressed (buffered) until
  89. // the backend has caught up to this snapshot_version again. This prevents
  90. // our cache from ever going backwards in time.
  91. //
  92. // This is updated whenever our we get a TargetChange with a read_time and
  93. // empty target_ids.
  94. google.protobuf.Timestamp last_remote_snapshot_version = 3;
  95. // On platforms that need it, holds the number of targets persisted.
  96. int32 target_count = 4;
  97. }