google-cloud-firestore 2.1.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/CONTRIBUTING.md +2 -2
- data/LOGGING.md +1 -1
- data/lib/google-cloud-firestore.rb +1 -0
- data/lib/google/cloud/firestore/batch.rb +3 -4
- data/lib/google/cloud/firestore/client.rb +10 -10
- data/lib/google/cloud/firestore/collection_reference_list.rb +3 -3
- data/lib/google/cloud/firestore/convert.rb +151 -173
- data/lib/google/cloud/firestore/document_listener.rb +86 -7
- data/lib/google/cloud/firestore/document_reference.rb +3 -4
- data/lib/google/cloud/firestore/document_reference/list.rb +4 -5
- data/lib/google/cloud/firestore/document_snapshot.rb +1 -2
- data/lib/google/cloud/firestore/field_path.rb +2 -2
- data/lib/google/cloud/firestore/query.rb +22 -20
- data/lib/google/cloud/firestore/query_listener.rb +82 -1
- data/lib/google/cloud/firestore/service.rb +4 -1
- data/lib/google/cloud/firestore/transaction.rb +5 -5
- data/lib/google/cloud/firestore/version.rb +1 -1
- data/lib/google/cloud/firestore/watch/inventory.rb +9 -8
- data/lib/google/cloud/firestore/watch/listener.rb +24 -17
- metadata +6 -6
@@ -33,7 +33,8 @@ module Google
|
|
33
33
|
# make inserting and removing objects much more efficent.
|
34
34
|
class Inventory
|
35
35
|
attr_accessor :current
|
36
|
-
attr_reader :resume_token
|
36
|
+
attr_reader :resume_token
|
37
|
+
attr_reader :read_time
|
37
38
|
|
38
39
|
def initialize client, query
|
39
40
|
@client = client
|
@@ -155,24 +156,24 @@ module Google
|
|
155
156
|
|
156
157
|
protected
|
157
158
|
|
158
|
-
def query_comparison_proc
|
159
|
+
def query_comparison_proc left, right
|
159
160
|
# TODO: Remove this when done benchmarking
|
160
161
|
@comp_proc_counter += 1
|
161
162
|
|
162
|
-
return Order.compare_field_values
|
163
|
+
return Order.compare_field_values left.ref, right.ref if @query.nil?
|
163
164
|
|
164
165
|
@directions ||= @query.query.order_by.map(&:direction)
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
@directions.zip(
|
169
|
-
comp =
|
167
|
+
left_comps = left.query_comparisons_for @query.query
|
168
|
+
right_comps = right.query_comparisons_for @query.query
|
169
|
+
@directions.zip(left_comps, right_comps).each do |dir, left_comp, right_comp|
|
170
|
+
comp = left_comp <=> right_comp
|
170
171
|
comp = 0 - comp if dir == :DESCENDING
|
171
172
|
return comp unless comp.zero?
|
172
173
|
end
|
173
174
|
|
174
175
|
# Compare paths when everything else is equal
|
175
|
-
ref_comp = Order.compare_field_values
|
176
|
+
ref_comp = Order.compare_field_values left.ref, right.ref
|
176
177
|
ref_comp = 0 - ref_comp if @directions.last == :DESCENDING
|
177
178
|
ref_comp
|
178
179
|
end
|
@@ -30,7 +30,7 @@ module Google
|
|
30
30
|
class Listener
|
31
31
|
include MonitorMixin
|
32
32
|
|
33
|
-
def self.for_doc_ref doc_ref, &callback
|
33
|
+
def self.for_doc_ref parent, doc_ref, &callback
|
34
34
|
raise ArgumentError if doc_ref.nil?
|
35
35
|
raise ArgumentError if callback.nil?
|
36
36
|
|
@@ -44,10 +44,10 @@ module Google
|
|
44
44
|
)
|
45
45
|
)
|
46
46
|
|
47
|
-
new nil, doc_ref, doc_ref.client, init_listen_req, &callback
|
47
|
+
new parent, nil, doc_ref, doc_ref.client, init_listen_req, &callback
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.for_query query, &callback
|
50
|
+
def self.for_query parent, query, &callback
|
51
51
|
raise ArgumentError if query.nil?
|
52
52
|
raise ArgumentError if callback.nil?
|
53
53
|
|
@@ -61,12 +61,13 @@ module Google
|
|
61
61
|
)
|
62
62
|
)
|
63
63
|
|
64
|
-
new query, nil, query.client, init_listen_req, &callback
|
64
|
+
new parent, query, nil, query.client, init_listen_req, &callback
|
65
65
|
end
|
66
66
|
|
67
|
-
def initialize query, doc_ref, client, init_listen_req, &callback
|
67
|
+
def initialize parent, query, doc_ref, client, init_listen_req, &callback
|
68
68
|
super() # to init MonitorMixin
|
69
69
|
|
70
|
+
@parent = parent
|
70
71
|
@query = query
|
71
72
|
@doc_ref = doc_ref
|
72
73
|
@client = client
|
@@ -82,7 +83,7 @@ module Google
|
|
82
83
|
def stop
|
83
84
|
synchronize do
|
84
85
|
@stopped = true
|
85
|
-
@request_queue
|
86
|
+
@request_queue&.push self
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -119,6 +120,8 @@ module Google
|
|
119
120
|
|
120
121
|
def send_callback query_snp
|
121
122
|
@callback.call query_snp
|
123
|
+
rescue StandardError => e
|
124
|
+
@parent.error! e
|
122
125
|
end
|
123
126
|
|
124
127
|
def start_listening!
|
@@ -270,25 +273,29 @@ module Google
|
|
270
273
|
@request_queue.push self
|
271
274
|
rescue GRPC::Cancelled, GRPC::DeadlineExceeded, GRPC::Internal,
|
272
275
|
GRPC::ResourceExhausted, GRPC::Unauthenticated,
|
273
|
-
GRPC::Unavailable, GRPC::Core::CallError
|
276
|
+
GRPC::Unavailable, GRPC::Core::CallError => e
|
274
277
|
# Restart the stream with an incremental back for a retriable error.
|
275
278
|
# Also when GRPC raises the internal CallError.
|
276
279
|
|
277
|
-
#
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
280
|
+
# Raise if retried more than the max
|
281
|
+
if @backoff[:current] > @backoff[:max]
|
282
|
+
@parent.error! e
|
283
|
+
raise e
|
284
|
+
else
|
285
|
+
# Sleep with incremental backoff before restarting
|
286
|
+
sleep @backoff[:delay]
|
282
287
|
|
283
|
-
|
284
|
-
|
285
|
-
|
288
|
+
# Update increment backoff delay and retry counter
|
289
|
+
@backoff[:delay] *= @backoff[:mod]
|
290
|
+
@backoff[:current] += 1
|
286
291
|
|
287
|
-
|
292
|
+
retry
|
293
|
+
end
|
288
294
|
rescue RestartStream
|
289
295
|
retry
|
290
296
|
rescue StandardError => e
|
291
|
-
|
297
|
+
@parent.error! e
|
298
|
+
raise e
|
292
299
|
end
|
293
300
|
end
|
294
301
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-firestore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-core
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.25.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.25.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,14 +262,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
262
|
requirements:
|
263
263
|
- - ">="
|
264
264
|
- !ruby/object:Gem::Version
|
265
|
-
version: '2.
|
265
|
+
version: '2.5'
|
266
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
267
|
requirements:
|
268
268
|
- - ">="
|
269
269
|
- !ruby/object:Gem::Version
|
270
270
|
version: '0'
|
271
271
|
requirements: []
|
272
|
-
rubygems_version: 3.
|
272
|
+
rubygems_version: 3.2.13
|
273
273
|
signing_key:
|
274
274
|
specification_version: 4
|
275
275
|
summary: API Client library for Google Cloud Firestore API
|