grpc 1.0.1.pre1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +3 -0
- data/src/core/ext/client_config/subchannel.c +27 -27
- data/src/core/lib/channel/channel_args.c +18 -0
- data/src/core/lib/channel/channel_args.h +8 -0
- data/src/core/lib/surface/version.c +1 -1
- data/src/ruby/ext/grpc/rb_call_credentials.c +5 -8
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +51 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3448def060d575a19002dd3fb8ba6a7705985d68
|
4
|
+
data.tar.gz: a0b1f3e1b81fa26895f977bc0f5c64bd3c346c82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb7112e9dbb7cac530e08f507ba59536a864ff911cb76722e74c0a12fdfd79f0c539c5d7b5de2680d96a85fe757ad18ce3804eccbdb65da1a29f3f065bd2aa9
|
7
|
+
data.tar.gz: 3e720ec2e8a3f5326b23074d01703c138e045d02103f148c13a071e7d276be1443b7e5263a7cdf8ccf01e605ce48e466e549a2de3a771a213dcf5e72cf83ad1e
|
data/Makefile
CHANGED
@@ -153,6 +153,9 @@ typedef struct {
|
|
153
153
|
#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent"
|
154
154
|
/** The maximum time between subsequent connection attempts, in ms */
|
155
155
|
#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms"
|
156
|
+
/** The time between the first and second connection attempts, in ms */
|
157
|
+
#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \
|
158
|
+
"grpc.initial_reconnect_backoff_ms"
|
156
159
|
/* The caller of the secure_channel_create functions may override the target
|
157
160
|
name used for SSL host name checking using this channel argument which is of
|
158
161
|
type \a GRPC_ARG_STRING. This *should* be used for testing only.
|
@@ -33,6 +33,7 @@
|
|
33
33
|
|
34
34
|
#include "src/core/ext/client_config/subchannel.h"
|
35
35
|
|
36
|
+
#include <limits.h>
|
36
37
|
#include <string.h>
|
37
38
|
|
38
39
|
#include <grpc/support/alloc.h>
|
@@ -331,41 +332,40 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
|
|
331
332
|
grpc_closure_init(&c->connected, subchannel_connected, c);
|
332
333
|
grpc_connectivity_state_init(&c->state_tracker, GRPC_CHANNEL_IDLE,
|
333
334
|
"subchannel");
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
|
335
|
+
int initial_backoff_ms =
|
336
|
+
GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS * 1000;
|
337
|
+
int max_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000;
|
338
|
+
bool fixed_reconnect_backoff = false;
|
339
339
|
if (c->args) {
|
340
340
|
for (size_t i = 0; i < c->args->num_args; i++) {
|
341
341
|
if (0 == strcmp(c->args->args[i].key,
|
342
342
|
"grpc.testing.fixed_reconnect_backoff")) {
|
343
343
|
GPR_ASSERT(c->args->args[i].type == GRPC_ARG_INTEGER);
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
if (0 ==
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
" : must be non-negative");
|
361
|
-
}
|
362
|
-
} else {
|
363
|
-
gpr_log(GPR_ERROR,
|
364
|
-
GRPC_ARG_MAX_RECONNECT_BACKOFF_MS " : must be an integer");
|
365
|
-
}
|
344
|
+
fixed_reconnect_backoff = true;
|
345
|
+
initial_backoff_ms = max_backoff_ms = grpc_channel_arg_get_integer(
|
346
|
+
&c->args->args[i],
|
347
|
+
(grpc_integer_options){initial_backoff_ms, 100, INT_MAX});
|
348
|
+
} else if (0 == strcmp(c->args->args[i].key,
|
349
|
+
GRPC_ARG_MAX_RECONNECT_BACKOFF_MS)) {
|
350
|
+
fixed_reconnect_backoff = false;
|
351
|
+
max_backoff_ms = grpc_channel_arg_get_integer(
|
352
|
+
&c->args->args[i],
|
353
|
+
(grpc_integer_options){max_backoff_ms, 100, INT_MAX});
|
354
|
+
} else if (0 == strcmp(c->args->args[i].key,
|
355
|
+
GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS)) {
|
356
|
+
fixed_reconnect_backoff = false;
|
357
|
+
initial_backoff_ms = grpc_channel_arg_get_integer(
|
358
|
+
&c->args->args[i],
|
359
|
+
(grpc_integer_options){initial_backoff_ms, 100, INT_MAX});
|
366
360
|
}
|
367
361
|
}
|
368
362
|
}
|
363
|
+
gpr_backoff_init(
|
364
|
+
&c->backoff_state,
|
365
|
+
fixed_reconnect_backoff ? 1.0
|
366
|
+
: GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER,
|
367
|
+
fixed_reconnect_backoff ? 0.0 : GRPC_SUBCHANNEL_RECONNECT_JITTER,
|
368
|
+
initial_backoff_ms, max_backoff_ms);
|
369
369
|
gpr_mu_init(&c->mu);
|
370
370
|
|
371
371
|
return grpc_subchannel_index_register(exec_ctx, key, c);
|
@@ -271,3 +271,21 @@ int grpc_channel_args_compare(const grpc_channel_args *a,
|
|
271
271
|
}
|
272
272
|
return 0;
|
273
273
|
}
|
274
|
+
|
275
|
+
int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) {
|
276
|
+
if (arg->type != GRPC_ARG_INTEGER) {
|
277
|
+
gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key);
|
278
|
+
return options.default_value;
|
279
|
+
}
|
280
|
+
if (arg->value.integer < options.min_value) {
|
281
|
+
gpr_log(GPR_ERROR, "%s ignored: it must be >= %d", arg->key,
|
282
|
+
options.min_value);
|
283
|
+
return options.default_value;
|
284
|
+
}
|
285
|
+
if (arg->value.integer > options.max_value) {
|
286
|
+
gpr_log(GPR_ERROR, "%s ignored: it must be <= %d", arg->key,
|
287
|
+
options.max_value);
|
288
|
+
return options.default_value;
|
289
|
+
}
|
290
|
+
return arg->value.integer;
|
291
|
+
}
|
@@ -87,4 +87,12 @@ uint32_t grpc_channel_args_compression_algorithm_get_states(
|
|
87
87
|
int grpc_channel_args_compare(const grpc_channel_args *a,
|
88
88
|
const grpc_channel_args *b);
|
89
89
|
|
90
|
+
typedef struct grpc_integer_options {
|
91
|
+
int default_value; // Return this if value is outside of expected bounds.
|
92
|
+
int min_value;
|
93
|
+
int max_value;
|
94
|
+
} grpc_integer_options;
|
95
|
+
/** Returns the value of \a arg, subject to the contraints in \a options. */
|
96
|
+
int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options);
|
97
|
+
|
90
98
|
#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */
|
@@ -86,19 +86,16 @@ static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
|
|
86
86
|
rb_funcall(exception_object, rb_intern("backtrace"), 0),
|
87
87
|
rb_intern("join"),
|
88
88
|
1, rb_str_new2("\n\tfrom "));
|
89
|
-
VALUE rb_exception_info = rb_funcall(exception_object, rb_intern("
|
90
|
-
const char *exception_classname = rb_obj_classname(exception_object);
|
89
|
+
VALUE rb_exception_info = rb_funcall(exception_object, rb_intern("inspect"), 0);
|
91
90
|
(void)args;
|
92
|
-
gpr_log(GPR_INFO, "Call credentials callback failed: %s
|
93
|
-
|
91
|
+
gpr_log(GPR_INFO, "Call credentials callback failed: %s\n%s",
|
92
|
+
StringValueCStr(rb_exception_info),
|
94
93
|
StringValueCStr(backtrace));
|
95
94
|
rb_hash_aset(result, rb_str_new2("metadata"), Qnil);
|
96
|
-
/* Currently only gives the exception class name. It should be possible get
|
97
|
-
more details */
|
98
95
|
rb_hash_aset(result, rb_str_new2("status"),
|
99
|
-
INT2NUM(
|
96
|
+
INT2NUM(GRPC_STATUS_UNAUTHENTICATED));
|
100
97
|
rb_hash_aset(result, rb_str_new2("details"),
|
101
|
-
|
98
|
+
rb_exception_info);
|
102
99
|
return result;
|
103
100
|
}
|
104
101
|
|
@@ -168,23 +168,61 @@ describe 'ClientStub' do
|
|
168
168
|
expect(&blk).to raise_error(GRPC::BadStatus)
|
169
169
|
th.join
|
170
170
|
end
|
171
|
+
|
172
|
+
it 'should receive UNAUTHENTICATED if call credentials plugin fails' do
|
173
|
+
server_port = create_secure_test_server
|
174
|
+
th = run_request_response(@sent_msg, @resp, @pass)
|
175
|
+
|
176
|
+
certs = load_test_certs
|
177
|
+
secure_channel_creds = GRPC::Core::ChannelCredentials.new(
|
178
|
+
certs[0], nil, nil)
|
179
|
+
secure_stub_opts = {
|
180
|
+
channel_args: {
|
181
|
+
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr'
|
182
|
+
}
|
183
|
+
}
|
184
|
+
stub = GRPC::ClientStub.new("localhost:#{server_port}",
|
185
|
+
secure_channel_creds, **secure_stub_opts)
|
186
|
+
|
187
|
+
error_message = 'Failing call credentials callback'
|
188
|
+
failing_auth = proc do
|
189
|
+
fail error_message
|
190
|
+
end
|
191
|
+
creds = GRPC::Core::CallCredentials.new(failing_auth)
|
192
|
+
|
193
|
+
error_occured = false
|
194
|
+
begin
|
195
|
+
get_response(stub, credentials: creds)
|
196
|
+
rescue GRPC::BadStatus => e
|
197
|
+
error_occured = true
|
198
|
+
expect(e.code).to eq(GRPC::Core::StatusCodes::UNAUTHENTICATED)
|
199
|
+
expect(e.details.include?(error_message)).to be true
|
200
|
+
end
|
201
|
+
expect(error_occured).to eq(true)
|
202
|
+
|
203
|
+
# Kill the server thread so tests can complete
|
204
|
+
th.kill
|
205
|
+
end
|
171
206
|
end
|
172
207
|
|
173
208
|
describe 'without a call operation' do
|
174
|
-
def get_response(stub)
|
209
|
+
def get_response(stub, credentials: nil)
|
210
|
+
puts credentials.inspect
|
175
211
|
stub.request_response(@method, @sent_msg, noop, noop,
|
176
|
-
metadata: { k1: 'v1', k2: 'v2' }
|
212
|
+
metadata: { k1: 'v1', k2: 'v2' },
|
213
|
+
credentials: credentials)
|
177
214
|
end
|
178
215
|
|
179
216
|
it_behaves_like 'request response'
|
180
217
|
end
|
181
218
|
|
182
219
|
describe 'via a call operation' do
|
183
|
-
def get_response(stub)
|
220
|
+
def get_response(stub, credentials: nil)
|
184
221
|
op = stub.request_response(@method, @sent_msg, noop, noop,
|
185
222
|
return_op: true,
|
186
223
|
metadata: { k1: 'v1', k2: 'v2' },
|
187
|
-
deadline: from_relative_time(2)
|
224
|
+
deadline: from_relative_time(2),
|
225
|
+
credentials: credentials)
|
188
226
|
expect(op).to be_a(GRPC::ActiveCall::Operation)
|
189
227
|
op.execute
|
190
228
|
end
|
@@ -441,6 +479,15 @@ describe 'ClientStub' do
|
|
441
479
|
end
|
442
480
|
end
|
443
481
|
|
482
|
+
def create_secure_test_server
|
483
|
+
certs = load_test_certs
|
484
|
+
secure_credentials = GRPC::Core::ServerCredentials.new(
|
485
|
+
nil, [{ private_key: certs[1], cert_chain: certs[2] }], false)
|
486
|
+
|
487
|
+
@server = GRPC::Core::Server.new(nil)
|
488
|
+
@server.add_http2_port('0.0.0.0:0', secure_credentials)
|
489
|
+
end
|
490
|
+
|
444
491
|
def create_test_server
|
445
492
|
@server = GRPC::Core::Server.new(nil)
|
446
493
|
@server.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -1177,9 +1177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1177
1177
|
version: 2.0.0
|
1178
1178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1179
1179
|
requirements:
|
1180
|
-
- - "
|
1180
|
+
- - ">="
|
1181
1181
|
- !ruby/object:Gem::Version
|
1182
|
-
version:
|
1182
|
+
version: '0'
|
1183
1183
|
requirements: []
|
1184
1184
|
rubyforge_project:
|
1185
1185
|
rubygems_version: 2.5.1
|