diff --git a/example/client.py b/example/client.py new file mode 100644 index 0000000..1e7dc84 --- /dev/null +++ b/example/client.py @@ -0,0 +1,4 @@ +"""Echo client.""" + +if __name__ == "__main__": + pass diff --git a/example/schema.proto b/example/schema.proto new file mode 100644 index 0000000..3247e86 --- /dev/null +++ b/example/schema.proto @@ -0,0 +1,9 @@ +syntax = "proto2"; + +message EchoMsg { + required string value = 1; +} + +service Example { + rpc Echo (EchoMsg) returns (EchoMsg) {} +} diff --git a/example/server.py b/example/server.py new file mode 100644 index 0000000..1921bbe --- /dev/null +++ b/example/server.py @@ -0,0 +1,4 @@ +"""Echo server.""" + +if __name__ == "__main__": + pass diff --git a/hrpc/hrpc.py b/hrpc/hrpc.py new file mode 100644 index 0000000..b8eb2fe --- /dev/null +++ b/hrpc/hrpc.py @@ -0,0 +1,24 @@ +"""Simple RPC with Protobuf Services.""" +from argparse import ArgumentParser, FileType +from shlex import split +from subprocess import run + + +def main(): + """Command-line entrypoint.""" + parser = ArgumentParser(description="Generate hrpc service and stubs") + parser.add_argument("protobuf", type=FileType("r"), help="protobuf file") + args = parser.parse_args() + generate(args) + + +def generate(args): + """Generate services and stubs.""" + cmd = ( + "python -m grpc_tools.protoc " + "--purerpc_out=. " + "--python_out=. " + "-I. " + f"{args.protobuf.name}" + ) + run(split(cmd))