-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
RPC server code example? #742
Comments
You are right, there is neither specific server-side code nor documentation currently. It is intentional, though, that the library does not make any assumptions about the actual transport channel. Also note that such a transport channel differs significantly on the server because the server does not just send and receive messages like a client but actually processes requests. For example, if your server is based on http requests, it'd require an http library and probably some sort of routing. The routing then defines which message type is used to decode received data, then executing specific logic and encoding a response. Nonetheless, there are server-side RPC implementations provided for specific use cases or libraries afaik, for example one using express (seems to be a bit outdated though). |
Thanks for the quick reply. The express-protobuf code is an example of code that does something similar to what I'm trying to do (protobuf RPC over express), so thanks for that. It is, however, an undocumented, terse, hard to follow example. I am starting to understand it. Even if it is intentional that Protobuf.js does not make assumptions about the transport channel, it would make the example code on your project's page much clearer if you add / modify these things in the docs:
|
Closing this issue for now as it hasn't received any replies recently. Feel free to reopen it if necessary! |
Yes, that's fine. Thank you for your edits. I read through them and it all appeared to be helpful improvements. I'm still of the opinion that the docs are missing several fundamental things, but I may contribute to improving that in the future. Thanks for your help! |
I agree that there should be no implementation in protobufjs for an RPC server. The whole reason we're attempting to use this project is that it's hands off on the transport mechanism and is just a mature encoding/decoding library with TS support. That being said, there should be enough in the documentation to give hints at how to implement a server. For instance, how to read a protobuf body (binary or JSON) and determine what the message is, if it's an RPC request, what method, etc. |
protobuf.js version: 6.6.5
Hello. I'm writing a protobuf RPC service, and client code that uses it. I read all through the documentation and examples, and what I am not seeing is: a server-side code example of an RPC server. Could someone show one, or say the reason why you don't believe there should be one shown?
I see example code, with no text near it saying whether it is meant to be a client-side example or a server-side example. Shouldn't you say that by each example? Without it being explicitly labeled, it isn't clear what code is meant to be run where, since Protobuf.js can run in Node and also in a web browser. I have concluded that some of the RPC code examples are meant to be client-side, but I haven't found any examples that are clearly server-side code, so I don't know whether Protobuf.js is meant to implement both sides of the RPC or not. In fact, the documentation doesn't mention that either (shouldn't it?).
Thanks in advance!
The text was updated successfully, but these errors were encountered: