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
047f20d3
Commit
047f20d3
authored
Aug 27, 2015
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Make single-response calls emit INTERNAL status for unparseable responses
parent
6f1e2ea7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/node/src/client.js
+55
-19
55 additions, 19 deletions
src/node/src/client.js
with
55 additions
and
19 deletions
src/node/src/client.js
+
55
−
19
View file @
047f20d3
...
@@ -142,7 +142,13 @@ function _read(size) {
...
@@ -142,7 +142,13 @@ function _read(size) {
return
;
return
;
}
}
var
data
=
event
.
read
;
var
data
=
event
.
read
;
if
(
self
.
push
(
self
.
deserialize
(
data
))
&&
data
!==
null
)
{
var
deserialized
;
try
{
deserialized
=
self
.
deserialize
(
data
);
}
catch
(
e
)
{
self
.
cancel
();
}
if
(
self
.
push
(
deserialized
)
&&
data
!==
null
)
{
var
read_batch
=
{};
var
read_batch
=
{};
read_batch
[
grpc
.
opType
.
RECV_MESSAGE
]
=
true
;
read_batch
[
grpc
.
opType
.
RECV_MESSAGE
]
=
true
;
self
.
call
.
startBatch
(
read_batch
,
readCallback
);
self
.
call
.
startBatch
(
read_batch
,
readCallback
);
...
@@ -296,23 +302,38 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
...
@@ -296,23 +302,38 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
call
.
startBatch
(
client_batch
,
function
(
err
,
response
)
{
call
.
startBatch
(
client_batch
,
function
(
err
,
response
)
{
response
.
status
.
metadata
=
Metadata
.
_fromCoreRepresentation
(
response
.
status
.
metadata
=
Metadata
.
_fromCoreRepresentation
(
response
.
status
.
metadata
);
response
.
status
.
metadata
);
emitter
.
emit
(
'
status
'
,
response
.
status
);
var
status
=
response
.
status
;
if
(
response
.
status
.
code
!==
grpc
.
status
.
OK
)
{
var
error
;
var
error
=
new
Error
(
response
.
status
.
details
);
var
deserialized
;
error
.
code
=
response
.
status
.
code
;
if
(
status
.
code
===
grpc
.
status
.
OK
)
{
error
.
metadata
=
response
.
status
.
metadata
;
callback
(
error
);
return
;
}
else
{
if
(
err
)
{
if
(
err
)
{
// Got a batch error, but OK status. Something went wrong
// Got a batch error, but OK status. Something went wrong
callback
(
err
);
callback
(
err
);
return
;
return
;
}
else
{
try
{
deserialized
=
deserialize
(
response
.
read
);
}
catch
(
e
)
{
/* Change status to indicate bad server response. This will result
* in passing an error to the callback */
status
=
{
code
:
grpc
.
status
.
INTERNAL
,
details
:
'
Failed to parse server response
'
};
}
}
}
}
}
if
(
status
.
code
!==
grpc
.
status
.
OK
)
{
error
=
new
Error
(
response
.
status
.
details
);
error
.
code
=
status
.
code
;
error
.
metadata
=
status
.
metadata
;
callback
(
error
);
}
else
{
callback
(
null
,
deserialized
);
}
emitter
.
emit
(
'
status
'
,
status
);
emitter
.
emit
(
'
metadata
'
,
Metadata
.
_fromCoreRepresentation
(
emitter
.
emit
(
'
metadata
'
,
Metadata
.
_fromCoreRepresentation
(
response
.
metadata
));
response
.
metadata
));
callback
(
null
,
deserialize
(
response
.
read
));
});
});
});
});
return
emitter
;
return
emitter
;
...
@@ -374,21 +395,36 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
...
@@ -374,21 +395,36 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
call
.
startBatch
(
client_batch
,
function
(
err
,
response
)
{
call
.
startBatch
(
client_batch
,
function
(
err
,
response
)
{
response
.
status
.
metadata
=
Metadata
.
_fromCoreRepresentation
(
response
.
status
.
metadata
=
Metadata
.
_fromCoreRepresentation
(
response
.
status
.
metadata
);
response
.
status
.
metadata
);
stream
.
emit
(
'
status
'
,
response
.
status
);
var
status
=
response
.
status
;
if
(
response
.
status
.
code
!==
grpc
.
status
.
OK
)
{
var
error
;
var
error
=
new
Error
(
response
.
status
.
details
);
var
deserialized
;
error
.
code
=
response
.
status
.
code
;
if
(
status
.
code
===
grpc
.
status
.
OK
)
{
error
.
metadata
=
response
.
status
.
metadata
;
callback
(
error
);
return
;
}
else
{
if
(
err
)
{
if
(
err
)
{
// Got a batch error, but OK status. Something went wrong
// Got a batch error, but OK status. Something went wrong
callback
(
err
);
callback
(
err
);
return
;
return
;
}
else
{
try
{
deserialized
=
deserialize
(
response
.
read
);
}
catch
(
e
)
{
/* Change status to indicate bad server response. This will result
* in passing an error to the callback */
status
=
{
code
:
grpc
.
status
.
INTERNAL
,
details
:
'
Failed to parse server response
'
};
}
}
}
}
}
callback
(
null
,
deserialize
(
response
.
read
));
if
(
status
.
code
!==
grpc
.
status
.
OK
)
{
error
=
new
Error
(
response
.
status
.
details
);
error
.
code
=
status
.
code
;
error
.
metadata
=
status
.
metadata
;
callback
(
error
);
}
else
{
callback
(
null
,
deserialized
);
}
stream
.
emit
(
'
status
'
,
status
);
});
});
});
});
return
stream
;
return
stream
;
...
...
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