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.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Firestore
19
- VERSION = "2.1.0".freeze
19
+ VERSION = "2.5.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -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, :read_time
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 a, b
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 a.ref, b.ref if @query.nil?
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
- a_comps = a.query_comparisons_for @query.query
167
- b_comps = b.query_comparisons_for @query.query
168
- @directions.zip(a_comps, b_comps).each do |dir, a_comp, b_comp|
169
- comp = a_comp <=> b_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 a.ref, b.ref
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.push self if @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
- # Re-raise if retried more than the max
278
- raise err if @backoff[:current] > @backoff[:max]
279
-
280
- # Sleep with incremental backoff before restarting
281
- sleep @backoff[:delay]
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
- # Update increment backoff delay and retry counter
284
- @backoff[:delay] *= @backoff[:mod]
285
- @backoff[:current] += 1
288
+ # Update increment backoff delay and retry counter
289
+ @backoff[:delay] *= @backoff[:mod]
290
+ @backoff[:current] += 1
286
291
 
287
- retry
292
+ retry
293
+ end
288
294
  rescue RestartStream
289
295
  retry
290
296
  rescue StandardError => e
291
- raise Google::Cloud::Error.from_error(e)
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.1.0
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: 2020-09-10 00:00:00.000000000 Z
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.24.0
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.24.0
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.4'
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.1.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