google-cloud-spanner 2.8.0 → 2.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8347879380e3278cec1dee95179755b0f1ff4ffecea9fae6b04861bd43976d1
4
- data.tar.gz: b6c66cb0637a396bfee1e590b6316826f24a5dc45739c57de19c14c0304bc501
3
+ metadata.gz: 0beabc13ee4d11f2c6c0cc632bcf78359fc6e9d090ae53beed550fd86409feca
4
+ data.tar.gz: c24820a5fafff86d5a668df2715ae6b81420fab10a4aea60654c48ae0456a502
5
5
  SHA512:
6
- metadata.gz: 5a2caf305e7484bd7c17d89973ee3eb536a11b202fa7b85443f33b60ebafc65fb67a57106ca75fda2d448c45614479c44745344af17267f6577b37a5389c2d02
7
- data.tar.gz: 3be51dc4c55d948f57c19e2be190cbc27b259793d63b77d366ae9bc8beb7e64c67135127e130b3837305576a41eb5ae370e810ec58ccbb46f627e0816c0359f8
6
+ metadata.gz: 4322a66151a30d42daaecbedbf3a49e78ca80b34d3c991f196beb2af3293ae173ce99ce7e49338e383dbe6da29c2ec9877c94e3ed6973d6935da07421bcdee61
7
+ data.tar.gz: d78c1bc68027481ddc8674a958df3e32a93191618829aa9a16fa87fb9d407d49c8243c9482fc07e39022d2c54144a6edc98d2934bde4736a7a276ed669e2d645
data/AUTHENTICATION.md CHANGED
@@ -95,7 +95,8 @@ client = Google::Cloud::Spanner.new
95
95
 
96
96
  ### Configuration
97
97
 
98
- The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
98
+ The **Project ID** and the path to the **Credentials JSON** file can be configured
99
+ instead of placing them in environment variables or providing them as arguments.
99
100
 
