google-gax 1.6.3 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google/gax/grpc.rb +5 -2
- data/lib/google/gax/version.rb +1 -1
- data/lib/google/longrunning/operations_client.rb +10 -3
- data/spec/google/gax/grpc_spec.rb +13 -4
- data/spec/google/longrunning_spec.rb +73 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7271bd48161698b84de9f66e337c3742e44b765f75fa1344c2e59b3608359e65
|
4
|
+
data.tar.gz: d2483f6d0f41e82f6655a1d5893712785721b73b7c675772752f457c9de0986e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b92de0ba1398fd9d71a7cdd66aa000975677996fefcfdcf4828d12c6fff7194c0b93da9178eaf26d51d924f77dc3b493ad3bffba5011d1e8ea7bfb670d92311
|
7
|
+
data.tar.gz: cf0103edeab0f7e8244b2e008d72974bb7562236281d6eed0ce2466740f48a56a433d934286d9205d89d84382003ace8f55527250cba09b4868b6b57b80b74e1
|
data/lib/google/gax/grpc.rb
CHANGED
@@ -122,11 +122,13 @@ module Google
|
|
122
122
|
interceptors: [])
|
123
123
|
verify_params(channel, chan_creds, updater_proc)
|
124
124
|
address = "#{service_path}:#{port}"
|
125
|
+
default_channel_args = { 'grpc.service_config_disable_resolution' => 1 }
|
125
126
|
if channel
|
126
127
|
yield(address, nil, channel_override: channel,
|
127
128
|
interceptors: interceptors)
|
128
129
|
elsif chan_creds
|
129
|
-
yield(address, chan_creds, interceptors: interceptors
|
130
|
+
yield(address, chan_creds, interceptors: interceptors,
|
131
|
+
channel_args: default_channel_args)
|
130
132
|
else
|
131
133
|
if updater_proc.nil?
|
132
134
|
auth_creds = Google::Auth.get_application_default(scopes)
|
@@ -134,7 +136,8 @@ module Google
|
|
134
136
|
end
|
135
137
|
call_creds = GRPC::Core::CallCredentials.new(updater_proc)
|
136
138
|
chan_creds = GRPC::Core::ChannelCredentials.new.compose(call_creds)
|
137
|
-
yield(address, chan_creds, interceptors: interceptors
|
139
|
+
yield(address, chan_creds, interceptors: interceptors,
|
140
|
+
channel_args: default_channel_args)
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
data/lib/google/gax/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# Copyright 2017, Google LLC
|
1
|
+
# Copyright 2017, Google LLC
|
2
|
+
# All rights reserved.
|
2
3
|
#
|
3
4
|
# Redistribution and use in source and binary forms, with or without
|
4
5
|
# modification, are permitted provided that the following conditions are
|
@@ -108,6 +109,10 @@ module Google
|
|
108
109
|
# or the specified config is missing data points.
|
109
110
|
# @param timeout [Numeric]
|
110
111
|
# The default timeout, in seconds, for calls made through this client.
|
112
|
+
# @param service_address [String]
|
113
|
+
# The hostname of the backend service. Defaults to {SERVICE_ADDRESS}.
|
114
|
+
# @param service_port [Integer]
|
115
|
+
# The port of the backend service. Defaults to {DEFAULT_SERVICE_PORT}.
|
111
116
|
# @param metadata [Hash]
|
112
117
|
# The request metadata headers.
|
113
118
|
def initialize \
|
@@ -117,6 +122,8 @@ module Google
|
|
117
122
|
timeout: DEFAULT_TIMEOUT,
|
118
123
|
lib_name: nil,
|
119
124
|
lib_version: "",
|
125
|
+
service_address: nil,
|
126
|
+
service_port: nil,
|
120
127
|
metadata: nil
|
121
128
|
# These require statements are intentionally placed here to initialize
|
122
129
|
# the gRPC module only when it's required.
|
@@ -169,8 +176,8 @@ module Google
|
|
169
176
|
end
|
170
177
|
|
171
178
|
# Allow overriding the service path/port in subclasses.
|
172
|
-
service_path = self.class::SERVICE_ADDRESS
|
173
|
-
port = self.class::DEFAULT_SERVICE_PORT
|
179
|
+
service_path = service_address || self.class::SERVICE_ADDRESS
|
180
|
+
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
174
181
|
@operations_stub = Google::Gax::Grpc.create_stub(
|
175
182
|
service_path,
|
176
183
|
port,
|
@@ -35,6 +35,7 @@ describe Google::Gax::Grpc do
|
|
35
35
|
mock = instance_double(GRPC::Core::ChannelCredentials)
|
36
36
|
composed_mock = instance_double(GRPC::Core::ChannelCredentials)
|
37
37
|
default_creds = instance_double(Google::Auth::ServiceAccountCredentials)
|
38
|
+
channel_args = { 'grpc.service_config_disable_resolution' => 1 }
|
38
39
|
updater_proc = proc {}
|
39
40
|
|
40
41
|
allow(Google::Auth)
|
@@ -45,7 +46,10 @@ describe Google::Gax::Grpc do
|
|
45
46
|
|
46
47
|
expect do |blk|
|
47
48
|
Google::Gax::Grpc.create_stub('service', 'port', &blk)
|
48
|
-
end.to yield_with_args(
|
49
|
+
end.to yield_with_args(
|
50
|
+
'service:port', composed_mock,
|
51
|
+
interceptors: [], channel_args: channel_args
|
52
|
+
)
|
49
53
|
end
|
50
54
|
|
51
55
|
it 'yields given channel' do
|
@@ -85,25 +89,28 @@ describe Google::Gax::Grpc do
|
|
85
89
|
end
|
86
90
|
|
87
91
|
it 'yields given channel credentials' do
|
92
|
+
channel_args = { 'grpc.service_config_disable_resolution' => 1 }
|
88
93
|
mock = instance_double(GRPC::Core::ChannelCredentials)
|
89
94
|
expect do |blk|
|
90
95
|
Google::Gax::Grpc.create_stub(
|
91
96
|
'service', 'port', chan_creds: mock, &blk
|
92
97
|
)
|
93
98
|
end.to yield_with_args(
|
94
|
-
'service:port', mock, interceptors: []
|
99
|
+
'service:port', mock, interceptors: [], channel_args: channel_args
|
95
100
|
)
|
96
101
|
end
|
97
102
|
|
98
103
|
it 'yields given channel credentials and interceptors' do
|
99
104
|
mock = instance_double(GRPC::Core::ChannelCredentials)
|
100
105
|
interceptors = instance_double(Array)
|
106
|
+
channel_args = { 'grpc.service_config_disable_resolution' => 1 }
|
101
107
|
expect do |blk|
|
102
108
|
Google::Gax::Grpc.create_stub(
|
103
109
|
'service', 'port', chan_creds: mock, interceptors: interceptors, &blk
|
104
110
|
)
|
105
111
|
end.to yield_with_args(
|
106
|
-
'service:port', mock,
|
112
|
+
'service:port', mock,
|
113
|
+
interceptors: interceptors, channel_args: channel_args
|
107
114
|
)
|
108
115
|
end
|
109
116
|
|
@@ -112,6 +119,7 @@ describe Google::Gax::Grpc do
|
|
112
119
|
composed_chan_creds = instance_double(GRPC::Core::ChannelCredentials)
|
113
120
|
call_creds = instance_double(GRPC::Core::CallCredentials)
|
114
121
|
updater_proc = proc {}
|
122
|
+
channel_args = { 'grpc.service_config_disable_resolution' => 1 }
|
115
123
|
|
116
124
|
allow(GRPC::Core::CallCredentials)
|
117
125
|
.to receive(:new).with(updater_proc).and_return(call_creds)
|
@@ -124,7 +132,8 @@ describe Google::Gax::Grpc do
|
|
124
132
|
'service', 'port', updater_proc: updater_proc, &blk
|
125
133
|
)
|
126
134
|
end.to yield_with_args(
|
127
|
-
'service:port', composed_chan_creds,
|
135
|
+
'service:port', composed_chan_creds,
|
136
|
+
interceptors: [], channel_args: channel_args
|
128
137
|
)
|
129
138
|
end
|
130
139
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright 2019, Google LLC
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are
|
6
|
+
# met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright
|
9
|
+
# notice, this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above
|
11
|
+
# copyright notice, this list of conditions and the following disclaimer
|
12
|
+
# in the documentation and/or other materials provided with the
|
13
|
+
# distribution.
|
14
|
+
# * Neither the name of Google LLC nor the names of its
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
16
|
+
# this software without specific prior written permission.
|
17
|
+
#
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
require 'google/gax'
|
31
|
+
require 'google/longrunning/operations_client'
|
32
|
+
|
33
|
+
class MockCredentials < Google::Auth::Credentials
|
34
|
+
def initialize; end
|
35
|
+
|
36
|
+
def updater_proc
|
37
|
+
proc do
|
38
|
+
raise 'The credentials tried to make an update request. This should' \
|
39
|
+
' not happen since the grpc layer is being mocked.'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe Google::Longrunning::OperationsClient do
|
45
|
+
it 'uses the default address' do
|
46
|
+
client = Google::Longrunning::OperationsClient.new(
|
47
|
+
credentials: MockCredentials.new
|
48
|
+
)
|
49
|
+
host = client.instance_variable_get(:@operations_stub)
|
50
|
+
.instance_variable_get(:@host)
|
51
|
+
expect(host).to eq('longrunning.googleapis.com:443')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'supports subclass overriding of the address' do
|
55
|
+
class CustomClient < Google::Longrunning::OperationsClient
|
56
|
+
SERVICE_ADDRESS = 'my-service.example.com'.freeze
|
57
|
+
DEFAULT_SERVICE_PORT = 8080
|
58
|
+
end
|
59
|
+
client = CustomClient.new(credentials: MockCredentials.new)
|
60
|
+
host = client.instance_variable_get(:@operations_stub)
|
61
|
+
.instance_variable_get(:@host)
|
62
|
+
expect(host).to eq('my-service.example.com:8080')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'supports parameter overriding of the address' do
|
66
|
+
client = CustomClient.new(credentials: MockCredentials.new,
|
67
|
+
service_address: 'foo-service.example.com',
|
68
|
+
service_port: 8081)
|
69
|
+
host = client.instance_variable_get(:@operations_stub)
|
70
|
+
.instance_variable_get(:@host)
|
71
|
+
expect(host).to eq('foo-service.example.com:8081')
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-gax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google API Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: googleauth
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- spec/google/gax/path_template_spec.rb
|
202
202
|
- spec/google/gax/settings_spec.rb
|
203
203
|
- spec/google/gax/util_spec.rb
|
204
|
+
- spec/google/longrunning_spec.rb
|
204
205
|
- spec/spec_helper.rb
|
205
206
|
homepage: https://github.com/googleapis/gax-ruby
|
206
207
|
licenses:
|