Merge pull request #24679 from murgatroid99/node_examples_grpc-js

Update Node examples to use @grpc/grpc-js
pull/24674/head
Michael Lumish 4 years ago committed by GitHub
commit cc03415b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      examples/node/dynamic_codegen/greeter_client.js
  2. 5
      examples/node/dynamic_codegen/greeter_server.js
  3. 2
      examples/node/dynamic_codegen/route_guide/route_guide_client.js
  4. 5
      examples/node/dynamic_codegen/route_guide/route_guide_server.js
  5. 570
      examples/node/package-lock.json
  6. 4
      examples/node/package.json
  7. 4
      examples/node/static_codegen/README.md
  8. 2
      examples/node/static_codegen/greeter_client.js
  9. 5
      examples/node/static_codegen/greeter_server.js
  10. 26
      examples/node/static_codegen/helloworld_grpc_pb.js
  11. 163
      examples/node/static_codegen/helloworld_pb.js
  12. 2
      examples/node/static_codegen/route_guide/route_guide_client.js
  13. 74
      examples/node/static_codegen/route_guide/route_guide_grpc_pb.js
  14. 594
      examples/node/static_codegen/route_guide/route_guide_pb.js
  15. 5
      examples/node/static_codegen/route_guide/route_guide_server.js

@ -18,7 +18,7 @@
var PROTO_PATH = __dirname + '/../../protos/helloworld.proto'; var PROTO_PATH = __dirname + '/../../protos/helloworld.proto';
var grpc = require('grpc'); 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(
PROTO_PATH, PROTO_PATH,

@ -18,7 +18,7 @@
var PROTO_PATH = __dirname + '/../../protos/helloworld.proto'; var PROTO_PATH = __dirname + '/../../protos/helloworld.proto';
var grpc = require('grpc'); 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(
PROTO_PATH, PROTO_PATH,
@ -44,8 +44,9 @@ function sayHello(call, callback) {
function main() { function main() {
var server = new grpc.Server(); var server = new grpc.Server();
server.addService(hello_proto.Greeter.service, {sayHello: sayHello}); server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
server.start(); server.start();
});
} }
main(); main();

@ -23,7 +23,7 @@ var fs = require('fs');
var parseArgs = require('minimist'); var parseArgs = require('minimist');
var path = require('path'); var path = require('path');
var _ = require('lodash'); var _ = require('lodash');
var grpc = require('grpc'); 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(
PROTO_PATH, PROTO_PATH,

@ -22,7 +22,7 @@ var fs = require('fs');
var parseArgs = require('minimist'); var parseArgs = require('minimist');
var path = require('path'); var path = require('path');
var _ = require('lodash'); var _ = require('lodash');
var grpc = require('grpc'); 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(
PROTO_PATH, PROTO_PATH,
@ -230,7 +230,7 @@ function getServer() {
if (require.main === module) { if (require.main === module) {
// If this is run as a script, start a server on an unused port // If this is run as a script, start a server on an unused port
var routeServer = getServer(); var routeServer = getServer();
routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); routeServer.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
var argv = parseArgs(process.argv, { var argv = parseArgs(process.argv, {
string: 'db_path' string: 'db_path'
}); });
@ -239,6 +239,7 @@ if (require.main === module) {
feature_list = JSON.parse(data); feature_list = JSON.parse(data);
routeServer.start(); routeServer.start();
}); });
});
} }
exports.getServer = getServer; exports.getServer = getServer;

