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
1f5fad5c
Commit
1f5fad5c
authored
8 years ago
by
Noah Eisen
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9245 from ncteisen/ruby_advanced_interop_server_side
Ruby Advanced Interop Server Side
parents
ea917301
46b716d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ruby/pb/test/server.rb
+26
-1
26 additions, 1 deletion
src/ruby/pb/test/server.rb
with
26 additions
and
1 deletion
src/ruby/pb/test/server.rb
+
26
−
1
View file @
1f5fad5c
...
@@ -129,6 +129,27 @@ def nulls(l)
...
@@ -129,6 +129,27 @@ def nulls(l)
[].
pack
(
'x'
*
l
).
force_encoding
(
'ascii-8bit'
)
[].
pack
(
'x'
*
l
).
force_encoding
(
'ascii-8bit'
)
end
end
def
maybe_echo_metadata
(
_call
)
# these are consistent for all interop tests
initial_metadata_key
=
"x-grpc-test-echo-initial"
trailing_metadata_key
=
"x-grpc-test-echo-trailing-bin"
if
_call
.
metadata
.
has_key?
(
initial_metadata_key
)
_call
.
metadata_to_send
[
initial_metadata_key
]
=
_call
.
metadata
[
initial_metadata_key
]
end
if
_call
.
metadata
.
has_key?
(
trailing_metadata_key
)
_call
.
output_metadata
[
trailing_metadata_key
]
=
_call
.
metadata
[
trailing_metadata_key
]
end
end
def
maybe_echo_status_and_message
(
req
)
unless
req
.
response_status
.
nil?
fail
GRPC
::
BadStatus
.
new_status_exception
(
req
.
response_status
.
code
,
req
.
response_status
.
message
)
end
end
# A FullDuplexEnumerator passes requests to a block and yields generated responses
# A FullDuplexEnumerator passes requests to a block and yields generated responses
class
FullDuplexEnumerator
class
FullDuplexEnumerator
include
Grpc
::
Testing
include
Grpc
::
Testing
...
@@ -143,6 +164,7 @@ class FullDuplexEnumerator
...
@@ -143,6 +164,7 @@ class FullDuplexEnumerator
begin
begin
cls
=
StreamingOutputCallResponse
cls
=
StreamingOutputCallResponse
@requests
.
each
do
|
req
|
@requests
.
each
do
|
req
|
maybe_echo_status_and_message
(
req
)
req
.
response_parameters
.
each
do
|
params
|
req
.
response_parameters
.
each
do
|
params
|
resp_size
=
params
.
size
resp_size
=
params
.
size
GRPC
.
logger
.
info
(
"read a req, response size is
#{
resp_size
}
"
)
GRPC
.
logger
.
info
(
"read a req, response size is
#{
resp_size
}
"
)
...
@@ -170,6 +192,8 @@ class TestTarget < Grpc::Testing::TestService::Service
...
@@ -170,6 +192,8 @@ class TestTarget < Grpc::Testing::TestService::Service
end
end
def
unary_call
(
simple_req
,
_call
)
def
unary_call
(
simple_req
,
_call
)
maybe_echo_metadata
(
_call
)
maybe_echo_status_and_message
(
simple_req
)
req_size
=
simple_req
.
response_size
req_size
=
simple_req
.
response_size
SimpleResponse
.
new
(
payload:
Payload
.
new
(
type: :COMPRESSABLE
,
SimpleResponse
.
new
(
payload:
Payload
.
new
(
type: :COMPRESSABLE
,
body:
nulls
(
req_size
)))
body:
nulls
(
req_size
)))
...
@@ -189,7 +213,8 @@ class TestTarget < Grpc::Testing::TestService::Service
...
@@ -189,7 +213,8 @@ class TestTarget < Grpc::Testing::TestService::Service
end
end
end
end
def
full_duplex_call
(
reqs
)
def
full_duplex_call
(
reqs
,
_call
)
maybe_echo_metadata
(
_call
)
# reqs is a lazy Enumerator of the requests sent by the client.
# reqs is a lazy Enumerator of the requests sent by the client.
FullDuplexEnumerator
.
new
(
reqs
).
each_item
FullDuplexEnumerator
.
new
(
reqs
).
each_item
end
end
...
...
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