{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "[![Build Status](https://travis-ci.com/johntmyers/falcon-rpc.png?branch=master)](https://travis-ci.com/johntmyers/falcon-rpc)\n\n\n# Falcon RPC\n\n## Background\n\nA wrapper that utilizes the [Falcon Framework](https://falconframework.org/) to create a HTTP RPC API.\n\nThe motivation for this API is the [Slack Web API](https://api.slack.com/web). \n\n*NOTE*: I suggest being familiar with Falcon and Slack's APIs on your own, first.\n\nI found myself creating lots of APIs for various projects and realized that RESTful APIs are not really useful for the type of stuff I work on. While there is a certain degree of CRUD operations I usually need to do, a lot of the \"resources\" I created were for kicking of backend processing jobs, running async analytic workloads, executing complex queries, etc.\n\nMost of the things I do just don't fit into REST. Frankly, instead of \"bending\" REST to fit my will I found API's like Slack that seemed perfect for being flexible enough to fit any use case. However, while I was bending REST for my bidding I became really fond of the Falcon Framework. I 100% understand Falcon is designed for REST but guess what, I can do whatever I want so here we are. \n\n## Quickstart\n\nClone the repo and install.\n\n```\ncd falcon_rpc\npip install -I .\n``` \n\n```python\nimport falcon_rpc\n\n\nclass Test:\n \"\"\"``test`` method family \"\"\"\n\n def ok(self, req):\n # /test.ok\n req.resp_body = {'foo': 'bar'}\n\n def error(self, req):\n # /test.error\n # can raise an error at anytime\n raise falcon_rpc.RPCError('dummy_error_code')\n\n def fatal(self, req):\n # /test.fatal\n not_a_dict = 1\n not_a_dict['nope'] = 2 # pylint: disable=unsupported-assignment-operation # noqa\n\n def echo(self, req):\n # /test.echo\n req.resp_body = {'you_sent': req.params}\n\n def warn(self, req):\n # /test.warn\n req.resp_body = {'data': 'mostly good'}\n # setting a warning even though the request was handled\n req.set_warning('some_warning')\n\n\nclass Another:\n\n def show_me(self, req):\n # req.req is the original Falcon Request object\n req.resp_body = {'hello_there': req.req.remote_addr}\n\n\ndef start():\n rpc = falcon_rpc.RPC()\n rpc.add_family(Test())\n rpc.add_family(Another())\n return rpc()\n```\n\nThis can be launched just like you would Falcon:\n\n```\n$ gunicorn -b :8000 \"app:start()\" --workers 2 --log-level DEBUG --reload\n```\n\n## Method Families and Methods\n\nInstead of adding routes to your API, you add method families, which are Python classes here.\n\nYour API follows the `/METHOD_FAMILY.method` structure like Slack and the name of your Python class corresponds to the method family, and methods of that class are utilized as the actual method being called.\n\nIt is important to note that method family names are case insensitive, they will always be cast to lowercase.\n\nMethod names are case sensitive.\n\n### Method Handlers\n\nMethod handlers take one arg, an instance of `RPCRequest`.\n\nThe `resp_body` attribute of this object can be set with your response data.\n\nLike Slack, if your request could be processed, but you need to add a warning, you can do so by using the `set_warning` method.\n\n## Tests\n\n```\n$ pip install -r test-requirements.txt\n$ pytest -s -vv --cov falcon_rpc --cov-report=term-missing tests/\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": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "falcon-rpc", "package_url": "https://pypi.org/project/falcon-rpc/", "platform": "", "project_url": "https://pypi.org/project/falcon-rpc/", "project_urls": null, "release_url": "https://pypi.org/project/falcon-rpc/0.5.0/", "requires_dist": [ "falcon (==2.0.0)", "falcon-cors" ], "requires_python": "", "summary": "RPC API based on the Falcon Framework", "version": "0.5.0" }, "last_serial": 5600932, "releases": { "0.4.0": [ { "comment_text": "", "digests": { "md5": "740a2ab6c40a32394567dc155421b156", "sha256": "89bcf50eca928daa9a8bcecbdcc7f23f689773219cc4d3251dc1f17785b55182" }, "downloads": -1, "filename": "falcon_rpc-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "740a2ab6c40a32394567dc155421b156", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10441, "upload_time": "2019-07-14T17:08:34", "url": "https://files.pythonhosted.org/packages/8e/89/46f6016b61a3076ce4eff42b95b1463b587120efd3837f44ccc5d1ede964/falcon_rpc-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "26b39607bb2e4452a717ef6d1e5d2440", "sha256": "8f6c0f30ceece135ec87e9aabbb349e65e6eae2895a4dc0d276e7cfb90c7bce4" }, "downloads": -1, "filename": "falcon-rpc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "26b39607bb2e4452a717ef6d1e5d2440", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5653, "upload_time": "2019-07-14T17:06:08", "url": "https://files.pythonhosted.org/packages/da/4b/dbc928e26bc860d7d12a5036b1259ae32453fad6dab1fe943f84b0292ec9/falcon-rpc-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "51a92658472f8bbc54e3a42bc7183aca", "sha256": "75a51a6fa9043425117985b8e179bcc5d69a788cfd973d5d5cf7ec01e41fe924" }, "downloads": -1, "filename": "falcon_rpc-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "51a92658472f8bbc54e3a42bc7183aca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10472, "upload_time": "2019-07-29T18:02:09", "url": "https://files.pythonhosted.org/packages/d0/70/e8fd8b3b928232f06addc1f6e81d66102b830eef404ec224ebec74b9e6bb/falcon_rpc-0.5.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "51a92658472f8bbc54e3a42bc7183aca", "sha256": "75a51a6fa9043425117985b8e179bcc5d69a788cfd973d5d5cf7ec01e41fe924" }, "downloads": -1, "filename": "falcon_rpc-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "51a92658472f8bbc54e3a42bc7183aca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10472, "upload_time": "2019-07-29T18:02:09", "url": "https://files.pythonhosted.org/packages/d0/70/e8fd8b3b928232f06addc1f6e81d66102b830eef404ec224ebec74b9e6bb/falcon_rpc-0.5.0-py3-none-any.whl" } ] }