{ "info": { "author": "Ian Murphy", "author_email": "3jackdaws@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Distributed ASGI\nUses Redis to distribute ASGI messages between worker ASGI apps based on routes. Workers can be on different machines, they just must be able to connect to the central Redis server.\n\n\n# Usage\n\nRoutes are made of two parts: a regular expression that matches a path, and a key template string that is used to form the key that ASGI events are pushed to.\n\nKey templates can also use numbered regex backslash replacements. For example, the route `{\"/api/([a-z-]+)\":r\"API-\\1\"}` will match and produce the following keys:\n\n```\nPATH KEY\n/api/test API-test\n/api/test/38 API-test\n/api/banana API-banana\n/test/api/test2 API-test2\n```\n\nHere's an example:\n\n```py\n# distributor.py\nfrom distributed_asgi import create_path_distributor\n\napp = create_path_distributor(\n host=\"mywebsite.com\", # point to redis server\n port=6379,\n db=0,\n password=\"abc123\",\n routes={\n \"/api/([a-z-]+)\": r\"ASGI-\\1\",\n \"/worker/([0-9]+)\": r\"worker-queue-\\1\",\n \"/\": \"ALL-WEBSITE-TRAFFIC\"\n }\n)\n\n```\n\nTo actually make use of this, we need to make a worker that listens on one or more of the keys\n\n\n```py\n# worker.py\nfrom distributed_asgi import Node\n\n\nclass ASGIApp:\n def __init__(self, scope):\n self.scope = scope\n\n async def __call__(self, receive, send):\n await send({\n \"type\": \"http.response.start\",\n \"status\": 200\n })\n\n await send({\n \"type\": \"http.response.body\",\n \"body\": b\"Hello World!\"\n })\n\n\nnode = Node(\n host=\"mywebsite.com\",\n port=\"6379\",\n password=\"abc123\",\n cls=ASGIApp,\n key='ASGI-testing'\n)\n\nprint(f\"Starting worker\")\nnode.run()\n```\n\nOnce you have `worker.py` and `server.py`, use some interface server to run `distributor.py`.\n\n```\n$ uvicorn server:App\n```\n\nand run `worker.py` as a normal python script:\n\n```\n$ python worker.py\n```\n\nThe worker will only respond to http requests with a path that contains `/api/testing` because that is the only key we told it to listen to.\n\n# What happens if there are no workers?\nIf there is no Node instance listening on a key that the Distributor pushes events to, the Distributor will timeout after 5 seconds, close the connection, and return a 405 error. Workers do not need to respond within 5 seconds, the Node class will automatically let the Distributor know there is a worker at least listening.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/3jackdaws/distributed-asgi", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "distributed-asgi", "package_url": "https://pypi.org/project/distributed-asgi/", "platform": "", "project_url": "https://pypi.org/project/distributed-asgi/", "project_urls": { "Homepage": "https://github.com/3jackdaws/distributed-asgi" }, "release_url": "https://pypi.org/project/distributed-asgi/0.0.7/", "requires_dist": null, "requires_python": "", "summary": "Create distributed ASGI applications that pull events from a central Redis queue.", "version": "0.0.7" }, "last_serial": 4253020, "releases": { "0.0.1.dev0": [ { "comment_text": "", "digests": { "md5": "65e127df30a150d136f879f14649a14a", "sha256": "13a4f84f4788301a74d543176311fb7cf8f950175406b68820f1de8c84f895aa" }, "downloads": -1, "filename": "distributed_asgi-0.0.1.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "65e127df30a150d136f879f14649a14a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4208, "upload_time": "2018-08-18T23:29:48", "url": "https://files.pythonhosted.org/packages/45/b1/f921650450c26209343f3f6d2ada247484d47a5e6c4be106d8e930cf8536/distributed_asgi-0.0.1.dev0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a3e3e61f810ef82641436d9b22748c2a", "sha256": "6294b3ab65641a719afaf2ec245b4c9d8fd1615d8c648ad39ed0bbb693a4d3e1" }, "downloads": -1, "filename": "distributed-asgi-0.0.1.dev0.tar.gz", "has_sig": false, "md5_digest": "a3e3e61f810ef82641436d9b22748c2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2922, "upload_time": "2018-08-18T23:29:49", "url": "https://files.pythonhosted.org/packages/7a/88/96a18af6458039f9cd34183e5b0a50e52fea388dcec66af66f62a6521777/distributed-asgi-0.0.1.dev0.tar.gz" } ], "0.0.2.dev0": [ { "comment_text": "", "digests": { "md5": "8afdac90ca3298a99ea65e98fc2847a6", "sha256": "726bfa9bb69209eec7903a2498d1fee5b433aaae74e2fa2b89840cf9af0005cd" }, "downloads": -1, "filename": "distributed_asgi-0.0.2.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "8afdac90ca3298a99ea65e98fc2847a6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4209, "upload_time": "2018-08-19T03:33:52", "url": "https://files.pythonhosted.org/packages/5b/ad/7d44ffe2efc53730729fc6a44ab04320b08b088fdde4aedcf8d0d887bff2/distributed_asgi-0.0.2.dev0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0c38a564a0d1656e7c14e40a5e1c7943", "sha256": "5c9188b5465852f3ea8ab9bad553eaf0771d20d77bdc65195f16cf194d779233" }, "downloads": -1, "filename": "distributed-asgi-0.0.2.dev0.tar.gz", "has_sig": false, "md5_digest": "0c38a564a0d1656e7c14e40a5e1c7943", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2923, "upload_time": "2018-08-19T03:33:53", "url": "https://files.pythonhosted.org/packages/42/78/491d5982a4c391ae5262be6db04cd6feb057f96370dd97a28edef22cc0a5/distributed-asgi-0.0.2.dev0.tar.gz" } ], "0.0.3.dev0": [ { "comment_text": "", "digests": { "md5": "291dc40b401ba1fd26fc702779612a97", "sha256": "bf14d63a5347b04f5794682df2e11e6d30ed6d70f4378017cd0e6e70f1a3bc8a" }, "downloads": -1, "filename": "distributed-asgi-0.0.3.dev0.macosx-10.13-intel.tar.gz", "has_sig": false, "md5_digest": "291dc40b401ba1fd26fc702779612a97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3336, "upload_time": "2018-09-03T19:16:53", "url": "https://files.pythonhosted.org/packages/b6/4d/709b6b023bd50cfef85fbf559d03e170c03f4b103a401c969816b20fdea3/distributed-asgi-0.0.3.dev0.macosx-10.13-intel.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "529457553b1db656c2c1963e355d80ee", "sha256": "6e836fbaa43e886e30c56d8b1c9474f90ff63139bcd0eca13cbabeaae2dfa7ce" }, "downloads": -1, "filename": "distributed-asgi-0.0.5.tar.gz", "has_sig": false, "md5_digest": "529457553b1db656c2c1963e355d80ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3336, "upload_time": "2018-09-03T19:29:04", "url": "https://files.pythonhosted.org/packages/24/ce/b941fce02f0b6c398edfb5384e567a6f4eaa3152290686df2649bf932bbf/distributed-asgi-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "80f131fb6cdfe816113e9b6f852a1eca", "sha256": "604e8029bdd4c0632e800a26c52fecc49ff2da81f052b99c29bd7409951d76ba" }, "downloads": -1, "filename": "distributed-asgi-0.0.6.tar.gz", "has_sig": false, "md5_digest": "80f131fb6cdfe816113e9b6f852a1eca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3394, "upload_time": "2018-09-08T23:35:23", "url": "https://files.pythonhosted.org/packages/69/6e/7505dc1e584e1a941c2eff5b605ae7f89db8a2282811c77977461feb402f/distributed-asgi-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "944a2c30f4f932a77058f43a945a7951", "sha256": "f6855711b2b8d39ac1315657307377247676548d0ae4155396a8ae365ce3715a" }, "downloads": -1, "filename": "distributed-asgi-0.0.7.tar.gz", "has_sig": false, "md5_digest": "944a2c30f4f932a77058f43a945a7951", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4357, "upload_time": "2018-09-09T06:25:16", "url": "https://files.pythonhosted.org/packages/c5/c4/b4adc38e5f44d4f4b5a026f11298613e7237d1094b0d8863869d6cf3e423/distributed-asgi-0.0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "944a2c30f4f932a77058f43a945a7951", "sha256": "f6855711b2b8d39ac1315657307377247676548d0ae4155396a8ae365ce3715a" }, "downloads": -1, "filename": "distributed-asgi-0.0.7.tar.gz", "has_sig": false, "md5_digest": "944a2c30f4f932a77058f43a945a7951", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4357, "upload_time": "2018-09-09T06:25:16", "url": "https://files.pythonhosted.org/packages/c5/c4/b4adc38e5f44d4f4b5a026f11298613e7237d1094b0d8863869d6cf3e423/distributed-asgi-0.0.7.tar.gz" } ] }