google-cloud-spanner 1.16.2 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +66 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/google-cloud-spanner.rb +11 -13
- data/lib/google/cloud/spanner.rb +13 -13
- data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
- data/lib/google/cloud/spanner/backup.rb +9 -1
- data/lib/google/cloud/spanner/backup/job.rb +2 -2
- data/lib/google/cloud/spanner/backup/job/list.rb +2 -2
- data/lib/google/cloud/spanner/backup/list.rb +1 -2
- data/lib/google/cloud/spanner/backup/restore/job.rb +2 -2
- data/lib/google/cloud/spanner/batch_client.rb +2 -2
- data/lib/google/cloud/spanner/batch_snapshot.rb +120 -23
- data/lib/google/cloud/spanner/batch_update.rb +1 -1
- data/lib/google/cloud/spanner/client.rb +388 -47
- data/lib/google/cloud/spanner/commit.rb +14 -14
- data/lib/google/cloud/spanner/commit_response.rb +87 -0
- data/lib/google/cloud/spanner/commit_response/commit_stats.rb +51 -0
- data/lib/google/cloud/spanner/convert.rb +16 -7
- data/lib/google/cloud/spanner/credentials.rb +2 -2
- data/lib/google/cloud/spanner/data.rb +2 -2
- data/lib/google/cloud/spanner/database.rb +47 -25
- data/lib/google/cloud/spanner/database/backup_info.rb +13 -4
- data/lib/google/cloud/spanner/database/job.rb +3 -3
- data/lib/google/cloud/spanner/database/job/list.rb +2 -2
- data/lib/google/cloud/spanner/database/list.rb +1 -1
- data/lib/google/cloud/spanner/database/restore_info.rb +1 -1
- data/lib/google/cloud/spanner/fields.rb +8 -8
- data/lib/google/cloud/spanner/instance.rb +5 -12
- data/lib/google/cloud/spanner/instance/config.rb +1 -1
- data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
- data/lib/google/cloud/spanner/instance/job.rb +2 -2
- data/lib/google/cloud/spanner/instance/list.rb +1 -1
- data/lib/google/cloud/spanner/partition.rb +4 -4
- data/lib/google/cloud/spanner/policy.rb +2 -2
- data/lib/google/cloud/spanner/results.rb +103 -24
- data/lib/google/cloud/spanner/service.rb +369 -350
- data/lib/google/cloud/spanner/session.rb +370 -39
- data/lib/google/cloud/spanner/snapshot.rb +60 -6
- data/lib/google/cloud/spanner/transaction.rb +116 -10
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +20 -107
- data/lib/google/cloud/spanner/admin/database.rb +0 -149
- data/lib/google/cloud/spanner/admin/database/v1.rb +0 -147
- data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -1513
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -111
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +0 -325
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -368
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance.rb +0 -164
- data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
- data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -334
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -975
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
- data/lib/google/cloud/spanner/v1.rb +0 -16
- data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -95
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -570
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
- data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1485
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
- data/lib/google/spanner/admin/database/v1/backup_pb.rb +0 -98
- data/lib/google/spanner/admin/database/v1/common_pb.rb +0 -28
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -141
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -169
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -181
- data/lib/google/spanner/v1/keys_pb.rb +0 -34
- data/lib/google/spanner/v1/mutation_pb.rb +0 -39
- data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
- data/lib/google/spanner/v1/result_set_pb.rb +0 -48
- data/lib/google/spanner/v1/spanner_pb.rb +0 -179
- data/lib/google/spanner/v1/spanner_services_pb.rb +0 -179
- data/lib/google/spanner/v1/transaction_pb.rb +0 -56
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6bfbaef2aa9726c4f6546f22d9ad3da14cdd74f1d5704f0af88aaa197285af7
|
4
|
+
data.tar.gz: b21b4f7ce50132358a00b6d4f2723e2299b449edf7cdb50652263f3dc1e7a417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b26a10becd37ce0527996754eb16f368635269144f584d5cf1c25f17285d280f847e58ca49ccd942fb7adff59779e2a63f5c90987f548786759a5b65b337e49
|
7
|
+
data.tar.gz: 4e46cc9fddeb100349f410c08ef2b7d21fe0f43f6368e5ee3d2e6231c4da4ed7eb781fafb795408fbfadaca29dbcefc2b55ef290ccd39eab74d953959f59838b
|
data/AUTHENTICATION.md
CHANGED
@@ -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
|
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
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,71 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.4.0 / 2021-02-18
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Point In Time Recovery (PITR) ([#8169](https://www.github.com/googleapis/google-cloud-ruby/issues/8169))
|
8
|
+
* feat(spanner): support pitr-lite
|
9
|
+
* feature(spanner): adds test for throttled
|
10
|
+
* feat(spanner): adds version time to backup
|
11
|
+
* test(spanner): adds unit test for create backup
|
12
|
+
* feat(spanner): exposes version time in backup
|
13
|
+
* chore: fixes rubocop violations
|
14
|
+
* fix: addresses PR comments
|
15
|
+
* test: adds integration tests for pitr backup
|
16
|
+
|
17
|
+
### 2.3.0 / 2021-02-09
|
18
|
+
|
19
|
+
#### Features
|
20
|
+
|
21
|
+
* CommitStats in CommitResponse ([#8058](https://www.github.com/googleapis/google-cloud-ruby/issues/8058))
|
22
|
+
* optionalize `credentials` when using cloud spanner emulator host ([#8416](https://www.github.com/googleapis/google-cloud-ruby/issues/8416))
|
23
|
+
* Optionalize `credentials` when using Cloud Spanner Emulator
|
24
|
+
* Remove unnecessary credentials stub for emulator_host in Google::Cloud::Spanner.new
|
25
|
+
* Add test of explicit project_id in Google::Cloud::Spanner.new
|
26
|
+
* Update document for `emulator_host` without credentials
|
27
|
+
* Tidy code according to rubocop settings
|
28
|
+
|
29
|
+
### 2.2.0 / 2020-09-15
|
30
|
+
|
31
|
+
#### Features
|
32
|
+
|
33
|
+
* quota_project can be set via library configuration
|
34
|
+
* Support numeric type.
|
35
|
+
|
36
|
+
#### Bug Fixes
|
37
|
+
|
38
|
+
* retry or resume eos and rst_stream errors
|
39
|
+
|
40
|
+
### 2.1.0 / 2020-08-05
|
41
|
+
|
42
|
+
#### Features
|
43
|
+
|
44
|
+
* Support custom setting of timeout and retry
|
45
|
+
|
46
|
+
### 2.0.0 / 2020-07-23
|
47
|
+
|
48
|
+
This is a major update that removes the "low-level" client interface code, and
|
49
|
+
instead adds `google-cloud-spanner-v1`, `google-cloud-spanner-admin-database-v1`,
|
50
|
+
and `google-cloud-spanner-admin-instance-v1` as dependencies.
|
51
|
+
The new dependencies are rewritten low-level clients, produced by a next-
|
52
|
+
generation client code generator, with improved performance and stability.
|
53
|
+
|
54
|
+
This change should have no effect on the high-level interface that most users
|
55
|
+
will use. The one exception is that the (mostly undocumented) `client_config`
|
56
|
+
argument, for adjusting low-level parameters such as RPC retry settings on
|
57
|
+
client objects, has been removed. If you need to adjust these parameters, use
|
58
|
+
the configuration interface in low-level clients.
|
59
|
+
|
60
|
+
Substantial changes have been made in the low-level interfaces, however. If you
|
61
|
+
are using the low-level classes under the old `Google::Spanner::V1` module,
|
62
|
+
please review the docs for the new `google-cloud-spanner-v1` gem. In particular:
|
63
|
+
|
64
|
+
* Some classes have been renamed, notably the client class itself.
|
65
|
+
* The client constructor takes a configuration block instead of configuration
|
66
|
+
keyword arguments.
|
67
|
+
* All RPC method arguments are now keyword arguments.
|
68
|
+
|
3
69
|
### 1.16.2 / 2020-05-28
|
4
70
|
|
5
71
|
#### Documentation
|
data/CONTRIBUTING.md
CHANGED
data/lib/google-cloud-spanner.rb
CHANGED
@@ -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,
|
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,
|
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,
|
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! :
|
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
|
data/lib/google/cloud/spanner.rb
CHANGED
@@ -49,6 +49,8 @@ module Google
|
|
49
49
|
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
50
50
|
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
51
51
|
# Google::Auth::Credentials object. (See {Spanner::Credentials})
|
52
|
+
# If `emulator_host` is present, this becomes optional and the value is
|
53
|
+
# internally overriden with `:this_channel_is_insecure`.
|
52
54
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
53
55
|
# the set of resources and operations that the connection can access.
|
54
56
|
# See [Using OAuth 2.0 to Access Google
|
@@ -59,10 +61,8 @@ module Google
|
|
59
61
|
# * `https://www.googleapis.com/auth/spanner`
|
60
62
|
# * `https://www.googleapis.com/auth/spanner.data`
|
61
63
|
# @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
64
|
# @param [String] endpoint Override of the endpoint host name. Optional.
|
65
|
-
# If the param is nil, uses the default endpoint.
|
65
|
+
# If the param is nil, uses `emulator_host` or the default endpoint.
|
66
66
|
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
67
67
|
# @param [String] keyfile Alias for the `credentials` argument.
|
68
68
|
# Deprecated.
|
@@ -91,22 +91,21 @@ module Google
|
|
91
91
|
# spanner = Google::Cloud::Spanner.new
|
92
92
|
#
|
93
93
|
def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
|
94
|
-
|
94
|
+
endpoint: nil, project: nil, keyfile: nil,
|
95
95
|
emulator_host: nil, lib_name: nil, lib_version: nil
|
96
|
-
project_id ||=
|
96
|
+
project_id ||= project || default_project_id
|
97
97
|
scope ||= configure.scope
|
98
98
|
timeout ||= configure.timeout
|
99
|
-
client_config ||= configure.client_config
|
100
|
-
endpoint ||= configure.endpoint
|
101
|
-
credentials ||= (keyfile || default_credentials(scope: scope))
|
102
99
|
emulator_host ||= configure.emulator_host
|
100
|
+
endpoint ||= emulator_host || configure.endpoint
|
101
|
+
credentials ||= keyfile
|
103
102
|
lib_name ||= configure.lib_name
|
104
103
|
lib_version ||= configure.lib_version
|
105
104
|
|
106
105
|
if emulator_host
|
107
106
|
credentials = :this_channel_is_insecure
|
108
|
-
endpoint = emulator_host
|
109
107
|
else
|
108
|
+
credentials ||= default_credentials scope: scope
|
110
109
|
unless credentials.is_a? Google::Auth::Credentials
|
111
110
|
credentials = Spanner::Credentials.new credentials, scope: scope
|
112
111
|
end
|
@@ -122,8 +121,8 @@ module Google
|
|
122
121
|
Spanner::Project.new(
|
123
122
|
Spanner::Service.new(
|
124
123
|
project_id, credentials,
|
125
|
-
host: endpoint, timeout: timeout,
|
126
|
-
|
124
|
+
host: endpoint, timeout: timeout, lib_name: lib_name,
|
125
|
+
lib_version: lib_version
|
127
126
|
),
|
128
127
|
query_options: configure.query_options
|
129
128
|
)
|
@@ -145,8 +144,6 @@ module Google
|
|
145
144
|
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
146
145
|
# the set of resources and operations that the connection can access.
|
147
146
|
# * `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
147
|
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
|
151
148
|
# to use the default endpoint.
|
152
149
|
# * `emulator_host` - (String) Host name of the emulator. Defaults to
|
@@ -184,4 +181,7 @@ module Google
|
|
184
181
|
end
|
185
182
|
end
|
186
183
|
end
|
184
|
+
|
185
|
+
# @private
|
186
|
+
Spanner = Cloud::Spanner unless const_defined? :Spanner
|
187
187
|
end
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "
|
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 =
|
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 "
|
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 =
|
26
|
+
Credentials = V1::InstanceAdmin::Credentials
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -160,6 +160,14 @@ module Google
|
|
160
160
|
raise error
|
161
161
|
end
|
162
162
|
|
163
|
+
##
|
164
|
+
# The timestamp when a consistent copy of the database for the backup was
|
165
|
+
# taken. The version time has microseconds granularity.
|
166
|
+
# @return [Time]
|
167
|
+
def version_time
|
168
|
+
Convert.timestamp_to_time @grpc.version_time
|
169
|
+
end
|
170
|
+
|
163
171
|
##
|
164
172
|
# Create time is approximately the time when the backup request was
|
165
173
|
# received.
|
@@ -296,7 +304,7 @@ module Google
|
|
296
304
|
##
|
297
305
|
# @private
|
298
306
|
# Creates a new Backup instance from a
|
299
|
-
#
|
307
|
+
# `Google::Cloud::Spanner::Admin::Database::V1::Backup`.
|
300
308
|
def self.from_grpc grpc, service
|
301
309
|
new grpc, service
|
302
310
|
end
|
@@ -53,7 +53,7 @@ module Google
|
|
53
53
|
#
|
54
54
|
class Job
|
55
55
|
##
|
56
|
-
# @private The
|
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
|
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
|
-
#
|
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
|
-
|
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
|
-
#
|
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
|
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
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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 =
|
667
|
-
|
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
|
-
|
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
|