Skip to content

Commit

Permalink
Update Node examples to use @grpc/grpc-js
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Nov 5, 2020
1 parent ce4870d commit 273e3cf
Show file tree
Hide file tree
Showing 15 changed files with 1,075 additions and 478 deletions.
2 changes: 1 addition & 1 deletion examples/node/dynamic_codegen/greeter_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var PROTO_PATH = __dirname + '/../../protos/helloworld.proto';

var grpc = require('grpc');
var grpc = require('@grpc/grpc-js');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
PROTO_PATH,
Expand Down
7 changes: 4 additions & 3 deletions examples/node/dynamic_codegen/greeter_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

var PROTO_PATH = __dirname + '/../../protos/helloworld.proto';

var grpc = require('grpc');
var grpc = require('@grpc/grpc-js');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
PROTO_PATH,
Expand All @@ -44,8 +44,9 @@ function sayHello(call, callback) {
function main() {
var server = new grpc.Server();
server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
server.start();
});
}

main();
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
var _ = require('lodash');
var grpc = require('grpc');
var grpc = require('@grpc/grpc-js');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
PROTO_PATH,
Expand Down
19 changes: 10 additions & 9 deletions examples/node/dynamic_codegen/route_guide/route_guide_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var fs = require('fs');
var parseArgs = require('minimist');
var path = require('path');
var _ = require('lodash');
var grpc = require('grpc');
var grpc = require('@grpc/grpc-js');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
PROTO_PATH,
Expand Down Expand Up @@ -230,14 +230,15 @@ function getServer() {
if (require.main === module) {
// If this is run as a script, start a server on an unused port
var routeServer = getServer();
routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
var argv = parseArgs(process.argv, {
string: 'db_path'
});
fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) throw err;
feature_list = JSON.parse(data);
routeServer.start();
routeServer.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
var argv = parseArgs(process.argv, {
string: 'db_path'
});
fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) throw err;
feature_list = JSON.parse(data);
routeServer.start();
});
});
}

Expand Down
Loading

0 comments on commit 273e3cf

Please sign in to comment.