Skip to content

Latest commit

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SimpleRPC

Simple framework to create your own gRPC server with grpcio.

Installation

pip install git+https://github.com/NF-coder/SimpleRPC.git

Todo

  • Exceptions handling
  • Secure channels support
  • Autoconfigure from pydantic model
  • Source-of-truth for protos
  • Tests and docs

Quick Start

server.py

fromsimple_rpcimportGrpcServerfrompydanticimportBaseModelclassRequestModel(BaseModel):
passclassResponceModel(BaseModel):
num2: intnum4: intapp=GrpcServer()
classServer:
@app.grpc_method()asyncdefexample_method(self, request: RequestModel) ->ResponceModel:
returnResponceModel(
num2=3,
num4=1
)
app.configure_service(
cls=Server(),
port=50051
)
app.run()

client.py

frompydanticimportBaseModelfromsimple_rpcimportGrpcClientimportasyncioclient=GrpcClient(
proto_file_relpath="simplerpc_tmp/Server.proto", # Generates automatically on server startupport=50051
)
command=client.configure_command(
functionName="example_method",
className="Server"
)
asyncdefrun():
print(
awaitcommand()
)
if__name__=="__main__":
asyncio.run(
run()
)

About

Simple framework to create your own gRPC server with grpcio

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages