-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support of the protobuf protoset binary format? #556
Comments
Sorry, but what you're describing isn't a feature request for grpc-node, but for the third party package There's two ways of using grpc-node. One is the static codepath, which is using protoc at build time to generate service files, and one is the dynamic codepath, which is using the third-party protobufjs package under the hood, where you load your proto files at runtime. The static codepath is using protoc, and will therefore support protoset naturally. Please either file a feature request with protobufjs here: https://github.com/dcodeIO/protobuf.js, or switch to using protoc. |
Also, here's a link to a quick example using the static codepath: https://github.com/grpc/grpc/tree/master/examples/node/static_codegen |
About this part below, can I file a request better Documentation ticket? make better documentation about how to use this grpc.load method: does it already support parameter as { file: p, root: include } ?? does it already support multiple proto_path ? does it already support the protoset binary proto definition? |
/cc @konsumer as well... |
then should have a better linking to var grpc = require('grpc');
var protoLoader = require('@grpc/proto-loader'); lead me to its npmjs package description, both have same homepage => grpc.io repository => github ==> https://github.com/grpc/grpc-node (this repo) |
This function is flagged as deprecated. Please use the proto loader package instead, with its documentation available in it: https://www.npmjs.com/package/@grpc/proto-loader |
That's fair. The documentation already mentions protobufjs, but we could link to it as well. |
could the Deprecation being documented? https://grpc.io/grpc/node/grpc.html#.load__anchor |
I'm surprised it's not in there. We'll fix this. |
I see #558 has been merged but I wonder will |
The website will be updated for the next minor release. |
No, I checked https://grpc.io/grpc/node/grpc.html#.load__anchor ; for 2 months passed it did not happen Does it mean nobody care the documentation at https://grpc.io/grpc/node/ ? or too few users using grpc with node ? |
I got the answer from the site footnotes, it's not updated since August? Would you set up some sort of automated Documentation re-generation? otherwise the online documentation is not useful |
The documentation has now been updated for 1.16, including that deprecation notice |
still questions: is this https://grpc.io/grpc/node/grpc.html#.loadObject__anchor
it says the value Object is The ProtoBuf.js reflection object but what is that? do you have some examples how to call this the problem still comes from the protoset format support, so my solution is using a copy and modified version of the but your Documentation looks like the https://grpc.io/grpc/node/grpc.html#.loadObject__anchor but I have tried, it isn't working so, can only guess it might also be deprecated? if you have gave up your own |
One other thing I would like to mention is that it is not really accurate to say that we replaced |
ok, code is like this below: the Root object is loaded from the intention is to not use a modified const grpc = require('grpc');
const protobuf = require("protobufjs"), // requires the full library
descriptor = require("protobufjs/ext/descriptor");
const pbroot = protobuf.Root.fromDescriptor(
fs.readFileSync(path.join(__dirname, 'api-protos.bin'))
).resolveAll();
const pkgd = require('./loader.js').createPackageDefinition(
pbroot,
{ keepCase: true, longs: String, enums: String, defaults: true, oneofs: true, });
const api = grpc.loadPackageDefinition(pkgd);
const api2 = grpc.loadObject(pbroot, { protobufjsVersion: 6 });
const client = new api.api.Api(
'grpc-server-address:8443',
grpc.credentials.createSsl( ...
),
); I am expecting the /home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:140
Object.keys(value.nested).forEach(name => {
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at loadObject (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:140:12)
at Object.keys.forEach.name (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:142:22)
at Array.forEach (<anonymous>)
at loadObject (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:140:31)
at Object.keys.forEach.name (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:142:22)
at Array.forEach (<anonymous>)
at loadObject (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:140:31)
at Object.keys.forEach.name (/home/drc/tmp/node_modules/grpc/src/protobuf_js_6_common.js:142:22)
at Array.forEach (<anonymous>)
Command exited with non-zero status 1 if I pass in by then I compared what's the returned api2 object from So the question is Could you document the |
Another thing: the |
OK, as far as I know, the code you wrote there should work. If you have [email protected] installed, please switch to 1.16.1 for now. We are aware of bugs in that specific code path in 1.17.0-pre1. Based on your specific error, I think that will solve your problem. Regarding |
No; I've installed would you give any working example in the documentation? is that what you were saying const pkgd = require('@grpc/proto-loader').createPackageDefinition(pbroot, options);
const api = grpc.loadPackageDefinition( pkgd ); then a question followed is the supporting options are not exactly same: |
I sincerely doubt that your code is failing with the exact same error in version 1.16, because the referenced line of code did not exist in that form in 1.16. Can you please check what version you actually have installed? I didn't say anything about |
from konsumer/grpc-dynamic-gateway#15
and https://groups.google.com/d/msg/grpc-io/dAJz2sPwir8/TlgLny-PBgAJ nobody answered the protoset questions in this discussion thread ,
Is your feature request related to a problem? Please describe.
google searched grpc + nodejs + protoset seems nothing, and searched this issues board as well,
no one has discussed about protoset support before;
I see the compiled protoset binary format is a good solution to bundle many related
*.proto
files into a single one, it's pretty well supported by protoc compiler, and in Go language pkggithub.com/golang/protobuf
, and tools like grpcurlhttps://github.com/fullstorydev/grpcurl#protoset-files
I hope this base library should include protoset support, for tools like the grpc-dynamic-gateway to be able to load from a single protoset binary file
Describe the solution you'd like
the
golang/protobuf
package has good support of protoset support, I think this grpc-node should have similar support, to parse one binary protoset file only, instead of multiple plaintext*.proto
fileshttps://github.com/golang/protobuf/tree/master/protoc-gen-go/descriptor
Describe alternatives you've considered
No one discussed grpc + nodejs + protoset before.
Additional
make better documentation about how to use this
grpc.load
method: does it already support parameter as{ file: p, root: include }
?? does it already support multiple proto_path ? does it already support the protoset binary proto definition?https://grpc.io/grpc/node/grpc.html#.load__anchor
The text was updated successfully, but these errors were encountered: