google-cloud-spanner 2.0.0 → 2.1.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 +6 -0
- data/lib/google/cloud/spanner/batch_snapshot.rb +114 -15
- data/lib/google/cloud/spanner/client.rb +181 -22
- data/lib/google/cloud/spanner/results.rb +9 -6
- data/lib/google/cloud/spanner/service.rb +205 -104
- data/lib/google/cloud/spanner/session.rb +177 -22
- data/lib/google/cloud/spanner/snapshot.rb +58 -4
- data/lib/google/cloud/spanner/transaction.rb +114 -8
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +2 -2
@@ -162,6 +162,19 @@ module Google
|
|
162
162
|
# * `:optimizer_version` (String) The version of optimizer to use.
|
163
163
|
# Empty to use database default. "latest" to use the latest
|
164
164
|
# available optimizer version.
|
165
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
166
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
167
|
+
# optional. The following settings can be provided:
|
168
|
+
#
|
169
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
170
|
+
# that overrides the default setting.
|
171
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
172
|
+
# setting of retry policy with the following keys:
|
173
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
174
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
175
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
176
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
177
|
+
# trigger a retry.
|
165
178
|
#
|
166
179
|
# @return [Google::Cloud::Spanner::Results] The results of the query
|
167
180
|
# execution.
|
@@ -275,8 +288,32 @@ module Google
|
|
275
288
|
# puts "User #{row[:id]} is #{row[:name]}"
|
276
289
|
# end
|
277
290
|
#
|
291
|
+
# @example Query using custom timeout and retry policy:
|
292
|
+
# require "google/cloud/spanner"
|
293
|
+
#
|
294
|
+
# spanner = Google::Cloud::Spanner.new
|
295
|
+
#
|
296
|
+
# db = spanner.client "my-instance", "my-database"
|
297
|
+
#
|
298
|
+
# timeout = 30.0
|
299
|
+
# retry_policy = {
|
300
|
+
# initial_delay: 0.25,
|
301
|
+
# max_delay: 32.0,
|
302
|
+
# multiplier: 1.3,
|
303
|
+
# retry_codes: ["UNAVAILABLE"]
|
304
|
+
# }
|
305
|
+
# call_options = { timeout: timeout, retry_policy: retry_policy }
|
306
|
+
#
|
307
|
+
# results = db.execute_query \
|
308
|
+
# "SELECT * FROM users", call_options: call_options
|
309
|
+
#
|
310
|
+
# results.rows.each do |row|
|
311
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
312
|
+
# end
|
313
|
+
#
|
278
314
|
def execute_query sql, params: nil, types: nil, transaction: nil,
|
279
|
-
partition_token: nil, seqno: nil, query_options: nil
|
315
|
+
partition_token: nil, seqno: nil, query_options: nil,
|
316
|
+
call_options: nil
|
280
317
|
ensure_service!
|
281
318
|
if query_options.nil?
|
282
319
|
query_options = @query_options
|
@@ -289,7 +326,8 @@ module Google
|
|
289
326
|
transaction: transaction,
|
290
327
|
partition_token: partition_token,
|
291
328
|
seqno: seqno,
|
292
|
-
query_options: query_options
|
329
|
+
query_options: query_options,
|
330
|
+
call_options: call_options
|
293
331
|
@last_updated_at = Time.now
|
294
332
|
results
|
295
333
|
end
|
@@ -302,6 +340,20 @@ module Google
|
|
302
340
|
# transactions.
|
303
341
|
# @param [Integer] seqno A per-transaction sequence number used to
|
304
342
|
# identify this request.
|
343
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
344
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
345
|
+
# optional. The following settings can be provided:
|
346
|
+
#
|
347
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
348
|
+
# that overrides the default setting.
|
349
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
350
|
+
# setting of retry policy with the following keys:
|
351
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
352
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
353
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
354
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
355
|
+
# trigger a retry.
|
356
|
+
#
|
305
357
|
# @yield [batch_update] a batch update object
|
306
358
|
# @yieldparam [Google::Cloud::Spanner::BatchUpdate] batch_update a batch
|
307
359
|
# update object accepting DML statements and optional parameters and
|
@@ -316,7 +368,7 @@ module Google
|
|
316
368
|
# @return [Array<Integer>] A list with the exact number of rows that
|
317
369
|
# were modified for each DML statement.
|
318
370
|
#
|
319
|
-
def batch_update transaction, seqno
|
371
|
+
def batch_update transaction, seqno, call_options: nil
|
320
372
|
ensure_service!
|
321
373
|
|
322
374
|
raise ArgumentError, "block is required" unless block_given?
|
@@ -325,7 +377,8 @@ module Google
|
|
325
377
|
yield batch
|
326
378
|
|
327
379
|
results = service.execute_batch_dml path, transaction,
|
328
|
-
batch.statements, seqno
|
380
|
+
batch.statements, seqno,
|
381
|
+
call_options: call_options
|
329
382
|
@last_updated_at = Time.now
|
330
383
|
results
|
331
384
|
end
|
@@ -349,6 +402,19 @@ module Google
|
|
349
402
|
# @param [Google::Cloud::Spanner::V1::TransactionSelector] transaction The
|
350
403
|
# transaction selector value to send. Only used for single-use
|
351
404
|
# transactions.
|
405
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
406
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
407
|
+
# optional. The following settings can be provided:
|
408
|
+
#
|
409
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
410
|
+
# that overrides the default setting.
|
411
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
412
|
+
# setting of retry policy with the following keys:
|
413
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
414
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
415
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
416
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
417
|
+
# trigger a retry.
|
352
418
|
#
|
353
419
|
# @return [Google::Cloud::Spanner::Results] The results of the read
|
354
420
|
# operation.
|
@@ -367,25 +433,28 @@ module Google
|
|
367
433
|
# end
|
368
434
|
#
|
369
435
|
def read table, columns, keys: nil, index: nil, limit: nil,
|
370
|
-
transaction: nil, partition_token: nil
|
436
|
+
transaction: nil, partition_token: nil, call_options: nil
|
371
437
|
ensure_service!
|
372
438
|
|
373
439
|
results = Results.read service, path, table, columns,
|
374
440
|
keys: keys, index: index, limit: limit,
|
375
441
|
transaction: transaction,
|
376
|
-
partition_token: partition_token
|
442
|
+
partition_token: partition_token,
|
443
|
+
call_options: call_options
|
377
444
|
@last_updated_at = Time.now
|
378
445
|
results
|
379
446
|
end
|
380
447
|
|
381
448
|
def partition_query sql, transaction, params: nil, types: nil,
|
382
|
-
partition_size_bytes: nil, max_partitions: nil
|
449
|
+
partition_size_bytes: nil, max_partitions: nil,
|
450
|
+
call_options: nil
|
383
451
|
ensure_service!
|
384
452
|
|
385
453
|
results = service.partition_query \
|
386
454
|
path, sql, transaction, params: params, types: types,
|
387
455
|
partition_size_bytes: partition_size_bytes,
|
388
|
-
max_partitions: max_partitions
|
456
|
+
max_partitions: max_partitions,
|
457
|
+
call_options: call_options
|
389
458
|
|
390
459
|
@last_updated_at = Time.now
|
391
460
|
|
@@ -394,14 +463,15 @@ module Google
|
|
394
463
|
|
395
464
|
def partition_read table, columns, transaction, keys: nil,
|
396
465
|
index: nil, partition_size_bytes: nil,
|
397
|
-
max_partitions: nil
|
466
|
+
max_partitions: nil, call_options: nil
|
398
467
|
ensure_service!
|
399
468
|
|
400
469
|
results = service.partition_read \
|
401
470
|
path, table, columns, transaction,
|
402
471
|
keys: keys, index: index,
|
403
472
|
partition_size_bytes: partition_size_bytes,
|
404
|
-
max_partitions: max_partitions
|
473
|
+
max_partitions: max_partitions,
|
474
|
+
call_options: call_options
|
405
475
|
|
406
476
|
@last_updated_at = Time.now
|
407
477
|
|
@@ -414,6 +484,20 @@ module Google
|
|
414
484
|
# @param [String] transaction_id The identifier of previously-started
|
415
485
|
# transaction to be used instead of starting a new transaction.
|
416
486
|
# Optional.
|
487
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
488
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
489
|
+
# optional. The following settings can be provided:
|
490
|
+
#
|
491
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
492
|
+
# that overrides the default setting.
|
493
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
494
|
+
# setting of retry policy with the following keys:
|
495
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
496
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
497
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
498
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
499
|
+
# trigger a retry.
|
500
|
+
#
|
417
501
|
# @yield [commit] The block for mutating the data.
|
418
502
|
# @yieldparam [Google::Cloud::Spanner::Commit] commit The Commit object.
|
419
503
|
#
|
@@ -431,12 +515,13 @@ module Google
|
|
431
515
|
# c.insert "users", [{ id: 2, name: "Harvey", active: true }]
|
432
516
|
# end
|
433
517
|
#
|
434
|
-
def commit transaction_id: nil
|
518
|
+
def commit transaction_id: nil, call_options: nil
|
435
519
|
ensure_service!
|
436
520
|
commit = Commit.new
|
437
521
|
yield commit
|
438
522
|
commit_resp = service.commit path, commit.mutations,
|
439
|
-
transaction_id: transaction_id
|
523
|
+
transaction_id: transaction_id,
|
524
|
+
call_options: call_options
|
440
525
|
@last_updated_at = Time.now
|
441
526
|
Convert.timestamp_to_time commit_resp.commit_timestamp
|
442
527
|
end
|
@@ -467,6 +552,19 @@ module Google
|
|
467
552
|
#
|
468
553
|
# See [Data
|
469
554
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
555
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
556
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
557
|
+
# optional. The following settings can be provided:
|
558
|
+
#
|
559
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
560
|
+
# that overrides the default setting.
|
561
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
562
|
+
# setting of retry policy with the following keys:
|
563
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
564
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
565
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
566
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
567
|
+
# trigger a retry.
|
470
568
|
#
|
471
569
|
# @return [Time] The timestamp at which the operation committed.
|
472
570
|
#
|
@@ -480,8 +578,9 @@ module Google
|
|
480
578
|
# db.upsert "users", [{ id: 1, name: "Charlie", active: false },
|
481
579
|
# { id: 2, name: "Harvey", active: true }]
|
482
580
|
#
|
483
|
-
def upsert table, *rows, transaction_id: nil
|
484
|
-
|
581
|
+
def upsert table, *rows, transaction_id: nil, call_options: nil
|
582
|
+
opts = { transaction_id: transaction_id, call_options: call_options }
|
583
|
+
commit opts do |c|
|
485
584
|
c.upsert table, rows
|
486
585
|
end
|
487
586
|
end
|
@@ -512,6 +611,19 @@ module Google
|
|
512
611
|
#
|
513
612
|
# See [Data
|
514
613
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
614
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
615
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
616
|
+
# optional. The following settings can be provided:
|
617
|
+
#
|
618
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
619
|
+
# that overrides the default setting.
|
620
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
621
|
+
# setting of retry policy with the following keys:
|
622
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
623
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
624
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
625
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
626
|
+
# trigger a retry.
|
515
627
|
#
|
516
628
|
# @return [Time] The timestamp at which the operation committed.
|
517
629
|
#
|
@@ -525,8 +637,9 @@ module Google
|
|
525
637
|
# db.insert "users", [{ id: 1, name: "Charlie", active: false },
|
526
638
|
# { id: 2, name: "Harvey", active: true }]
|
527
639
|
#
|
528
|
-
def insert table, *rows, transaction_id: nil
|
529
|
-
|
640
|
+
def insert table, *rows, transaction_id: nil, call_options: nil
|
641
|
+
opts = { transaction_id: transaction_id, call_options: call_options }
|
642
|
+
commit opts do |c|
|
530
643
|
c.insert table, rows
|
531
644
|
end
|
532
645
|
end
|
@@ -556,6 +669,19 @@ module Google
|
|
556
669
|
#
|
557
670
|
# See [Data
|
558
671
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
672
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
673
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
674
|
+
# optional. The following settings can be provided:
|
675
|
+
#
|
676
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
677
|
+
# that overrides the default setting.
|
678
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
679
|
+
# setting of retry policy with the following keys:
|
680
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
681
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
682
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
683
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
684
|
+
# trigger a retry.
|
559
685
|
#
|
560
686
|
# @return [Time] The timestamp at which the operation committed.
|
561
687
|
#
|
@@ -569,8 +695,9 @@ module Google
|
|
569
695
|
# db.update "users", [{ id: 1, name: "Charlie", active: false },
|
570
696
|
# { id: 2, name: "Harvey", active: true }]
|
571
697
|
#
|
572
|
-
def update table, *rows, transaction_id: nil
|
573
|
-
|
698
|
+
def update table, *rows, transaction_id: nil, call_options: nil
|
699
|
+
opts = { transaction_id: transaction_id, call_options: call_options }
|
700
|
+
commit opts do |c|
|
574
701
|
c.update table, rows
|
575
702
|
end
|
576
703
|
end
|
@@ -602,6 +729,19 @@ module Google
|
|
602
729
|
#
|
603
730
|
# See [Data
|
604
731
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
732
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
733
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
734
|
+
# optional. The following settings can be provided:
|
735
|
+
#
|
736
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
737
|
+
# that overrides the default setting.
|
738
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
739
|
+
# setting of retry policy with the following keys:
|
740
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
741
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
742
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
743
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
744
|
+
# trigger a retry.
|
605
745
|
#
|
606
746
|
# @return [Time] The timestamp at which the operation committed.
|
607
747
|
#
|
@@ -615,8 +755,9 @@ module Google
|
|
615
755
|
# db.replace "users", [{ id: 1, name: "Charlie", active: false },
|
616
756
|
# { id: 2, name: "Harvey", active: true }]
|
617
757
|
#
|
618
|
-
def replace table, *rows, transaction_id: nil
|
619
|
-
|
758
|
+
def replace table, *rows, transaction_id: nil, call_options: nil
|
759
|
+
opts = { transaction_id: transaction_id, call_options: call_options }
|
760
|
+
commit opts do |c|
|
620
761
|
c.replace table, rows
|
621
762
|
end
|
622
763
|
end
|
@@ -630,6 +771,19 @@ module Google
|
|
630
771
|
# @param [Object, Array<Object>] keys A single, or list of keys or key
|
631
772
|
# ranges to match returned data to. Values should have exactly as many
|
632
773
|
# elements as there are columns in the primary key.
|
774
|
+
# @param [Hash] call_options A hash of values to specify the custom
|
775
|
+
# call options, e.g., timeout, retries, etc. Call options are
|
776
|
+
# optional. The following settings can be provided:
|
777
|
+
#
|
778
|
+
# * `:timeout` (Numeric) A numeric value of custom timeout in seconds
|
779
|
+
# that overrides the default setting.
|
780
|
+
# * `:retry_policy` (Hash) A hash of values that overrides the default
|
781
|
+
# setting of retry policy with the following keys:
|
782
|
+
# * `:initial_delay` (`Numeric`) - The initial delay in seconds.
|
783
|
+
# * `:max_delay` (`Numeric`) - The max delay in seconds.
|
784
|
+
# * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
|
785
|
+
# * `:retry_codes` (`Array<String>`) - The error codes that should
|
786
|
+
# trigger a retry.
|
633
787
|
#
|
634
788
|
# @return [Time] The timestamp at which the operation committed.
|
635
789
|
#
|
@@ -642,8 +796,9 @@ module Google
|
|
642
796
|
#
|
643
797
|
# db.delete "users", [1, 2, 3]
|
644
798
|
#
|
645
|
-
def delete table, keys = [], transaction_id: nil
|
646
|
-
|
799
|
+
def delete table, keys = [], transaction_id: nil, call_options: nil
|
800
|
+
opts = { transaction_id: transaction_id, call_options: call_options }
|
801
|
+
commit opts do |c|
|
647
802
|
c.delete table, keys
|
648
803
|
end
|
649
804
|
end
|
@@ -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
|
##
|