Skip to content

Latest commit

 

History

History
98 lines (66 loc) · 2.32 KB

README.rst

File metadata and controls

98 lines (66 loc) · 2.32 KB

gRPCAlchemy

Documentation Status

The Python micro framework for building gPRC application based on official gRPC project.

Installation

$ pipenv install grpcalchemy
✨🍰✨

Only Python 3.6+ is supported.

Example

Server

from grpcalchemy.orm import Message, StringField
from grpcalchemy import Server, Context, grpcmethod

class HelloMessage(Message):
    text: str

class HelloService(Server):
    @grpcmethod
    def Hello(self, request: HelloMessage, context: Context) -> HelloMessage:
        return HelloMessage(text=f'Hello {request.text}')

if __name__ == '__main__':
    HelloService.run()

Then Using gRPC channel to connect the server:

from grpc import insecure_channel

from protos.helloservice_pb2_grpc import HelloServiceStub
from protos.hellomessage_pb2 import HelloMessage

with insecure_channel("localhost:50051") as channel:
    response = HelloServiceStub(channel).Hello(
        HelloMessage(text="world")
    )

Features

  • gPRC Service Support
  • gRPC Message Support
    • Scalar Value Types
    • Message Types
    • Repeated Field
    • Maps
  • Define Message With Type Hint
  • Middleware
  • App Context Manger
  • Error Handler Support
  • Streaming Method Support
  • gRPC-Health Checking and Reflection Support (Alpha)
  • Multiple Processor Support

TODO

  • Test Client Support
  • Async Server Support