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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
98a32d39
Commit
98a32d39
authored
10 years ago
by
Tim Emiola
Browse files
Options
Downloads
Patches
Plain Diff
Adds symbols to access the fields in Status struct
parent
6de558f9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ruby/ext/grpc/rb_grpc.c
+5
-2
5 additions, 2 deletions
src/ruby/ext/grpc/rb_grpc.c
src/ruby/ext/grpc/rb_grpc.h
+9
-0
9 additions, 0 deletions
src/ruby/ext/grpc/rb_grpc.h
src/ruby/spec/call_spec.rb
+4
-33
4 additions, 33 deletions
src/ruby/spec/call_spec.rb
with
18 additions
and
35 deletions
src/ruby/ext/grpc/rb_grpc.c
+
5
−
2
View file @
98a32d39
...
@@ -195,7 +195,7 @@ static ID id_inspect;
...
@@ -195,7 +195,7 @@ static ID id_inspect;
/* id_to_s is the to_s method found on various ruby objects. */
/* id_to_s is the to_s method found on various ruby objects. */
static
ID
id_to_s
;
static
ID
id_to_s
;
/* Converts
`
a wrapped time constant to a standard time. */
/* Converts a wrapped time constant to a standard time. */
VALUE
grpc_rb_time_val_to_time
(
VALUE
self
)
{
VALUE
grpc_rb_time_val_to_time
(
VALUE
self
)
{
gpr_timespec
*
time_const
=
NULL
;
gpr_timespec
*
time_const
=
NULL
;
Data_Get_Struct
(
self
,
gpr_timespec
,
time_const
);
Data_Get_Struct
(
self
,
gpr_timespec
,
time_const
);
...
@@ -257,8 +257,11 @@ void Init_grpc() {
...
@@ -257,8 +257,11 @@ void Init_grpc() {
rb_mGRPC
=
rb_define_module
(
"GRPC"
);
rb_mGRPC
=
rb_define_module
(
"GRPC"
);
rb_mGrpcCore
=
rb_define_module_under
(
rb_mGRPC
,
"Core"
);
rb_mGrpcCore
=
rb_define_module_under
(
rb_mGRPC
,
"Core"
);
rb_sNewServerRpc
=
rb_struct_define
(
"NewServerRpc"
,
"method"
,
"host"
,
rb_sNewServerRpc
=
rb_struct_define
(
"NewServerRpc"
,
"method"
,
"host"
,
"deadline"
,
"metadata"
,
NULL
);
"deadline"
,
"metadata"
,
"call"
,
NULL
);
rb_sStatus
=
rb_struct_define
(
"Status"
,
"code"
,
"details"
,
"metadata"
,
NULL
);
rb_sStatus
=
rb_struct_define
(
"Status"
,
"code"
,
"details"
,
"metadata"
,
NULL
);
sym_code
=
ID2SYM
(
rb_intern
(
"code"
));
sym_details
=
ID2SYM
(
rb_intern
(
"details"
));
sym_metadata
=
ID2SYM
(
rb_intern
(
"metadata"
));
Init_grpc_byte_buffer
();
Init_grpc_byte_buffer
();
Init_grpc_event
();
Init_grpc_event
();
...
...
This diff is collapsed.
Click to expand it.
src/ruby/ext/grpc/rb_grpc.h
+
9
−
0
View file @
98a32d39
...
@@ -50,6 +50,15 @@ extern VALUE rb_sNewServerRpc;
...
@@ -50,6 +50,15 @@ extern VALUE rb_sNewServerRpc;
/* rb_sStruct is the struct that holds status details. */
/* rb_sStruct is the struct that holds status details. */
extern
VALUE
rb_sStatus
;
extern
VALUE
rb_sStatus
;
/* sym_code is the symbol for the code attribute of rb_sStatus. */
VALUE
sym_code
;
/* sym_details is the symbol for the details attribute of rb_sStatus. */
VALUE
sym_details
;
/* sym_metadata is the symbol for the metadata attribute of rb_sStatus. */
VALUE
sym_metadata
;
/* GC_NOT_MARKED is used in calls to Data_Wrap_Struct to indicate that the
/* GC_NOT_MARKED is used in calls to Data_Wrap_Struct to indicate that the
wrapped struct does not need to participate in ruby gc. */
wrapped struct does not need to participate in ruby gc. */
extern
const
RUBY_DATA_FUNC
GC_NOT_MARKED
;
extern
const
RUBY_DATA_FUNC
GC_NOT_MARKED
;
...
...
This diff is collapsed.
Click to expand it.
src/ruby/spec/call_spec.rb
+
4
−
33
View file @
98a32d39
...
@@ -76,7 +76,7 @@ describe GRPC::Core::CallOps do
...
@@ -76,7 +76,7 @@ describe GRPC::Core::CallOps do
RECV_INITIAL_METADATA
:
4
,
RECV_INITIAL_METADATA
:
4
,
RECV_MESSAGE
:
5
,
RECV_MESSAGE
:
5
,
RECV_STATUS_ON_CLIENT
:
6
,
RECV_STATUS_ON_CLIENT
:
6
,
RECV_CLOSE_ON_SERVER
:
7
,
RECV_CLOSE_ON_SERVER
:
7
}
}
end
end
...
@@ -88,43 +88,14 @@ describe GRPC::Core::CallOps do
...
@@ -88,43 +88,14 @@ describe GRPC::Core::CallOps do
end
end
describe
GRPC
::
Core
::
Call
do
describe
GRPC
::
Core
::
Call
do
let
(
:client_queue
)
{
GRPC
::
Core
::
CompletionQueue
.
new
}
let
(
:client_queue
)
{
GRPC
::
Core
::
CompletionQueue
.
new
}
let
(
:test_tag
)
{
Object
.
new
}
let
(
:test_tag
)
{
Object
.
new
}
let
(
:fake_host
)
{
'localhost:10101'
}
let
(
:fake_host
)
{
'localhost:10101'
}
before
(
:each
)
do
before
(
:each
)
do
@ch
=
GRPC
::
Core
::
Channel
.
new
(
fake_host
,
nil
)
@ch
=
GRPC
::
Core
::
Channel
.
new
(
fake_host
,
nil
)
end
end
describe
'#start_read'
do
xit
'should fail if called immediately'
do
blk
=
proc
{
make_test_call
.
start_read
(
test_tag
)
}
expect
(
&
blk
).
to
raise_error
GRPC
::
Core
::
CallError
end
end
describe
'#start_write'
do
xit
'should fail if called immediately'
do
bytes
=
GRPC
::
Core
::
ByteBuffer
.
new
(
'test string'
)
blk
=
proc
{
make_test_call
.
start_write
(
bytes
,
test_tag
)
}
expect
(
&
blk
).
to
raise_error
GRPC
::
Core
::
CallError
end
end
describe
'#start_write_status'
do
xit
'should fail if called immediately'
do
blk
=
proc
{
make_test_call
.
start_write_status
(
153
,
'x'
,
test_tag
)
}
expect
(
&
blk
).
to
raise_error
GRPC
::
Core
::
CallError
end
end
describe
'#writes_done'
do
xit
'should fail if called immediately'
do
blk
=
proc
{
make_test_call
.
writes_done
(
Object
.
new
)
}
expect
(
&
blk
).
to
raise_error
GRPC
::
Core
::
CallError
end
end
describe
'#add_metadata'
do
describe
'#add_metadata'
do
it
'adds metadata to a call without fail'
do
it
'adds metadata to a call without fail'
do
call
=
make_test_call
call
=
make_test_call
...
...
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
register
or
sign in
to comment