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
6f34bad5
Commit
6f34bad5
authored
9 years ago
by
murgatroid99
Browse files
Options
Downloads
Patches
Plain Diff
Ensure that client generated methods don't conflict with other properties
parent
ef4aac6d
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/node/src/client.js
+15
-12
15 additions, 12 deletions
src/node/src/client.js
src/node/test/surface_test.js
+19
-1
19 additions, 1 deletion
src/node/test/surface_test.js
with
34 additions
and
13 deletions
src/node/src/client.js
+
15
−
12
View file @
6f34bad5
...
...
@@ -236,7 +236,7 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
deadline
=
Infinity
;
}
var
emitter
=
new
EventEmitter
();
var
call
=
new
grpc
.
Call
(
this
.
channel
,
method
,
deadline
);
var
call
=
new
grpc
.
Call
(
this
.
$
channel
,
method
,
deadline
);
if
(
metadata
===
null
||
metadata
===
undefined
)
{
metadata
=
{};
}
...
...
@@ -246,7 +246,7 @@ function makeUnaryRequestFunction(method, serialize, deserialize) {
emitter
.
getPeer
=
function
getPeer
()
{
return
call
.
getPeer
();
};
this
.
updateMetadata
(
this
.
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
this
.
$
updateMetadata
(
this
.
$
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
if
(
error
)
{
call
.
cancel
();
callback
(
error
);
...
...
@@ -309,12 +309,12 @@ function makeClientStreamRequestFunction(method, serialize, deserialize) {
if
(
deadline
===
undefined
)
{
deadline
=
Infinity
;
}
var
call
=
new
grpc
.
Call
(
this
.
channel
,
method
,
deadline
);
var
call
=
new
grpc
.
Call
(
this
.
$
channel
,
method
,
deadline
);
if
(
metadata
===
null
||
metadata
===
undefined
)
{
metadata
=
{};
}
var
stream
=
new
ClientWritableStream
(
call
,
serialize
);
this
.
updateMetadata
(
this
.
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
this
.
$
updateMetadata
(
this
.
$
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
if
(
error
)
{
call
.
cancel
();
callback
(
error
);
...
...
@@ -383,12 +383,12 @@ function makeServerStreamRequestFunction(method, serialize, deserialize) {
if
(
deadline
===
undefined
)
{
deadline
=
Infinity
;
}
var
call
=
new
grpc
.
Call
(
this
.
channel
,
method
,
deadline
);
var
call
=
new
grpc
.
Call
(
this
.
$
channel
,
method
,
deadline
);
if
(
metadata
===
null
||
metadata
===
undefined
)
{
metadata
=
{};
}
var
stream
=
new
ClientReadableStream
(
call
,
deserialize
);
this
.
updateMetadata
(
this
.
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
this
.
$
updateMetadata
(
this
.
$
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
if
(
error
)
{
call
.
cancel
();
stream
.
emit
(
'
error
'
,
error
);
...
...
@@ -455,12 +455,12 @@ function makeBidiStreamRequestFunction(method, serialize, deserialize) {
if
(
deadline
===
undefined
)
{
deadline
=
Infinity
;
}
var
call
=
new
grpc
.
Call
(
this
.
channel
,
method
,
deadline
);
var
call
=
new
grpc
.
Call
(
this
.
$
channel
,
method
,
deadline
);
if
(
metadata
===
null
||
metadata
===
undefined
)
{
metadata
=
{};
}
var
stream
=
new
ClientDuplexStream
(
call
,
serialize
,
deserialize
);
this
.
updateMetadata
(
this
.
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
this
.
$
updateMetadata
(
this
.
$
auth_uri
,
metadata
,
function
(
error
,
metadata
)
{
if
(
error
)
{
call
.
cancel
();
stream
.
emit
(
'
error
'
,
error
);
...
...
@@ -545,14 +545,17 @@ exports.makeClientConstructor = function(methods, serviceName) {
options
=
{};
}
options
[
'
grpc.primary_user_agent
'
]
=
'
grpc-node/
'
+
version
;
this
.
channel
=
new
grpc
.
Channel
(
address
,
options
);
this
.
server_address
=
address
.
replace
(
/
\/
$/
,
''
);
this
.
auth_uri
=
this
.
server_address
+
'
/
'
+
serviceName
;
this
.
updateMetadata
=
updateMetadata
;
this
.
$
channel
=
new
grpc
.
Channel
(
address
,
options
);
this
.
$
server_address
=
address
.
replace
(
/
\/
$/
,
''
);
this
.
$
auth_uri
=
this
.
$
server_address
+
'
/
'
+
serviceName
;
this
.
$
updateMetadata
=
updateMetadata
;
}
_
.
each
(
methods
,
function
(
attrs
,
name
)
{
var
method_type
;
if
(
_
.
startsWith
(
name
,
'
$
'
))
{
throw
new
Error
(
'
Method names cannot start with $
'
);
}
if
(
attrs
.
requestStream
)
{
if
(
attrs
.
responseStream
)
{
method_type
=
'
bidi
'
;
...
...
This diff is collapsed.
Click to expand it.
src/node/test/surface_test.js
+
19
−
1
View file @
6f34bad5
...
...
@@ -110,6 +110,24 @@ describe('Server.prototype.addProtoService', function() {
});
});
});
describe
(
'
Client constructor building
'
,
function
()
{
var
illegal_service_attrs
=
{
$method
:
{
path
:
'
/illegal/$method
'
,
requestStream
:
false
,
responseStream
:
false
,
requestSerialize
:
_
.
identity
,
requestDeserialize
:
_
.
identity
,
responseSerialize
:
_
.
identity
,
responseDeserialize
:
_
.
identity
}
};
it
(
'
Should reject method names starting with $
'
,
function
()
{
assert
.
throws
(
function
()
{
grpc
.
makeGenericClientConstructor
(
illegal_service_attrs
);
},
/
\$
/
);
});
});
describe
(
'
Echo service
'
,
function
()
{
var
server
;
var
client
;
...
...
@@ -344,7 +362,7 @@ describe('Other conditions', function() {
server
.
shutdown
();
});
it
(
'
channel.getTarget should be available
'
,
function
()
{
assert
.
strictEqual
(
typeof
client
.
channel
.
getTarget
(),
'
string
'
);
assert
.
strictEqual
(
typeof
client
.
$
channel
.
getTarget
(),
'
string
'
);
});
describe
(
'
Server recieving bad input
'
,
function
()
{
var
misbehavingClient
;
...
...
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