File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -242,15 +242,10 @@ const message = 'this is examples/metadata';
242
242
243
243
async function main ( ) {
244
244
let argv = parseArgs ( process . argv . slice ( 2 ) , {
245
- string : 'target'
245
+ string : 'target' ,
246
+ default : { target : 'localhost:50052' }
246
247
} ) ;
247
- let target ;
248
- if ( argv . target ) {
249
- target = argv . target ;
250
- } else {
251
- target = 'localhost:50051' ;
252
- }
253
- const client = new echoProto . Echo ( target , grpc . credentials . createInsecure ( ) ) ;
248
+ const client = new echoProto . Echo ( argv . target , grpc . credentials . createInsecure ( ) ) ;
254
249
await unaryCallWithMetadata ( client , message ) ;
255
250
await asyncWait ( 1000 ) ;
256
251
Original file line number Diff line number Diff line change @@ -142,9 +142,13 @@ const serviceImplementation = {
142
142
} ;
143
143
144
144
function main ( ) {
145
+ const argv = parseArgs ( process . argv . slice ( 2 ) , {
146
+ string : 'port' ,
147
+ default : { port : '50052' }
148
+ } ) ;
145
149
const server = new grpc . Server ( ) ;
146
150
server . addService ( echoProto . Echo . service , serviceImplementation ) ;
147
- server . bindAsync ( ' 0.0.0.0:50051' , grpc . ServerCredentials . createInsecure ( ) , ( ) => {
151
+ server . bindAsync ( ` 0.0.0.0:${ argv . port } ` , grpc . ServerCredentials . createInsecure ( ) , ( ) => {
148
152
server . start ( ) ;
149
153
} ) ;
150
154
}
You can’t perform that action at this time.
0 commit comments