google-cloud-spanner 2.0.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +2 -2
- data/LOGGING.md +1 -1
- data/lib/google-cloud-spanner.rb +1 -0
- data/lib/google/cloud/spanner.rb +7 -5
- data/lib/google/cloud/spanner/backup.rb +10 -2
- data/lib/google/cloud/spanner/backup/job.rb +8 -8
- data/lib/google/cloud/spanner/backup/job/list.rb +2 -2
- data/lib/google/cloud/spanner/backup/list.rb +2 -2
- data/lib/google/cloud/spanner/batch_snapshot.rb +114 -15
- data/lib/google/cloud/spanner/batch_update.rb +3 -1
- data/lib/google/cloud/spanner/client.rb +413 -78
- data/lib/google/cloud/spanner/commit_response.rb +87 -0
- data/lib/google/cloud/spanner/commit_response/commit_stats.rb +51 -0
- data/lib/google/cloud/spanner/convert.rb +9 -0
- data/lib/google/cloud/spanner/data.rb +4 -5
- data/lib/google/cloud/spanner/database.rb +25 -3
- data/lib/google/cloud/spanner/database/backup_info.rb +12 -3
- data/lib/google/cloud/spanner/database/job/list.rb +2 -2
- data/lib/google/cloud/spanner/database/list.rb +4 -4
- data/lib/google/cloud/spanner/fields.rb +3 -2
- data/lib/google/cloud/spanner/instance/config/list.rb +4 -4
- data/lib/google/cloud/spanner/instance/list.rb +4 -4
- data/lib/google/cloud/spanner/partition.rb +4 -2
- data/lib/google/cloud/spanner/policy.rb +3 -2
- data/lib/google/cloud/spanner/pool.rb +10 -10
- data/lib/google/cloud/spanner/results.rb +105 -26
- data/lib/google/cloud/spanner/service.rb +218 -107
- data/lib/google/cloud/spanner/session.rb +361 -30
- data/lib/google/cloud/spanner/snapshot.rb +58 -4
- data/lib/google/cloud/spanner/status.rb +4 -1
- data/lib/google/cloud/spanner/transaction.rb +114 -8
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +12 -10
@@ -125,6 +125,19 @@ module Google
|
|
125
125
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
126
126
|
# Empty to use database default. "latest" to use the latest
|
127
127
|
# available optimizer version.
|
128
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
129
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
130
|
+
# optional. The following settings can be provided:
|
131
|
+
#
|
132
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
133
|
+
# that overrides the default setting.
|
134
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
135
|
+
# setting of retry policy with the following keys:
|
136
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
137
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
138
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
139
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
140
|
+
# trigger a retry.
|
128
141
|
#
|
129
142
|
# @return [Google::Cloud::Spanner::Results] The results of the query
|
130
143
|
# execution.
|
@@ -243,13 +256,39 @@ module Google
|
|
243
256
|
# end
|
244
257
|
# end
|
245
258
|
#
|
246
|
-
|
259
|
+
# @example Query using custom timeout and retry policy:
|
260
|
+
# require "google/cloud/spanner"
|
261
|
+
#
|
262
|
+
# spanner = Google::Cloud::Spanner.new
|
263
|
+
# db = spanner.client "my-instance", "my-database"
|
264
|
+
#
|
265
|
+
# timeout = 30.0
|
266
|
+
# retry_policy = {
|
267
|
+
# initial_delay: 0.25,
|
268
|
+
# max_delay: 32.0,
|
269
|
+
# multiplier: 1.3,
|
270
|
+
# retry_codes: ["UNAVAILABLE"]
|
271
|
+
# }
|
272
|
+
# call_options = { timeout: timeout, retry_policy: retry_policy }
|
273
|
+
#
|
274
|
+
# db.snapshot do |snp|
|
275
|
+
# results = snp.execute_query \
|
276
|
+
# "SELECT * FROM users", call_options: call_options
|
277
|
+
#
|
278
|
+
# results.rows.each do |row|
|
279
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
280
|
+
# end
|
281
|
+
# end
|
282
|
+
#
|
283
|
+
def execute_query sql, params: nil, types: nil, query_options: nil,
|
284
|
+
call_options: nil
|
247
285
|
ensure_session!
|
248
286
|
|
249
287
|
params, types = Convert.to_input_params_and_types params, types
|
250
288
|
session.execute_query sql, params: params, types: types,
|
251
289
|
transaction: tx_selector,
|
252
|
-
query_options: query_options
|
290
|
+
query_options: query_options,
|
291
|
+
call_options: call_options
|
253
292
|
end
|
254
293
|
alias execute execute_query
|
255
294
|
alias query execute_query
|
@@ -271,6 +310,19 @@ module Google
|
|
271
310
|
# Optional.
|
272
311
|
# @param [Integer] limit If greater than zero, no more than this number
|
273
312
|
# of rows will be returned. The default is no limit.
|
313
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
314
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
315
|
+
# optional. The following settings can be provided:
|
316
|
+
#
|
317
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
318
|
+
# that overrides the default setting.
|
319
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
320
|
+
# setting of retry policy with the following keys:
|
321
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
322
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
323
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
324
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
325
|
+
# trigger a retry.
|
274
326
|
#
|
275
327
|
# @return [Google::Cloud::Spanner::Results] The results of the read
|
276
328
|
# operation.
|
@@ -289,14 +341,16 @@ module Google
|
|
289
341
|
# end
|
290
342
|
# end
|
291
343
|
#
|
292
|
-
def read table, columns, keys: nil, index: nil, limit: nil
|
344
|
+
def read table, columns, keys: nil, index: nil, limit: nil,
|
345
|
+
call_options: nil
|
293
346
|
ensure_session!
|
294
347
|
|
295
348
|
columns = Array(columns).map(&:to_s)
|
296
349
|
keys = Convert.to_key_set keys
|
297
350
|
|
298
351
|
session.read table, columns, keys: keys, index: index, limit: limit,
|
299
|
-
transaction: tx_selector
|
352
|
+
transaction: tx_selector,
|
353
|
+
call_options: call_options
|
300
354
|
end
|
301
355
|
|
302
356
|
##
|
@@ -155,6 +155,19 @@ module Google
|
|
155
155
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
156
156
|
# Empty to use database default. "latest" to use the latest
|
157
157
|
# available optimizer version.
|
158
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
159
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
160
|
+
# optional. The following settings can be provided:
|
161
|
+
#
|
162
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
163
|
+
# that overrides the default setting.
|
164
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
165
|
+
# setting of retry policy with the following keys:
|
166
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
167
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
168
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
169
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
170
|
+
# trigger a retry.
|
158
171
|
#
|
159
172
|
# @return [Google::Cloud::Spanner::Results] The results of the query
|
160
173
|
# execution.
|
@@ -274,7 +287,32 @@ module Google
|
|
274
287
|
# end
|
275
288
|
# end
|
276
289
|
#
|
277
|
-
|
290
|
+
# @example Query using custom timeout and retry policy:
|
291
|
+
# require "google/cloud/spanner"
|
292
|
+
#
|
293
|
+
# spanner = Google::Cloud::Spanner.new
|
294
|
+
# db = spanner.client "my-instance", "my-database"
|
295
|
+
#
|
296
|
+
# timeout = 30.0
|
297
|
+
# retry_policy = {
|
298
|
+
# initial_delay: 0.25,
|
299
|
+
# max_delay: 32.0,
|
300
|
+
# multiplier: 1.3,
|
301
|
+
# retry_codes: ["UNAVAILABLE"]
|
302
|
+
# }
|
303
|
+
# call_options = { timeout: timeout, retry_policy: retry_policy }
|
304
|
+
#
|
305
|
+
# db.transaction do |tx|
|
306
|
+
# results = tx.execute_query \
|
307
|
+
# "SELECT * FROM users", call_options: call_options
|
308
|
+
#
|
309
|
+
# results.rows.each do |row|
|
310
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
311
|
+
# end
|
312
|
+
# end
|
313
|
+
#
|
314
|
+
def execute_query sql, params: nil, types: nil, query_options: nil,
|
315
|
+
call_options: nil
|
278
316
|
ensure_session!
|
279
317
|
|
280
318
|
@seqno += 1
|
@@ -282,7 +320,8 @@ module Google
|
|
282
320
|
params, types = Convert.to_input_params_and_types params, types
|
283
321
|
session.execute_query sql, params: params, types: types,
|
284
322
|
transaction: tx_selector, seqno: @seqno,
|
285
|
-
query_options: query_options
|
323
|
+
query_options: query_options,
|
324
|
+
call_options: call_options
|
286
325
|
end
|
287
326
|
alias execute execute_query
|
288
327
|
alias query execute_query
|
@@ -352,6 +391,19 @@ module Google
|
|
352
391
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
353
392
|
# Empty to use database default. "latest" to use the latest
|
354
393
|
# available optimizer version.
|
394
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
395
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
396
|
+
# optional. The following settings can be provided:
|
397
|
+
#
|
398
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
399
|
+
# that overrides the default setting.
|
400
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
401
|
+
# setting of retry policy with the following keys:
|
402
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
403
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
404
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
405
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
406
|
+
# trigger a retry.
|
355
407
|
#
|
356
408
|
# @return [Integer] The exact number of rows that were modified.
|
357
409
|
#
|
@@ -393,9 +445,33 @@ module Google
|
|
393
445
|
# )
|
394
446
|
# end
|
395
447
|
#
|
396
|
-
|
448
|
+
# @example Update using custom timeout and retry policy:
|
449
|
+
# require "google/cloud/spanner"
|
450
|
+
#
|
451
|
+
# spanner = Google::Cloud::Spanner.new
|
452
|
+
# db = spanner.client "my-instance", "my-database"
|
453
|
+
#
|
454
|
+
# timeout = 30.0
|
455
|
+
# retry_policy = {
|
456
|
+
# initial_delay: 0.25,
|
457
|
+
# max_delay: 32.0,
|
458
|
+
# multiplier: 1.3,
|
459
|
+
# retry_codes: ["UNAVAILABLE"]
|
460
|
+
# }
|
461
|
+
# call_options = { timeout: timeout, retry_policy: retry_policy }
|
462
|
+
#
|
463
|
+
# db.transaction do |tx|
|
464
|
+
# row_count = tx.execute_update(
|
465
|
+
# "UPDATE users SET name = 'Charlie' WHERE id = 1",
|
466
|
+
# call_options: call_options
|
467
|
+
# )
|
468
|
+
# end
|
469
|
+
#
|
470
|
+
def execute_update sql, params: nil, types: nil, query_options: nil,
|
471
|
+
call_options: nil
|
397
472
|
results = execute_query sql, params: params, types: types,
|
398
|
-
query_options: query_options
|
473
|
+
query_options: query_options,
|
474
|
+
call_options: call_options
|
399
475
|
# Stream all PartialResultSet to get ResultSetStats
|
400
476
|
results.rows.to_a
|
401
477
|
# Raise an error if there is not a row count returned
|
@@ -409,6 +485,20 @@ module Google
|
|
409
485
|
##
|
410
486
|
# Executes DML statements in a batch.
|
411
487
|
#
|
488
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
489
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
490
|
+
# optional. The following settings can be provided:
|
491
|
+
#
|
492
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
493
|
+
# that overrides the default setting.
|
494
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
495
|
+
# setting of retry policy with the following keys:
|
496
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
497
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
498
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
499
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
500
|
+
# trigger a retry.
|
501
|
+
#
|
412
502
|
# @yield [batch_update] a batch update object
|
413
503
|
# @yieldparam [Google::Cloud::Spanner::BatchUpdate] batch_update a batch
|
414
504
|
# update object accepting DML statements and optional parameters and
|
@@ -464,10 +554,11 @@ module Google
|
|
464
554
|
# end
|
465
555
|
# end
|
466
556
|
#
|
467
|
-
def batch_update &block
|
557
|
+
def batch_update call_options: nil, &block
|
468
558
|
ensure_session!
|
469
559
|
@seqno += 1
|
470
|
-
session.batch_update tx_selector, @seqno,
|
560
|
+
session.batch_update tx_selector, @seqno,
|
561
|
+
call_options: call_options, &block
|
471
562
|
end
|
472
563
|
|
473
564
|
##
|
@@ -486,6 +577,19 @@ module Google
|
|
486
577
|
# Optional.
|
487
578
|
# @param [Integer] limit If greater than zero, no more than this number
|
488
579
|
# of rows will be returned. The default is no limit.
|
580
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
581
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
582
|
+
# optional. The following settings can be provided:
|
583
|
+
#
|
584
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
585
|
+
# that overrides the default setting.
|
586
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
587
|
+
# setting of retry policy with the following keys:
|
588
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
589
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
590
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
591
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
592
|
+
# trigger a retry.
|
489
593
|
#
|
490
594
|
# @return [Google::Cloud::Spanner::Results] The results of the read
|
491
595
|
# operation.
|
@@ -504,14 +608,16 @@ module Google
|
|
504
608
|
# end
|
505
609
|
# end
|
506
610
|
#
|
507
|
-
def read table, columns, keys: nil, index: nil, limit: nil
|
611
|
+
def read table, columns, keys: nil, index: nil, limit: nil,
|
612
|
+
call_options: nil
|
508
613
|
ensure_session!
|
509
614
|
|
510
615
|
columns = Array(columns).map(&:to_s)
|
511
616
|
keys = Convert.to_key_set keys
|
512
617
|
|
513
618
|
session.read table, columns, keys: keys, index: index, limit: limit,
|
514
|
-
transaction: tx_selector
|
619
|
+
transaction: tx_selector,
|
620
|
+
call_options: call_options
|
515
621
|
end
|
516
622
|
|
517
623
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-spanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.
|
90
|
+
version: 1.25.1
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.
|
97
|
+
version: 1.25.1
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: minitest
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,28 +227,28 @@ dependencies:
|
|
227
227
|
requirements:
|
228
228
|
- - "~>"
|
229
229
|
- !ruby/object:Gem::Version
|
230
|
-
version: 1.
|
230
|
+
version: '1.36'
|
231
231
|
type: :development
|
232
232
|
prerelease: false
|
233
233
|
version_requirements: !ruby/object:Gem::Requirement
|
234
234
|
requirements:
|
235
235
|
- - "~>"
|
236
236
|
- !ruby/object:Gem::Version
|
237
|
-
version: 1.
|
237
|
+
version: '1.36'
|
238
238
|
- !ruby/object:Gem::Dependency
|
239
239
|
name: grpc-tools
|
240
240
|
requirement: !ruby/object:Gem::Requirement
|
241
241
|
requirements:
|
242
242
|
- - "~>"
|
243
243
|
- !ruby/object:Gem::Version
|
244
|
-
version: 1.
|
244
|
+
version: '1.36'
|
245
245
|
type: :development
|
246
246
|
prerelease: false
|
247
247
|
version_requirements: !ruby/object:Gem::Requirement
|
248
248
|
requirements:
|
249
249
|
- - "~>"
|
250
250
|
- !ruby/object:Gem::Version
|
251
|
-
version: 1.
|
251
|
+
version: '1.36'
|
252
252
|
description: google-cloud-spanner is the official library for Google Cloud Spanner
|
253
253
|
API.
|
254
254
|
email:
|
@@ -282,6 +282,8 @@ files:
|
|
282
282
|
- lib/google/cloud/spanner/client.rb
|
283
283
|
- lib/google/cloud/spanner/column_value.rb
|
284
284
|
- lib/google/cloud/spanner/commit.rb
|
285
|
+
- lib/google/cloud/spanner/commit_response.rb
|
286
|
+
- lib/google/cloud/spanner/commit_response/commit_stats.rb
|
285
287
|
- lib/google/cloud/spanner/convert.rb
|
286
288
|
- lib/google/cloud/spanner/credentials.rb
|
287
289
|
- lib/google/cloud/spanner/data.rb
|
@@ -322,14 +324,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
322
324
|
requirements:
|
323
325
|
- - ">="
|
324
326
|
- !ruby/object:Gem::Version
|
325
|
-
version: '2.
|
327
|
+
version: '2.5'
|
326
328
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
327
329
|
requirements:
|
328
330
|
- - ">="
|
329
331
|
- !ruby/object:Gem::Version
|
330
332
|
version: '0'
|
331
333
|
requirements: []
|
332
|
-
rubygems_version: 3.
|
334
|
+
rubygems_version: 3.2.13
|
333
335
|
signing_key:
|
334
336
|
specification_version: 4
|
335
337
|
summary: API Client library for Google Cloud Spanner API
|