google-cloud-spanner 1.16.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +54 -0
  4. data/CONTRIBUTING.md +5 -5
  5. data/TROUBLESHOOTING.md +0 -6
  6. data/lib/google-cloud-spanner.rb +11 -13
  7. data/lib/google/cloud/spanner.rb +6 -8
  8. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  9. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  10. data/lib/google/cloud/spanner/backup.rb +1 -1
  11. data/lib/google/cloud/spanner/backup/job.rb +2 -2
  12. data/lib/google/cloud/spanner/backup/job/list.rb +2 -2
  13. data/lib/google/cloud/spanner/backup/list.rb +1 -2
  14. data/lib/google/cloud/spanner/backup/restore/job.rb +2 -2
  15. data/lib/google/cloud/spanner/batch_client.rb +2 -2
  16. data/lib/google/cloud/spanner/batch_snapshot.rb +120 -23
  17. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  18. data/lib/google/cloud/spanner/client.rb +189 -30
  19. data/lib/google/cloud/spanner/commit.rb +14 -14
  20. data/lib/google/cloud/spanner/convert.rb +16 -7
  21. data/lib/google/cloud/spanner/credentials.rb +2 -2
  22. data/lib/google/cloud/spanner/data.rb +2 -2
  23. data/lib/google/cloud/spanner/database.rb +22 -22
  24. data/lib/google/cloud/spanner/database/backup_info.rb +1 -1
  25. data/lib/google/cloud/spanner/database/job.rb +3 -3
  26. data/lib/google/cloud/spanner/database/job/list.rb +2 -2
  27. data/lib/google/cloud/spanner/database/list.rb +1 -1
  28. data/lib/google/cloud/spanner/database/restore_info.rb +1 -1
  29. data/lib/google/cloud/spanner/fields.rb +8 -8
  30. data/lib/google/cloud/spanner/instance.rb +5 -12
  31. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  32. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  33. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  34. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  35. data/lib/google/cloud/spanner/partition.rb +4 -4
  36. data/lib/google/cloud/spanner/policy.rb +2 -2
  37. data/lib/google/cloud/spanner/results.rb +103 -24
  38. data/lib/google/cloud/spanner/service.rb +363 -350
  39. data/lib/google/cloud/spanner/session.rb +186 -31
  40. data/lib/google/cloud/spanner/snapshot.rb +60 -6
  41. data/lib/google/cloud/spanner/transaction.rb +116 -10
  42. data/lib/google/cloud/spanner/version.rb +1 -1
  43. metadata +20 -109
  44. data/lib/google/cloud/spanner/admin/database.rb +0 -149
  45. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -147
  46. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  47. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -1513
  48. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -111
  49. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +0 -222
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +0 -113
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +0 -325
  59. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -368
  60. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  61. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  62. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  63. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  64. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  71. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  72. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -334
  73. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  74. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -975
  75. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  76. data/lib/google/cloud/spanner/v1.rb +0 -16
  77. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  78. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  80. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  81. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  82. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  83. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  84. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -95
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  88. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -570
  89. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  90. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  91. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1485
  92. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  93. data/lib/google/spanner/admin/database/v1/backup_pb.rb +0 -98
  94. data/lib/google/spanner/admin/database/v1/common_pb.rb +0 -28
  95. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -141
  96. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -169
  97. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  98. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -181
  99. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  100. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  101. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  102. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  103. data/lib/google/spanner/v1/spanner_pb.rb +0 -179
  104. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -179
  105. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  106. data/lib/google/spanner/v1/type_pb.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f50e50b175e8946175ae34b8eae4e2ad6a9df8c2ab38ab71db0f4a7820b683f5
4
- data.tar.gz: 3494e84da57d1d7f98fb96069435106d91a7c84d773e26722073ade94f2b47fe
3
+ metadata.gz: 01dd371ff37296529b691fd13961d7e7681e63480a88202b9e958a8c28bc480b
4
+ data.tar.gz: 9915fdf52be7508c55380b193a9586a35c702617080d3bf93a9f53b37b62be84
5
5
  SHA512:
