{"id":17343036,"url":"https://github.com/taogeyt/fast-grpc","last_synced_at":"2025-04-14T19:53:34.814Z","repository":{"id":165232542,"uuid":"637357766","full_name":"taogeYT/fast-grpc","owner":"taogeYT","description":"Fast to Code gRPC in Python","archived":false,"fork":false,"pushed_at":"2025-04-10T15:49:53.000Z","size":999,"stargazers_count":42,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T16:03:53.431Z","etag":null,"topics":["asyncio","fastapi","grpc","grpc-client","grpc-python","grpc-server","microservice","pydantic","python","rpc"],"latest_commit_sha":null,"homepage":"https://taogeYT.github.io/fast-grpc/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taogeYT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-07T10:05:52.000Z","updated_at":"2025-04-10T15:49:57.000Z","dependencies_parsed_at":"2025-01-14T18:18:59.070Z","dependency_job_id":"aceb65c9-2d35-46c8-9209-309da1cf81d4","html_url":"https://github.com/taogeYT/fast-grpc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Ffast-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Ffast-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Ffast-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taogeYT%2Ffast-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taogeYT","download_url":"https://codeload.github.com/taogeYT/fast-grpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248951980,"owners_count":21188420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","fastapi","grpc","grpc-client","grpc-python","grpc-server","microservice","pydantic","python","rpc"],"created_at":"2024-10-15T16:08:10.103Z","updated_at":"2025-04-14T19:53:34.806Z","avatar_url":"https://github.com/taogeYT.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastGRPC\n🚀 Build gRPC services in Python 3.9+ as easily as FastAPI.\n\n## Installation\nRequire Python 3.9+\n```shell\npip install python-fast-grpc\n```\n\n## A Simple Example\nDefine a gRPC service:\n```python\nfrom pydantic import BaseModel\nfrom fast_grpc import FastGRPC\n\napp = FastGRPC()\n\nclass HelloRequest(BaseModel):\n    name: str\n\nclass HelloReply(BaseModel):\n    message: str\n\n@app.unary_unary()\nasync def say_hello(request: HelloRequest) -\u003e HelloReply:\n    return HelloReply(message=f\"Greeter SayHello {request.name}\")\n\nif __name__ == '__main__':\n    app.run()\n```\nClient Test:\n```python\nimport grpc\nimport fast_grpc_pb2 as pb2\nimport fast_grpc_pb2_grpc as pb2_grpc\n\nchannel = grpc.insecure_channel(\"127.0.0.1:50051\")\nstub = pb2_grpc.FastGRPCStub(channel)\nresponse = stub.SayHello(pb2.HelloRequest(name=\"FastGRPC\"))\nprint(\"Client received: \", response)\n```\n## Use Middleware\n```python\n@app.middleware()\nasync def middleware(call_next, request, context):\n    print(\"before request\")\n    response = await call_next(request, context)\n    print(\"after request\")\n    return response\n\n@app.middleware(is_server_streaming=True)\nasync def middleware(call_next, request, context):\n    print(\"before streaming request\")\n    async for response in call_next(request, context):\n        yield response\n    print(\"after streaming request\")\n```\n## Service\nUse Service for modular design, similar to FastAPI's router.\n```python\nfrom fast_grpc import Service\nsrv = Service(name=\"Greeter\")\n\n@srv.unary_unary()\nasync def say_again(request: HelloRequest) -\u003e HelloReply:\n    return HelloReply(message=f\"Greeter SayHello {request.name}\")\n```\n## Pb2Service\nUse Pb2Service if you're working with generated *_pb2.py and *_pb2_grpc.py files.\n```python\nimport greeter_pb2\nimport greeter_pb2_grpc\nsrv = Pb2Service(\"Greeter\", pb2_module=greeter_pb2, pb2_grpc_module=greeter_pb2_grpc)\n\n@srv.unary_unary()\nasync def say_again(request: HelloRequest) -\u003e HelloReply:\n    return HelloReply(message=f\"Greeter SayHello {request.name}\")\n```\n## Generate Clients Using Pydantic\nAutomatically generate a Pydantic-based gRPC client from .proto files:\n```python\nfrom fast_grpc.proto import proto_to_python_client\nproto_to_python_client(\"fast_grpc.proto\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaogeyt%2Ffast-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaogeyt%2Ffast-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaogeyt%2Ffast-grpc/lists"}