@ -0,0 +1,570 @@
{
"name": "grpc-examples",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@grpc/grpc-js": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.1.8.tgz",
"integrity": "sha512-64hg5rmEm6F/NvlWERhHmmgxbWU8nD2TMWE+9TvG7/WcOrFT3fzg/Uu631pXRFwmJ4aWO/kp9vVSlr8FUjBDLA==",
"requires": {
"@grpc/proto-loader": "^0.6.0-pre14",
"@types/node": "^12.12.47",
"google-auth-library": "^6.0.0",
"semver": "^6.2.0"
},
"dependencies": {
"@grpc/proto-loader": {
"version": "0.6.0-pre9",
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.0-pre9.tgz",
"integrity": "sha512-oM+LjpEjNzW5pNJjt4/hq1HYayNeQT+eGrOPABJnYHv7TyNPDNzkQ76rDYZF86X5swJOa4EujEMzQ9iiTdPgww==",
"requires": {
"@types/long": "^4.0.1",
"lodash.camelcase": "^4.3.0",
"long": "^4.0.0",
"protobufjs": "^6.9.0",
"yargs": "^15.3.1"
}
},
"ansi-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg=="
},
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
},
"string-width": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
"integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
"requires": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.0"
}
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"requires": {
"ansi-regex": "^5.0.0"
}
},
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w=="
},
"yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"requires": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
}
}
}
},
"@grpc/proto-loader": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.5.tgz",
"integrity": "sha512-WwN9jVNdHRQoOBo9FDH7qU+mgfjPc8GygPYms3M+y3fbQLfnCe/Kv/E01t7JRgnrsOHH8euvSbed3mIalXhwqQ==",
"requires": {
"lodash.camelcase": "^4.3.0",
"protobufjs": "^6.8.6"
}
},
"@protobufjs/aspromise": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
"integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78="
},
"@protobufjs/base64": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
"integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="
},
"@protobufjs/codegen": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
"integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="
},
"@protobufjs/eventemitter": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
"integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A="
},
"@protobufjs/fetch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
"integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=",
"requires": {
"@protobufjs/aspromise": "^1.1.1",
"@protobufjs/inquire": "^1.1.0"
}
},
"@protobufjs/float": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
"integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E="
},
"@protobufjs/inquire": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
"integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik="
},
"@protobufjs/path": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
"integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0="
},
"@protobufjs/pool": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
"integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q="
},
"@protobufjs/utf8": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
},
"@types/long": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz",
"integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w=="
},
"@types/node": {
"version": "12.19.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.3.tgz",
"integrity": "sha512-8Jduo8wvvwDzEVJCOvS/G6sgilOLvvhn1eMmK3TW8/T217O7u1jdrK6ImKLv80tVryaPSVeKu6sjDEiFjd4/eg=="
},
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
"requires": {
"debug": "4"
},
"dependencies": {
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"requires": {
"ms": "2.1.2"
}
}
}
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"arrify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz",
"integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug=="
},
"async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
},
"base64-js": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
},
"bignumber.js": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz",
"integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA=="
},
"buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"fast-text-encoding": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz",
"integrity": "sha512-dtm4QZH9nZtcDt8qJiOH9fcQd1NAgi+K1O2DbE6GG1PPCK/BWfOH3idCTRQ4ImXRUOyopDEgDEnVEE7Y/2Wrig=="
},
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"requires": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
}
},
"gaxios": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-4.0.1.tgz",
"integrity": "sha512-jOin8xRZ/UytQeBpSXFqIzqU7Fi5TqgPNLlUsSB8kjJ76+FiGBfImF8KJu++c6J4jOldfJUtt0YmkRj2ZpSHTQ==",
"requires": {
"abort-controller": "^3.0.0",
"extend": "^3.0.2",
"https-proxy-agent": "^5.0.0",
"is-stream": "^2.0.0",
"node-fetch": "^2.3.0"
}
},
"gcp-metadata": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.2.1.tgz",
"integrity": "sha512-tSk+REe5iq/N+K+SK1XjZJUrFPuDqGZVzCy2vocIHIGmPlTGsa8owXMJwGkrXr73NO0AzhPW4MF2DEHz7P2AVw==",
"requires": {
"gaxios": "^4.0.0",
"json-bigint": "^1.0.0"
}
},
"get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
},
"google-auth-library": {
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.1.3.tgz",
"integrity": "sha512-m9mwvY3GWbr7ZYEbl61isWmk+fvTmOt0YNUfPOUY2VH8K5pZlAIWJjxEi0PqR3OjMretyiQLI6GURMrPSwHQ2g==",
"requires": {
"arrify": "^2.0.0",
"base64-js": "^1.3.0",
"ecdsa-sig-formatter": "^1.0.11",
"fast-text-encoding": "^1.0.0",
"gaxios": "^4.0.0",
"gcp-metadata": "^4.2.0",
"gtoken": "^5.0.4",
"jws": "^4.0.0",
"lru-cache": "^6.0.0"
}
},
"google-p12-pem": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.0.3.tgz",
"integrity": "sha512-wS0ek4ZtFx/ACKYF3JhyGe5kzH7pgiQ7J5otlumqR9psmWMYc+U9cErKlCYVYHoUaidXHdZ2xbo34kB+S+24hA==",
"requires": {
"node-forge": "^0.10.0"
}
},
"google-protobuf": {
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.13.0.tgz",
"integrity": "sha512-ZIf3qfLFayVrPvAjeKKxO5FRF1/NwRxt6Dko+fWEMuHwHbZx8/fcaAao9b0wCM6kr8qeg2te8XTpyuvKuD9aKw=="
},
"gtoken": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.0.5.tgz",
"integrity": "sha512-wvjkecutFh8kVfbcdBdUWqDRrXb+WrgD79DBDEYf1Om8S1FluhylhtFjrL7Tx69vNhh259qA3Q1P4sPtb+kUYw==",
"requires": {
"gaxios": "^4.0.0",
"google-p12-pem": "^3.0.3",
"jws": "^4.0.0",
"mime": "^2.2.0"
}
},
"https-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
"requires": {
"agent-base": "6",
"debug": "4"
},
"dependencies": {
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"requires": {
"ms": "2.1.2"
}
}
}
},
"is-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
"integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw=="
},
"json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"requires": {
"bignumber.js": "^9.0.0"
}
},
"jwa": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz",
"integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==",
"requires": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"jws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz",
"integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==",
"requires": {
"jwa": "^2.0.0",
"safe-buffer": "^5.0.1"
}
},
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"requires": {
"p-locate": "^4.1.0"
}
},
"lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
},
"long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"requires": {
"yallist": "^4.0.0"
},
"dependencies": {
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
},
"mime": {
"version": "2.4.6",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz",
"integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA=="
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"node-forge": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz",
"integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA=="
},
"p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"requires": {
"p-try": "^2.0.0"
}
},
"p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"requires": {
"p-limit": "^2.2.0"
}
},
"p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="
},
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
},
"protobufjs": {
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.1.tgz",
"integrity": "sha512-pb8kTchL+1Ceg4lFd5XUpK8PdWacbvV5SK2ULH2ebrYtl4GjJmS24m6CKME67jzV53tbJxHlnNOSqQHbTsR9JQ==",
"requires": {
"@protobufjs/aspromise": "^1.1.2",
"@protobufjs/base64": "^1.1.2",
"@protobufjs/codegen": "^2.0.4",
"@protobufjs/eventemitter": "^1.1.0",
"@protobufjs/fetch": "^1.1.0",
"@protobufjs/float": "^1.0.2",
"@protobufjs/inquire": "^1.1.0",
"@protobufjs/path": "^1.1.2",
"@protobufjs/pool": "^1.1.0",
"@protobufjs/utf8": "^1.1.0",
"@types/long": "^4.0.1",
"@types/node": "^13.7.0",
"long": "^4.0.0"
},
"dependencies": {
"@types/node": {
"version": "13.13.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.30.tgz",
"integrity": "sha512-HmqFpNzp3TSELxU/bUuRK+xzarVOAsR00hzcvM0TXrMlt/+wcSLa5q6YhTb6/cA6wqDCZLDcfd8fSL95x5h7AA=="
}
}
},
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
},
"require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"set-blocking": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc="
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho="
},
"yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"dependencies": {
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
}
}
}
}
}