6
- metadata.gz: bbcf972b4d1548ebfae47f13ac49f5f77472b6ce914172ac56acbb42b46f44c2a047868bee5dc8f1bf0a33bce4d937720be43a6e6bc349d661090c1e6e89fe70
7
- data.tar.gz: 796d977752cd8f8cd699237fda28fcf964324e7542feb4ac1b9d9b6a6eeeb07111d4473292e318fb72b6d35ea5d4853b023770625ec225b6067ddbb0eba2102e
6
+ metadata.gz: 0a34c4eeaaf84abe4d311350a155b22190c7dbc426a48719df4ad553692d841aa1a2d3a72d7f043b2fef7b3fa87a81cda69f965f5eef58a8ce17a77bf186a48e
7
+ data.tar.gz: 36062397079b8960916575b9188c0ad10f376d27b7d194a20e7f4c6e69f29eeb018b499576209bf1b2d2985725233db5de3e233ff840b5c93790d15b9b4204ab
@@ -76,7 +76,7 @@ The environment variables that google-cloud-spanner checks for project ID are:
76
76
  1. `SPANNER_PROJECT`
77
77
  2. `GOOGLE_CLOUD_PROJECT`
78
78
 
79
- The environment variables that google-cloud-spanner checks for credentials are configured on {Google::Cloud::Spanner::V1::Credentials}:
79
+ The environment variables that google-cloud-spanner checks for credentials are configured on `Google::Cloud::Spanner::V1::Spanner::Credentials`:
80
80
 
81
81
  1. `SPANNER_CREDENTIALS` - Path to JSON file, or JSON contents
82
82
  2. `SPANNER_KEYFILE` - Path to JSON file, or JSON contents
@@ -1,5 +1,59 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.0 / 2020-09-15
4
+
5
+ #### Features
6
+
7
+ * quota_project can be set via library configuration
8
+ * Support numeric type.
9
+
10
+ #### Bug Fixes
11
+
12
+ * retry or resume eos and rst_stream errors
13
+
14
+ ### 2.1.0 / 2020-08-05
15
+
16
+ #### Features
17
+
18
+ * Support custom setting of timeout and retry
19
+
20
+ ### 2.0.0 / 2020-07-23
21
+
22
+ This is a major update that removes the "low-level" client interface code, and
23
+ instead adds `google-cloud-spanner-v1`, `google-cloud-spanner-admin-database-v1`,
24
+ and `google-cloud-spanner-admin-instance-v1` as dependencies.
25
+ The new dependencies are rewritten low-level clients, produced by a next-
26
+ generation client code generator, with improved performance and stability.
27
+
28
+ This change should have no effect on the high-level interface that most users
29
+ will use. The one exception is that the (mostly undocumented) `client_config`
30
+ argument, for adjusting low-level parameters such as RPC retry settings on
31
+ client objects, has been removed. If you need to adjust these parameters, use
32
+ the configuration interface in low-level clients.
33
+
34
+ Substantial changes have been made in the low-level interfaces, however. If you
35
+ are using the low-level classes under the old `Google::Spanner::V1` module,
36
+ please review the docs for the new `google-cloud-spanner-v1` gem. In particular:
37
+
38
+ * Some classes have been renamed, notably the client class itself.
39
+ * The client constructor takes a configuration block instead of configuration
40
+ keyword arguments.
41
+ * All RPC method arguments are now keyword arguments.
42
+
43
+ ### 1.16.2 / 2020-05-28
44
+
45
+ #### Documentation
46
+
47
+ * Fix a few broken links
48
+
49
+ ### 1.16.1 / 2020-05-21
50
+
51
+ #### Bug Fixes
52
+
53
+ * Increased default timeouts to match clients in other languages
54
+ * Run system tests against the emulator, skipping those not supported by the emulator
55
+ * Do not require a key file when running against the emulator
56
+
3
57
  ### 1.16.0 / 2020-03-20
4
58
 
5
59
  #### Features
@@ -53,7 +53,7 @@ there is a small amount of setup:
53
53
  In order to run code interactively, you can automatically load
54
54
  google-cloud-spanner and its dependencies in IRB. This requires that your
55
55
  developer environment has already been configured by following the steps
56
- described in the [Authentication Guide](AUTHENTICATION.md). An IRB console
56
+ described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
57
  can be created with:
58
58
 
