{ "info": { "author": "Plivo Team", "author_email": "hello@plivo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "SharQ\n=======\n\nSharQ is a flexible rate limited queueing system built using [Redis](http://redis.io). SharQ is the core library that powers the [SharQ Server](https://github.com/plivo/sharq-server).\n\n## Installation\n\n* Install the [latest stable release of Redis](http://redis.io/download).\n* Install SharQ using pip\n```\npip install sharq\n```\n\n## Configuration\n\nSample SharQ Config file.\n```\n[sharq]\njob_expire_interval : 1000 ; in milliseconds\njob_requeue_interval : 1000 ; in milliseconds\ndefault_job_requeue_limit : -1 ; retries infinitely\n\n[redis]\ndb : 0\nkey_prefix : sharq_server\nconn_type : tcp_sock ; or unix_sock\n;; unix connection settings\nunix_socket_path : /tmp/redis.sock\n;; tcp connection settings\nport : 6379\nhost : 127.0.0.1\n```\n\n__Note:__ Uncomment the following lines in your `redis.conf` if you are using unix socket to connect to Redis.\n```\nunixsocket /var/run/redis/redis.sock\nunixsocketperm 755\n```\n\n## Usage\n\n### Initialization\n\n```python\n>>> from sharq import SharQ\n\n>>> sq = SharQ('/path/to/config/sharq.conf')\n```\n\n### Enqueue\n\nEnqueues a job into the queue. Every enqueue request is accompanied with an `interval`. The interval specifies the rate limiting capability of SharQ. An interval of 1000ms implies that SharQ will ensure two successful dequeue requests will be separated by 1000ms (interval is the inverse of rate. 1000ms interval means 1 job per second)\n\n```python\n>>> response = sq.enqueue(\n\t job_id='cea84623-be35-4368-90fa-7736570dabc4',\n\t\tpayload={'message': 'hello, world'},\n\t\tinterval=1000, # in milliseconds.\n\t\tqueue_id='user001',\n\t\tqueue_type='sms' # optional. defaults to 'default' queue type.\n\t)\n>>> print response\n{'status': 'queued'}\n```\n### Dequeue\n\nDequeues a job (non-blocking). It returns a job only if available or if it is ready for dequeue (based on the interval set while enqueueing).\n\n```python\n>>> response = sq.dequeue(\n\t queue_type='sms' # optional.\n\t)\n>>> print response # when the queue is empty or no job is ready.\n{'status': 'failure'}\n>>> print response # when the job is ready.\n{'job_id': 'cea84623-be35-4368-90fa-7736570dabc4',\n 'payload': {'message': 'hello, world'},\n 'queue_id': 'johndoe',\n 'status': 'success'}\n```\n\n### Finish\n\nMarks any dequeued job as _succesfully completed_. Any job which does get marked as finished upon dequeue will be re-enqueued into its respective queue after an expiry time (the `job_requeue_interval` in the config).\n\n```python\n>>> response = sq.finish(\n\t queue_type='sms',\n\t\tjob_id='bb59a2be-3b48-4645-8134-d9181742e3cf',\n\t\tqueue_id='user001'\n\t)\n>>> print response\n{'status': 'success'}\n```\n\n### Requeue\n\nEe-queues all the jobs which do not get the finish (ACK) within the expiry time (the `job_requeue_interval` in the config file).\n\n```python\n>>> response = sq.requeue() # re-queues all expired jobs.\n>>> print response\nNone\n```\n\n### Interval\n\nUpdates the interval for a specified queue on the fly. The interval specifies the rate limiting capability of SharQ. An interval of 1000ms implies that SharQ will ensure two successful dequeue requests will be separated by 1000ms (interval is the inverse of rate. 1000ms interval means 1 job per second).\n\n```python\n>>> response = sq.interval(\n\t queue_type='sms',\n\t\tinterval=5000, # interval between two successful dequeues is set to 5s\n\t\tqueue_id='user001'\n\t)\n>>> print response\n{'status': 'success'}\n```\n\n### Merics\n\nGets the SharQ metrics like,\n\n* Overall enqueue / dequeue rate.\n* Queue specific enqueue / dequeue rate.\n* Queue types and queue ids in SharQ.\n* Queue length of a particual queue.\n\n```python\n>>> response = sq.metrics() # gets the overall statistics.\n>>> print response\n{'dequeue_counts': {\n '1406280420000': 10, # epoch timestamp of the minute & the dequeue count.\n '1406280480000': 0,\n '1406280540000': 304,\n '1406280600000': 0,\n '1406280660000': 605,\n '1406280720000': 604,\n '1406280780000': 615,\n '1406280840000': 233,\n '1406280900000': 322,\n '1406280960000': 272},\n 'enqueue_counts': {\n '1406280420000': 0,\n '1406280480000': 0,\n '1406280540000': 0,\n '1406280600000': 0,\n '1406280660000': 0,\n '1406280720000': 0,\n '1406280780000': 40,\n '1406280840000': 40,\n '1406280900000': 40,\n '1406280960000': 39},\n 'queue_types': ['sms'],\n 'status': u'success'}\n\n>>> response = sq.metrics(queue_type='sms') # gets the queue ids of this type.\n>>> print response\n{'queue_ids': ['user001', 'user002'], 'status': 'success'}\n\n>>> response = sq.metrics( # gets the stats for this particular queue.\n queue_type='sms',\n queue_id='user001'\n )\n>>> print response\n{'dequeue_counts': {\n '1406280420000': 10, # epoch timestamp of the minute & the dequeue count.\n '1406280480000': 0,\n '1406280540000': 304,\n '1406280600000': 0,\n '1406280660000': 605,\n '1406280720000': 604,\n '1406280780000': 615,\n '1406280840000': 233,\n '1406280900000': 322,\n '1406280960000': 272},\n 'enqueue_counts': {\n '1406280420000': 0,\n '1406280480000': 0,\n '1406280540000': 0,\n '1406280600000': 0,\n '1406280660000': 0,\n '1406280720000': 0,\n '1406280780000': 40,\n '1406280840000': 40,\n '1406280900000': 40,\n '1406280960000': 39},\n 'queue_length': 2400, # the number of jobs in this queue.\n 'status': u'success'}\n```\n\n## Development\n\n### Getting the source code\n\n```\ngit clone https://github.com/plivo/sharq.git\n```\n\n### Running Tests\n\n```\nmake test\n```\n\n### Building a Package\n\n```\nmake build\n```\n\n### Install / Uninstall\n\n```\nmake install\nmake uninstall\n```\n\n## License\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2014 Plivo Inc\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\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/plivo/sharq", "keywords": "", "license": "The MIT License (MIT)", "maintainer": "", "maintainer_email": "", "name": "SharQ", "package_url": "https://pypi.org/project/SharQ/", "platform": "", "project_url": "https://pypi.org/project/SharQ/", "project_urls": { "Homepage": "https://github.com/plivo/sharq" }, "release_url": "https://pypi.org/project/SharQ/0.5.1/", "requires_dist": null, "requires_python": "", "summary": "An API queueing system built at Plivo.", "version": "0.5.1" }, "last_serial": 5582895, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "4a6042dc3515441524d72ff141edba64", "sha256": "b4945c238081606c9baf826131929f7432f9500122ff212a956b6e3ebf742fc9" }, "downloads": -1, "filename": "SharQ-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4a6042dc3515441524d72ff141edba64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8382, "upload_time": "2014-07-28T14:39:30", "url": "https://files.pythonhosted.org/packages/36/7b/0a41215ba3e769ea651585717f5ae9bed54b2241bdfcee8d1b1e7cbcb55f/SharQ-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "51716e9da507b48e4535607e1e29264e", "sha256": "f8c574d8dacfcc914b2c3247b90506a42ed1623f61376acc6de327797e91ce15" }, "downloads": -1, "filename": "SharQ-0.1.1.tar.gz", "has_sig": false, "md5_digest": "51716e9da507b48e4535607e1e29264e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8468, "upload_time": "2014-09-15T13:26:42", "url": "https://files.pythonhosted.org/packages/6a/10/f39371710195f48158922dad913b322f976a988fe66793429673d094fc24/SharQ-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "671d2b93544e7f7dbf1bbacc8a32da76", "sha256": "0f2cbf35c2aa42cefda1bf47a7cd14ede98579065454426e07cfcc2842d655de" }, "downloads": -1, "filename": "SharQ-0.2.0.tar.gz", "has_sig": false, "md5_digest": "671d2b93544e7f7dbf1bbacc8a32da76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11880, "upload_time": "2014-09-22T06:46:40", "url": "https://files.pythonhosted.org/packages/10/25/ea4ffdbdea2e0c703ca8c4dbdda058c28efc5176d2346074527c60732ab1/SharQ-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "9d8dc2ca04e6d98683f615ba456e4789", "sha256": "392681842d819618589c78291ffb62bf23a6cc0f95f4883ed71d5100b6b90bb3" }, "downloads": -1, "filename": "SharQ-0.3.0.tar.gz", "has_sig": false, "md5_digest": "9d8dc2ca04e6d98683f615ba456e4789", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12391, "upload_time": "2014-11-19T03:47:47", "url": "https://files.pythonhosted.org/packages/57/75/a9193b7443b5fb36ed2b4d7616dd8b70e1f884ca01716b264470bebe0b50/SharQ-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "9b52ca063007e14541f2db14367e9a21", "sha256": "9ece334b496f208f73960354545770dc52342565497384c8dc3dcb2b826c0cf2" }, "downloads": -1, "filename": "SharQ-0.4.0.tar.gz", "has_sig": false, "md5_digest": "9b52ca063007e14541f2db14367e9a21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10940, "upload_time": "2019-04-03T07:01:59", "url": "https://files.pythonhosted.org/packages/28/5b/c21bc9f0e6951d43a2b646cc48086df457b14375c3df19bd17ec92a4a15e/SharQ-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "a58181efa6f87e74be8d5df3f2671cba", "sha256": "18657d63dbc5f1113bc860f4dc4597cd43eb492cf1ae38e1b8c5d17b24de9912" }, "downloads": -1, "filename": "SharQ-0.5.0.tar.gz", "has_sig": false, "md5_digest": "a58181efa6f87e74be8d5df3f2671cba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11034, "upload_time": "2019-07-24T08:02:28", "url": "https://files.pythonhosted.org/packages/fe/74/eeb100b41dc803906a416f4d34f488cd8c89f50564b8e7f95c53dae728e1/SharQ-0.5.0.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "61424a11323cf2f60f5fd3b362efb814", "sha256": "024d0fe94b32b17a0af4a44bfb087a2cafdbe66ff16cd77101c749ff506c9ff5" }, "downloads": -1, "filename": "SharQ-0.5.1.tar.gz", "has_sig": false, "md5_digest": "61424a11323cf2f60f5fd3b362efb814", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11025, "upload_time": "2019-07-24T12:44:08", "url": "https://files.pythonhosted.org/packages/ef/e5/d7ed941686d901897df943b69ec2b9d52586abb89f5eac834e31e52c2912/SharQ-0.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "61424a11323cf2f60f5fd3b362efb814", "sha256": "024d0fe94b32b17a0af4a44bfb087a2cafdbe66ff16cd77101c749ff506c9ff5" }, "downloads": -1, "filename": "SharQ-0.5.1.tar.gz", "has_sig": false, "md5_digest": "61424a11323cf2f60f5fd3b362efb814", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11025, "upload_time": "2019-07-24T12:44:08", "url": "https://files.pythonhosted.org/packages/ef/e5/d7ed941686d901897df943b69ec2b9d52586abb89f5eac834e31e52c2912/SharQ-0.5.1.tar.gz" } ] }