FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
grpc-web-python-example/node-client.js at main · gitpushdashf/grpc-web-python-example · GitHub
gitpushdashf
grpc-web-python-example
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
grpc-web-python-example
/
node-client.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (49 loc) · 1.19 KB
Breadcrumbs
grpc-web-python-example
/
node-client.js
Copy path
File metadata and controls
55 lines (49 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var
PROTO_PATH
=
__dirname
+
'/helloworld.proto'
;
var
async
=
require
(
'async'
)
;
var
grpc
=
require
(
'@grpc/grpc-js'
)
;
var
protoLoader
=
require
(
'@grpc/proto-loader'
)
;
var
packageDefinition
=
protoLoader
.
loadSync
(
PROTO_PATH
,
{
keepCase
:
true
,
longs
:
String
,
enums
:
String
,
defaults
:
true
,
oneofs
:
true
}
)
;
var
protoDescriptor
=
grpc
.
loadPackageDefinition
(
packageDefinition
)
;
var
helloworld
=
protoDescriptor
.
helloworld
;
var
client
=
new
helloworld
.
Greeter
(
'localhost:9090'
,
grpc
.
credentials
.
createInsecure
(
)
)
;
/**
*
@param
{
function():?
} callback
*/
function
runSayHello
(
callback
)
{
client
.
sayHello
(
{
name
:
'John'
}
,
{
}
,
(
err
,
response
)
=>
{
console
.
log
(
response
.
message
)
;
callback
(
)
;
}
)
;
}
/**
*
@param
{
function():?
} callback
*/
function
runSayRepeatHello
(
callback
)
{
var
stream
=
client
.
sayRepeatHello
(
{
name
:
'John'
,
count
:
5
}
,
{
}
)
;
stream
.
on
(
'data'
,
(
response
)
=>
{
console
.
log
(
response
.
message
)
;
}
)
;
stream
.
on
(
'end'
,
(
)
=>
{
callback
(
)
;
}
)
;
}
/**
* Run all of the demos in order
*/
function
main
(
)
{
async
.
series
(
[
runSayHello
,
runSayRepeatHello
,
]
)
;
}
if
(
require
.
main
===
module
)
{
main
(
)
;
}
Back
|
FazBrowse Home
|
New Git URL