{ "info": { "author": "Dominik Walder and Marko Ristin", "author_email": "marko.ristin@parquery.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5" ], "description": "persizmq\n========\n\npersizmq provides persistence to zeromq. Messages are received in background and stored on disk before further\nmanipulation.\n\nCurrently, we only support the zeromq subscriber. Adding support for other classes can be easily done; we simply have\nnot had need for them so far.\n\nUsage\n=====\nSubscriber\n----------\nThe persistent subscriber wraps a zeromq subscriber. We split up the persistence subscription in two components:\na threaded subscriber that listens on the messages in background, and a persistence component that stores the messages\non disk.\n\nThreaded Subscriber\n~~~~~~~~~~~~~~~~~~~\nThe threaded subscriber is implemented as ``persizmq.ThreadedSubscriber``. You need to specify a callback which is\ncalled upon each received message.\n\nYou also need to specify on-exception callback in order to handle exceptions raised in the listening thread.\n\nExample:\n\n.. code-block:: python\n\n import time\n\n import zmq\n\n import persizmq\n\n context = zmq.Context()\n subscriber = context.socket(zmq.SUB)\n subscriber.setsockopt_string(zmq.SUBSCRIBE, \"\")\n subscriber.connect(\"ipc:///some-queue.zeromq\")\n\n def callback(msg: bytes)->None:\n print(\"received a message: {}\".format(msg))\n\n def on_exception(exception: Exception)->None:\n print(\"an exception was raised in the listening thread: {}\".format(exception))\n\n with persizmq.ThreadedSubscriber(callback=callback, subscriber=subscriber, on_exception=on_exception):\n # do something while we are listening on messages...\n time.sleep(10)\n\n\n\nStorage\n~~~~~~~\nWe provide two storage modes for the received messages:\n\n1. ``persizmq.PersistentStorage``: stores messages in a FIFO queue on disk.\n2. ``persizmq.PersistentLatestStorage``: solely stores the newest message on disk.\n\nThe storage component is passed directly to the threaded subscriber as a callback.\n\nExample:\n\n.. code-block:: python\n\n import pathlib\n\n import zmq\n\n import persizmq\n\n context = zmq.Context()\n subscriber = context.socket(zmq.SUB)\n subscriber.setsockopt_string(zmq.SUBSCRIBE, \"\")\n subscriber.connect(\"ipc:///some-queue.zeromq\")\n\n persistent_dir = pathlib.Path(\"/some/dir\")\n storage = persizmq.PersistentStorage(persistent_dir=persistent_dir)\n\n def on_exception(exception: Exception)->None:\n print(\"an exception was raised in the listening thread: {}\".format(exception))\n\n with persizmq.ThreadedSubscriber(callback=storage.add_message, subscriber=subscriber, on_exception=on_exception):\n msg = storage.front() # non-blocking\n if msg is not None:\n print(\"Received a persistent message: {}\".format(msg))\n storage.pop_front()\n\nFiltering\n~~~~~~~~~\nWe also provide filtering components which can be chained on the threaded subscriber. The filtering chains are\nparticularly handy if you want to persist only a small amount of messages and ignore the rest.\n\nThe filters are implemented in ``persizmq.filter`` module.\n\nExample:\n\n.. code-block:: python\n\n import pathlib\n\n import zmq\n\n import persizmq\n import persizmq.filter\n\n context = zmq.Context()\n subscriber = context.socket(zmq.SUB)\n subscriber.setsockopt_string(zmq.SUBSCRIBE, \"\")\n subscriber.connect(\"ipc:///some-queue.zeromq\")\n\n persistent_dir = pathlib.Path(\"/some/dir\")\n storage = persizmq.PersistentStorage(persistent_dir=persistent_dir)\n\n def on_exception(exception: Exception)->None:\n print(\"an exception was raised in the listening thread: {}\".format(exception))\n\n with persizmq.ThreadedSubscriber(\n lambda msg: storage.add_message(persizmq.filter.MaxSize(max_size=1000)(msg)),\n subscriber=subscriber,\n on_exception=on_exception):\n\n msg = storage.front() # non-blocking\n if msg is not None:\n print(\"Received a persistent message: {}\".format(msg))\n storage.pop_front()\n\n\nInstallation\n============\n\n* Create a virtual environment:\n\n.. code-block:: bash\n\n python3 -m venv venv3\n\n* Activate it:\n\n.. code-block:: bash\n\n source venv3/bin/activate\n\n* Install persizmq with pip:\n\n.. code-block:: bash\n\n pip3 install persizmq\n\nDevelopment\n===========\n\n* Check out the repository.\n\n* In the repository root, create the virtual environment:\n\n.. code-block:: bash\n\n python3 -m venv venv3\n\n* Activate the virtual environment:\n\n.. code-block:: bash\n\n source venv3/bin/activate\n\n* Install the development dependencies:\n\n.. code-block:: bash\n\n pip3 install -e .[dev]\n\n* We use tox for testing and packaging the distribution. Assuming that the virtual environment has been activated and\n the development dependencies have been installed, run:\n\n.. code-block:: bash\n\n tox\n\n* We also provide a set of pre-commit checks that lint and check code for formatting. Run them locally from an activated\n virtual environment with development dependencies:\n\n.. code-block:: bash\n\n ./precommit.py\n\n* The pre-commit script can also automatically format the code:\n\n.. code-block:: bash\n\n ./precommit.py --overwrite\n\nVersioning\n==========\nWe follow `Semantic Versioning `_. The version X.Y.Z indicates:\n\n* X is the major version (backward-incompatible),\n* Y is the minor version (backward-compatible), and\n* Z is the patch version (backward-compatible bug fix).", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Parquery/persizmq", "keywords": "persistent zeromq", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "persizmq", "package_url": "https://pypi.org/project/persizmq/", "platform": "", "project_url": "https://pypi.org/project/persizmq/", "project_urls": { "Homepage": "https://github.com/Parquery/persizmq" }, "release_url": "https://pypi.org/project/persizmq/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "provides persistence to zeromq.", "version": "1.0.3" }, "last_serial": 5410394, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "0b2065966c661ac9691367c041b00227", "sha256": "4cf1dfaafade9ce6bdeb67740812efc938090d28465ab6f8c15911eddc44b023" }, "downloads": -1, "filename": "persizmq-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0b2065966c661ac9691367c041b00227", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6492, "upload_time": "2018-02-27T10:38:13", "url": "https://files.pythonhosted.org/packages/66/a9/b30f32f2aa971358ef716db774e95bc1f9f4075ca06fda4525cb64c4db64/persizmq-0.0.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "10f81dc52eba72dda75c9f866b2c28fd", "sha256": "53a077f6e716a6903b6a53c50fa6281a50d8314de202a9f8793742456847591b" }, "downloads": -1, "filename": "persizmq-1.0.0.tar.gz", "has_sig": false, "md5_digest": "10f81dc52eba72dda75c9f866b2c28fd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5692, "upload_time": "2018-05-05T08:12:53", "url": "https://files.pythonhosted.org/packages/d9/44/6540b0552bc9a65a3e1b2e1260b7ba4b7b02a8ba768ca56dba044fdcf07c/persizmq-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "77201934a82cd068c035141f27cb6b19", "sha256": "bd7545a6d6b276c7bc4ba0b7ab8fafa0d7fb1457b701a8a834587f39eb2f07dc" }, "downloads": -1, "filename": "persizmq-1.0.1.tar.gz", "has_sig": false, "md5_digest": "77201934a82cd068c035141f27cb6b19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6142, "upload_time": "2018-05-05T08:14:40", "url": "https://files.pythonhosted.org/packages/7d/44/da9efacd7f241772bc6beac7d1f7b344ff5b69f1a729e479bc59ad2915dd/persizmq-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "f8129d2038bc274bc682d6a5f295a7a4", "sha256": "6d273186ebc4df90d36b1a4d9ddf1aba8ae5639936542116f2a40d222ba3293f" }, "downloads": -1, "filename": "persizmq-1.0.2.tar.gz", "has_sig": false, "md5_digest": "f8129d2038bc274bc682d6a5f295a7a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6565, "upload_time": "2018-05-07T16:03:38", "url": "https://files.pythonhosted.org/packages/6d/b0/09226d1abec31dc62eb362d19f36b0ca3b451f32dbbcb4f75c844ad0dc7e/persizmq-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "75d8df058ed2138b0b7e01b305f8329b", "sha256": "80967dfffd2a699a5cbf12bef481dde54e69ca7347e4c36f8ac04cd1421850fa" }, "downloads": -1, "filename": "persizmq-1.0.3.tar.gz", "has_sig": false, "md5_digest": "75d8df058ed2138b0b7e01b305f8329b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6660, "upload_time": "2018-08-03T14:55:10", "url": "https://files.pythonhosted.org/packages/14/26/123c1bde346544ce70d0d28a1bd1fd823f10b5845ea2fabd0efbedffceaf/persizmq-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "75d8df058ed2138b0b7e01b305f8329b", "sha256": "80967dfffd2a699a5cbf12bef481dde54e69ca7347e4c36f8ac04cd1421850fa" }, "downloads": -1, "filename": "persizmq-1.0.3.tar.gz", "has_sig": false, "md5_digest": "75d8df058ed2138b0b7e01b305f8329b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6660, "upload_time": "2018-08-03T14:55:10", "url": "https://files.pythonhosted.org/packages/14/26/123c1bde346544ce70d0d28a1bd1fd823f10b5845ea2fabd0efbedffceaf/persizmq-1.0.3.tar.gz" } ] }