{ "info": { "author": "chuncheng", "author_email": "ischuncheng@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], "description": "# Features\n* Easy registration of methods\n* Custom Exception and Options\n* Includes plenty testing helpers\n\n# Installation\nOn most systems, its a matter of\n```bash\npip install qrpc\n```\n\n# Quickstart\n## A Simple Example\nThis is a realy simple example of how to create your own API using QRpc\n\n### Server\n\n```python\nfrom qrpc.server import Server\n\nserver = Server()\n\n\n@server.registe(\"service1/hello\")\ndef hello(name=None):\n if name:\n return \"hello \" + name\n return \"hello anonymous\"\n\n\n@server.registe(\"service1/add\")\ndef add(x, y):\n return x + y\n\n\nserver.run('127.0.0.1', 8080)\n```\n\n\n### Client\n\n```python\nfrom qrpc.client import RpcClient\nfrom qrpc.client import ServerProxy\n\nserver = ServerProxy('http://localhost:8080/v1/batch')\nrpc = RpcClient(server=server)\nresult = rpc.service1.hello.call(name='ycc')\nprint(result.data)\n\n```\n# Core content\n## Request\n\n\n## Response(Result)\nThe response of an rpc request has three attributes that user should concern, rpc_code, data, message.\n\nThe rpc_code indicates if the rpc request has been successfully received, understood, and accepted. 0 and all the positive numbers are **reserved code**, and can't be used by user.\n\nThe data is the result of an rpc method.\n\nThe message provides some helpful information.\n\n\n## Exceptions\nYou can define an RPCException and raise it when you want to tell the caller there is something wrong in some rpc method. For example a division rpc method and the second argument of a division is zero.\n\n```python\n# server\nfrom qrpc.exceptions import RPCFaultException\n@server.registe(\"service/div\")\ndef test_div(x, y):\n if y == 0:\n raise RPCFaultException(\n code=99, # Use any code in your as you like except reserved code.\n message=\"ZeroDivisionError: integer division or modulo by zero\"\n )\n return x / y\n\n# client\ndiv_result = rpc.service.div.call(x=1, y=0)\n```\n\nThe QRpc will catch the exception and wrap it in reponse.\n\n\n\n\n#Lazy Call and Evaluation\n\nRPC call are lazy--the act of creating an rpc call doesn't send the network request to server. You can stack call together all day long, and the framework won't actually send the network request until one of the calls is evaluated. You can get detail from the following example:\n\n```python\n add_result = rpc.service.add.call(x=1, y=2)\n dict_result = rpc.service.dictionary.call(dictionary={\"test_key\": \"test_value\"})\n hello_result = rpc.service.hello.call(name='world')\n print (add_result.data) # only one network request\n print (dict_result.data)\n print (hello_result.data)\n```\n\nThough this looks like sending three rpc call request, in fact it only send one network request, at the \"add_result.data\" line. An rpc call is just added into a job list when it is constructed. The real network request will be executed when any of the 'rcp call' in the job list is evaluated. The framework evaluates all the rpc call in the job list at one time. So only send one network request.You can evaluate an rpc call by get any attribute of the rcp result.\n\nIn the last example, there are three rpc calls in the job list. The three rpc calls are evaluated at one network request when you get the data of add_result.\nSo dict_result.data or hello_result.data won't cause any network request.\n\nIn general, the result of an rpc call isn't fetched from the server until you ask them.\n\n# Adcanced Usage\n# TODO\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oangeor/qrpc", "keywords": "rpc", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "qrpc", "package_url": "https://pypi.org/project/qrpc/", "platform": "", "project_url": "https://pypi.org/project/qrpc/", "project_urls": { "Homepage": "https://github.com/oangeor/qrpc" }, "release_url": "https://pypi.org/project/qrpc/0.1.0/", "requires_dist": [ "falcon (>=1.2.0)", "requests (>=2.18.4)", "six (>=1.10.0)" ], "requires_python": "", "summary": "A Python RPC Framework", "version": "0.1.0" }, "last_serial": 3143268, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "c041363cdcb561fa0ab15aaac60bd7c1", "sha256": "c89632ca1fc6bd7a0bde14fe1ec96882a5e90cb1e2568ebf9b2e43f67db65e4a" }, "downloads": -1, "filename": "qrpc-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "c041363cdcb561fa0ab15aaac60bd7c1", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12772, "upload_time": "2017-09-02T16:23:12", "url": "https://files.pythonhosted.org/packages/4b/b2/ecbb9d566110bc81dcffd1f96f275dcf323b2fdb6f5317b8ae0c3fceb550/qrpc-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c582bc99ecc2dc23d883dca71f0938bf", "sha256": "e8e4e65561a90a218a4ed3e79a704ab562f676bd999df957d6bf797807a27d77" }, "downloads": -1, "filename": "qrpc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c582bc99ecc2dc23d883dca71f0938bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8703, "upload_time": "2017-09-02T16:23:15", "url": "https://files.pythonhosted.org/packages/71/27/f9fc24fc4304d574209b3a89dc3b70d723029d5820622ad5567f7943f456/qrpc-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c041363cdcb561fa0ab15aaac60bd7c1", "sha256": "c89632ca1fc6bd7a0bde14fe1ec96882a5e90cb1e2568ebf9b2e43f67db65e4a" }, "downloads": -1, "filename": "qrpc-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "c041363cdcb561fa0ab15aaac60bd7c1", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 12772, "upload_time": "2017-09-02T16:23:12", "url": "https://files.pythonhosted.org/packages/4b/b2/ecbb9d566110bc81dcffd1f96f275dcf323b2fdb6f5317b8ae0c3fceb550/qrpc-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c582bc99ecc2dc23d883dca71f0938bf", "sha256": "e8e4e65561a90a218a4ed3e79a704ab562f676bd999df957d6bf797807a27d77" }, "downloads": -1, "filename": "qrpc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c582bc99ecc2dc23d883dca71f0938bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8703, "upload_time": "2017-09-02T16:23:15", "url": "https://files.pythonhosted.org/packages/71/27/f9fc24fc4304d574209b3a89dc3b70d723029d5820622ad5567f7943f456/qrpc-0.1.0.tar.gz" } ] }