Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
e57cd90c
Commit
e57cd90c
authored
Mar 3, 2017
by
Alexander Polcyn
Browse files
Options
Downloads
Patches
Plain Diff
fix channel connectivity state function
parent
b60e6ac1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ruby/ext/grpc/rb_channel.c
+12
-8
12 additions, 8 deletions
src/ruby/ext/grpc/rb_channel.c
src/ruby/spec/channel_spec.rb
+29
-0
29 additions, 0 deletions
src/ruby/spec/channel_spec.rb
with
41 additions
and
8 deletions
src/ruby/ext/grpc/rb_channel.c
+
12
−
8
View file @
e57cd90c
...
@@ -175,19 +175,23 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
...
@@ -175,19 +175,23 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
/*
/*
call-seq:
call-seq:
insecure_channel = Channel:new("myhost:8080", {'arg1': 'value1'})
ch.connectivity_state -> state
creds = ...
ch.connectivity_state(true) -> state
secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds)
Creates channel instances. */
Indicates the current state of the channel, whose value is one of the
constants defined in GRPC::Core::ConnectivityStates.
It also tries to connect if the chennel is idle in the second form. */
static
VALUE
grpc_rb_channel_get_connectivity_state
(
int
argc
,
VALUE
*
argv
,
static
VALUE
grpc_rb_channel_get_connectivity_state
(
int
argc
,
VALUE
*
argv
,
VALUE
self
)
{
VALUE
self
)
{
VALUE
try_to_connect
=
Qfalse
;
VALUE
try_to_connect_param
=
Qfalse
;
int
grpc_try_to_connect
=
0
;
grpc_rb_channel
*
wrapper
=
NULL
;
grpc_rb_channel
*
wrapper
=
NULL
;
grpc_channel
*
ch
=
NULL
;
grpc_channel
*
ch
=
NULL
;
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
rb_scan_args
(
argc
,
argv
,
"01"
,
try_to_connect
);
rb_scan_args
(
argc
,
argv
,
"01"
,
&
try_to_connect_param
);
grpc_try_to_connect
=
try_to_connect_param
==
Qtrue
?
1
:
0
;
TypedData_Get_Struct
(
self
,
grpc_rb_channel
,
&
grpc_channel_data_type
,
wrapper
);
TypedData_Get_Struct
(
self
,
grpc_rb_channel
,
&
grpc_channel_data_type
,
wrapper
);
ch
=
wrapper
->
wrapped
;
ch
=
wrapper
->
wrapped
;
...
@@ -195,8 +199,8 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
...
@@ -195,8 +199,8 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
rb_raise
(
rb_eRuntimeError
,
"closed!"
);
rb_raise
(
rb_eRuntimeError
,
"closed!"
);
return
Qnil
;
return
Qnil
;
}
}
return
NUM2
LONG
(
return
LONG
2NUM
(
grpc_channel_check_connectivity_state
(
ch
,
(
int
)
try_to_connect
));
grpc_channel_check_connectivity_state
(
ch
,
grpc_
try_to_connect
));
}
}
/* Watch for a change in connectivity state.
/* Watch for a change in connectivity state.
...
...
This diff is collapsed.
Click to expand it.
src/ruby/spec/channel_spec.rb
+
29
−
0
View file @
e57cd90c
...
@@ -153,6 +153,35 @@ describe GRPC::Core::Channel do
...
@@ -153,6 +153,35 @@ describe GRPC::Core::Channel do
end
end
end
end
describe
'#connectivity_state'
do
it
'returns an enum'
do
ch
=
GRPC
::
Core
::
Channel
.
new
(
fake_host
,
nil
,
:this_channel_is_insecure
)
valid_states
=
[
GRPC
::
Core
::
ConnectivityStates
::
IDLE
,
GRPC
::
Core
::
ConnectivityStates
::
CONNECTING
,
GRPC
::
Core
::
ConnectivityStates
::
READY
,
GRPC
::
Core
::
ConnectivityStates
::
TRANSIENT_FAILURE
,
GRPC
::
Core
::
ConnectivityStates
::
FATAL_FAILURE
]
expect
(
valid_states
).
to
include
(
ch
.
connectivity_state
)
end
it
'returns an enum when trying to connect'
do
ch
=
GRPC
::
Core
::
Channel
.
new
(
fake_host
,
nil
,
:this_channel_is_insecure
)
ch
.
connectivity_state
(
true
)
valid_states
=
[
GRPC
::
Core
::
ConnectivityStates
::
IDLE
,
GRPC
::
Core
::
ConnectivityStates
::
CONNECTING
,
GRPC
::
Core
::
ConnectivityStates
::
READY
,
GRPC
::
Core
::
ConnectivityStates
::
TRANSIENT_FAILURE
,
GRPC
::
Core
::
ConnectivityStates
::
FATAL_FAILURE
]
expect
(
valid_states
).
to
include
(
ch
.
connectivity_state
)
end
end
describe
'::SSL_TARGET'
do
describe
'::SSL_TARGET'
do
it
'is a symbol'
do
it
'is a symbol'
do
expect
(
GRPC
::
Core
::
Channel
::
SSL_TARGET
).
to
be_a
(
Symbol
)
expect
(
GRPC
::
Core
::
Channel
::
SSL_TARGET
).
to
be_a
(
Symbol
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment