{ "info": { "author": "Jacob Svensson", "author_email": "jacob@nephics.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Topic :: System :: Distributed Computing", "Topic :: System :: Networking", "Topic :: Utilities" ], "description": "# Lingerclient\n\n*-- Blocking and non-blocking (asynchronous) clients for Linger*\n\nThis package provides Python clients for interacting with a [Linger](https://github.com/nephics/linger) server, which is a message queue and pubsub service with a REST HTTP API.\n\nThe linger clients are implemented in Python 3 using [Tornado](http://www.tornadoweb.org/) HTTP clients.\n\n## Install\n\nInstall the `lingerclient` package with the following pip command:\n\n pip install lingerclient\n\nThis will also ensure that the dependency package `tornado` is installed.\n\n## Example code\n\n*Blocking client example:*\n\n import lingerclient\n\n\tlc = lingerclient.BlockingLingerClient()\n\tr = lc.post('test-channel', {'msg': 'My first message'})\n\tprint(r)\n\tprint(lc.channels())\n\tm = lc.get('test-channel')\n\tlc.delete(m['id'])\n\nThe `stream` method can be used for iterating over a stream from a channel:\n\n for m in lc.stream('test-channel'):\n print(m['body'])\n lc.delete(m['id'])\n\n*Async client example:*\n\nimport lingerclient\nfrom tornado import ioloop, gen\n\n\n\t@gen.coroutine\n\tdef run_test():\n\t lc = lingerclient.AsyncLingerClient()\n\t r = yield lc.post('test-channel', {'msg': 'My first message'})\n\t print(r)\n\t r = yield lc.channels()\n\t print(r)\n\t m = yield lc.get('test-channel')\n\t yield lc.delete(m['id'])\n\n\n\tioloop.IOLoop.current().run_sync(run_test)\n\n\n## Main client methods\n\n**`channels()`** \nList active channels\n\n**`post(channel, body, **kwargs)`** \nPost a message in the channel. Accepts keyword arguments for the query parameters: priority, timeout, deliver and linger.\n\n\n**`get(channel, nowait=False)`** \nGet a message from the channel. Returns the a dict with the message id, body, channel, etc. If no message is available, None is returned. Set argument `nowait` to True to prevent long-polling.\n\n**`stream(channel, max_retries=0)`** \nGet a stream (iterator) for channel. Argument max_retries can limit the number of failed reconnection attempts. Default is max_retries=0, which means no limit.\n\n**`drain(channel)`** \nDrain the channel for messages (ie, delete all messages in the channel).\n\n**`channel_stats(channel)`** \nGet channel stats\n\n**`subscriptions(channel)`** \nList topics the channel is subscribed to\n\n**`subscribe(channel, topic, **kwargs)`** \nSubscribe channel to topic. Accepts keyword arguments for the query parameters: priority, timeout, deliver and linger\n\n**`unsubscribe(channel, topic)`** \nUnsubscribe channel from topic\n\n**`topics()`** \nList all topics\n\n**`publish(topic, body)`** \nPublish message on topic\n\n**`subscribers(topic)`** \nList channels subscribed to topic\n\n**`delete(msg_id)`** \nDelete message\n\n**`stats()`** \nGet server stats\n\n## Other client methods\n\n\n**`__init__(linger_url=None, encode=json_encode, decode=json_decode, content_type='application/json', io_loop=None, **request_args)`**\n\nThe method signature is the same for `AsyncLingerClient` and `BlockingLingerClient`, as BlockingLingerClient is a wrapper for AsyncLingerClient, where each HTTP request to Linger is run in an IOLoop.\n\nAll parameters are optional.\n\nThe `linger_url` argument is the base url for the Linger server. Default is `http://127.0.0.1:8989/`.\n\nThe `encode` and `decode` arguments are for supplying custom message encoding and decoding functions. Default is JSON encoding/decoding.\n\nThe `content_type` argument should be set to the appropriate mime-type of the output of the encoding function. Default is `application/json`.\n\nThe `io_loop` is passed to the AsyncHTTPClient, used for connecting.\n\nKeyword arguments in `request_args` are applied when making requests to Linger. By default the request argument `use_gzip` is True. Accessing a local Linger server, it may be relevant to set `use_gzip` to False.\n\nThe request arguments may include `auth_username` and `auth_password` for basic authentication. See `tornado.httpclient.HTTPRequest` for other possible arguments.\n\n**`close()`** \nCloses the Linger client, freeing any resources used.\n\n**`closed`** (property) \nBoolean indicating if the Linger client is closed.\n\n# Support\n\nSupport for the software can be provided on a commercial basis, please see [www.nephics.com](http://www.nephics.com) for contact information.\n\n# License\n\nThe code and documentation is licensed under the Apache License v2.0, see more in the LICENSE file.\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/nephics/lingerclient", "keywords": "", "license": "http://www.apache.org/licenses/LICENSE-2.0", "maintainer": "", "maintainer_email": "", "name": "lingerclient", "package_url": "https://pypi.org/project/lingerclient/", "platform": "", "project_url": "https://pypi.org/project/lingerclient/", "project_urls": { "Homepage": "https://github.com/nephics/lingerclient" }, "release_url": "https://pypi.org/project/lingerclient/1.0.0/", "requires_dist": [ "tornado (>=4.5.2)" ], "requires_python": "", "summary": "Blocking and non-blocking (asynchronous) clients for Linger", "version": "1.0.0" }, "last_serial": 4987869, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0e8665bc6123963ba4d1ed5f7e549126", "sha256": "bc8cf642a4ad5d8d37bc76dff812912d653252ea7ad652a81276c2b487b843d4" }, "downloads": -1, "filename": "lingerclient-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0e8665bc6123963ba4d1ed5f7e549126", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7731, "upload_time": "2019-03-26T14:28:07", "url": "https://files.pythonhosted.org/packages/7e/8e/a4a4e9c120878c7225e6bde58b2a099070c3e3cdf0ef9caebf492bc7db31/lingerclient-1.0.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0e8665bc6123963ba4d1ed5f7e549126", "sha256": "bc8cf642a4ad5d8d37bc76dff812912d653252ea7ad652a81276c2b487b843d4" }, "downloads": -1, "filename": "lingerclient-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0e8665bc6123963ba4d1ed5f7e549126", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7731, "upload_time": "2019-03-26T14:28:07", "url": "https://files.pythonhosted.org/packages/7e/8e/a4a4e9c120878c7225e6bde58b2a099070c3e3cdf0ef9caebf492bc7db31/lingerclient-1.0.0-py2.py3-none-any.whl" } ] }