{ "info": { "author": "timeroute", "author_email": "chinesejar@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "# mprpc_config\n\n\u8fd9\u662f\u4e00\u4e2a [mprpc](https://github.com/studio-ousia/mprpc) \u4e8c\u6b21\u5c01\u88c5\u7684\u5305\u3002\n\n## \u5b89\u88c5\n\n```shell\npip install mprpc_config\n```\n\n## \u7528\u6cd5\n\n\u6784\u5efa\u4e00\u4e2a\u5982\u4e0b\u7684\u76ee\u5f55\u7ed3\u6784\n\n- config.py \u5305\u542bRPC\u914d\u7f6e\u5c5e\u6027\uff08\u4efb\u610f\u547d\u540d\uff09\n\n INSTALLED_APP \u5fc5\u586b\u53c2\u6570\uff0clist \u7c7b\u578b\uff0c\u5c06\u6bcf\u4e00\u4e2a\u5305\u542b RPC \u63a5\u53e3\u7684\u6a21\u5757\u540d\u653e\u8fdb\u53bb\n- app_module_name RPC \u63a5\u53e3\u6a21\u5757\uff08\u4efb\u610f\u547d\u540d\uff0c\u53ef\u6709\u591a\u4e2a\uff09\n - implement.py \u63a5\u53e3\u6a21\u5757\uff08\u4efb\u610f\u547d\u540d\uff0c\u53ef\u6709\u591a\u4e2a\uff09\uff0c\u91cc\u9762\u5305\u542b rpc \u65b9\u6cd5\u88c5\u9970\u7684\u63a5\u53e3\u51fd\u6570\n- server.py RPC \u670d\u52a1\u5668\n 1. \u521d\u59cb\u5316 mprpc_config \u7684 `Configration` \u7c7b\uff0c\u5c06 `config.py` \u7684\u6a21\u5757\u540d `config` \u4f5c\u4e3a\u5b57\u7b26\u4e32\u4f20\u5165\n 2. \u5bfc\u5165 mprpc_config.rpc_server \u7684 RPCServer \u548c StreamServer\uff0c\u542f\u52a8 RPC \u670d\u52a1\u5668\n 3. \u4f7f\u7528 `bind_class` \u65b9\u6cd5\u5c06\u521d\u59cb\u5316\u540e\u7684\u6240\u6709 RPC \u63a5\u53e3\u7ed1\u5b9a\u7ed9 `RPCServer`\n 4. \u4f7f\u7528 StreamServer \u542f\u52a8 RPC \u670d\u52a1\u5668\n- client.py RPC \u5ba2\u6237\u7aef\uff08\u6d4b\u8bd5\u7528\uff0c\u5b9e\u9645\u53ef\u5206\u79bb\uff09\n\n \u5ba2\u6237\u7aef\u542f\u52a8\u65b9\u5f0f\u53ef\u53c2\u8003 [mprpc](https://github.com/studio-ousia/mprpc) \u3002\n\n- rpc_config RPC \u670d\u52a1\u914d\u7f6e\u6a21\u5757\uff0c\n\n\u50cf Celery \u4e00\u6837\u4f7f\u7528\u3002\u5b9a\u4e49\u4e00\u4e2a RPC \u63a5\u53e3\u53ea\u9700\u5728\u63a5\u53e3\u4e0a\u52a0\u4e00\u4e2a `@rpc` \u65b9\u6cd5\u5373\u53ef\u3002\n\n## \u793a\u4f8b\n\n> \u793a\u4f8b\u4ee3\u7801\u5728 `example` \u76ee\u5f55\n\nserver.py\n\n```python\nfrom mprpc_config.rpc_server import RPCServer, StreamServer\nfrom mprpc_config import rpc_config\n\n\nif __name__ == '__main__':\n print('-------start server--------')\n config = rpc_config.Configuration(\"config\")\n config.bind_class(RPCServer)\n server = StreamServer(('127.0.0.1', 6000), RPCServer)\n server.serve_forever(stop_timeout=10)\n\n```\n\nclient.py\n\n```python\nfrom mprpc_config.rpc_client import RPCClient, RPCPoolClient\nfrom mprpc_config.rpc_client import RPCPool\n\nprint('---------- client ----------')\nclient = RPCClient('127.0.0.1', 6000)\nprint('2 add 4: ', client.call('add', 2, 4))\nprint('2 plus 4: ', client.call('plus', 2, 4))\nprint('2 minus 4: ', client.call('minus', 2, 4))\nprint('---------- done ----------')\n\nprint('---------- client pool ----------')\nclient_pool = RPCPool(RPCPoolClient, dict(host='127.0.0.1', port=6000))\nwith client_pool.connection() as client:\n print('2 add 4: ', client.call('add', 2, 4))\n print('2 plus 4: ', client.call('plus', 2, 4))\n print('2 minus 4: ', client.call('minus', 2, 4))\nprint('---------- done ----------')\n\n```\n\n\u542f\u52a8 server \u548c client\n\n```shell\n$ python server.py\n\n---------- server ----------\n\n$ python client.py\n\n---------- client ----------\n2 add 4: 6\n2 plus 4: 8\n2 minus 4: -2\n---------- done ----------\n---------- client pool ----------\n2 add 4: 6\n2 plus 4: 8\n2 minus 4: -2\n---------- done ----------\n```\n\n\n", "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/chinesejar/mprpc_config", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mprpc-config", "package_url": "https://pypi.org/project/mprpc-config/", "platform": "", "project_url": "https://pypi.org/project/mprpc-config/", "project_urls": { "Homepage": "https://github.com/chinesejar/mprpc_config" }, "release_url": "https://pypi.org/project/mprpc-config/0.0.3/", "requires_dist": [ "mprpc", "gevent", "gsocketpool" ], "requires_python": "", "summary": "A wrapper config for mprpc", "version": "0.0.3" }, "last_serial": 4439644, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "b4aa852474a6a1a45c611235b1e39ff2", "sha256": "635354181b2fb2dd15a7956f1cfe0527c808f3cbaad0d4f52495c0e336f24123" }, "downloads": -1, "filename": "mprpc_config-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b4aa852474a6a1a45c611235b1e39ff2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5080, "upload_time": "2018-11-01T06:13:53", "url": "https://files.pythonhosted.org/packages/e1/a5/10f8d9e5002f30f8d47071f47e2641f5137e4def39932c197374a1332cfb/mprpc_config-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f54e77d83dc2d4e3ede9c8875045069e", "sha256": "07aba4519010c313245722e42cd6afece9fd5c223d977eb1f3dee92910d96951" }, "downloads": -1, "filename": "mprpc_config-0.0.3.tar.gz", "has_sig": false, "md5_digest": "f54e77d83dc2d4e3ede9c8875045069e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3430, "upload_time": "2018-11-01T06:13:54", "url": "https://files.pythonhosted.org/packages/40/8f/1de7283122e574347c11a225531d8205f67c5f8e11759f4cd03360f1ee17/mprpc_config-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b4aa852474a6a1a45c611235b1e39ff2", "sha256": "635354181b2fb2dd15a7956f1cfe0527c808f3cbaad0d4f52495c0e336f24123" }, "downloads": -1, "filename": "mprpc_config-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b4aa852474a6a1a45c611235b1e39ff2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5080, "upload_time": "2018-11-01T06:13:53", "url": "https://files.pythonhosted.org/packages/e1/a5/10f8d9e5002f30f8d47071f47e2641f5137e4def39932c197374a1332cfb/mprpc_config-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f54e77d83dc2d4e3ede9c8875045069e", "sha256": "07aba4519010c313245722e42cd6afece9fd5c223d977eb1f3dee92910d96951" }, "downloads": -1, "filename": "mprpc_config-0.0.3.tar.gz", "has_sig": false, "md5_digest": "f54e77d83dc2d4e3ede9c8875045069e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3430, "upload_time": "2018-11-01T06:13:54", "url": "https://files.pythonhosted.org/packages/40/8f/1de7283122e574347c11a225531d8205f67c5f8e11759f4cd03360f1ee17/mprpc_config-0.0.3.tar.gz" } ] }