@ -2,10 +2,10 @@
"name": "grpc-examples", "name": "grpc-examples",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@grpc/proto-loader": "^0.1.0", "@grpc/proto-loader": "^0.5.0",
"async": "^1.5.2", "async": "^1.5.2",
"google-protobuf": "^3.0.0", "google-protobuf": "^3.0.0",
"grpc": "^1.11.0", "@grpc/grpc-js": "^1.1.0",
"lodash": "^4.6.1", "lodash": "^4.6.1",
"minimist": "^1.2.0" "minimist": "^1.2.0"
} }

@ -3,6 +3,6 @@ This is the static code generation variant of the Node examples. Code in these e
```sh ```sh
cd ../../protos cd ../../protos
npm install -g grpc-tools npm install -g grpc-tools
grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../node/static_codegen/ --grpc_out=../node/static_codegen --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` helloworld.proto grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../node/static_codegen/ --grpc_out=grpc_js:../node/static_codegen helloworld.proto
grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../node/static_codegen/route_guide/ --grpc_out=../node/static_codegen/route_guide/ --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` route_guide.proto grpc_tools_node_protoc --js_out=import_style=commonjs,binary:../node/static_codegen/route_guide/ --grpc_out=grpc_js:../node/static_codegen/route_guide/ route_guide.proto
``` ```

