fast to code grpc in python
Project description
fast-grpc
fast to code grpc in Python 3.9+
Installation
Require Python 3.9+
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.0.tar.gz
(12.9 kB
view hashes)
Built Distribution
Close
Hashes for python_fast_grpc-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541dcb0241e474a2d99a1b949c7435848d0f784290d4a6b51b5234be80f8894a |
|
MD5 | beb499642daed2a60f828378cad26162 |
|
BLAKE2b-256 | 6cfdeac768c49f87b914f34728ce070e4bdf27280a05b1de4cd6af254fdaf3a4 |