59
59
  ```sh
@@ -119,7 +119,7 @@ If you alter an example's title, you may encounter breaking tests.
119
119
  ### Spanner Acceptance Tests
120
120
 
121
121
  The Spanner acceptance tests interact with the live service API. Follow the
122
- instructions in the [Authentication Guide](AUTHENTICATION.md) for enabling
122
+ instructions in the {file:AUTHENTICATION.md Authentication Guide} for enabling
123
123
  the Spanner API. Occasionally, some API features may not yet be generally
124
124
  available, making it difficult for some contributors to successfully run the
125
125
  entire acceptance test suite. However, please ensure that you do successfully
@@ -127,7 +127,7 @@ run acceptance tests for any code areas covered by your pull request.
127
127
 
128
128
  To run the acceptance tests, first create and configure a project in the Google
129
129
  Developers Console, as described in the
130
- [Authentication Guide](AUTHENTICATION.md). Be sure to download the JSON KEY
130
+ {file:AUTHENTICATION.md Authentication Guide}. Be sure to download the JSON KEY
131
131
  file. Make note of the PROJECT_ID and the KEYFILE location on your system.
132
132
 
133
133
  Before you can run the Spanner acceptance tests, you must first create indexes
@@ -184,5 +184,5 @@ $ bundle exec rake rubocop
184
184
  ## Code of Conduct
185
185
 
186
186
  Please note that this project is released with a Contributor Code of Conduct. By
187
- participating in this project you agree to abide by its terms. See
188
- [Code of Conduct](CODE_OF_CONDUCT.md) for more information.
187
+ participating in this project you agree to abide by its terms. See the
188
+ {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
24
24
 
25
25
  - [New issue][gh-ruby]
26
26
 
27
- Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
- can use the "ruby" channel for general Ruby questions, or use the
29
- "google-cloud-ruby" channel if you have questions about this gem in particular.
30
-
31
27
  [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+spanner
32
28
 
33
29
  [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+spanner%22
34
30
 
35
31
  [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
36
-
37
- [slack-ruby]: https://gcp-slack.appspot.com/
@@ -43,8 +43,6 @@ module Google
43
43
  # * `https://www.googleapis.com/auth/spanner`
44
44
  # * `https://www.googleapis.com/auth/spanner.data`
45
45
  # @param [Integer] timeout Default timeout to use in requests. Optional.
46
- # @param [Hash] client_config A hash of values to override the default
47
- # behavior of the API client. Optional.
48
46
  # @param [String] lib_name Library name. This will be added as a prefix
49
47
  # to the API call tracking header `x-goog-api-client` with provided
50
48
  # lib version for telemetry. Optional. For example prefix looks like
@@ -75,11 +73,9 @@ module Google
75
73
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
76
74
  # spanner = gcloud.spanner scope: platform_scope
77
75
  #
78
- def spanner scope: nil, timeout: nil, client_config: nil, lib_name: nil,
79
- lib_version: nil
76
+ def spanner scope: nil, timeout: nil, lib_name: nil, lib_version: nil
80
77
  Google::Cloud.spanner @project, @keyfile, scope: scope,
81
78
  timeout: (timeout || @timeout),
82
- client_config: client_config,
83
79
  lib_name: lib_name,
84
80
  lib_version: lib_version
85
81
  end
@@ -107,8 +103,6 @@ module Google
107
103
  # * `https://www.googleapis.com/auth/spanner`
108
104
  # * `https://www.googleapis.com/auth/spanner.data`
109
105
  # @param [Integer] timeout Default timeout to use in requests. Optional.
110
- # @param [Hash] client_config A hash of values to override the default
111
- # behavior of the API client. Optional.
112
106
  # @param [String] lib_name Library name. This will be added as a prefix
113
107
  # to the API call tracking header `x-goog-api-client` with provided
114
108
  # lib version for telemetry. Optional. For example prefix looks like
@@ -132,13 +126,11 @@ module Google
132
126
  # spanner = Google::Cloud.spanner
133
127
  #
134
128
  def self.spanner project_id = nil, credentials = nil, scope: nil,
135
- timeout: nil, client_config: nil, lib_name: nil,
136
- lib_version: nil
129
+ timeout: nil, lib_name: nil, lib_version: nil
137
130
  require "google/cloud/spanner"
138
131
  Google::Cloud::Spanner.new project_id: project_id,
139
132
  credentials: credentials,
140
133
  scope: scope, timeout: timeout,
141
- client_config: client_config,
142
134
  lib_name: lib_name, lib_version: lib_version
143
135
  end
144
136
  end
@@ -169,16 +161,22 @@ Google::Cloud.configure.add_config! :spanner do |config|
169
161
  query_options
170
162
  end