@ -19,7 +19,7 @@
var messages = require('./helloworld_pb'); var messages = require('./helloworld_pb');
var services = require('./helloworld_grpc_pb'); var services = require('./helloworld_grpc_pb');
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
function main() { function main() {
var client = new services.GreeterClient('localhost:50051', var client = new services.GreeterClient('localhost:50051',

@ -19,7 +19,7 @@
var messages = require('./helloworld_pb'); var messages = require('./helloworld_pb');
var services = require('./helloworld_grpc_pb'); var services = require('./helloworld_grpc_pb');
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
/** /**
* Implements the SayHello RPC method. * Implements the SayHello RPC method.
@ -37,8 +37,9 @@ function sayHello(call, callback) {
function main() { function main() {
var server = new grpc.Server(); var server = new grpc.Server();
server.addService(services.GreeterService, {sayHello: sayHello}); server.addService(services.GreeterService, {sayHello: sayHello});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
server.start(); server.start();
});
} }
main(); main();

@ -16,28 +16,28 @@
// limitations under the License. // limitations under the License.
// //
'use strict'; 'use strict';
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
var helloworld_pb = require('./helloworld_pb.js'); var helloworld_pb = require('./helloworld_pb.js');
function serialize_HelloReply(arg) { function serialize_helloworld_HelloReply(arg) {
if (!(arg instanceof helloworld_pb.HelloReply)) { if (!(arg instanceof helloworld_pb.HelloReply)) {
throw new Error('Expected argument of type HelloReply'); throw new Error('Expected argument of type helloworld.HelloReply');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_HelloReply(buffer_arg) { function deserialize_helloworld_HelloReply(buffer_arg) {
return helloworld_pb.HelloReply.deserializeBinary(new Uint8Array(buffer_arg)); return helloworld_pb.HelloReply.deserializeBinary(new Uint8Array(buffer_arg));
} }
function serialize_HelloRequest(arg) { function serialize_helloworld_HelloRequest(arg) {
if (!(arg instanceof helloworld_pb.HelloRequest)) { if (!(arg instanceof helloworld_pb.HelloRequest)) {
throw new Error('Expected argument of type HelloRequest'); throw new Error('Expected argument of type helloworld.HelloRequest');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_HelloRequest(buffer_arg) { function deserialize_helloworld_HelloRequest(buffer_arg) {
return helloworld_pb.HelloRequest.deserializeBinary(new Uint8Array(buffer_arg)); return helloworld_pb.HelloRequest.deserializeBinary(new Uint8Array(buffer_arg));
} }
@ -51,10 +51,10 @@ var GreeterService = exports.GreeterService = {
responseStream: false, responseStream: false,
requestType: helloworld_pb.HelloRequest, requestType: helloworld_pb.HelloRequest,
responseType: helloworld_pb.HelloReply, responseType: helloworld_pb.HelloReply,
requestSerialize: serialize_HelloRequest, requestSerialize: serialize_helloworld_HelloRequest,
requestDeserialize: deserialize_HelloRequest, requestDeserialize: deserialize_helloworld_HelloRequest,
responseSerialize: serialize_HelloReply, responseSerialize: serialize_helloworld_HelloReply,
responseDeserialize: deserialize_HelloReply, responseDeserialize: deserialize_helloworld_HelloReply,
}, },
}; };

@ -1,6 +1,9 @@
// source: helloworld.proto
/** /**
* @fileoverview * @fileoverview
* @enhanceable * @enhanceable
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public * @public
*/ */
// GENERATED CODE -- DO NOT EDIT! // GENERATED CODE -- DO NOT EDIT!
@ -11,7 +14,6 @@ var global = Function('return this')();
goog.exportSymbol('proto.helloworld.HelloReply', null, global); goog.exportSymbol('proto.helloworld.HelloReply', null, global);
goog.exportSymbol('proto.helloworld.HelloRequest', null, global); goog.exportSymbol('proto.helloworld.HelloRequest', null, global);
/** /**
* Generated by JsPbCodeGenerator. * Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a * @param {Array=} opt_data Optional initial data array, typically from a
@ -27,19 +29,47 @@ proto.helloworld.HelloRequest = function(opt_data) {
}; };
goog.inherits(proto.helloworld.HelloRequest, jspb.Message); goog.inherits(proto.helloworld.HelloRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) { if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.helloworld.HelloRequest.displayName = 'proto.helloworld.HelloRequest'; proto.helloworld.HelloRequest.displayName = 'proto.helloworld.HelloRequest';
} }
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.helloworld.HelloReply = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.helloworld.HelloReply, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.helloworld.HelloReply.displayName = 'proto.helloworld.HelloReply';
}
if (jspb.Message.GENERATE_TO_OBJECT) { if (jspb.Message.GENERATE_TO_OBJECT) {
/** /**
* Creates an object representation of this proto suitable for use in Soy templates. * Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name. * Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see: * For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. * net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance * @param {boolean=} opt_includeInstance Deprecated. whether to include the
* for transitional soy proto support: http://goto/soy-param-migration * JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object} * @return {!Object}
*/ */
proto.helloworld.HelloRequest.prototype.toObject = function(opt_includeInstance) { proto.helloworld.HelloRequest.prototype.toObject = function(opt_includeInstance) {
@ -49,15 +79,16 @@ proto.helloworld.HelloRequest.prototype.toObject = function(opt_includeInstance)
/** /**
* Static version of the {@see toObject} method. * Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB * @param {boolean|undefined} includeInstance Deprecated. Whether to include
* instance for transitional soy proto support: * the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration * http://goto/soy-param-migration
* @param {!proto.helloworld.HelloRequest} msg The msg instance to transform. * @param {!proto.helloworld.HelloRequest} msg The msg instance to transform.
* @return {!Object} * @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/ */
proto.helloworld.HelloRequest.toObject = function(includeInstance, msg) { proto.helloworld.HelloRequest.toObject = function(includeInstance, msg) {
var f, obj = { var f, obj = {
name: msg.getName() name: jspb.Message.getFieldWithDefault(msg, 1, "")
}; };
if (includeInstance) { if (includeInstance) {
@ -107,36 +138,27 @@ proto.helloworld.HelloRequest.deserializeBinaryFromReader = function(msg, reader
}; };
/**
* Class method variant: serializes the given message to binary data
* (in protobuf wire format), writing to the given BinaryWriter.
* @param {!proto.helloworld.HelloRequest} message
* @param {!jspb.BinaryWriter} writer
*/
proto.helloworld.HelloRequest.serializeBinaryToWriter = function(message, writer) {
message.serializeBinaryToWriter(writer);
};
/** /**
* Serializes the message to binary data (in protobuf wire format). * Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array} * @return {!Uint8Array}
*/ */
proto.helloworld.HelloRequest.prototype.serializeBinary = function() { proto.helloworld.HelloRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter(); var writer = new jspb.BinaryWriter();
this.serializeBinaryToWriter(writer); proto.helloworld.HelloRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer(); return writer.getResultBuffer();
}; };
/** /**
* Serializes the message to binary data (in protobuf wire format), * Serializes the given message to binary data (in protobuf wire
* writing to the given BinaryWriter. * format), writing to the given BinaryWriter.
* @param {!proto.helloworld.HelloRequest} message
* @param {!jspb.BinaryWriter} writer * @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/ */
proto.helloworld.HelloRequest.prototype.serializeBinaryToWriter = function (writer) { proto.helloworld.HelloRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined; var f = undefined;
f = this.getName(); f = message.getName();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
1, 1,
@ -146,59 +168,38 @@ proto.helloworld.HelloRequest.prototype.serializeBinaryToWriter = function (writ
}; };
/**
* Creates a deep clone of this proto. No data is shared with the original.
* @return {!proto.helloworld.HelloRequest} The clone.
*/
proto.helloworld.HelloRequest.prototype.cloneMessage = function() {
return /** @type {!proto.helloworld.HelloRequest} */ (jspb.Message.cloneMessage(this));
};
/** /**
* optional string name = 1; * optional string name = 1;
* @return {string} * @return {string}
*/ */
proto.helloworld.HelloRequest.prototype.getName = function() { proto.helloworld.HelloRequest.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
}; };
/** @param {string} value */ /**
* @param {string} value
* @return {!proto.helloworld.HelloRequest} returns this
*/
proto.helloworld.HelloRequest.prototype.setName = function(value) { proto.helloworld.HelloRequest.prototype.setName = function(value) {
jspb.Message.setField(this, 1, value); return jspb.Message.setProto3StringField(this, 1, value);
}; };
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.helloworld.HelloReply = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.helloworld.HelloReply, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.helloworld.HelloReply.displayName = 'proto.helloworld.HelloReply';
}
if (jspb.Message.GENERATE_TO_OBJECT) { if (jspb.Message.GENERATE_TO_OBJECT) {
/** /**
* Creates an object representation of this proto suitable for use in Soy templates. * Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name. * Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see: * For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. * net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance * @param {boolean=} opt_includeInstance Deprecated. whether to include the
* for transitional soy proto support: http://goto/soy-param-migration * JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object} * @return {!Object}
*/ */
proto.helloworld.HelloReply.prototype.toObject = function(opt_includeInstance) { proto.helloworld.HelloReply.prototype.toObject = function(opt_includeInstance) {
@ -208,15 +209,16 @@ proto.helloworld.HelloReply.prototype.toObject = function(opt_includeInstance) {
/** /**
* Static version of the {@see toObject} method. * Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB * @param {boolean|undefined} includeInstance Deprecated. Whether to include
* instance for transitional soy proto support: * the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration * http://goto/soy-param-migration
* @param {!proto.helloworld.HelloReply} msg The msg instance to transform. * @param {!proto.helloworld.HelloReply} msg The msg instance to transform.
* @return {!Object} * @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/ */
proto.helloworld.HelloReply.toObject = function(includeInstance, msg) { proto.helloworld.HelloReply.toObject = function(includeInstance, msg) {
var f, obj = { var f, obj = {
message: msg.getMessage() message: jspb.Message.getFieldWithDefault(msg, 1, "")
}; };
if (includeInstance) { if (includeInstance) {
@ -266,36 +268,27 @@ proto.helloworld.HelloReply.deserializeBinaryFromReader = function(msg, reader)
}; };
/**
* Class method variant: serializes the given message to binary data
* (in protobuf wire format), writing to the given BinaryWriter.
* @param {!proto.helloworld.HelloReply} message
* @param {!jspb.BinaryWriter} writer
*/
proto.helloworld.HelloReply.serializeBinaryToWriter = function(message, writer) {
message.serializeBinaryToWriter(writer);
};
/** /**
* Serializes the message to binary data (in protobuf wire format). * Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array} * @return {!Uint8Array}
*/ */
proto.helloworld.HelloReply.prototype.serializeBinary = function() { proto.helloworld.HelloReply.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter(); var writer = new jspb.BinaryWriter();
this.serializeBinaryToWriter(writer); proto.helloworld.HelloReply.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer(); return writer.getResultBuffer();
}; };
/** /**
* Serializes the message to binary data (in protobuf wire format), * Serializes the given message to binary data (in protobuf wire
* writing to the given BinaryWriter. * format), writing to the given BinaryWriter.
* @param {!proto.helloworld.HelloReply} message
* @param {!jspb.BinaryWriter} writer * @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/ */
proto.helloworld.HelloReply.prototype.serializeBinaryToWriter = function (writer) { proto.helloworld.HelloReply.serializeBinaryToWriter = function(message, writer) {
var f = undefined; var f = undefined;
f = this.getMessage(); f = message.getMessage();
if (f.length > 0) { if (f.length > 0) {
writer.writeString( writer.writeString(
1, 1,
@ -305,27 +298,21 @@ proto.helloworld.HelloReply.prototype.serializeBinaryToWriter = function (writer
}; };
/**
* Creates a deep clone of this proto. No data is shared with the original.
* @return {!proto.helloworld.HelloReply} The clone.
*/
proto.helloworld.HelloReply.prototype.cloneMessage = function() {
return /** @type {!proto.helloworld.HelloReply} */ (jspb.Message.cloneMessage(this));
};
/** /**
* optional string message = 1; * optional string message = 1;
* @return {string} * @return {string}
*/ */
proto.helloworld.HelloReply.prototype.getMessage = function() { proto.helloworld.HelloReply.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
}; };
/** @param {string} value */ /**
* @param {string} value
* @return {!proto.helloworld.HelloReply} returns this
*/
proto.helloworld.HelloReply.prototype.setMessage = function(value) { proto.helloworld.HelloReply.prototype.setMessage = function(value) {
jspb.Message.setField(this, 1, value); return jspb.Message.setProto3StringField(this, 1, value);
}; };

@ -24,7 +24,7 @@ var fs = require('fs');
var parseArgs = require('minimist'); var parseArgs = require('minimist');
var path = require('path'); var path = require('path');
var _ = require('lodash'); var _ = require('lodash');
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
var client = new services.RouteGuideClient('localhost:50051', var client = new services.RouteGuideClient('localhost:50051',
grpc.credentials.createInsecure()); grpc.credentials.createInsecure());

@ -16,61 +16,61 @@
// limitations under the License. // limitations under the License.
// //
'use strict'; 'use strict';
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
var route_guide_pb = require('./route_guide_pb.js'); var route_guide_pb = require('./route_guide_pb.js');
function serialize_Feature(arg) { function serialize_routeguide_Feature(arg) {
if (!(arg instanceof route_guide_pb.Feature)) { if (!(arg instanceof route_guide_pb.Feature)) {
throw new Error('Expected argument of type Feature'); throw new Error('Expected argument of type routeguide.Feature');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_Feature(buffer_arg) { function deserialize_routeguide_Feature(buffer_arg) {
return route_guide_pb.Feature.deserializeBinary(new Uint8Array(buffer_arg)); return route_guide_pb.Feature.deserializeBinary(new Uint8Array(buffer_arg));
} }
function serialize_Point(arg) { function serialize_routeguide_Point(arg) {
if (!(arg instanceof route_guide_pb.Point)) { if (!(arg instanceof route_guide_pb.Point)) {
throw new Error('Expected argument of type Point'); throw new Error('Expected argument of type routeguide.Point');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_Point(buffer_arg) { function deserialize_routeguide_Point(buffer_arg) {
return route_guide_pb.Point.deserializeBinary(new Uint8Array(buffer_arg)); return route_guide_pb.Point.deserializeBinary(new Uint8Array(buffer_arg));
} }
function serialize_Rectangle(arg) { function serialize_routeguide_Rectangle(arg) {
if (!(arg instanceof route_guide_pb.Rectangle)) { if (!(arg instanceof route_guide_pb.Rectangle)) {
throw new Error('Expected argument of type Rectangle'); throw new Error('Expected argument of type routeguide.Rectangle');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_Rectangle(buffer_arg) { function deserialize_routeguide_Rectangle(buffer_arg) {
return route_guide_pb.Rectangle.deserializeBinary(new Uint8Array(buffer_arg)); return route_guide_pb.Rectangle.deserializeBinary(new Uint8Array(buffer_arg));
} }
function serialize_RouteNote(arg) { function serialize_routeguide_RouteNote(arg) {
if (!(arg instanceof route_guide_pb.RouteNote)) { if (!(arg instanceof route_guide_pb.RouteNote)) {
throw new Error('Expected argument of type RouteNote'); throw new Error('Expected argument of type routeguide.RouteNote');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_RouteNote(buffer_arg) { function deserialize_routeguide_RouteNote(buffer_arg) {
return route_guide_pb.RouteNote.deserializeBinary(new Uint8Array(buffer_arg)); return route_guide_pb.RouteNote.deserializeBinary(new Uint8Array(buffer_arg));
} }
function serialize_RouteSummary(arg) { function serialize_routeguide_RouteSummary(arg) {
if (!(arg instanceof route_guide_pb.RouteSummary)) { if (!(arg instanceof route_guide_pb.RouteSummary)) {
throw new Error('Expected argument of type RouteSummary'); throw new Error('Expected argument of type routeguide.RouteSummary');
} }
return new Buffer(arg.serializeBinary()); return Buffer.from(arg.serializeBinary());
} }
function deserialize_RouteSummary(buffer_arg) { function deserialize_routeguide_RouteSummary(buffer_arg) {
return route_guide_pb.RouteSummary.deserializeBinary(new Uint8Array(buffer_arg)); return route_guide_pb.RouteSummary.deserializeBinary(new Uint8Array(buffer_arg));
} }
@ -89,10 +89,10 @@ var RouteGuideService = exports.RouteGuideService = {
responseStream: false, responseStream: false,
requestType: route_guide_pb.Point, requestType: route_guide_pb.Point,
responseType: route_guide_pb.Feature, responseType: route_guide_pb.Feature,
requestSerialize: serialize_Point, requestSerialize: serialize_routeguide_Point,
requestDeserialize: deserialize_Point, requestDeserialize: deserialize_routeguide_Point,
responseSerialize: serialize_Feature, responseSerialize: serialize_routeguide_Feature,
responseDeserialize: deserialize_Feature, responseDeserialize: deserialize_routeguide_Feature,
}, },
// A server-to-client streaming RPC. // A server-to-client streaming RPC.
// //
@ -106,10 +106,10 @@ var RouteGuideService = exports.RouteGuideService = {
responseStream: true, responseStream: true,
requestType: route_guide_pb.Rectangle, requestType: route_guide_pb.Rectangle,
responseType: route_guide_pb.Feature, responseType: route_guide_pb.Feature,
requestSerialize: serialize_Rectangle, requestSerialize: serialize_routeguide_Rectangle,
requestDeserialize: deserialize_Rectangle, requestDeserialize: deserialize_routeguide_Rectangle,
responseSerialize: serialize_Feature, responseSerialize: serialize_routeguide_Feature,
responseDeserialize: deserialize_Feature, responseDeserialize: deserialize_routeguide_Feature,
}, },
// A client-to-server streaming RPC. // A client-to-server streaming RPC.
// //
@ -121,10 +121,10 @@ var RouteGuideService = exports.RouteGuideService = {
responseStream: false, responseStream: false,
requestType: route_guide_pb.Point, requestType: route_guide_pb.Point,
responseType: route_guide_pb.RouteSummary, responseType: route_guide_pb.RouteSummary,
requestSerialize: serialize_Point, requestSerialize: serialize_routeguide_Point,
requestDeserialize: deserialize_Point, requestDeserialize: deserialize_routeguide_Point,
responseSerialize: serialize_RouteSummary, responseSerialize: serialize_routeguide_RouteSummary,
responseDeserialize: deserialize_RouteSummary, responseDeserialize: deserialize_routeguide_RouteSummary,
}, },
// A Bidirectional streaming RPC. // A Bidirectional streaming RPC.
// //
@ -136,10 +136,10 @@ var RouteGuideService = exports.RouteGuideService = {
responseStream: true, responseStream: true,
requestType: route_guide_pb.RouteNote, requestType: route_guide_pb.RouteNote,
responseType: route_guide_pb.RouteNote, responseType: route_guide_pb.RouteNote,
requestSerialize: serialize_RouteNote, requestSerialize: serialize_routeguide_RouteNote,
requestDeserialize: deserialize_RouteNote, requestDeserialize: deserialize_routeguide_RouteNote,
responseSerialize: serialize_RouteNote, responseSerialize: serialize_routeguide_RouteNote,
responseDeserialize: deserialize_RouteNote, responseDeserialize: deserialize_routeguide_RouteNote,
}, },
}; };

File diff suppressed because it is too large Load Diff

@ -23,7 +23,7 @@ var fs = require('fs');
var parseArgs = require('minimist'); var parseArgs = require('minimist');
var path = require('path'); var path = require('path');
var _ = require('lodash'); var _ = require('lodash');
var grpc = require('grpc'); var grpc = require('@grpc/grpc-js');
var COORD_FACTOR = 1e7; var COORD_FACTOR = 1e7;
@ -220,7 +220,7 @@ function getServer() {
if (require.main === module) { if (require.main === module) {
// If this is run as a script, start a server on an unused port // If this is run as a script, start a server on an unused port
var routeServer = getServer(); var routeServer = getServer();
routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); routeServer.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), () => {
var argv = parseArgs(process.argv, { var argv = parseArgs(process.argv, {
string: 'db_path' string: 'db_path'
}); });
@ -238,6 +238,7 @@ if (require.main === module) {
}); });
routeServer.start(); routeServer.start();
}); });
});
} }
exports.getServer = getServer; exports.getServer = getServer;

Loading…
Cancel
Save