I found an excellent article on this very topic and decided to extend this a bit further with a client in NodeJS as well. Make sure you run the (Rust) server first.
We will need to use
Tonic
Tonic is a super lightweight gRPC implementation with batteries (prost, hyper, and protobuf) included to build both gRPC servers and clients. The server and client can leverage HTTP/2 and code generation to generate the necessary code for individual services from standard protocol buffer specifications (.proto).
This trivial example is still a private repository, but I will clean it up when time permits and share a link here - TBD.
Use the following to interact with the node client:
-> % node client.js --vote 0 --url foo.com
Resp: { confirmation: 'Happy to confirm that you upvoted for foo.com' }
-> % node client.js --vote 1 --url foo.com
Resp: { confirmation: 'Confirmation that you downvoted for foo.com' }
I can interact with the server using the Rust client as well
[16:47] M1MaxMacBookPro.local:client (master *%) | cargo r
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/client`
Please vote for a particular url
Please provide a url:
cnn.com
Please vote (d)own or (u)p:
u
Got: 'Happy to confirm that you upvoted for cnn.com' from service
Please vote for a particular url
Please provide a url:
cnn.com
Please vote (d)own or (u)p:
d
Got: 'Confirmation that you downvoted for cnn.com' from service
Please vote for a particular url
Please provide a url:
Error: URL is required.