171
163
 
164
+ default_scopes = [
165
+ "https://www.googleapis.com/auth/cloud-platform",
166
+ "https://www.googleapis.com/auth/spanner.admin",
167
+ "https://www.googleapis.com/auth/spanner.data"
168
+ ]
169
+
172
170
  config.add_field! :project_id, default_project, match: String, allow_nil: true
173
171
  config.add_alias! :project, :project_id
174
172
  config.add_field! :credentials, default_creds,
175
173
  match: [String, Hash, Google::Auth::Credentials],
176
174
  allow_nil: true
177
175
  config.add_alias! :keyfile, :credentials
178
- config.add_field! :scope, nil, match: [String, Array]
176
+ config.add_field! :scope, default_scopes, match: [String, Array]
177
+ config.add_field! :quota_project, nil, match: String
179
178
  config.add_field! :timeout, nil, match: Integer
180
- config.add_field! :client_config, nil, match: Hash
181
- config.add_field! :endpoint, nil, match: String
179
+ config.add_field! :endpoint, "spanner.googleapis.com", match: String
182
180
  config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
183
181
  config.add_field! :lib_name, nil, match: String, allow_nil: true
184
182
  config.add_field! :lib_version, nil, match: String, allow_nil: true
@@ -59,8 +59,6 @@ module Google
59
59
  # * `https://www.googleapis.com/auth/spanner`
60
60
  # * `https://www.googleapis.com/auth/spanner.data`
61
61
  # @param [Integer] timeout Default timeout to use in requests. Optional.
62
- # @param [Hash] client_config A hash of values to override the default
63
- # behavior of the API client. Optional.
64
62
  # @param [String] endpoint Override of the endpoint host name. Optional.
65
63
  # If the param is nil, uses the default endpoint.
66
64
  # @param [String] project Alias for the `project_id` argument. Deprecated.
@@ -91,12 +89,11 @@ module Google
91
89
  # spanner = Google::Cloud::Spanner.new
92
90
  #
93
91
  def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
94
- client_config: nil, endpoint: nil, project: nil, keyfile: nil,
92
+ endpoint: nil, project: nil, keyfile: nil,
95
93
  emulator_host: nil, lib_name: nil, lib_version: nil
96
94
  project_id ||= (project || default_project_id)
97
95
  scope ||= configure.scope
98
96
  timeout ||= configure.timeout
99
- client_config ||= configure.client_config
100
97
  endpoint ||= configure.endpoint
101
98
  credentials ||= (keyfile || default_credentials(scope: scope))
102
99
  emulator_host ||= configure.emulator_host
@@ -122,8 +119,8 @@ module Google
122
119
  Spanner::Project.new(
123
120
  Spanner::Service.new(
124
121
  project_id, credentials,
125
- host: endpoint, timeout: timeout, client_config: client_config,
126
- lib_name: lib_name, lib_version: lib_version
122
+ host: endpoint, timeout: timeout, lib_name: lib_name,
123
+ lib_version: lib_version
127
124
  ),
128
125
  query_options: configure.query_options
129
126
  )
@@ -145,8 +142,6 @@ module Google
145
142
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
146
143
  # the set of resources and operations that the connection can access.
147
144
  # * `timeout` - (Integer) Default timeout to use in requests.
148
- # * `client_config` - (Hash) A hash of values to override the default
149
- # behavior of the API client.
150
145
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
151
146
  # to use the default endpoint.
152
147
  # * `emulator_host` - (String) Host name of the emulator. Defaults to
@@ -184,4 +179,7 @@ module Google
184
179
  end
185
180
  end
186
181
  end
182
+
183
+ # @private
184
+ Spanner = Cloud::Spanner unless const_defined? :Spanner
187
185
  end
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "googleauth"
16
+ require "google/cloud/spanner/admin/database/v1/database_admin/credentials"
17
17
 
18
18
  module Google
19
19
  module Cloud
@@ -23,7 +23,7 @@ module Google
23
23
  ##
24
24
  # @deprecated Use version-specific credentials classes
25
25
  #
26
- Credentials = Google::Cloud::Spanner::Admin::Database::V1::Credentials
26
+ Credentials = V1::DatabaseAdmin::Credentials
27
27
  end
28
28
  end
29
29
  end
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "googleauth"
16
+ require "google/cloud/spanner/admin/instance/v1/instance_admin/credentials"
17
17
 
