fast to code grpc in python
Project description
fast-grpc
fast to code grpc in Python 3.7+
Installation
Require Python 3.7+
pip install python-fast-grpc
Quick start
- Run a gRPC application
from fast_grpc import BaseSchema, FastGRPC
rpc = FastGRPC("Greeter")
class HelloRequest(BaseSchema):
name: str
class HelloReply(BaseSchema):
message: str
@rpc.add_method("SayHello", request_model=HelloRequest, response_model=HelloReply)
async def say_hello(request: HelloRequest) -> HelloReply:
return HelloReply(message=f"Hello {request.name}")
# this step will generate .proto file and python gRPC code, then start a grpc server
rpc.run()
- run client invoke
import grpc
import greeter_pb2 as pb2
import greeter_pb2_grpc as pb2_grpc
channel = grpc.insecure_channel("127.0.0.1:50051")
stub = pb2_grpc.GreeterStub(channel)
response = stub.SayHello(pb2.HelloRequest(name="fastGRPC"))
print("Greeter client received: ", response)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_fast_grpc-0.1.2.tar.gz
(13.5 kB
view hashes)
Built Distribution
Close
Hashes for python_fast_grpc-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 667eb383454d2012a28ded4b7dedd2251b9bc0cac0b8c1ec3c216fa7fdc685e5 |
|
MD5 | 5c934da1e4bd4efa0915a16eb56f820f |
|
BLAKE2b-256 | db83c2859430d79e5181f1427ea17a4aa04e879b563bd2d6b5a797f9586867bb |