Simple RPC with Protobuf Services
|
||
---|---|---|
example | ||
hrpc | ||
.drone.yml | ||
.gitignore | ||
CHANGELOG.md | ||
LICENSE | ||
poetry.lock | ||
pyproject.toml | ||
README.md |
hrpc
Simple RPC with Protobuf Services
Install
$ pip install hrpc
Example
TLDR; See the example directory
Define an RPC service in a schema.proto
.
syntax = "proto2";
message EchoMsg {
required string value = 1;
}
service Example {
rpc Echo (EchoMsg) returns (EchoMsg) {}
}
Then generate the services and stubs with hrpc
.
$ pip install hrpc
$ hrpc schema.proto
This creates schema_gprc.py
(services) and schema_pb2.py
(stubs) files.
You can then write a async-ready server and client like so.
# server.py
# client.py
And run them in separate terminals to see the output.
$ python server.py # terminal 1
$ python client.py # terminal 2
Go forth and Remote Procedure Call.