{"id":15489280,"url":"https://github.com/klen/muffin-grpc","last_synced_at":"2026-03-06T19:02:05.018Z","repository":{"id":50864917,"uuid":"344480627","full_name":"klen/muffin-grpc","owner":"klen","description":"GRPC Support for Muffin Framework","archived":false,"fork":false,"pushed_at":"2025-07-15T11:59:05.000Z","size":259,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-07-16T00:22:35.474Z","etag":null,"topics":["asyncio","grpc","grpc-python","muffin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klen.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/codeowners","security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-04T13:17:31.000Z","updated_at":"2025-07-15T11:59:08.000Z","dependencies_parsed_at":"2025-03-04T04:30:43.137Z","dependency_job_id":"0f339209-fc77-407b-b4bf-f5c9fcef9806","html_url":"https://github.com/klen/muffin-grpc","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/klen/muffin-grpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klen","download_url":"https://codeload.github.com/klen/muffin-grpc/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klen%2Fmuffin-grpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266424014,"owners_count":23926123,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","grpc","grpc-python","muffin"],"created_at":"2024-10-02T07:04:46.706Z","updated_at":"2026-03-06T19:01:59.991Z","avatar_url":"https://github.com/klen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Muffin-GRPC\n############\n\n.. image:: https://github.com/klen/muffin-grpc/workflows/tests/badge.svg\n    :target: https://github.com/klen/muffin-grpc/actions\n    :alt: Tests Status\n\n.. image:: https://img.shields.io/pypi/v/muffin-grpc\n    :target: https://pypi.org/project/muffin-grpc/\n    :alt: PyPI Version\n\n**Muffin-GRPC** is a plugin for the Muffin_ framework that brings gRPC support to your application.\n\n.. contents::\n\nFeatures\n========\n\n- 📦 Automatically compiles `.proto` files to Python\n- ⚙️ Simplified gRPC server and client integration\n- 🔁 CLI commands to manage proto compilation and server lifecycle\n- 🧩 Automatically handles proto dependencies and import fixes\n- 🧪 Designed with asyncio and modern Python standards\n\nRequirements\n============\n\n- Python \u003e= 3.10\n- `grpcio`\n- `grpcio-tools`\n- `protobuf`\n- `muffin`\n\n.. note:: This plugin supports only the asyncio event loop (Trio is not supported).\n\nInstallation\n============\n\nInstall via pip:\n\n.. code-block:: shell\n\n    pip install muffin-grpc\n\nUsage\n=====\n\nSet up the plugin and attach it to your Muffin application:\n\n.. code-block:: python\n\n    from muffin import Application\n    from muffin_grpc import Plugin as GRPC\n\n    app = Application(\"example\")\n    grpc = GRPC(default_channel=\"localhost:50051\")\n    grpc.setup(app)\n\nCreate a `helloworld.proto`:\n\n.. code-block:: proto\n\n    syntax = \"proto3\";\n\n    package helloworld;\n\n    service Greeter {\n        rpc SayHello (HelloRequest) returns (HelloReply);\n    }\n\n    message HelloRequest {\n        string name = 1;\n    }\n\n    message HelloReply {\n        string message = 1;\n    }\n\nRegister the file:\n\n.. code-block:: python\n\n    grpc.add_proto(\"project_name/proto/helloworld.proto\")\n\nCompile proto files:\n\n.. code-block:: shell\n\n    muffin project_name grpc_build\n\nThis generates:\n\n- `helloworld_pb2.py` — messages\n- `helloworld_pb2_grpc.py` — gRPC services\n- `helloworld.py` — bundled import helper\n- `__init__.py` — so the folder is importable\n\n.. note:: Muffin-GRPC automatically fixes Python imports.\n\nNow implement the Greeter service:\n\n.. code-block:: python\n\n    from .proto.helloworld import GreeterServicer, HelloReply, HelloRequest\n    import grpc.aio as grpc_aio\n\n    @grpc.add_to_server\n    class Greeter(GreeterServicer):\n\n        async def SayHello(\n            self, request: HelloRequest, context: grpc_aio.ServicerContext\n        ) -\u003e HelloReply:\n            return HelloReply(message=f\"Hello, {request.name}!\")\n\nRun the gRPC server:\n\n.. code-block:: shell\n\n    muffin project_name grpc_server\n\nClient example:\n\n.. code-block:: python\n\n    from .proto.helloworld import GreeterStub, HelloRequest\n    from aiohttp.web import Application, Response\n\n    @app.route(\"/\")\n    async def index(request):\n        name = request.url.query.get(\"name\", \"anonymous\")\n        try:\n            async with grpc.get_channel() as channel:\n                stub = GreeterStub(channel)\n                response = await stub.SayHello(HelloRequest(name=name), timeout=10)\n                return Response(text=response.message)\n\n        except grpc_aio.AioRpcError as exc:\n            return Response(text=exc.details())\n\nConfiguration\n=============\n\nYou can configure the plugin either via `setup()` or using `GRPC_` prefixed settings in the Muffin app config.\n\n**Available options:**\n\n=========================== ================================ =========================================\nName                        Default value                    Description\n=========================== ================================ =========================================\n**build_dir**               `None`                           Directory to store compiled files\n**server_listen**           `\"[::]:50051\"`                   gRPC server address\n**ssl_server**              `False`                          Enable SSL for server\n**ssl_server_params**       `None`                           Tuple of credentials for SSL server\n**ssl_client**              `False`                          Enable SSL for client\n**ssl_client_params**       `None`                           Tuple of credentials for SSL client\n**default_channel**         `\"localhost:50051\"`              Default gRPC client target\n**default_channel_options** `{}`                             Additional gRPC options\n=========================== ================================ =========================================\n\nVia `setup()`:\n\n.. code-block:: python\n\n    grpc.setup(app, server_listen=\"localhost:40000\")\n\nOr from config:\n\n.. code-block:: python\n\n    GRPC_SERVER_LISTEN = \"localhost:40000\"\n\nCLI Commands\n============\n\nBuild registered proto files:\n\n.. code-block:: shell\n\n    muffin project_name grpc_build\n\nStart the gRPC server:\n\n.. code-block:: shell\n\n    muffin project_name grpc_server\n\n\nBug Tracker\n===========\n\nFound a bug or have a suggestion?\nSubmit an issue here: https://github.com/klen/muffin-grpc/issues\n\nContributing\n============\n\nWant to contribute? Pull requests are welcome!\nDevelopment happens at: https://github.com/klen/muffin-grpc\n\nLicense\n=======\n\nLicensed under the `MIT license`_.\n\n.. _Muffin: https://github.com/klen/muffin\n.. _MIT license: http://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklen%2Fmuffin-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklen%2Fmuffin-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklen%2Fmuffin-grpc/lists"}