18
18
  module Google
19
19
  module Cloud
@@ -23,7 +23,7 @@ module Google
23
23
  ##
24
24
  # @deprecated Use version-specific credentials classes
25
25
  #
26
- Credentials = Google::Cloud::Spanner::Admin::Instance::V1::Credentials
26
+ Credentials = V1::InstanceAdmin::Credentials
27
27
  end
28
28
  end
29
29
  end
@@ -296,7 +296,7 @@ module Google
296
296
  ##
297
297
  # @private
298
298
  # Creates a new Backup instance from a
299
- # {Google::Spanner::Admin::Database::V1::Backup}.
299
+ # `Google::Cloud::Spanner::Admin::Database::V1::Backup`.
300
300
  def self.from_grpc grpc, service
301
301
  new grpc, service
302
302
  end
@@ -53,7 +53,7 @@ module Google
53
53
  #
54
54
  class Job
55
55
  ##
56
- # @private The Google::Gax::Operation gRPC object.
56
+ # @private The `Gapic::Operation` gRPC object.
57
57
  attr_accessor :grpc
58
58
 
59
59
  ##
@@ -260,7 +260,7 @@ module Google
260
260
  end
261
261
 
262
262
  ##
263
- # @private New Backup::Job from a Google::Gax::Operation object.
263
+ # @private New Backup::Job from a `Gapic::Operation` object.
264
264
  def self.from_grpc grpc, service
265
265
  new.tap do |job|
266
266
  job.instance_variable_set :@grpc, grpc
@@ -146,7 +146,7 @@ module Google
146
146
  # @private
147
147
  #
148
148
  # New Backup::Job::List from a
149
- # Google::Gax::PagedEnumerable<Google::Longrunning::Operation>
149
+ # `Gapic::PagedEnumerable<Google::Longrunning::Operation>`
150
150
  # object. Operation object is a backup operation.
151
151
  #
152
152
  def self.from_grpc grpc, service
@@ -154,7 +154,7 @@ module Google
154
154
  service.databases.instance_variable_get "@operations_client"
155
155
  jobs = new(Array(grpc.response.operations).map do |job_grpc|
156
156
  Job.from_grpc \
157
- Google::Gax::Operation.new(job_grpc, operations_client),
157
+ Gapic::Operation.new(job_grpc, operations_client),
158
158
  service
159
159
  end)
160
160
  jobs.grpc = grpc
@@ -143,8 +143,7 @@ module Google
143
143
  ##
144
144
  # @private
145
145
  # New Backup::List from a
146
- # Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::\
147
- # V1::Backup>
146
+ # `Gapic::PagedEnumerable<Google::Cloud::Spanner::Admin::Database::V1::Backup>`
148
147
  # object.
149
148
  def self.from_grpc grpc, service
