grpc 1.2.5-universal-darwin → 1.3.4-universal-darwin

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.

@@ -41,6 +41,8 @@
41
41
  /* Initializes the Channel class. */
42
42
  void Init_grpc_channel();
43
43
 
44
+ void grpc_rb_channel_polling_thread_start();
45
+
44
46
  /* Gets the wrapped channel from the ruby wrapper */
45
47
  grpc_channel* grpc_rb_get_wrapped_channel(VALUE v);
46
48
 
@@ -156,6 +156,9 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv, VALUE self)
156
156
  grpc_ssl_pem_key_cert_pair key_cert_pair;
157
157
  const char *pem_root_certs_cstr = NULL;
158
158
  MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
159
+
160
+ grpc_ruby_once_init();
161
+
159
162
  /* "03" == no mandatory arg, 3 optional */
160
163
  rb_scan_args(argc, argv, "03", &pem_root_certs, &pem_private_key,
161
164
  &pem_cert_chain);
@@ -100,8 +100,11 @@ static rb_data_type_t grpc_rb_compression_options_data_type = {
100
100
  Allocate the wrapped grpc compression options and
101
101
  initialize it here too. */
102
102
  static VALUE grpc_rb_compression_options_alloc(VALUE cls) {
103
- grpc_rb_compression_options *wrapper =
104
- gpr_malloc(sizeof(grpc_rb_compression_options));
103
+ grpc_rb_compression_options *wrapper = NULL;
104
+
105
+ grpc_ruby_once_init();
106
+
107
+ wrapper = gpr_malloc(sizeof(grpc_rb_compression_options));
105
108
  wrapper->wrapped = NULL;
106
109
  wrapper->wrapped = gpr_malloc(sizeof(grpc_compression_options));
107
110
  grpc_compression_options_init(wrapper->wrapped);
@@ -106,17 +106,17 @@ static void *grpc_rb_wait_for_event_no_gil(void *param) {
106
106
  grpc_rb_event *event = NULL;
107
107
  (void)param;
108
108
  gpr_mu_lock(&event_queue.mu);
109
- while ((event = grpc_rb_event_queue_dequeue()) == NULL) {
109
+ while (!event_queue.abort) {
110
+ if ((event = grpc_rb_event_queue_dequeue()) != NULL) {
111
+ gpr_mu_unlock(&event_queue.mu);
112
+ return event;
113
+ }
110
114
  gpr_cv_wait(&event_queue.cv,
111
115
  &event_queue.mu,
112
116
  gpr_inf_future(GPR_CLOCK_REALTIME));
113
- if (event_queue.abort) {
114
- gpr_mu_unlock(&event_queue.mu);
115
- return NULL;
116
- }
117
117
  }
118
118
  gpr_mu_unlock(&event_queue.mu);
119
- return event;
119
+ return NULL;
120
120
  }
121
121
 
122
122
  static void grpc_rb_event_unblocking_func(void *arg) {
@@ -50,6 +50,8 @@
50
50
  #include "rb_server.h"
51
51
  #include "rb_server_credentials.h"
52
52
  #include "rb_compression_options.h"
53
+ #include "rb_event_thread.h"
54
+ #include "rb_channel.h"
53
55
 
54
56
  static VALUE grpc_rb_cTimeVal = Qnil;
55
57
 
@@ -291,17 +293,15 @@ VALUE sym_metadata = Qundef;
291
293
 
292
294
  static gpr_once g_once_init = GPR_ONCE_INIT;
293
295
 
294
- static void grpc_ruby_once_init() {
296
+ static void grpc_ruby_once_init_internal() {
295
297
  grpc_init();
296
298
  atexit(grpc_rb_shutdown);
297
299
  }
298
300
 
299
- void Init_grpc_c() {
300
- if (!grpc_rb_load_core()) {
301
- rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
302
- return;
303
- }
301
+ static VALUE bg_thread_init_rb_mu = Qundef;
302
+ static int bg_thread_init_done = 0;
304
303
 
304
+ void grpc_ruby_once_init() {
305
305
  /* ruby_vm_at_exit doesn't seem to be working. It would crash once every
306
306
  * blue moon, and some users are getting it repeatedly. See the discussions
307
307
  * - https://github.com/grpc/grpc/pull/5337
@@ -312,7 +312,29 @@ void Init_grpc_c() {
312
312
  * then loaded again by another VM within the same process, we need to
313
313
  * schedule our initialization and destruction only once.
314
314
  */
315
- gpr_once_init(&g_once_init, grpc_ruby_once_init);
315
+ gpr_once_init(&g_once_init, grpc_ruby_once_init_internal);
316
+
317
+ // Avoid calling calling into ruby library (when creating threads here)
318
+ // in gpr_once_init. In general, it appears to be unsafe to call
319
+ // into the ruby library while holding a non-ruby mutex, because a gil yield
320
+ // could end up trying to lock onto that same mutex and deadlocking.
321
+ rb_mutex_lock(bg_thread_init_rb_mu);
322
+ if (!bg_thread_init_done) {
323
+ grpc_rb_event_queue_thread_start();
324
+ grpc_rb_channel_polling_thread_start();
325
+ bg_thread_init_done = 1;
326
+ }
327
+ rb_mutex_unlock(bg_thread_init_rb_mu);
328
+ }
329
+
330
+ void Init_grpc_c() {
331
+ if (!grpc_rb_load_core()) {
332
+ rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
333
+ return;
334
+ }
335
+
336
+ bg_thread_init_rb_mu = rb_mutex_new();
337
+ rb_global_variable(&bg_thread_init_rb_mu);
316
338
 
317
339
  grpc_rb_mGRPC = rb_define_module("GRPC");
318
340
  grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
@@ -82,4 +82,6 @@ VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self);
82
82
  /* grpc_rb_time_timeval creates a gpr_timespec from a ruby time object. */
83
83
  gpr_timespec grpc_rb_time_timeval(VALUE time, int interval);
84
84
 
85
+ void grpc_ruby_once_init();
86
+
85
87
  #endif /* GRPC_RB_H_ */
@@ -91,6 +91,9 @@ grpc_init_type grpc_init_import;
91
91
  grpc_shutdown_type grpc_shutdown_import;
92
92
  grpc_version_string_type grpc_version_string_import;
93
93
  grpc_g_stands_for_type grpc_g_stands_for_import;
94
+ grpc_completion_queue_factory_lookup_type grpc_completion_queue_factory_lookup_import;
95
+ grpc_completion_queue_create_for_next_type grpc_completion_queue_create_for_next_import;
96
+ grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
94
97
  grpc_completion_queue_create_type grpc_completion_queue_create_import;
95
98
  grpc_completion_queue_next_type grpc_completion_queue_next_import;
96
99
  grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import;
@@ -100,6 +103,7 @@ grpc_alarm_create_type grpc_alarm_create_import;
100
103
  grpc_alarm_cancel_type grpc_alarm_cancel_import;
101
104
  grpc_alarm_destroy_type grpc_alarm_destroy_import;
102
105
  grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
106
+ grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
103
107
  grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
104
108
  grpc_channel_create_call_type grpc_channel_create_call_import;
105
109
  grpc_channel_ping_type grpc_channel_ping_import;
@@ -296,6 +300,7 @@ gpr_ref_type gpr_ref_import;
296
300
  gpr_ref_non_zero_type gpr_ref_non_zero_import;
297
301
  gpr_refn_type gpr_refn_import;
298
302
  gpr_unref_type gpr_unref_import;
303
+ gpr_ref_is_unique_type gpr_ref_is_unique_import;
299
304
  gpr_stats_init_type gpr_stats_init_import;
300
305
  gpr_stats_inc_type gpr_stats_inc_import;
301
306
  gpr_stats_read_type gpr_stats_read_import;
@@ -384,6 +389,9 @@ void grpc_rb_load_imports(HMODULE library) {
384
389
  grpc_shutdown_import = (grpc_shutdown_type) GetProcAddress(library, "grpc_shutdown");
385
390
  grpc_version_string_import = (grpc_version_string_type) GetProcAddress(library, "grpc_version_string");
386
391
  grpc_g_stands_for_import = (grpc_g_stands_for_type) GetProcAddress(library, "grpc_g_stands_for");
392
+ grpc_completion_queue_factory_lookup_import = (grpc_completion_queue_factory_lookup_type) GetProcAddress(library, "grpc_completion_queue_factory_lookup");
393
+ grpc_completion_queue_create_for_next_import = (grpc_completion_queue_create_for_next_type) GetProcAddress(library, "grpc_completion_queue_create_for_next");
394
+ grpc_completion_queue_create_for_pluck_import = (grpc_completion_queue_create_for_pluck_type) GetProcAddress(library, "grpc_completion_queue_create_for_pluck");
387
395
  grpc_completion_queue_create_import = (grpc_completion_queue_create_type) GetProcAddress(library, "grpc_completion_queue_create");
388
396
  grpc_completion_queue_next_import = (grpc_completion_queue_next_type) GetProcAddress(library, "grpc_completion_queue_next");
389
397
  grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck");
@@ -393,6 +401,7 @@ void grpc_rb_load_imports(HMODULE library) {
393
401
  grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel");
394
402
  grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy");
395
403
  grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state");
404
+ grpc_channel_num_external_connectivity_watchers_import = (grpc_channel_num_external_connectivity_watchers_type) GetProcAddress(library, "grpc_channel_num_external_connectivity_watchers");
396
405
  grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state");
397
406
  grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call");
398
407
  grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping");
@@ -589,6 +598,7 @@ void grpc_rb_load_imports(HMODULE library) {
589
598
  gpr_ref_non_zero_import = (gpr_ref_non_zero_type) GetProcAddress(library, "gpr_ref_non_zero");
590
599
  gpr_refn_import = (gpr_refn_type) GetProcAddress(library, "gpr_refn");
591
600
  gpr_unref_import = (gpr_unref_type) GetProcAddress(library, "gpr_unref");
601
+ gpr_ref_is_unique_import = (gpr_ref_is_unique_type) GetProcAddress(library, "gpr_ref_is_unique");
592
602
  gpr_stats_init_import = (gpr_stats_init_type) GetProcAddress(library, "gpr_stats_init");
593
603
  gpr_stats_inc_import = (gpr_stats_inc_type) GetProcAddress(library, "gpr_stats_inc");
594
604
  gpr_stats_read_import = (gpr_stats_read_type) GetProcAddress(library, "gpr_stats_read");
@@ -224,6 +224,15 @@ extern grpc_version_string_type grpc_version_string_import;
224
224
  typedef const char *(*grpc_g_stands_for_type)(void);
225
225
  extern grpc_g_stands_for_type grpc_g_stands_for_import;
226
226
  #define grpc_g_stands_for grpc_g_stands_for_import
227
+ typedef const grpc_completion_queue_factory *(*grpc_completion_queue_factory_lookup_type)(const grpc_completion_queue_attributes *attributes);
228
+ extern grpc_completion_queue_factory_lookup_type grpc_completion_queue_factory_lookup_import;
229
+ #define grpc_completion_queue_factory_lookup grpc_completion_queue_factory_lookup_import
230
+ typedef grpc_completion_queue *(*grpc_completion_queue_create_for_next_type)(void *reserved);
231
+ extern grpc_completion_queue_create_for_next_type grpc_completion_queue_create_for_next_import;
232
+ #define grpc_completion_queue_create_for_next grpc_completion_queue_create_for_next_import
233
+ typedef grpc_completion_queue *(*grpc_completion_queue_create_for_pluck_type)(void *reserved);
234
+ extern grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
235
+ #define grpc_completion_queue_create_for_pluck grpc_completion_queue_create_for_pluck_import
227
236
  typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved);
228
237
  extern grpc_completion_queue_create_type grpc_completion_queue_create_import;
229
238
  #define grpc_completion_queue_create grpc_completion_queue_create_import
@@ -251,6 +260,9 @@ extern grpc_alarm_destroy_type grpc_alarm_destroy_import;
251
260
  typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect);
252
261
  extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
253
262
  #define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import
263
+ typedef int(*grpc_channel_num_external_connectivity_watchers_type)(grpc_channel *channel);
264
+ extern grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
265
+ #define grpc_channel_num_external_connectivity_watchers grpc_channel_num_external_connectivity_watchers_import
254
266
  typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
255
267
  extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
256
268
  #define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import
@@ -839,6 +851,9 @@ extern gpr_refn_type gpr_refn_import;
839
851
  typedef int(*gpr_unref_type)(gpr_refcount *r);
840
852
  extern gpr_unref_type gpr_unref_import;
841
853
  #define gpr_unref gpr_unref_import
854
+ typedef int(*gpr_ref_is_unique_type)(gpr_refcount *r);
855
+ extern gpr_ref_is_unique_type gpr_ref_is_unique_import;
856
+ #define gpr_ref_is_unique gpr_ref_is_unique_import
842
857
  typedef void(*gpr_stats_init_type)(gpr_stats_counter *c, intptr_t n);
843
858
  extern gpr_stats_init_type gpr_stats_init_import;
844
859
  #define gpr_stats_init gpr_stats_init_import
@@ -131,11 +131,15 @@ static VALUE grpc_rb_server_alloc(VALUE cls) {
131
131
 
132
132
  Initializes server instances. */
133
133
  static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) {
134
- grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
134
+ grpc_completion_queue *cq = NULL;
135
135
  grpc_rb_server *wrapper = NULL;
136
136
  grpc_server *srv = NULL;
137
137
  grpc_channel_args args;
138
138
  MEMZERO(&args, grpc_channel_args, 1);
139
+
140
+ grpc_ruby_once_init();
141
+
142
+ cq = grpc_completion_queue_create(NULL);
139
143
  TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type,
140
144
  wrapper);
141
145
  grpc_rb_hash_convert_to_channel_args(channel_args, &args);
@@ -218,8 +222,6 @@ static VALUE grpc_rb_server_request_call(VALUE self) {
218
222
  return Qnil;
219
223
  }
220
224
 
221
-
222
-
223
225
  /* build the NewServerRpc struct result */
224
226
  deadline = gpr_convert_clock_type(st.details.deadline, GPR_CLOCK_REALTIME);
225
227
  result = rb_struct_new(
@@ -29,5 +29,5 @@
29
29
 
30
30
  # GRPC contains the General RPC module.
31
31
  module GRPC
32
- VERSION = '1.2.5'
32
+ VERSION = '1.3.4'
33
33
  end
@@ -0,0 +1,173 @@
1
+ # Copyright 2015, Google Inc.
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 Inc. 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 'grpc'
31
+ require 'timeout'
32
+
33
+ include Timeout
34
+ include GRPC::Core
35
+
36
+ # A test message
37
+ class EchoMsg
38
+ def self.marshal(_o)
39
+ ''
40
+ end
41
+
42
+ def self.unmarshal(_o)
43
+ EchoMsg.new
44
+ end
45
+ end
46
+
47
+ # A test service with an echo implementation.
48
+ class EchoService
49
+ include GRPC::GenericService
50
+ rpc :an_rpc, EchoMsg, EchoMsg
51
+ attr_reader :received_md
52
+
53
+ def initialize(**kw)
54
+ @trailing_metadata = kw
55
+ @received_md = []
56
+ end
57
+
58
+ def an_rpc(req, call)
59
+ GRPC.logger.info('echo service received a request')
60
+ call.output_metadata.update(@trailing_metadata)
61
+ @received_md << call.metadata unless call.metadata.nil?
62
+ req
63
+ end
64
+ end
65
+
66
+ EchoStub = EchoService.rpc_stub_class
67
+
68
+ def start_server(port = 0)
69
+ @srv = GRPC::RpcServer.new(pool_size: 1)
70
+ server_port = @srv.add_http2_port("localhost:#{port}", :this_port_is_insecure)
71
+ @srv.handle(EchoService)
72
+ @server_thd = Thread.new { @srv.run }
73
+ @srv.wait_till_running
74
+ server_port
75
+ end
76
+
77
+ def stop_server
78
+ expect(@srv.stopped?).to be(false)
79
+ @srv.stop
80
+ @server_thd.join
81
+ expect(@srv.stopped?).to be(true)
82
+ end
83
+
84
+ describe 'channel connection behavior' do
85
+ it 'the client channel handles temporary loss of a transport' do
86
+ port = start_server
87
+ stub = EchoStub.new("localhost:#{port}", :this_channel_is_insecure)
88
+ req = EchoMsg.new
89
+ expect(stub.an_rpc(req)).to be_a(EchoMsg)
90
+ stop_server
91
+ sleep 1
92
+ # TODO(apolcyn) grabbing the same port might fail, is this stable enough?
93
+ start_server(port)
94
+ expect(stub.an_rpc(req)).to be_a(EchoMsg)
95
+ stop_server
96
+ end
97
+
98
+ it 'observably connects and reconnects to transient server' \
99
+ ' when using the channel state API' do
100
+ port = start_server
101
+ ch = GRPC::Core::Channel.new("localhost:#{port}", {},
102
+ :this_channel_is_insecure)
103
+
104
+ expect(ch.connectivity_state).to be(GRPC::Core::ConnectivityStates::IDLE)
105
+
106
+ state = ch.connectivity_state(true)
107
+
108
+ count = 0
109
+ while count < 20 && state != GRPC::Core::ConnectivityStates::READY
110
+ ch.watch_connectivity_state(state, Time.now + 60)
111
+ state = ch.connectivity_state(true)
112
+ count += 1
113
+ end
114
+
115
+ expect(state).to be(GRPC::Core::ConnectivityStates::READY)
116
+
117
+ stop_server
118
+
119
+ state = ch.connectivity_state
120
+
121
+ count = 0
122
+ while count < 20 && state == GRPC::Core::ConnectivityStates::READY
123
+ ch.watch_connectivity_state(state, Time.now + 60)
124
+ state = ch.connectivity_state
125
+ count += 1
126
+ end
127
+
128
+ expect(state).to_not be(GRPC::Core::ConnectivityStates::READY)
129
+
130
+ start_server(port)
131
+
132
+ state = ch.connectivity_state(true)
133
+
134
+ count = 0
135
+ while count < 20 && state != GRPC::Core::ConnectivityStates::READY
136
+ ch.watch_connectivity_state(state, Time.now + 60)
137
+ state = ch.connectivity_state(true)
138
+ count += 1
139
+ end
140
+
141
+ expect(state).to be(GRPC::Core::ConnectivityStates::READY)
142
+
143
+ stop_server
144
+ end
145
+
146
+ it 'concurrent watches on the same channel' do
147
+ timeout(180) do
148
+ port = start_server
149
+ ch = GRPC::Core::Channel.new("localhost:#{port}", {},
150
+ :this_channel_is_insecure)
151
+ stop_server
152
+
153
+ thds = []
154
+ 50.times do
155
+ thds << Thread.new do
156
+ while ch.connectivity_state(true) != ConnectivityStates::READY
157
+ ch.watch_connectivity_state(
158
+ ConnectivityStates::READY, Time.now + 60)
159
+ break
160
+ end
161
+ end
162
+ end
163
+
164
+ sleep 0.01
165
+
166
+ start_server(port)
167
+
168
+ thds.each(&:join)
169
+
170
+ stop_server
171
+ end
172
+ end
173
+ end
@@ -153,6 +153,35 @@ describe GRPC::Core::Channel do
153
153
  end
154
154
  end
155
155
 
156
+ describe '#connectivity_state' do
157
+ it 'returns an enum' do
158
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
159
+ valid_states = [
160
+ GRPC::Core::ConnectivityStates::IDLE,
161
+ GRPC::Core::ConnectivityStates::CONNECTING,
162
+ GRPC::Core::ConnectivityStates::READY,
163
+ GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE,
164
+ GRPC::Core::ConnectivityStates::FATAL_FAILURE
165
+ ]
166
+
167
+ expect(valid_states).to include(ch.connectivity_state)
168
+ end
169
+
170
+ it 'returns an enum when trying to connect' do
171
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
172
+ ch.connectivity_state(true)
173
+ valid_states = [
174
+ GRPC::Core::ConnectivityStates::IDLE,
175
+ GRPC::Core::ConnectivityStates::CONNECTING,
176
+ GRPC::Core::ConnectivityStates::READY,
177
+ GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE,
178
+ GRPC::Core::ConnectivityStates::FATAL_FAILURE
179
+ ]
180
+
181
+ expect(valid_states).to include(ch.connectivity_state)
182
+ end
183
+ end
184
+
156
185
  describe '::SSL_TARGET' do
157
186
  it 'is a symbol' do
158
187
  expect(GRPC::Core::Channel::SSL_TARGET).to be_a(Symbol)