google-cloud-spanner 2.8.1 → 2.9.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 +6 -0
- data/lib/google/cloud/spanner/client.rb +236 -34
- data/lib/google/cloud/spanner/convert.rb +19 -0
- data/lib/google/cloud/spanner/service.rb +7 -2
- data/lib/google/cloud/spanner/session.rb +153 -0
- data/lib/google/cloud/spanner/transaction.rb +37 -1
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a33a615e75cde66aa1d0ebf4631f34d5b139fa0a5c9fe203a20a4f157c5534
|
4
|
+
data.tar.gz: 415409aa55971910e5c337a6d88a2ee0e78671a3cde9ab0ebf3170edab8151ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83fc9125b21861b192099c025596c0224eb3b2d4c7904809a52062358c35d621510ef0e8d2b9ecd583609514d440e19927130fcdf56242ea2a6765a5ce83a03
|
7
|
+
data.tar.gz: 0e5a053289cb6393d62533836eda651217e60388d43931613245ac3b55ddb3d17b8c98cbb866fc0efec703bba398ccb7f18b38fb6129c11b03306bb8419f823f
|
data/CHANGELOG.md
CHANGED
@@ -236,6 +236,10 @@ module Google
|
|
236
236
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
237
237
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
238
238
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
239
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
240
|
+
# queries or reads, used for statistics collection. Tag must be a
|
241
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
242
|
+
# and 64 characters in length.
|
239
243
|
# @param [Hash] call_options A hash of values to specify the custom
|
240
244
|
# call options, e.g., timeout, retries, etc. Call options are
|
241
245
|
# optional. The following settings can be provided:
|
@@ -403,6 +407,21 @@ module Google
|
|
403
407
|
# puts "User #{row[:id]} is #{row[:name]}"
|
404
408
|
# end
|
405
409
|
#
|
410
|
+
# @example Query using tag for request query statistics collection.
|
411
|
+
# require "google/cloud/spanner"
|
412
|
+
#
|
413
|
+
# spanner = Google::Cloud::Spanner.new
|
414
|
+
#
|
415
|
+
# db = spanner.client "my-instance", "my-database"
|
416
|
+
#
|
417
|
+
# request_options = { tag: "Read-Users" }
|
418
|
+
# results = db.execute_query "SELECT * FROM users",
|
419
|
+
# request_options: request_options
|
420
|
+
#
|
421
|
+
# results.rows.each do |row|
|
422
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
423
|
+
# end
|
424
|
+
#
|
406
425
|
def execute_query sql, params: nil, types: nil, single_use: nil,
|
407
426
|
query_options: nil, request_options: nil,
|
408
427
|
call_options: nil
|
@@ -410,7 +429,8 @@ module Google
|
|
410
429
|
ensure_service!
|
411
430
|
|
412
431
|
params, types = Convert.to_input_params_and_types params, types
|
413
|
-
|
432
|
+
request_options = Convert.to_request_options request_options,
|
433
|
+
tag_type: :request_tag
|
414
434
|
single_use_tx = single_use_transaction single_use
|
415
435
|
results = nil
|
416
436
|
@pool.with_session do |session|
|
@@ -580,6 +600,10 @@ module Google
|
|
580
600
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
581
601
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
582
602
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
603
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
604
|
+
# queries or reads, used for statistics collection. Tag must be a
|
605
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
606
|
+
# and 64 characters in length.
|
583
607
|
# @param [Hash] call_options A hash of values to specify the custom
|
584
608
|
# call options, e.g., timeout, retries, etc. Call options are
|
585
609
|
# optional. The following settings can be provided:
|
@@ -657,12 +681,27 @@ module Google
|
|
657
681
|
# "UPDATE users SET friends = NULL WHERE active = @active",
|
658
682
|
# params: { active: false }, request_options: request_options
|
659
683
|
#
|
684
|
+
# @example Query using tag for request query statistics collection.
|
685
|
+
#
|
686
|
+
# require "google/cloud/spanner"
|
687
|
+
#
|
688
|
+
# spanner = Google::Cloud::Spanner.new
|
689
|
+
# db = spanner.client "my-instance", "my-database"
|
690
|
+
#
|
691
|
+
# request_options = { tag: "Update-Users" }
|
692
|
+
# row_count = db.execute_partition_update \
|
693
|
+
# "UPDATE users SET friends = NULL WHERE active = false",
|
694
|
+
# request_options: request_options
|
695
|
+
#
|
660
696
|
def execute_partition_update sql, params: nil, types: nil,
|
661
697
|
query_options: nil, request_options: nil,
|
662
698
|
call_options: nil
|
663
699
|
ensure_service!
|
664
700
|
|
665
701
|
params, types = Convert.to_input_params_and_types params, types
|
702
|
+
request_options = Convert.to_request_options request_options,
|
703
|
+
tag_type: :request_tag
|
704
|
+
|
666
705
|
results = nil
|
667
706
|
@pool.with_session do |session|
|
668
707
|
results = session.execute_query \
|
@@ -761,6 +800,10 @@ module Google
|
|
761
800
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
762
801
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
763
802
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
803
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
804
|
+
# queries or reads, used for statistics collection. Tag must be a
|
805
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
806
|
+
# and 64 characters in length.
|
764
807
|
# @param [Hash] call_options A hash of values to specify the custom
|
765
808
|
# call options, e.g., timeout, retries, etc. Call options are
|
766
809
|
# optional. The following settings can be provided:
|
@@ -840,6 +883,22 @@ module Google
|
|
840
883
|
# puts "User #{row[:id]} is #{row[:name]}"
|
841
884
|
# end
|
842
885
|
#
|
886
|
+
# @example Read using tag for read statistics collection.
|
887
|
+
#
|
888
|
+
# require "google/cloud/spanner"
|
889
|
+
#
|
890
|
+
# spanner = Google::Cloud::Spanner.new
|
891
|
+
#
|
892
|
+
# db = spanner.client "my-instance", "my-database"
|
893
|
+
#
|
894
|
+
# request_options = { tag: "Read-Users-All" }
|
895
|
+
# results = db.read "users", [:id, :name],
|
896
|
+
# request_options: request_options
|
897
|
+
#
|
898
|
+
# results.rows.each do |row|
|
899
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
900
|
+
# end
|
901
|
+
#
|
843
902
|
def read table, columns, keys: nil, index: nil, limit: nil,
|
844
903
|
single_use: nil, request_options: nil, call_options: nil
|
845
904
|
validate_single_use_args! single_use
|
@@ -847,8 +906,10 @@ module Google
|
|
847
906
|
|
848
907
|
columns = Array(columns).map(&:to_s)
|
849
908
|
keys = Convert.to_key_set keys
|
850
|
-
|
851
909
|
single_use_tx = single_use_transaction single_use
|
910
|
+
request_options = Convert.to_request_options request_options,
|
911
|
+
tag_type: :request_tag
|
912
|
+
|
852
913
|
results = nil
|
853
914
|
@pool.with_session do |session|
|
854
915
|
results = session.read \
|
@@ -914,6 +975,9 @@ module Google
|
|
914
975
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
915
976
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
916
977
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
978
|
+
# * `:tag` (String) A tag used for statistics collection
|
979
|
+
# about transaction. A tag must be a valid identifier of the format:
|
980
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
917
981
|
#
|
918
982
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
919
983
|
# committed. If commit options are set it returns {CommitResponse}.
|
@@ -954,7 +1018,23 @@ module Google
|
|
954
1018
|
# db.upsert "users", [{ id: 1, name: "Charlie", active: false }],
|
955
1019
|
# request_options: request_options
|
956
1020
|
#
|
1021
|
+
# @example Upsert using tag for transaction statistics collection.
|
1022
|
+
#
|
1023
|
+
# require "google/cloud/spanner"
|
1024
|
+
#
|
1025
|
+
# spanner = Google::Cloud::Spanner.new
|
1026
|
+
#
|
1027
|
+
# db = spanner.client "my-instance", "my-database"
|
1028
|
+
#
|
1029
|
+
# request_options = { tag: "Bulk-Upsert" }
|
1030
|
+
# db.upsert "users", [{ id: 1, name: "Charlie", active: false },
|
1031
|
+
# { id: 2, name: "Harvey", active: true }],
|
1032
|
+
# request_options: request_options
|
1033
|
+
#
|
957
1034
|
def upsert table, rows, commit_options: nil, request_options: nil
|
1035
|
+
request_options = Convert.to_request_options \
|
1036
|
+
request_options, tag_type: :transaction_tag
|
1037
|
+
|
958
1038
|
@pool.with_session do |session|
|
959
1039
|
session.upsert table, rows, commit_options: commit_options,
|
960
1040
|
request_options: request_options
|
@@ -999,7 +1079,6 @@ module Google
|
|
999
1079
|
#
|
1000
1080
|
# See [Data
|
1001
1081
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
1002
|
-
#
|
1003
1082
|
# @param [Hash] commit_options A hash of commit options.
|
1004
1083
|
# e.g., return_commit_stats. Commit options are optional.
|
1005
1084
|
# The following options can be provided:
|
@@ -1015,6 +1094,9 @@ module Google
|
|
1015
1094
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1016
1095
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1017
1096
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1097
|
+
# * `:tag` (String) A tag used for statistics collection
|
1098
|
+
# about transaction. A tag must be a valid identifier of the
|
1099
|
+
# format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
1018
1100
|
#
|
1019
1101
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
1020
1102
|
# committed. If commit options are set it returns {CommitResponse}.
|
@@ -1055,7 +1137,23 @@ module Google
|
|
1055
1137
|
# db.insert "users", [{ id: 1, name: "Charlie", active: false }],
|
1056
1138
|
# request_options: request_options
|
1057
1139
|
#
|
1140
|
+
# @example Insert using tag for transaction statistics collection.
|
1141
|
+
#
|
1142
|
+
# require "google/cloud/spanner"
|
1143
|
+
#
|
1144
|
+
# spanner = Google::Cloud::Spanner.new
|
1145
|
+
#
|
1146
|
+
# db = spanner.client "my-instance", "my-database"
|
1147
|
+
#
|
1148
|
+
# request_options = { tag: "BulkInsert-Users" }
|
1149
|
+
# db.insert "users", [{ id: 1, name: "Charlie", active: false },
|
1150
|
+
# { id: 2, name: "Harvey", active: true }],
|
1151
|
+
# request_options: request_options
|
1152
|
+
#
|
1058
1153
|
def insert table, rows, commit_options: nil, request_options: nil
|
1154
|
+
request_options = Convert.to_request_options \
|
1155
|
+
request_options, tag_type: :transaction_tag
|
1156
|
+
|
1059
1157
|
@pool.with_session do |session|
|
1060
1158
|
session.insert table, rows, commit_options: commit_options,
|
1061
1159
|
request_options: request_options
|
@@ -1099,7 +1197,6 @@ module Google
|
|
1099
1197
|
#
|
1100
1198
|
# See [Data
|
1101
1199
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
1102
|
-
#
|
1103
1200
|
# @param [Hash] commit_options A hash of commit options.
|
1104
1201
|
# e.g., return_commit_stats. Commit options are optional.
|
1105
1202
|
# The following options can be provided:
|
@@ -1115,6 +1212,9 @@ module Google
|
|
1115
1212
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1116
1213
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1117
1214
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1215
|
+
# * `:tag` (String) A tag used for statistics collection
|
1216
|
+
# about transaction. A tag must be a valid identifier of the
|
1217
|
+
# format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
1118
1218
|
#
|
1119
1219
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
1120
1220
|
# committed. If commit options are set it returns {CommitResponse}.
|
@@ -1155,7 +1255,22 @@ module Google
|
|
1155
1255
|
# db.update "users", [{ id: 1, name: "Charlie", active: false }],
|
1156
1256
|
# request_options: request_options
|
1157
1257
|
#
|
1258
|
+
# @example Updte using tag for transaction statistics collection.
|
1259
|
+
# require "google/cloud/spanner"
|
1260
|
+
#
|
1261
|
+
# spanner = Google::Cloud::Spanner.new
|
1262
|
+
#
|
1263
|
+
# db = spanner.client "my-instance", "my-database"
|
1264
|
+
#
|
1265
|
+
# request_options = { tag: "BulkUpdate-Users" }
|
1266
|
+
# db.update "users", [{ id: 1, name: "Charlie", active: false },
|
1267
|
+
# { id: 2, name: "Harvey", active: true }],
|
1268
|
+
# request_options: request_options
|
1269
|
+
#
|
1158
1270
|
def update table, rows, commit_options: nil, request_options: nil
|
1271
|
+
request_options = Convert.to_request_options \
|
1272
|
+
request_options, tag_type: :transaction_tag
|
1273
|
+
|
1159
1274
|
@pool.with_session do |session|
|
1160
1275
|
session.update table, rows, commit_options: commit_options,
|
1161
1276
|
request_options: request_options
|
@@ -1201,7 +1316,6 @@ module Google
|
|
1201
1316
|
#
|
1202
1317
|
# See [Data
|
1203
1318
|
# types](https://cloud.google.com/spanner/docs/data-definition-language#data_types).
|
1204
|
-
#
|
1205
1319
|
# @param [Hash] commit_options A hash of commit options.
|
1206
1320
|
# e.g., return_commit_stats. Commit options are optional.
|
1207
1321
|
# The following options can be provided:
|
@@ -1217,6 +1331,9 @@ module Google
|
|
1217
1331
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1218
1332
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1219
1333
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1334
|
+
# * `:tag` (String) A tag used for statistics collection
|
1335
|
+
# about transaction. A tag must be a valid identifier of the
|
1336
|
+
# format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
1220
1337
|
#
|
1221
1338
|
# @return [Time, CommitResponse] The timestamp at which the operation
|
1222
1339
|
# committed. If commit options are set it returns {CommitResponse}.
|
@@ -1257,6 +1374,18 @@ module Google
|
|
1257
1374
|
# db.replace "users", [{ id: 1, name: "Charlie", active: false }],
|
1258
1375
|
# request_options: request_options
|
1259
1376
|
#
|
1377
|
+
# @example Replace using tag for transaction statistics collection.
|
1378
|
+
# require "google/cloud/spanner"
|
1379
|
+
#
|
1380
|
+
# spanner = Google::Cloud::Spanner.new
|
1381
|
+
#
|
1382
|
+
# db = spanner.client "my-instance", "my-database"
|
1383
|
+
#
|
1384
|
+
# request_options = { tag: "BulkReplace-Users" }
|
1385
|
+
# db.replace "users", [{ id: 1, name: "Charlie", active: false },
|
1386
|
+
# { id: 2, name: "Harvey", active: true }],
|
1387
|
+
# request_options: request_options
|
1388
|
+
#
|
1260
1389
|
def replace table, rows, commit_options: nil, request_options: nil
|
1261
1390
|
@pool.with_session do |session|
|
1262
1391
|
session.replace table, rows, commit_options: commit_options,
|
@@ -1299,6 +1428,9 @@ module Google
|
|
1299
1428
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1300
1429
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1301
1430
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1431
|
+
# * `:tag` (String) A tag used for statistics collection
|
1432
|
+
# about transaction. A tag must be a valid identifier of the
|
1433
|
+
# format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
1302
1434
|
# @param [Hash] call_options A hash of values to specify the custom
|
1303
1435
|
# call options, e.g., timeout, retries, etc. Call options are
|
1304
1436
|
# optional. The following settings can be provided:
|
@@ -1348,8 +1480,21 @@ module Google
|
|
1348
1480
|
# request_options = { priority: :PRIORITY_MEDIUM }
|
1349
1481
|
# db.delete "users", [1, 2, 3], request_options: request_options
|
1350
1482
|
#
|
1483
|
+
# @example Delete using tag for transaction statistics collection.
|
1484
|
+
# require "google/cloud/spanner"
|
1485
|
+
#
|
1486
|
+
# spanner = Google::Cloud::Spanner.new
|
1487
|
+
#
|
1488
|
+
# db = spanner.client "my-instance", "my-database"
|
1489
|
+
#
|
1490
|
+
# request_options = { tag: "BulkDelete-Users" }
|
1491
|
+
# db.delete "users", [1, 2, 3], request_options: request_options
|
1492
|
+
#
|
1351
1493
|
def delete table, keys = [], commit_options: nil, request_options: nil,
|
1352
1494
|
call_options: nil
|
1495
|
+
request_options = Convert.to_request_options \
|
1496
|
+
request_options, tag_type: :transaction_tag
|
1497
|
+
|
1353
1498
|
@pool.with_session do |session|
|
1354
1499
|
session.delete table, keys, commit_options: commit_options,
|
1355
1500
|
request_options: request_options,
|
@@ -1387,6 +1532,9 @@ module Google
|
|
1387
1532
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1388
1533
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1389
1534
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1535
|
+
# * `:tag` (String) A tag used for statistics collection
|
1536
|
+
# about transaction. A tag must be a valid identifier of the
|
1537
|
+
# format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`.
|
1390
1538
|
# @param [Hash] call_options A hash of values to specify the custom
|
1391
1539
|
# call options, e.g., timeout, retries, etc. Call options are
|
1392
1540
|
# optional. The following settings can be provided:
|
@@ -1447,10 +1595,26 @@ module Google
|
|
1447
1595
|
# c.insert "users", [{ id: 2, name: "Harvey", active: true }]
|
1448
1596
|
# end
|
1449
1597
|
#
|
1598
|
+
# @example Commit using tag for transaction statistics collection.
|
1599
|
+
# require "google/cloud/spanner"
|
1600
|
+
#
|
1601
|
+
# spanner = Google::Cloud::Spanner.new
|
1602
|
+
#
|
1603
|
+
# db = spanner.client "my-instance", "my-database"
|
1604
|
+
#
|
1605
|
+
# request_options = { tag: "BulkManipulate-Users" }
|
1606
|
+
# db.commit request_options: request_options do |c|
|
1607
|
+
# c.update "users", [{ id: 1, name: "Charlie", active: false }]
|
1608
|
+
# c.insert "users", [{ id: 2, name: "Harvey", active: true }]
|
1609
|
+
# end
|
1610
|
+
#
|
1450
1611
|
def commit commit_options: nil, request_options: nil,
|
1451
1612
|
call_options: nil, &block
|
1452
1613
|
raise ArgumentError, "Must provide a block" unless block_given?
|
1453
1614
|
|
1615
|
+
request_options = Convert.to_request_options \
|
1616
|
+
request_options, tag_type: :transaction_tag
|
1617
|
+
|
1454
1618
|
@pool.with_session do |session|
|
1455
1619
|
session.commit(
|
1456
1620
|
commit_options: commit_options, request_options: request_options,
|
@@ -1494,6 +1658,11 @@ module Google
|
|
1494
1658
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
1495
1659
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
1496
1660
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
1661
|
+
# * `:tag` (String)A tag used for statistics collection
|
1662
|
+
# about transaction. The value of a transaction tag should be the
|
1663
|
+
# same for all requests belonging to the same transaction. A tag must
|
1664
|
+
# be a valid identifier of the format: `[a-zA-Z][a-zA-Z0-9_\-]{0,49}`
|
1665
|
+
#
|
1497
1666
|
# @param [Hash] call_options A hash of values to specify the custom
|
1498
1667
|
# call options, e.g., timeout, retries, etc. Call options are
|
1499
1668
|
# optional. The following settings can be provided:
|
@@ -1585,6 +1754,30 @@ module Google
|
|
1585
1754
|
# request_options: request_options
|
1586
1755
|
# end
|
1587
1756
|
#
|
1757
|
+
# @example Tags for request and transaction statistics collection.
|
1758
|
+
#
|
1759
|
+
# require "google/cloud/spanner"
|
1760
|
+
#
|
1761
|
+
# spanner = Google::Cloud::Spanner.new
|
1762
|
+
# db = spanner.client "my-instance", "my-database"
|
1763
|
+
#
|
1764
|
+
# # Transaction tag will be set to "Users-Txn"
|
1765
|
+
# db.transaction request_options: { tag: "Users-Txn" } do |tx|
|
1766
|
+
# # The transaction tag set as "Users-Txn"
|
1767
|
+
# # The request tag set as "Users-Txn-1"
|
1768
|
+
# request_options = { tag: "Users-Txn-1" }
|
1769
|
+
# results = tx.execute_query "SELECT * FROM users",
|
1770
|
+
# request_options: request_options
|
1771
|
+
#
|
1772
|
+
# results.rows.each do |row|
|
1773
|
+
# puts "User #{row[:id]} is #{row[:name]}"
|
1774
|
+
# end
|
1775
|
+
#
|
1776
|
+
# # The transaction tag set as "Users-Txn"
|
1777
|
+
# tx.update "users", [{ id: 1, name: "Charlie", active: false }]
|
1778
|
+
# tx.insert "users", [{ id: 2, name: "Harvey", active: true }]
|
1779
|
+
# end
|
1780
|
+
#
|
1588
1781
|
def transaction deadline: 120, commit_options: nil,
|
1589
1782
|
request_options: nil, call_options: nil
|
1590
1783
|
ensure_service!
|
@@ -1596,39 +1789,48 @@ module Google
|
|
1596
1789
|
backoff = 1.0
|
1597
1790
|
start_time = current_time
|
1598
1791
|
|
1792
|
+
request_options = Convert.to_request_options \
|
1793
|
+
request_options, tag_type: :transaction_tag
|
1794
|
+
|
1599
1795
|
@pool.with_transaction do |tx|
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1796
|
+
if request_options
|
1797
|
+
tx.transaction_tag = request_options[:transaction_tag]
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
begin
|
1801
|
+
Thread.current[:transaction_id] = tx.transaction_id
|
1802
|
+
yield tx
|
1803
|
+
commit_resp = @project.service.commit \
|
1804
|
+
tx.session.path, tx.mutations,
|
1805
|
+
transaction_id: tx.transaction_id,
|
1806
|
+
commit_options: commit_options,
|
1807
|
+
request_options: request_options,
|
1808
|
+
call_options: call_options
|
1809
|
+
resp = CommitResponse.from_grpc commit_resp
|
1810
|
+
commit_options ? resp : resp.timestamp
|
1811
|
+
rescue GRPC::Aborted, Google::Cloud::AbortedError => e
|
1812
|
+
# Re-raise if deadline has passed
|
1813
|
+
if current_time - start_time > deadline
|
1814
|
+
if e.is_a? GRPC::BadStatus
|
1815
|
+
e = Google::Cloud::Error.from_error e
|
1816
|
+
end
|
1817
|
+
raise e
|
1615
1818
|
end
|
1819
|
+
# Sleep the amount from RetryDelay, or incremental backoff
|
1820
|
+
sleep(delay_from_aborted(e) || backoff *= 1.3)
|
1821
|
+
# Create new transaction on the session and retry the block
|
1822
|
+
tx = tx.session.create_transaction
|
1823
|
+
retry
|
1824
|
+
rescue StandardError => e
|
1825
|
+
# Rollback transaction when handling unexpected error
|
1826
|
+
tx.session.rollback tx.transaction_id
|
1827
|
+
# Return nil if raised with rollback.
|
1828
|
+
return nil if e.is_a? Rollback
|
1829
|
+
# Re-raise error.
|
1616
1830
|
raise e
|
1831
|
+
ensure
|
1832
|
+
Thread.current[:transaction_id] = nil
|
1617
1833
|
end
|
1618
|
-
# Sleep the amount from RetryDelay, or incremental backoff
|
1619
|
-
sleep(delay_from_aborted(e) || backoff *= 1.3)
|
1620
|
-
# Create new transaction on the session and retry the block
|
1621
|
-
tx = tx.session.create_transaction
|
1622
|
-
retry
|
1623
|
-
rescue StandardError => e
|
1624
|
-
# Rollback transaction when handling unexpected error
|
1625
|
-
tx.session.rollback tx.transaction_id
|
1626
|
-
# Return nil if raised with rollback.
|
1627
|
-
return nil if e.is_a? Rollback
|
1628
|
-
# Re-raise error.
|
1629
|
-
raise e
|
1630
|
-
ensure
|
1631
|
-
Thread.current[:transaction_id] = nil
|
1632
1834
|
end
|
1633
1835
|
end
|
1634
1836
|
|
@@ -324,6 +324,25 @@ module Google
|
|
324
324
|
|
325
325
|
[input_params, input_param_types]
|
326
326
|
end
|
327
|
+
|
328
|
+
##
|
329
|
+
# Build request options by replacing tag to respecitve statistics
|
330
|
+
# collection tag type.
|
331
|
+
#
|
332
|
+
# @param [Hash] options Common request options.
|
333
|
+
# * `:tag` (String) A tag used for statistics collection.
|
334
|
+
#
|
335
|
+
# @param [Symbol] tag_type Request tag type.
|
336
|
+
# Possible values are `request_tag`, `transaction_tag`
|
337
|
+
# @return [Hash, nil]
|
338
|
+
#
|
339
|
+
def to_request_options options, tag_type: nil
|
340
|
+
return unless options
|
341
|
+
|
342
|
+
return options unless options.key? :tag
|
343
|
+
|
344
|
+
options.transform_keys { |k| k == :tag ? tag_type : k }
|
345
|
+
end
|
327
346
|
end
|
328
347
|
|
329
348
|
# rubocop:enable all
|
@@ -441,13 +441,18 @@ module Google
|
|
441
441
|
service.rollback request, opts
|
442
442
|
end
|
443
443
|
|
444
|
-
def begin_transaction session_name,
|
444
|
+
def begin_transaction session_name, request_options: nil,
|
445
|
+
call_options: nil
|
445
446
|
tx_opts = V1::TransactionOptions.new(
|
446
447
|
read_write: V1::TransactionOptions::ReadWrite.new
|
447
448
|
)
|
448
449
|
opts = default_options session_name: session_name,
|
449
450
|
call_options: call_options
|
450
|
-
request = {
|
451
|
+
request = {
|
452
|
+
session: session_name,
|
453
|
+
options: tx_opts,
|
454
|
+
request_options: request_options
|
455
|
+
}
|
451
456
|
service.begin_transaction request, opts
|
452
457
|
end
|
453
458
|
|
@@ -167,6 +167,23 @@ module Google
|
|
167
167
|
# available optimizer version.
|
168
168
|
# * `:optimizer_statistics_package` (String) Statistics package to
|
169
169
|
# use. Empty to use the database default.
|
170
|
+
# @param [Hash] request_options Common request options.
|
171
|
+
#
|
172
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
173
|
+
# to queries or reads, used for statistics collection. Both
|
174
|
+
# request_tag and transaction_tag can be specified for a read or
|
175
|
+
# query that belongs to a transaction. This field is ignored for
|
176
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
177
|
+
# `request_tag` must be a valid identifier of the form:
|
178
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
179
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
180
|
+
# about this transaction. Both request_tag and transaction_tag can
|
181
|
+
# be specified for a read or query that belongs to a transaction.
|
182
|
+
# The value of transaction_tag should be the same for all requests
|
183
|
+
# belonging to the same transaction. If this request doesn't belong
|
184
|
+
# to any transaction, transaction_tag will be ignored.
|
185
|
+
# `transaction_tag` must be a valid identifier of the format:
|
186
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
170
187
|
# @param [Hash] call_options A hash of values to specify the custom
|
171
188
|
# call options, e.g., timeout, retries, etc. Call options are
|
172
189
|
# optional. The following settings can be provided:
|
@@ -349,6 +366,23 @@ module Google
|
|
349
366
|
# transactions.
|
350
367
|
# @param [Integer] seqno A per-transaction sequence number used to
|
351
368
|
# identify this request.
|
369
|
+
# @param [Hash] request_options Common request options.
|
370
|
+
#
|
371
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
372
|
+
# to queries or reads, used for statistics collection. Both
|
373
|
+
# request_tag and transaction_tag can be specified for a read or
|
374
|
+
# query that belongs to a transaction. This field is ignored for
|
375
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
376
|
+
# `request_tag` must be a valid identifier of the form:
|
377
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
378
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
379
|
+
# about this transaction. Both request_tag and transaction_tag can
|
380
|
+
# be specified for a read or query that belongs to a transaction.
|
381
|
+
# The value of transaction_tag should be the same for all requests
|
382
|
+
# belonging to the same transaction. If this request doesn't belong
|
383
|
+
# to any transaction, transaction_tag will be ignored.
|
384
|
+
# `transaction_tag` must be a valid identifier of the format:
|
385
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
352
386
|
# @param [Hash] call_options A hash of values to specify the custom
|
353
387
|
# call options, e.g., timeout, retries, etc. Call options are
|
354
388
|
# optional. The following settings can be provided:
|
@@ -413,6 +447,23 @@ module Google
|
|
413
447
|
# @param [Google::Cloud::Spanner::V1::TransactionSelector] transaction The
|
414
448
|
# transaction selector value to send. Only used for single-use
|
415
449
|
# transactions.
|
450
|
+
# @param [Hash] request_options Common request options.
|
451
|
+
#
|
452
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
453
|
+
# to queries or reads, used for statistics collection. Both
|
454
|
+
# request_tag and transaction_tag can be specified for a read or
|
455
|
+
# query that belongs to a transaction. This field is ignored for
|
456
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
457
|
+
# `request_tag` must be a valid identifier of the form:
|
458
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
459
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
460
|
+
# about this transaction. Both request_tag and transaction_tag can
|
461
|
+
# be specified for a read or query that belongs to a transaction.
|
462
|
+
# The value of transaction_tag should be the same for all requests
|
463
|
+
# belonging to the same transaction. If this request doesn't belong
|
464
|
+
# to any transaction, transaction_tag will be ignored.
|
465
|
+
# `transaction_tag` must be a valid identifier of the format:
|
466
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
416
467
|
# @param [Hash] call_options A hash of values to specify the custom
|
417
468
|
# call options, e.g., timeout, retries, etc. Call options are
|
418
469
|
# optional. The following settings can be provided:
|
@@ -506,6 +557,23 @@ module Google
|
|
506
557
|
# {CommitResponse}. Default value is `false`
|
507
558
|
#
|
508
559
|
# transaction. Default it is `false`.
|
560
|
+
# @param [Hash] request_options Common request options.
|
561
|
+
#
|
562
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
563
|
+
# to queries or reads, used for statistics collection. Both
|
564
|
+
# request_tag and transaction_tag can be specified for a read or
|
565
|
+
# query that belongs to a transaction. This field is ignored for
|
566
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
567
|
+
# `request_tag` must be a valid identifier of the form:
|
568
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
569
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
570
|
+
# about this transaction. Both request_tag and transaction_tag can
|
571
|
+
# be specified for a read or query that belongs to a transaction.
|
572
|
+
# The value of transaction_tag should be the same for all requests
|
573
|
+
# belonging to the same transaction. If this request doesn't belong
|
574
|
+
# to any transaction, transaction_tag will be ignored.
|
575
|
+
# `transaction_tag` must be a valid identifier of the format:
|
576
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
509
577
|
# @param [Hash] call_options A hash of values to specify the custom
|
510
578
|
# call options, e.g., timeout, retries, etc. Call options are
|
511
579
|
# optional. The following settings can be provided:
|
@@ -605,6 +673,23 @@ module Google
|
|
605
673
|
# then statistics related to the transaction will be included in
|
606
674
|
# {CommitResponse}. Default value is `false`
|
607
675
|
#
|
676
|
+
# @param [Hash] request_options Common request options.
|
677
|
+
#
|
678
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
679
|
+
# to queries or reads, used for statistics collection. Both
|
680
|
+
# request_tag and transaction_tag can be specified for a read or
|
681
|
+
# query that belongs to a transaction. This field is ignored for
|
682
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
683
|
+
# `request_tag` must be a valid identifier of the form:
|
684
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
685
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
686
|
+
# about this transaction. Both request_tag and transaction_tag can
|
687
|
+
# be specified for a read or query that belongs to a transaction.
|
688
|
+
# The value of transaction_tag should be the same for all requests
|
689
|
+
# belonging to the same transaction. If this request doesn't belong
|
690
|
+
# to any transaction, transaction_tag will be ignored.
|
691
|
+
# `transaction_tag` must be a valid identifier of the format:
|
692
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
608
693
|
# @param [Hash] call_options A hash of values to specify the custom
|
609
694
|
# call options, e.g., timeout, retries, etc. Call options are
|
610
695
|
# optional. The following settings can be provided:
|
@@ -696,6 +781,23 @@ module Google
|
|
696
781
|
# then statistics related to the transaction will be included in
|
697
782
|
# {CommitResponse}. Default value is `false`
|
698
783
|
#
|
784
|
+
# @param [Hash] request_options Common request options.
|
785
|
+
#
|
786
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
787
|
+
# to queries or reads, used for statistics collection. Both
|
788
|
+
# request_tag and transaction_tag can be specified for a read or
|
789
|
+
# query that belongs to a transaction. This field is ignored for
|
790
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
791
|
+
# `request_tag` must be a valid identifier of the form:
|
792
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
793
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
794
|
+
# about this transaction. Both request_tag and transaction_tag can
|
795
|
+
# be specified for a read or query that belongs to a transaction.
|
796
|
+
# The value of transaction_tag should be the same for all requests
|
797
|
+
# belonging to the same transaction. If this request doesn't belong
|
798
|
+
# to any transaction, transaction_tag will be ignored.
|
799
|
+
# `transaction_tag` must be a valid identifier of the format:
|
800
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
699
801
|
# @param [Hash] call_options A hash of values to specify the custom
|
700
802
|
# call options, e.g., timeout, retries, etc. Call options are
|
701
803
|
# optional. The following settings can be provided:
|
@@ -786,6 +888,23 @@ module Google
|
|
786
888
|
# then statistics related to the transaction will be included in
|
787
889
|
# {CommitResponse}. Default value is `false`
|
788
890
|
#
|
891
|
+
# @param [Hash] request_options Common request options.
|
892
|
+
#
|
893
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
894
|
+
# to queries or reads, used for statistics collection. Both
|
895
|
+
# request_tag and transaction_tag can be specified for a read or
|
896
|
+
# query that belongs to a transaction. This field is ignored for
|
897
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
898
|
+
# `request_tag` must be a valid identifier of the form:
|
899
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
900
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
901
|
+
# about this transaction. Both request_tag and transaction_tag can
|
902
|
+
# be specified for a read or query that belongs to a transaction.
|
903
|
+
# The value of transaction_tag should be the same for all requests
|
904
|
+
# belonging to the same transaction. If this request doesn't belong
|
905
|
+
# to any transaction, transaction_tag will be ignored.
|
906
|
+
# `transaction_tag` must be a valid identifier of the format:
|
907
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
789
908
|
# @param [Hash] call_options A hash of values to specify the custom
|
790
909
|
# call options, e.g., timeout, retries, etc. Call options are
|
791
910
|
# optional. The following settings can be provided:
|
@@ -878,6 +997,23 @@ module Google
|
|
878
997
|
# then statistics related to the transaction will be included in
|
879
998
|
# {CommitResponse}. Default value is `false`.
|
880
999
|
#
|
1000
|
+
# @param [Hash] request_options Common request options.
|
1001
|
+
#
|
1002
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
1003
|
+
# to queries or reads, used for statistics collection. Both
|
1004
|
+
# request_tag and transaction_tag can be specified for a read or
|
1005
|
+
# query that belongs to a transaction. This field is ignored for
|
1006
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
1007
|
+
# `request_tag` must be a valid identifier of the form:
|
1008
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
1009
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
1010
|
+
# about this transaction. Both request_tag and transaction_tag can
|
1011
|
+
# be specified for a read or query that belongs to a transaction.
|
1012
|
+
# The value of transaction_tag should be the same for all requests
|
1013
|
+
# belonging to the same transaction. If this request doesn't belong
|
1014
|
+
# to any transaction, transaction_tag will be ignored.
|
1015
|
+
# `transaction_tag` must be a valid identifier of the format:
|
1016
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
881
1017
|
# @param [Hash] call_options A hash of values to specify the custom
|
882
1018
|
# call options, e.g., timeout, retries, etc. Call options are
|
883
1019
|
# optional. The following settings can be provided:
|
@@ -950,6 +1086,23 @@ module Google
|
|
950
1086
|
# then statistics related to the transaction will be included in
|
951
1087
|
# {CommitResponse}. Default value is `false`
|
952
1088
|
#
|
1089
|
+
# @param [Hash] request_options Common request options.
|
1090
|
+
#
|
1091
|
+
# * `:request_tag` (String) A per-request tag which can be applied
|
1092
|
+
# to queries or reads, used for statistics collection. Both
|
1093
|
+
# request_tag and transaction_tag can be specified for a read or
|
1094
|
+
# query that belongs to a transaction. This field is ignored for
|
1095
|
+
# requests where it's not applicable (e.g. CommitRequest).
|
1096
|
+
# `request_tag` must be a valid identifier of the form:
|
1097
|
+
# `[a-zA-Z][a-zA-Z0-9_\-]` between 2 and 64 characters in length.
|
1098
|
+
# * `:transaction_tag` (String) A tag used for statistics collection
|
1099
|
+
# about this transaction. Both request_tag and transaction_tag can
|
1100
|
+
# be specified for a read or query that belongs to a transaction.
|
1101
|
+
# The value of transaction_tag should be the same for all requests
|
1102
|
+
# belonging to the same transaction. If this request doesn't belong
|
1103
|
+
# to any transaction, transaction_tag will be ignored.
|
1104
|
+
# `transaction_tag` must be a valid identifier of the format:
|
1105
|
+
# [a-zA-Z][a-zA-Z0-9_\-]{0,49}
|
953
1106
|
# @param [Hash] call_options A hash of values to specify the custom
|
954
1107
|
# call options, e.g., timeout, retries, etc. Call options are
|
955
1108
|
# optional. The following settings can be provided:
|
@@ -77,6 +77,9 @@ module Google
|
|
77
77
|
# @private The Session object.
|
78
78
|
attr_accessor :session
|
79
79
|
|
80
|
+
# @private Transaction tag for statistics collection.
|
81
|
+
attr_accessor :transaction_tag
|
82
|
+
|
80
83
|
def initialize
|
81
84
|
@commit = Commit.new
|
82
85
|
@seqno = 0
|
@@ -167,6 +170,10 @@ module Google
|
|
167
170
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
168
171
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
169
172
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
173
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
174
|
+
# queries or reads, used for statistics collection. Tag must be a
|
175
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
176
|
+
# and 64 characters in length.
|
170
177
|
# @param [Hash] call_options A hash of values to specify the custom
|
171
178
|
# call options, e.g., timeout, retries, etc. Call options are
|
172
179
|
# optional. The following settings can be provided:
|
@@ -333,6 +340,7 @@ module Google
|
|
333
340
|
@seqno += 1
|
334
341
|
|
335
342
|
params, types = Convert.to_input_params_and_types params, types
|
343
|
+
request_options = build_request_options request_options
|
336
344
|
session.execute_query sql, params: params, types: types,
|
337
345
|
transaction: tx_selector, seqno: @seqno,
|
338
346
|
query_options: query_options,
|
@@ -419,6 +427,10 @@ module Google
|
|
419
427
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
420
428
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
421
429
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
430
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
431
|
+
# queries or reads, used for statistics collection. Tag must be a
|
432
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
433
|
+
# and 64 characters in length.
|
422
434
|
# @param [Hash] call_options A hash of values to specify the custom
|
423
435
|
# call options, e.g., timeout, retries, etc. Call options are
|
424
436
|
# optional. The following settings can be provided:
|
@@ -525,6 +537,10 @@ module Google
|
|
525
537
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
526
538
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
527
539
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
540
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
541
|
+
# queries or reads, used for statistics collection. Tag must be a
|
542
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
543
|
+
# and 64 characters in length.
|
528
544
|
# @param [Hash] call_options A hash of values to specify the custom
|
529
545
|
# call options, e.g., timeout, retries, etc. Call options are
|
530
546
|
# optional. The following settings can be provided:
|
@@ -597,6 +613,8 @@ module Google
|
|
597
613
|
def batch_update request_options: nil, call_options: nil, &block
|
598
614
|
ensure_session!
|
599
615
|
@seqno += 1
|
616
|
+
|
617
|
+
request_options = build_request_options request_options
|
600
618
|
session.batch_update tx_selector, @seqno,
|
601
619
|
request_options: request_options,
|
602
620
|
call_options: call_options, &block
|
@@ -626,6 +644,10 @@ module Google
|
|
626
644
|
# Valid values are `:PRIORITY_LOW`, `:PRIORITY_MEDIUM`,
|
627
645
|
# `:PRIORITY_HIGH`. If priority not set then default is
|
628
646
|
# `PRIORITY_UNSPECIFIED` is equivalent to `:PRIORITY_HIGH`.
|
647
|
+
# * `:tag` (String) A per-request tag which can be applied to
|
648
|
+
# queries or reads, used for statistics collection. Tag must be a
|
649
|
+
# valid identifier of the form: `[a-zA-Z][a-zA-Z0-9_\-]` between 2
|
650
|
+
# and 64 characters in length.
|
629
651
|
# @param [Hash] call_options A hash of values to specify the custom
|
630
652
|
# call options, e.g., timeout, retries, etc. Call options are
|
631
653
|
# optional. The following settings can be provided:
|
@@ -663,7 +685,7 @@ module Google
|
|
663
685
|
|
664
686
|
columns = Array(columns).map(&:to_s)
|
665
687
|
keys = Convert.to_key_set keys
|
666
|
-
|
688
|
+
request_options = build_request_options request_options
|
667
689
|
session.read table, columns, keys: keys, index: index, limit: limit,
|
668
690
|
transaction: tx_selector,
|
669
691
|
request_options: request_options,
|
@@ -1097,6 +1119,20 @@ module Google
|
|
1097
1119
|
V1::TransactionSelector.new id: transaction_id
|
1098
1120
|
end
|
1099
1121
|
|
1122
|
+
##
|
1123
|
+
# @private Build request options. If transaction tag is set
|
1124
|
+
# then add into request options.
|
1125
|
+
def build_request_options options
|
1126
|
+
options = Convert.to_request_options options, tag_type: :request_tag
|
1127
|
+
|
1128
|
+
if transaction_tag
|
1129
|
+
options ||= {}
|
1130
|
+
options[:transaction_tag] = transaction_tag
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
options
|
1134
|
+
end
|
1135
|
+
|
1100
1136
|
##
|
1101
1137
|
# @private Raise an error unless an active connection to the service is
|
1102
1138
|
# available.
|
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.9.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: 2021-07-
|
12
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|