150
149
  backups = List.new(Array(grpc.response.backups).map do |backup|
@@ -53,7 +53,7 @@ module Google
53
53
  #
54
54
  class Job
55
55
  ##
56
- # @private The Google::Gax::Operation gRPC object.
56
+ # @private The `Gapic::Operation` gRPC object.
57
57
  attr_accessor :grpc
58
58
 
59
59
  ##
@@ -231,7 +231,7 @@ module Google
231
231
  end
232
232
 
233
233
  ##
234
- # @private New Restore::Job from a Google::Gax::Operation object.
234
+ # @private New Restore::Job from a `Gapic::Operation` object.
235
235
  def self.from_grpc grpc, service
236
236
  new.tap do |job|
237
237
  job.instance_variable_set :@grpc, grpc
@@ -407,8 +407,8 @@ module Google
407
407
  def session
408
408
  ensure_service!
409
409
  grpc = @project.service.create_session \
410
- Admin::Database::V1::DatabaseAdminClient.database_path(
411
- project_id, instance_id, database_id
410
+ V1::Spanner::Paths.database_path(
411
+ project: project_id, instance: instance_id, database: database_id
412
412
  ),
413
413
  labels: @session_labels
414
414
  Session.from_grpc grpc, @project.service, query_options: @query_options
@@ -173,6 +173,19 @@ module Google
173
173
  # * `:optimizer_version` (String) The version of optimizer to use.
174
174
  # Empty to use database default. "latest" to use the latest
175
175
  # available optimizer version.
176
+ # @param [Hash] call_options A hash of values to specify the custom
177
+ # call options, e.g., timeout, retries, etc. Call options are
178
+ # optional. The following settings can be provided:
179
+ #
180
+ # * `:timeout` (Numeric) A numeric value of custom timeout in seconds
181
+ # that overrides the default setting.
182
+ # * `:retry_policy` (Hash) A hash of values that overrides the default
183
+ # setting of retry policy with the following keys:
184
+ # * `:initial_delay` (`Numeric`) - The initial delay in seconds.
185
+ # * `:max_delay` (`Numeric`) - The max delay in seconds.
186
+ # * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
187
+ # * `:retry_codes` (`Array<String>`) - The error codes that should
188
+ # trigger a retry.
176
189
  #
177
190
  # @return [Array<Google::Cloud::Spanner::Partition>] The partitions
178
191
  # created by the query partition.
@@ -196,7 +209,7 @@ module Google
196
209
  #
197
210
  def partition_query sql, params: nil, types: nil,
198
211
  partition_size_bytes: nil, max_partitions: nil,
199
- query_options: nil
212
+ query_options: nil, call_options: nil
200
213
  ensure_session!
201
214
 
202
215
  params, types = Convert.to_input_params_and_types params, types
@@ -204,10 +217,11 @@ module Google
204
217
  results = session.partition_query \
205
218
  sql, tx_selector, params: params, types: types,
206
219
  partition_size_bytes: partition_size_bytes,
207
- max_partitions: max_partitions
220
+ max_partitions: max_partitions,
221
+ call_options: call_options
208
222
  results.partitions.map do |grpc|
209
223
  # Convert partition protos to execute sql request protos
210
- execute_sql_grpc = Google::Spanner::V1::ExecuteSqlRequest.new(
224
+ execute_sql_grpc = V1::ExecuteSqlRequest.new(
211
225
  {
212
226
  session: session.path,
213
227
  sql: sql,
@@ -248,6 +262,19 @@ module Google
248
262
  # partitions to return. For example, this may be set to the number of
249
263
  # workers available. This is only a hint and may provide different
250
264
  # results based on the request.
265
+ # @param [Hash] call_options A hash of values to specify the custom
266
+ # call options, e.g., timeout, retries, etc. Call options are
267
+ # optional. The following settings can be provided:
268
+ #
269
+ # * `:timeout` (Numeric) A numeric value of custom timeout in seconds
270
+ # that overrides the default setting.
271
+ # * `:retry_policy` (Hash) A hash of values that overrides the default
272
+ # setting of retry policy with the following keys:
273
+ # * `:initial_delay` (`Numeric`) - The initial delay in seconds.
274
+ # * `:max_delay` (`Numeric`) - The max delay in seconds.
275
+ # * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
276
+ # * `:retry_codes` (`Array<String>`) - The error codes that should
277
+ # trigger a retry.
251
278
  #
252
279
  # @return [Array<Google::Cloud::Spanner::Partition>] The partitions
253
280
  # created by the read partition.
@@ -268,7 +295,8 @@ module Google
268
295
  # batch_snapshot.close
269
296
  #
270
297
  def partition_read table, columns, keys: nil, index: nil,
271
- partition_size_bytes: nil, max_partitions: nil
298
+ partition_size_bytes: nil, max_partitions: nil,
299
+ call_options: nil
272
300
  ensure_session!
273
301
 
274
302
  columns = Array(columns).map(&:to_s)
@@ -278,11 +306,12 @@ module Google
278
306
  table, columns, tx_selector,
279
307
  keys: keys, index: index,
280
308
  partition_size_bytes: partition_size_bytes,
281
- max_partitions: max_partitions
309
+ max_partitions: max_partitions,
310
+ call_options: call_options
282
311
 
283
312
  results.partitions.map do |grpc|
284
313
  # Convert partition protos to read request protos
285
- read_grpc = Google::Spanner::V1::ReadRequest.new(
314
+ read_grpc = V1::ReadRequest.new(
286
315
  {
287
316
  session: session.path,
288
317
  table: table,
@@ -304,6 +333,19 @@ module Google
304
333
  #
305
334
  # @param [Google::Cloud::Spanner::Partition] partition The partition to
306
335
  # be executed.
336
+ # @param [Hash] call_options A hash of values to specify the custom
337
+ # call options, e.g., timeout, retries, etc. Call options are
338
+ # optional. The following settings can be provided:
339
+ #
340
+ # * `:timeout` (Numeric) A numeric value of custom timeout in seconds
341
+ # that overrides the default setting.
342
+ # * `:retry_policy` (Hash) A hash of values that overrides the default
343
+ # setting of retry policy with the following keys:
344
+ # * `:initial_delay` (`Numeric`) - The initial delay in seconds.
345
+ # * `:max_delay` (`Numeric`) - The max delay in seconds.
346
+ # * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
347
+ # * `:retry_codes` (`Array<String>`) - The error codes that should
348
+ # trigger a retry.
307
349
  #
308
350
  # @example
309
351
  # require "google/cloud/spanner"
@@ -320,7 +362,7 @@ module Google
320
362
  #
321
363
  # batch_snapshot.close
322
364
  #
323
- def execute_partition partition
365
+ def execute_partition partition, call_options: nil
324
366
  ensure_session!
325
367
 
326
368
  partition = Partition.load partition unless partition.is_a? Partition
@@ -329,10 +371,11 @@ module Google
329
371
  # TODO: raise if session.path != partition.session
330
372
  # TODO: raise if grpc.transaction != partition.transaction
331
373
 
374
+ opts = { call_options: call_options }
332
375
  if partition.execute?
333
- execute_partition_query partition
376
+ execute_partition_query partition, opts
334
377
  elsif partition.read?
335
- execute_partition_read partition
378
+ execute_partition_read partition, opts
336
379
  end
337
380
  end
338
381
 
@@ -430,6 +473,19 @@ module Google
430
473
  # * `:optimizer_version` (String) The version of optimizer to use.
431
474
  # Empty to use database default. "latest" to use the latest
432
475
  # available optimizer version.
476
+ # @param [Hash] call_options A hash of values to specify the custom
477
+ # call options, e.g., timeout, retries, etc. Call options are
478
+ # optional. The following settings can be provided:
479
+ #
480
+ # * `:timeout` (Numeric) A numeric value of custom timeout in seconds
481
+ # that overrides the default setting.
482
+ # * `:retry_policy` (Hash) A hash of values that overrides the default
483
+ # setting of retry policy with the following keys:
484
+ # * `:initial_delay` (`Numeric`) - The initial delay in seconds.
485
+ # * `:max_delay` (`Numeric`) - The max delay in seconds.
486
+ # * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
487
+ # * `:retry_codes` (`Array<String>`) - The error codes that should
488
+ # trigger a retry.
433
489
  #
434
490
  # @return [Google::Cloud::Spanner::Results] The results of the query
435
491
  # execution.
@@ -549,14 +605,40 @@ module Google
549
605
  # puts "User #{row[:id]} is #{row[:name]}"
550
606
  # end
551
607
  #
552
- def execute_query sql, params: nil, types: nil, query_options: nil
608
+ # @example Query using custom timeout and retry policy:
609
+ # require "google/cloud/spanner"
610
+ #
611
+ # spanner = Google::Cloud::Spanner.new
612
+ # batch_client = spanner.batch_client "my-instance", "my-database"
613
+ # batch_snapshot = batch_client.batch_snapshot
614
+ #
615
+ # timeout = 30.0
616
+ # retry_policy = {
617
+ # initial_delay: 0.25,
618
+ # max_delay: 32.0,
619
+ # multiplier: 1.3,
620
+ # retry_codes: ["UNAVAILABLE"]
621
+ # }
622
+ # call_options = { timeout: timeout, retry_policy: retry_policy }
623
+ #
624
+ # results = batch_snapshot.execute_query \
625
+ # "SELECT * FROM users",
626
+ # call_options: call_options
627
+ #
628
+ # results.rows.each do |row|
629
+ # puts "User #{row[:id]} is #{row[:name]}"
630
+ # end
631
+ #
632
+ def execute_query sql, params: nil, types: nil, query_options: nil,
633
+ call_options: nil
553
634
  ensure_session!
554
635
 
555
636
  params, types = Convert.to_input_params_and_types params, types
556
637
 
557
638
  session.execute_query sql, params: params, types: types,
558
639
  transaction: tx_selector,
559
- query_options: query_options
640
+ query_options: query_options,
641
+ call_options: call_options
560
642
  end
561
643
  alias execute execute_query
562
644
  alias query execute_query
@@ -578,6 +660,19 @@ module Google
578
660
  # Optional.
579
661
  # @param [Integer] limit If greater than zero, no more than this number
580
662
  # of rows will be returned. The default is no limit.
663
+ # @param [Hash] call_options A hash of values to specify the custom
664
+ # call options, e.g., timeout, retries, etc. Call options are
665
+ # optional. The following settings can be provided:
666
+ #
667
+ # * `:timeout` (Numeric) A numeric value of custom timeout in seconds
668
+ # that overrides the default setting.
669
+ # * `:retry_policy` (Hash) A hash of values that overrides the default
670
+ # setting of retry policy with the following keys:
671
+ # * `:initial_delay` (`Numeric`) - The initial delay in seconds.
672
+ # * `:max_delay` (`Numeric`) - The max delay in seconds.
673
+ # * `:multiplier` (`Numeric`) - The incremental backoff multiplier.
674
+ # * `:retry_codes` (`Array<String>`) - The error codes that should
675
+ # trigger a retry.
581
676
  #
582
677
  # @return [Google::Cloud::Spanner::Results] The results of the read
583
678
  # operation.
@@ -595,14 +690,16 @@ module Google
595
690
  # puts "User #{row[:id]} is #{row[:name]}"
596
691
  # end
597
692
  #
598
- def read table, columns, keys: nil, index: nil, limit: nil
693
+ def read table, columns, keys: nil, index: nil, limit: nil,
694
+ call_options: nil
599
695
  ensure_session!
600
696
 
601
697
  columns = Array(columns).map(&:to_s)
602
698
  keys = Convert.to_key_set keys
603
699
 
604
700
  session.read table, columns, keys: keys, index: index, limit: limit,
605
- transaction: tx_selector
701
+ transaction: tx_selector,
702
+ call_options: call_options
606
703
  end
607
704
 
608
705
  ##
@@ -663,17 +760,15 @@ module Google
663
760
  def self.load data, service: nil, query_options: nil
664
761
  data = JSON.parse data, symbolize_names: true unless data.is_a? Hash
665
762
 
666
- session_grpc = Google::Spanner::V1::Session.decode \
667
- Base64.decode64(data[:session])
668
- transaction_grpc = Google::Spanner::V1::Transaction.decode \
669
- Base64.decode64(data[:transaction])
763
+ session_grpc = V1::Session.decode Base64.decode64(data[:session])
764
+ transaction_grpc = V1::Transaction.decode Base64.decode64(data[:transaction])
670
765
 
671
766
  from_grpc transaction_grpc, Session.from_grpc(session_grpc, service, query_options: query_options)
672
767
  end
673
768
 
674
769
  ##
675
770
  # @private Creates a new BatchSnapshot instance from a
676
- # Google::Spanner::V1::Transaction.
771
+ # `Google::Cloud::Spanner::V1::Transaction`.
677
772
  def self.from_grpc grpc, session
678
773
  new grpc, session
679
774
  end
@@ -682,7 +777,7 @@ module Google
682
777
 
683
778
  # The TransactionSelector to be used for queries
684
779
  def tx_selector
685
- Google::Spanner::V1::TransactionSelector.new id: transaction_id
780
+ V1::TransactionSelector.new id: transaction_id
686
781
  end
687
782
 
688
783
  ##
@@ -692,7 +787,7 @@ module Google
692
787
  raise "Must have active connection to service" unless session
693
788
  end
694
789
 
695
- def execute_partition_query partition
790
+ def execute_partition_query partition, call_options: nil
696
791
  query_options = partition.execute.query_options
697
792
  query_options = query_options.to_h unless query_options.nil?
698
793
  session.execute_query \
@@ -701,16 +796,18 @@ module Google
701
796
  types: partition.execute.param_types.to_h,
702
797
  transaction: partition.execute.transaction,
703
798
  partition_token: partition.execute.partition_token,
704
- query_options: query_options
799
+ query_options: query_options,
800
+ call_options: call_options
705
801
  end
706
802
 
707
- def execute_partition_read partition
803
+ def execute_partition_read partition, call_options: nil
708
804
  session.read partition.read.table,
709
805
  partition.read.columns.to_a,
710
806
  keys: partition.read.key_set,
711
807
  index: partition.read.index,
712
808
  transaction: partition.read.transaction,
713
- partition_token: partition.read.partition_token
809
+ partition_token: partition.read.partition_token,
810
+ call_options: call_options
714
811
  end
715
812
  end
716
813
  end