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
9ffbd0ca
Commit
9ffbd0ca
authored
9 years ago
by
Vijay Pai
Browse files
Options
Downloads
Patches
Plain Diff
Mark proto ser/deser on server side
parent
0fb96e8b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cpp/server/async_server_context.cc
+4
-0
4 additions, 0 deletions
src/cpp/server/async_server_context.cc
src/cpp/server/server.cc
+5
-0
5 additions, 0 deletions
src/cpp/server/server.cc
with
9 additions
and
0 deletions
src/cpp/server/async_server_context.cc
+
4
−
0
View file @
9ffbd0ca
...
@@ -68,9 +68,11 @@ bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) {
...
@@ -68,9 +68,11 @@ bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) {
bool
AsyncServerContext
::
StartWrite
(
const
grpc
::
protobuf
::
Message
&
response
,
bool
AsyncServerContext
::
StartWrite
(
const
grpc
::
protobuf
::
Message
&
response
,
int
flags
)
{
int
flags
)
{
grpc_byte_buffer
*
buffer
=
nullptr
;
grpc_byte_buffer
*
buffer
=
nullptr
;
GRPC_TIMER_MARK
(
SER_PROTO_BEGIN
,
call_
->
call
());
if
(
!
SerializeProto
(
response
,
&
buffer
))
{
if
(
!
SerializeProto
(
response
,
&
buffer
))
{
return
false
;
return
false
;
}
}
GRPC_TIMER_MARK
(
SER_PROTO_END
,
call_
->
call
());
grpc_call_error
err
=
grpc_call_start_write_old
(
call_
,
buffer
,
this
,
flags
);
grpc_call_error
err
=
grpc_call_start_write_old
(
call_
,
buffer
,
this
,
flags
);
grpc_byte_buffer_destroy
(
buffer
);
grpc_byte_buffer_destroy
(
buffer
);
return
err
==
GRPC_CALL_OK
;
return
err
==
GRPC_CALL_OK
;
...
@@ -87,7 +89,9 @@ bool AsyncServerContext::StartWriteStatus(const Status& status) {
...
@@ -87,7 +89,9 @@ bool AsyncServerContext::StartWriteStatus(const Status& status) {
bool
AsyncServerContext
::
ParseRead
(
grpc_byte_buffer
*
read_buffer
)
{
bool
AsyncServerContext
::
ParseRead
(
grpc_byte_buffer
*
read_buffer
)
{
GPR_ASSERT
(
request_
);
GPR_ASSERT
(
request_
);
GRPC_TIMER_MARK
(
DESER_PROTO_BEGIN
,
call_
->
call
());
bool
success
=
DeserializeProto
(
read_buffer
,
request_
);
bool
success
=
DeserializeProto
(
read_buffer
,
request_
);
GRPC_TIMER_MARK
(
DESER_PROTO_BEGIN
,
call_
->
call
());
request_
=
nullptr
;
request_
=
nullptr
;
return
success
;
return
success
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/cpp/server/server.cc
+
5
−
0
View file @
9ffbd0ca
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
#include
<grpc++/server_credentials.h>
#include
<grpc++/server_credentials.h>
#include
<grpc++/thread_pool_interface.h>
#include
<grpc++/thread_pool_interface.h>
#include
"src/core/profiling/timers.h"
#include
"src/cpp/proto/proto_utils.h"
#include
"src/cpp/proto/proto_utils.h"
#include
"src/cpp/util/time.h"
#include
"src/cpp/util/time.h"
...
@@ -123,10 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
...
@@ -123,10 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
std
::
unique_ptr
<
grpc
::
protobuf
::
Message
>
req
;
std
::
unique_ptr
<
grpc
::
protobuf
::
Message
>
req
;
std
::
unique_ptr
<
grpc
::
protobuf
::
Message
>
res
;
std
::
unique_ptr
<
grpc
::
protobuf
::
Message
>
res
;
if
(
has_request_payload_
)
{
if
(
has_request_payload_
)
{
GRPC_TIMER_MARK
(
DESER_PROTO_BEGIN
,
call_
.
call
());
req
.
reset
(
method_
->
AllocateRequestProto
());
req
.
reset
(
method_
->
AllocateRequestProto
());
if
(
!
DeserializeProto
(
request_payload_
,
req
.
get
()))
{
if
(
!
DeserializeProto
(
request_payload_
,
req
.
get
()))
{
abort
();
// for now
abort
();
// for now
}
}
GRPC_TIMER_MARK
(
DESER_PROTO_END
,
call_
.
call
());
}
}
if
(
has_response_payload_
)
{
if
(
has_response_payload_
)
{
res
.
reset
(
method_
->
AllocateResponseProto
());
res
.
reset
(
method_
->
AllocateResponseProto
());
...
@@ -340,7 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
...
@@ -340,7 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
bool
orig_status
=
*
status
;
bool
orig_status
=
*
status
;
if
(
*
status
&&
request_
)
{
if
(
*
status
&&
request_
)
{
if
(
payload_
)
{
if
(
payload_
)
{
GRPC_TIMER_MARK
(
DESER_PROTO_BEGIN
,
call_
);
*
status
=
DeserializeProto
(
payload_
,
request_
);
*
status
=
DeserializeProto
(
payload_
,
request_
);
GRPC_TIMER_MARK
(
DESER_PROTO_END
,
call_
);
}
else
{
}
else
{
*
status
=
false
;
*
status
=
false
;
}
}
...
...
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