google-cloud-spanner 1.10.1 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +41 -21
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +41 -21
- data/lib/google/cloud/spanner/client.rb +29 -0
- data/lib/google/cloud/spanner/pool.rb +12 -12
- data/lib/google/cloud/spanner/service.rb +12 -0
- data/lib/google/cloud/spanner/v1/spanner_client.rb +11 -8
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +6 -6
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e23be8bb214edae828f3b6722eb184b92410f81d450f80e20a7da77ec4500c65
|
4
|
+
data.tar.gz: b058d7928f61b7a56bb07eb7d0363ee35d01c328f6724fdb4600db889bc12d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32be60bc2a9dd90922069e6026469386a067e840c655964d1b922c9c6fca619b01aa71fd4fd0b280fc923bcb640730035d1bb1e33755a82f7806e56c8fbc6aed
|
7
|
+
data.tar.gz: 29747283465fa90babaa936b5579499167c3c27b4f5d2de9da2e83e4f6eaf0699d2b807c856172838a7abd563fd7122b73c1f0fb7b9a35331b3054d8dc420ea4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.11.0 / 2019-10-07
|
4
|
+
|
5
|
+
#### BREAKING CHANGES (LOWER-LEVEL API ONLY)
|
6
|
+
|
7
|
+
* Make the session_count argument required in the lower-level API batch_create_sessions call
|
8
|
+
|
9
|
+
#### Performance Improvements
|
10
|
+
|
11
|
+
* Update Pool#init to use BatchCreateSessions
|
12
|
+
* Update pool checkout to pop sessions for LIFO
|
13
|
+
|
14
|
+
#### Documentation
|
15
|
+
|
16
|
+
* Update Policy example code
|
17
|
+
* Update IAM Policy class description and sample code
|
18
|
+
|
3
19
|
### 1.10.1 / 2019-09-04
|
4
20
|
|
5
21
|
#### Documentation
|
@@ -20,27 +20,36 @@ module Google
|
|
20
20
|
# specify access control policies for Cloud Platform resources.
|
21
21
|
#
|
22
22
|
#
|
23
|
-
# A `Policy`
|
24
|
-
# `members` to a `role
|
25
|
-
# Google
|
26
|
-
# defined by IAM.
|
23
|
+
# A `Policy` is a collection of `bindings`. A `binding` binds one or more
|
24
|
+
# `members` to a single `role`. Members can be user accounts, service accounts,
|
25
|
+
# Google groups, and domains (such as G Suite). A `role` is a named list of
|
26
|
+
# permissions (defined by IAM or configured by users). A `binding` can
|
27
|
+
# optionally specify a `condition`, which is a logic expression that further
|
28
|
+
# constrains the role binding based on attributes about the request and/or
|
29
|
+
# target resource.
|
27
30
|
#
|
28
31
|
# **JSON Example**
|
29
32
|
#
|
30
33
|
# {
|
31
34
|
# "bindings": [
|
32
35
|
# {
|
33
|
-
# "role": "roles/
|
36
|
+
# "role": "roles/resourcemanager.organizationAdmin",
|
34
37
|
# "members": [
|
35
38
|
# "user:mike@example.com",
|
36
39
|
# "group:admins@example.com",
|
37
40
|
# "domain:google.com",
|
38
|
-
# "serviceAccount:my-
|
41
|
+
# "serviceAccount:my-project-id@appspot.gserviceaccount.com"
|
39
42
|
# ]
|
40
43
|
# },
|
41
44
|
# {
|
42
|
-
# "role": "roles/
|
43
|
-
# "members": ["user:
|
45
|
+
# "role": "roles/resourcemanager.organizationViewer",
|
46
|
+
# "members": ["user:eve@example.com"],
|
47
|
+
# "condition": {
|
48
|
+
# "title": "expirable access",
|
49
|
+
# "description": "Does not grant access after Sep 2020",
|
50
|
+
# "expression": "request.time <
|
51
|
+
# timestamp('2020-10-01T00:00:00.000Z')",
|
52
|
+
# }
|
44
53
|
# }
|
45
54
|
# ]
|
46
55
|
# }
|
@@ -52,15 +61,18 @@ module Google
|
|
52
61
|
# * user:mike@example.com
|
53
62
|
# * group:admins@example.com
|
54
63
|
# * domain:google.com
|
55
|
-
# * serviceAccount:my-
|
56
|
-
# role: roles/
|
64
|
+
# * serviceAccount:my-project-id@appspot.gserviceaccount.com
|
65
|
+
# role: roles/resourcemanager.organizationAdmin
|
57
66
|
# * members:
|
58
|
-
# * user:
|
59
|
-
# role: roles/
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
67
|
+
# * user:eve@example.com
|
68
|
+
# role: roles/resourcemanager.organizationViewer
|
69
|
+
# condition:
|
70
|
+
# title: expirable access
|
71
|
+
# description: Does not grant access after Sep 2020
|
72
|
+
# expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
|
73
|
+
#
|
74
|
+
# For a description of IAM and its features, see the
|
75
|
+
# [IAM developer's guide](https://cloud.google.com/iam/docs).
|
64
76
|
# @!attribute [rw] version
|
65
77
|
# @return [Integer]
|
66
78
|
# Specifies the format of the policy.
|
@@ -68,12 +80,18 @@ module Google
|
|
68
80
|
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
|
69
81
|
# rejected.
|
70
82
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
83
|
+
# Operations affecting conditional bindings must specify version 3. This can
|
84
|
+
# be either setting a conditional policy, modifying a conditional binding,
|
85
|
+
# or removing a conditional binding from the stored conditional policy.
|
86
|
+
# Operations on non-conditional policies may specify any valid value or
|
87
|
+
# leave the field unset.
|
88
|
+
#
|
89
|
+
# If no etag is provided in the call to `setIamPolicy`, any version
|
90
|
+
# compliance checks on the incoming and/or stored policy is skipped.
|
74
91
|
# @!attribute [rw] bindings
|
75
92
|
# @return [Array<Google::Iam::V1::Binding>]
|
76
|
-
# Associates a list of `members` to a `role`.
|
93
|
+
# Associates a list of `members` to a `role`. Optionally may specify a
|
94
|
+
# `condition` that determines when binding is in effect.
|
77
95
|
# `bindings` with no members will result in an error.
|
78
96
|
# @!attribute [rw] etag
|
79
97
|
# @return [String]
|
@@ -86,7 +104,9 @@ module Google
|
|
86
104
|
# ensure that their change will be applied to the same version of the policy.
|
87
105
|
#
|
88
106
|
# If no `etag` is provided in the call to `setIamPolicy`, then the existing
|
89
|
-
# policy is overwritten.
|
107
|
+
# policy is overwritten. Due to blind-set semantics of an etag-less policy,
|
108
|
+
# 'setIamPolicy' will not fail even if either of incoming or stored policy
|
109
|
+
# does not meet the version requirements.
|
90
110
|
class Policy; end
|
91
111
|
|
92
112
|
# Associates `members` with a `role`.
|
@@ -20,27 +20,36 @@ module Google
|
|
20
20
|
# specify access control policies for Cloud Platform resources.
|
21
21
|
#
|
22
22
|
#
|
23
|
-
# A `Policy`
|
24
|
-
# `members` to a `role
|
25
|
-
# Google
|
26
|
-
# defined by IAM.
|
23
|
+
# A `Policy` is a collection of `bindings`. A `binding` binds one or more
|
24
|
+
# `members` to a single `role`. Members can be user accounts, service accounts,
|
25
|
+
# Google groups, and domains (such as G Suite). A `role` is a named list of
|
26
|
+
# permissions (defined by IAM or configured by users). A `binding` can
|
27
|
+
# optionally specify a `condition`, which is a logic expression that further
|
28
|
+
# constrains the role binding based on attributes about the request and/or
|
29
|
+
# target resource.
|
27
30
|
#
|
28
31
|
# **JSON Example**
|
29
32
|
#
|
30
33
|
# {
|
31
34
|
# "bindings": [
|
32
35
|
# {
|
33
|
-
# "role": "roles/
|
36
|
+
# "role": "roles/resourcemanager.organizationAdmin",
|
34
37
|
# "members": [
|
35
38
|
# "user:mike@example.com",
|
36
39
|
# "group:admins@example.com",
|
37
40
|
# "domain:google.com",
|
38
|
-
# "serviceAccount:my-
|
41
|
+
# "serviceAccount:my-project-id@appspot.gserviceaccount.com"
|
39
42
|
# ]
|
40
43
|
# },
|
41
44
|
# {
|
42
|
-
# "role": "roles/
|
43
|
-
# "members": ["user:
|
45
|
+
# "role": "roles/resourcemanager.organizationViewer",
|
46
|
+
# "members": ["user:eve@example.com"],
|
47
|
+
# "condition": {
|
48
|
+
# "title": "expirable access",
|
49
|
+
# "description": "Does not grant access after Sep 2020",
|
50
|
+
# "expression": "request.time <
|
51
|
+
# timestamp('2020-10-01T00:00:00.000Z')",
|
52
|
+
# }
|
44
53
|
# }
|
45
54
|
# ]
|
46
55
|
# }
|
@@ -52,15 +61,18 @@ module Google
|
|
52
61
|
# * user:mike@example.com
|
53
62
|
# * group:admins@example.com
|
54
63
|
# * domain:google.com
|
55
|
-
# * serviceAccount:my-
|
56
|
-
# role: roles/
|
64
|
+
# * serviceAccount:my-project-id@appspot.gserviceaccount.com
|
65
|
+
# role: roles/resourcemanager.organizationAdmin
|
57
66
|
# * members:
|
58
|
-
# * user:
|
59
|
-
# role: roles/
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
67
|
+
# * user:eve@example.com
|
68
|
+
# role: roles/resourcemanager.organizationViewer
|
69
|
+
# condition:
|
70
|
+
# title: expirable access
|
71
|
+
# description: Does not grant access after Sep 2020
|
72
|
+
# expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
|
73
|
+
#
|
74
|
+
# For a description of IAM and its features, see the
|
75
|
+
# [IAM developer's guide](https://cloud.google.com/iam/docs).
|
64
76
|
# @!attribute [rw] version
|
65
77
|
# @return [Integer]
|
66
78
|
# Specifies the format of the policy.
|
@@ -68,12 +80,18 @@ module Google
|
|
68
80
|
# Valid values are 0, 1, and 3. Requests specifying an invalid value will be
|
69
81
|
# rejected.
|
70
82
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
83
|
+
# Operations affecting conditional bindings must specify version 3. This can
|
84
|
+
# be either setting a conditional policy, modifying a conditional binding,
|
85
|
+
# or removing a conditional binding from the stored conditional policy.
|
86
|
+
# Operations on non-conditional policies may specify any valid value or
|
87
|
+
# leave the field unset.
|
88
|
+
#
|
89
|
+
# If no etag is provided in the call to `setIamPolicy`, any version
|
90
|
+
# compliance checks on the incoming and/or stored policy is skipped.
|
74
91
|
# @!attribute [rw] bindings
|
75
92
|
# @return [Array<Google::Iam::V1::Binding>]
|
76
|
-
# Associates a list of `members` to a `role`.
|
93
|
+
# Associates a list of `members` to a `role`. Optionally may specify a
|
94
|
+
# `condition` that determines when binding is in effect.
|
77
95
|
# `bindings` with no members will result in an error.
|
78
96
|
# @!attribute [rw] etag
|
79
97
|
# @return [String]
|
@@ -86,7 +104,9 @@ module Google
|
|
86
104
|
# ensure that their change will be applied to the same version of the policy.
|
87
105
|
#
|
88
106
|
# If no `etag` is provided in the call to `setIamPolicy`, then the existing
|
89
|
-
# policy is overwritten.
|
107
|
+
# policy is overwritten. Due to blind-set semantics of an etag-less policy,
|
108
|
+
# 'setIamPolicy' will not fail even if either of incoming or stored policy
|
109
|
+
# does not meet the version requirements.
|
90
110
|
class Policy; end
|
91
111
|
|
92
112
|
# Associates `members` with a `role`.
|
@@ -1287,6 +1287,35 @@ module Google
|
|
1287
1287
|
Session.from_grpc grpc, @project.service
|
1288
1288
|
end
|
1289
1289
|
|
1290
|
+
##
|
1291
|
+
# @private
|
1292
|
+
# Creates a batch of new session objects of size `total`.
|
1293
|
+
# Makes multiple RPCs if necessary. Returns empty array if total is 0.
|
1294
|
+
def batch_create_new_sessions total
|
1295
|
+
sessions = []
|
1296
|
+
remaining = total
|
1297
|
+
while remaining > 0
|
1298
|
+
sessions += batch_create_sessions remaining
|
1299
|
+
remaining = total - sessions.count
|
1300
|
+
end
|
1301
|
+
sessions
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
##
|
1305
|
+
# @private
|
1306
|
+
# The response may have fewer sessions than requested in the RPC.
|
1307
|
+
#
|
1308
|
+
def batch_create_sessions session_count
|
1309
|
+
ensure_service!
|
1310
|
+
resp = @project.service.batch_create_sessions \
|
1311
|
+
Admin::Database::V1::DatabaseAdminClient.database_path(
|
1312
|
+
project_id, instance_id, database_id
|
1313
|
+
),
|
1314
|
+
session_count,
|
1315
|
+
labels: @session_labels
|
1316
|
+
resp.session.map { |grpc| Session.from_grpc grpc, @project.service }
|
1317
|
+
end
|
1318
|
+
|
1290
1319
|
# @private
|
1291
1320
|
def to_s
|
1292
1321
|
"(project_id: #{project_id}, instance_id: #{instance_id}, " \
|
@@ -65,9 +65,11 @@ module Google
|
|
65
65
|
loop do
|
66
66
|
raise ClientClosedError if @closed
|
67
67
|
|
68
|
-
|
68
|
+
# Use LIFO to ensure sessions are used from backend caches, which
|
69
|
+
# will reduce the read / write latencies on user requests.
|
70
|
+
read_session = session_queue.pop # LIFO
|
69
71
|
return read_session if read_session
|
70
|
-
write_transaction = transaction_queue.
|
72
|
+
write_transaction = transaction_queue.pop # LIFO
|
71
73
|
return write_transaction.session if write_transaction
|
72
74
|
|
73
75
|
if can_allocate_more_sessions?
|
@@ -117,9 +119,9 @@ module Google
|
|
117
119
|
loop do
|
118
120
|
raise ClientClosedError if @closed
|
119
121
|
|
120
|
-
write_transaction = transaction_queue.
|
122
|
+
write_transaction = transaction_queue.pop # LIFO
|
121
123
|
return write_transaction if write_transaction
|
122
|
-
read_session = session_queue.
|
124
|
+
read_session = session_queue.pop
|
123
125
|
if read_session
|
124
126
|
action = read_session
|
125
127
|
break
|
@@ -204,21 +206,19 @@ module Google
|
|
204
206
|
max_threads: @threads
|
205
207
|
# init the queues
|
206
208
|
@new_sessions_in_process = 0
|
207
|
-
@all_sessions = []
|
208
|
-
@session_queue = []
|
209
209
|
@transaction_queue = []
|
210
210
|
# init the keepalive task
|
211
211
|
create_keepalive_task!
|
212
212
|
# init session queue
|
213
|
+
@all_sessions = @client.batch_create_new_sessions @min
|
214
|
+
sessions = @all_sessions.dup
|
213
215
|
num_transactions = (@min * @write_ratio).round
|
214
|
-
|
215
|
-
num_sessions.times.each do
|
216
|
-
future { checkin_session new_session! }
|
217
|
-
end
|
216
|
+
pending_transactions = sessions.shift num_transactions
|
218
217
|
# init transaction queue
|
219
|
-
|
220
|
-
future { checkin_transaction
|
218
|
+
pending_transactions.each do |transaction|
|
219
|
+
future { checkin_transaction transaction.create_transaction }
|
221
220
|
end
|
221
|
+
@session_queue = sessions
|
222
222
|
end
|
223
223
|
|
224
224
|
def shutdown
|
@@ -259,6 +259,18 @@ module Google
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
def batch_create_sessions database_name, session_count, labels: nil
|
263
|
+
opts = default_options_from_session database_name
|
264
|
+
session = Google::Spanner::V1::Session.new labels: labels if labels
|
265
|
+
execute do
|
266
|
+
# The response may have fewer sessions than requested in the RPC.
|
267
|
+
service.batch_create_sessions database_name,
|
268
|
+
session_count,
|
269
|
+
session_template: session,
|
270
|
+
options: opts
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
262
274
|
def delete_session session_name
|
263
275
|
opts = default_options_from_session session_name
|
264
276
|
execute do
|
@@ -406,10 +406,6 @@ module Google
|
|
406
406
|
#
|
407
407
|
# @param database [String]
|
408
408
|
# Required. The database in which the new sessions are created.
|
409
|
-
# @param session_template [Google::Spanner::V1::Session | Hash]
|
410
|
-
# Parameters to be applied to each created session.
|
411
|
-
# A hash of the same form as `Google::Spanner::V1::Session`
|
412
|
-
# can also be provided.
|
413
409
|
# @param session_count [Integer]
|
414
410
|
# Required. The number of sessions to be created in this batch call.
|
415
411
|
# The API may return fewer than the requested number of sessions. If a
|
@@ -417,6 +413,10 @@ module Google
|
|
417
413
|
# calls to BatchCreateSessions (adjusting
|
418
414
|
# {Google::Spanner::V1::BatchCreateSessionsRequest#session_count session_count}
|
419
415
|
# as necessary).
|
416
|
+
# @param session_template [Google::Spanner::V1::Session | Hash]
|
417
|
+
# Parameters to be applied to each created session.
|
418
|
+
# A hash of the same form as `Google::Spanner::V1::Session`
|
419
|
+
# can also be provided.
|
420
420
|
# @param options [Google::Gax::CallOptions]
|
421
421
|
# Overrides the default settings for this call, e.g, timeout,
|
422
422
|
# retries, etc.
|
@@ -430,18 +430,21 @@ module Google
|
|
430
430
|
#
|
431
431
|
# spanner_client = Google::Cloud::Spanner::V1::SpannerClient.new
|
432
432
|
# formatted_database = Google::Cloud::Spanner::V1::SpannerClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
433
|
-
#
|
433
|
+
#
|
434
|
+
# # TODO: Initialize `session_count`:
|
435
|
+
# session_count = 0
|
436
|
+
# response = spanner_client.batch_create_sessions(formatted_database, session_count)
|
434
437
|
|
435
438
|
def batch_create_sessions \
|
436
439
|
database,
|
440
|
+
session_count,
|
437
441
|
session_template: nil,
|
438
|
-
session_count: nil,
|
439
442
|
options: nil,
|
440
443
|
&block
|
441
444
|
req = {
|
442
445
|
database: database,
|
443
|
-
|
444
|
-
|
446
|
+
session_count: session_count,
|
447
|
+
session_template: session_template
|
445
448
|
}.delete_if { |_, v| v.nil? }
|
446
449
|
req = Google::Gax::to_proto(req, Google::Spanner::V1::BatchCreateSessionsRequest)
|
447
450
|
@batch_create_sessions.call(req, options, &block)
|
@@ -15,19 +15,19 @@
|
|
15
15
|
"initial_retry_delay_millis": 250,
|
16
16
|
"retry_delay_multiplier": 1.3,
|
17
17
|
"max_retry_delay_millis": 32000,
|
18
|
-
"initial_rpc_timeout_millis":
|
18
|
+
"initial_rpc_timeout_millis": 360000,
|
19
19
|
"rpc_timeout_multiplier": 1.0,
|
20
|
-
"max_rpc_timeout_millis":
|
21
|
-
"total_timeout_millis":
|
20
|
+
"max_rpc_timeout_millis": 360000,
|
21
|
+
"total_timeout_millis": 3600000
|
22
22
|
},
|
23
23
|
"streaming": {
|
24
24
|
"initial_retry_delay_millis": 250,
|
25
25
|
"retry_delay_multiplier": 1.3,
|
26
26
|
"max_retry_delay_millis": 32000,
|
27
|
-
"initial_rpc_timeout_millis":
|
27
|
+
"initial_rpc_timeout_millis": 360000,
|
28
28
|
"rpc_timeout_multiplier": 1.0,
|
29
|
-
"max_rpc_timeout_millis":
|
30
|
-
"total_timeout_millis":
|
29
|
+
"max_rpc_timeout_millis": 360000,
|
30
|
+
"total_timeout_millis": 3600000
|
31
31
|
},
|
32
32
|
"long_running": {
|
33
33
|
"initial_retry_delay_millis": 250,
|
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: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|