|
|
@ -18,6 +18,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
var PROTO_PATH = __dirname + '/../../protos/helloworld.proto'; |
|
|
|
var PROTO_PATH = __dirname + '/../../protos/helloworld.proto'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var parseArgs = require('minimist'); |
|
|
|
var grpc = require('@grpc/grpc-js'); |
|
|
|
var grpc = require('@grpc/grpc-js'); |
|
|
|
var protoLoader = require('@grpc/proto-loader'); |
|
|
|
var protoLoader = require('@grpc/proto-loader'); |
|
|
|
var packageDefinition = protoLoader.loadSync( |
|
|
|
var packageDefinition = protoLoader.loadSync( |
|
|
@ -31,11 +32,20 @@ var packageDefinition = protoLoader.loadSync( |
|
|
|
var hello_proto = grpc.loadPackageDefinition(packageDefinition).helloworld; |
|
|
|
var hello_proto = grpc.loadPackageDefinition(packageDefinition).helloworld; |
|
|
|
|
|
|
|
|
|
|
|
function main() { |
|
|
|
function main() { |
|
|
|
var client = new hello_proto.Greeter('localhost:50051', |
|
|
|
var argv = parseArgs(process.argv.slice(2), { |
|
|
|
|
|
|
|
string: 'target' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var target; |
|
|
|
|
|
|
|
if (argv.target) { |
|
|
|
|
|
|
|
target = argv.target; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
target = 'localhost:50051'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var client = new hello_proto.Greeter(target, |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
grpc.credentials.createInsecure()); |
|
|
|
var user; |
|
|
|
var user; |
|
|
|
if (process.argv.length >= 3) { |
|
|
|
if (argv._.length > 0) { |
|
|
|
user = process.argv[2]; |
|
|
|
user = argv._[0];
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
user = 'world'; |
|
|
|
user = 'world'; |
|
|
|
} |
|
|
|
} |
|
|
|