100
101
  ```ruby
101
102
  require "google/cloud/spanner"
data/CHANGELOG.md CHANGED
@@ -1,47 +1,52 @@
1
1
  # Release History
2
2
 
3
+ ### 2.10.1 / 2021-11-09
4
+
5
+ #### Documentation
6
+
7
+ * Add documentation for quota_project Configuration attribute
8
+
9
+ ### 2.10.0 / 2021-08-24
10
+
11
+ #### Features
12
+
13
+ * add field JSON type support
14
+
15
+ ### 2.9.0 / 2021-07-26
16
+
17
+ #### Features
18
+
19
+ * support request tagging
20
+
21
+ ### 2.8.1 / 2021-07-08
22
+
23
+ #### Documentation
24
+
25
+ * Update AUTHENTICATION.md in handwritten packages
26
+
3
27
  ### 2.8.0 / 2021-06-17
4
28
 
5
29
  #### Features
6
30
 
7
- * create instance using processing units/node count ([#11379](https://www.github.com/googleapis/google-cloud-ruby/issues/11379))
8
- * create instance using processing units/node count
9
- * fix typo
10
- * removed node count and processing unit validations
11
- * update orignal value on instance save
12
- * remove orignal_values to current_valuess
31
+ * create instance using processing units/node count
13
32
 
14
33
  ### 2.7.0 / 2021-06-09
15
34
 
16
35
  #### Features
17
36
 
18
- * add the support of optimizer statistics package ([#7591](https://www.github.com/googleapis/google-cloud-ruby/issues/7591))
19
- * feat(spanner): add the support of optimizer statistics package
20
- * Fix rubocop issues.
21
- * Fix the env issue.
22
- * database create time access method ([#11617](https://www.github.com/googleapis/google-cloud-ruby/issues/11617))
23
- * added database create time method
24
- * remove assert for databse create time
25
- * RPC priority request option. ([#11258](https://www.github.com/googleapis/google-cloud-ruby/issues/11258))
37
+ * add the support of optimizer statistics package
38
+ * database create time access method
39
+ * RPC priority request option.
26
40
 
27
41
  #### Bug Fixes
28
42
 
29
- * extract binary retry info from error ([#11656](https://www.github.com/googleapis/google-cloud-ruby/issues/11656))
30
- * fix: extract binary retry info from error
31
- * fix: remove unrelated frozen_string_literal change
32
- * fix: remove unnecessary parentheses
43
+ * extract binary retry info from error
33
44
 
34
45
  ### 2.6.0 / 2021-03-31
35
46
 
36
47
  #### Features
37
48
 
38
- * add cmek backup support - ext of [#8142](https://www.github.com/googleapis/google-cloud-ruby/issues/8142) ([#8168](https://www.github.com/googleapis/google-cloud-ruby/issues/8168))
39
- * feat(spanner): add cmek backup support
40
- * Add encryption_config to restore database.
41
- * doc example for backup create with encryption config
42
- * create backup with encryption type
43
- * backup restore with encryption type changes
44
- * fix typo
49
+ * add cmek backup support
45
50
  * add cmek db support
46
51
 
47
52
  ### 2.5.0 / 2021-03-10
@@ -54,27 +59,14 @@
54
59
 
55
60
  #### Features
56
61
 
57
- * Point In Time Recovery (PITR) ([#8169](https://www.github.com/googleapis/google-cloud-ruby/issues/8169))
58
- * feat(spanner): support pitr-lite
59
- * feature(spanner): adds test for throttled
60
- * feat(spanner): adds version time to backup
61
- * test(spanner): adds unit test for create backup
62
- * feat(spanner): exposes version time in backup
63
- * chore: fixes rubocop violations
64
- * fix: addresses PR comments
65
- * test: adds integration tests for pitr backup
62
+ * Point In Time Recovery (PITR)
66
63
 
67
64
  ### 2.3.0 / 2021-02-09
68
65
 
69
66
  #### Features
70
67
 
71
- * CommitStats in CommitResponse ([#8058](https://www.github.com/googleapis/google-cloud-ruby/issues/8058))
72
- * optionalize `credentials` when using cloud spanner emulator host ([#8416](https://www.github.com/googleapis/google-cloud-ruby/issues/8416))
73
- * Optionalize `credentials` when using Cloud Spanner Emulator
74
- * Remove unnecessary credentials stub for emulator_host in Google::Cloud::Spanner.new
75
- * Add test of explicit project_id in Google::Cloud::Spanner.new
76
- * Update document for `emulator_host` without credentials
77
- * Tidy code according to rubocop settings
68
+ * CommitStats in CommitResponse
69
+ * optionalize `credentials` when using cloud spanner emulator host
78
70
 
79
71
  ### 2.2.0 / 2020-09-15
80
72
 
@@ -134,25 +126,20 @@ please review the docs for the new `google-cloud-spanner-v1` gem. In particular:
134
126
 
135
127
  #### Features
136
128
 
137
- * Added support for backing up and restoring databases ([#5053](https://www.github.com/googleapis/google-cloud-ruby/issues/5053))
129
+ * Added support for backing up and restoring databases
138
130
 
139
131
  ### 1.15.0 / 2020-03-15
140
132
 
141
133
  #### Features
142
134
 
143
- * Added support for query options ([#4907](https://www.github.com/googleapis/google-cloud-ruby/issues/4907))
144
- * Added support for specifying the query optimizer version.
135
+ * Added support for query options
145
136
  * Support separate project setting for quota/billing
146
137
 
147
138
  ### 1.14.0 / 2020-02-18
148
139
 
149
140
  #### Features
150
141
 
151
- * allow custom lib name and version for telemetry purpose ([#4762](https://www.github.com/googleapis/google-cloud-ruby/issues/4762))
152
- * allow custom lib name and version for telemetry purpose
153
- * format docs
154
- * added custom lib name and version prefix
155
- * update test cases for lib name and version
142
+ * allow custom lib name and version for telemetry purpose
156
143
 
157
144
  ### 1.13.1 / 2020-01-22
158
145
 
@@ -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
- Thread.current[:transaction_id] = tx.transaction_id
1601
- yield tx
1602
- commit_resp = @project.service.commit \
1603
- tx.session.path, tx.mutations,
1604
- transaction_id: tx.transaction_id,
1605
- commit_options: commit_options,
1606
- request_options: request_options,
1607
- call_options: call_options
1608
- resp = CommitResponse.from_grpc commit_resp
1609
- commit_options ? resp : resp.timestamp
1610
- rescue GRPC::Aborted, Google::Cloud::AbortedError => e
1611
- # Re-raise if deadline has passed
1612
- if current_time - start_time > deadline
1613
- if e.is_a? GRPC::BadStatus
1614
- e = Google::Cloud::Error.from_error e
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
 
@@ -99,8 +99,7 @@ module Google
99
99
  if field.is_a? Fields
100
100
  field.struct(obj).to_grpc_value
101
101
  else
102
- raise ArgumentError,
103
- "A hash value cannot be set to type #{field}."
102
+ Google::Protobuf::Value.new string_value: obj.to_json
104
103
  end
105
104
  else
106
105
  if obj.respond_to?(:read) && obj.respond_to?(:rewind)
@@ -223,6 +222,8 @@ module Google
223
222
  Data.from_grpc value.list_value.values, type.struct_type.fields
224
223
  when :NUMERIC
225
224
  BigDecimal value.string_value
225
+ when :JSON
226
+ JSON.parse value.string_value
226
227
  end
227
228
  end
228
229
 
@@ -324,6 +325,25 @@ module Google
324
325
 
325
326
  [input_params, input_param_types]
326
327
  end
328
+
329
+ ##
330
+ # Build request options by replacing tag to respecitve statistics
331
+ # collection tag type.
332
+ #
333
+ # @param [Hash] options Common request options.
334
+ # * `:tag` (String) A tag used for statistics collection.
335
+ #
336
+ # @param [Symbol] tag_type Request tag type.
337
+ # Possible values are `request_tag`, `transaction_tag`
338
+ # @return [Hash, nil]
339
+ #
340
+ def to_request_options options, tag_type: nil
341
+ return unless options
342
+
343
+ return options unless options.key? :tag
344
+
345
+ options.transform_keys { |k| k == :tag ? tag_type : k }
346
+ end
327
347
  end
328
348
 
329
349
  # 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, call_options: nil
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 = { session: session_name, options: tx_opts }
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.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Spanner
19
- VERSION = "2.8.0".freeze
19
+ VERSION = "2.10.1".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -143,6 +143,8 @@ module Google
143
143
  # parameter `keyfile` is considered deprecated, but may also be used.)
144
144
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
145
145
  # the set of resources and operations that the connection can access.
146
+ # * `quota_project` - (String) The project ID for a project that can be
147
+ # used by client libraries for quota and billing purposes.
146
148
  # * `timeout` - (Integer) Default timeout to use in requests.
147
149
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
148
150
  # to use the default endpoint.
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.8.0
4
+ version: 2.10.1
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-06-17 00:00:00.000000000 Z
12
+ date: 2021-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core