{ "info": { "author": "Diogo Magalhaes Martins", "author_email": "magalhaesmartins@icloud.com", "bugtrack_url": null, "classifiers": [], "description": "Mongo Observer\n==============\n\nMongo Observer aims to provide an easy way to asynchronously subscribe\nto state change events on a given mongo collection.\n\nInstallation\n============\n\n``pip install mongo_observer``\n\nUsage\n=====\n\nThe Observer\n------------\n\nThe ``Observer`` handles state change observation on a given collection\nand dispatches events, delegating the responsibility to a handler.\n\nHandlers\n--------\n\nHandlers are objects that implement the ``OperationHandler`` protocol\nand implement the following abstract methods:\n\nasync def on\\_insert(self, operation: Dict[str, Any])\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhere ``operation`` is a dict containing a document corresponding to an\noperation on oplog. It will contain the following keys:\n\n- ``ts``: Timestamp of the operationa\n- ``h``: An unique signed long identifier of the operation\n- ``op``: A character representing the type of the operation\n- ``ns``: A namespace string formed with the concatenation of\n 'database.collection'\n- ``o``: The inserted document\n\nasync def on\\_update(self, operation: Dict[str, Any])\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhere ``operation`` is a dict containing a document corresponding to an\noperation on oplog. It will contain the following keys:\n\n- ``ts``: Timestamp of the operation\n- ``h``: An unique signed long identifier of the operation\n- ``op``: A character representing the type of the operation\n- ``ns``: A namespace string formed with the concatenation of\n 'database.collection'\n- ``o``: The operation data performed on the document\n- ``o2``: A dict with a single \\_id key of the document to be updated\n\nasync def on\\_delete(self, operation: Dict[str, Any])\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhere ``operation`` is a dict containing a document corresponding to an\noperation on oplog. It will contain the following keys:\n\n- ``ts``: Timestamp of the operation\n- ``h``: An unique signed long identifier of the operation\n- ``op``: A character representing the type of the operation\n- ``ns``: A namespace string formed with the concatenation of\n 'database.collection'\n- ``o``: A dict with a single \\_id key, of the ddeleted document\n\nReactiveCollection\n------------------\n\nA ``ReactiveCollection`` is a read-only, in-memory, non-persistent\nreplica of a remote mongo collection. It reacts to state changes caused\nby write operations (inserts, updates and deletes) on the remote\ncollection.\n\n.. code:: python\n\n import asyncio\n\n from motor.motor_asyncio import AsyncIOMotorClient\n\n from mongo_observer.observer import Observer\n from mongo_observer.operation_handlers import ReactiveCollection\n\n\n async def run(loop):\n client = AsyncIOMotorClient('mongodb://127.0.0.1')\n\n collection_to_observe = client['your_db']['your_collection']\n reactive_collection = await ReactiveCollection.init_async(collection_to_observe)\n \n observer = await Observer.init_async(oplog=client['local']['oplog.rs'],\n operation_handler=reactive_collection,\n namespace_filter='your_db.your_collection')\n \n loop.create_task(observer.observe_changes())\n\n\n loop = asyncio.get_event_loop()\n loop.run_until_complete(run(loop))\n loop.run_forever()\n\nOnce ``ReactiveCollection.init_async`` runs, it will perform an initial\nsync with the remote collection. We then connect it as the\n``operation_handler`` of an ``Observer``, and we are ready to\n``observe_changes`` to the current state of the collection.\n\nReactivePartialCollection\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nto-do\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/diogommartins/mongo_observer", "keywords": "collection mongodb oplog observer livecollection meteor", "license": "", "maintainer": "", "maintainer_email": "", "name": "mongo_observer", "package_url": "https://pypi.org/project/mongo_observer/", "platform": "", "project_url": "https://pypi.org/project/mongo_observer/", "project_urls": { "Homepage": "https://github.com/diogommartins/mongo_observer" }, "release_url": "https://pypi.org/project/mongo_observer/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "", "version": "0.0.1" }, "last_serial": 3309092, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f3a4f36e2e784e0814fc7990a831c1c0", "sha256": "bf948966477feb8e73364a5d47862f96ece3ca0e6955778a7f07ae1c0e13be8a" }, "downloads": -1, "filename": "mongo_observer-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f3a4f36e2e784e0814fc7990a831c1c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4872, "upload_time": "2017-11-06T11:11:10", "url": "https://files.pythonhosted.org/packages/b9/17/b13d50987b88b4520624514b305acfa9670161767086aa5fd94303991115/mongo_observer-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f3a4f36e2e784e0814fc7990a831c1c0", "sha256": "bf948966477feb8e73364a5d47862f96ece3ca0e6955778a7f07ae1c0e13be8a" }, "downloads": -1, "filename": "mongo_observer-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f3a4f36e2e784e0814fc7990a831c1c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4872, "upload_time": "2017-11-06T11:11:10", "url": "https://files.pythonhosted.org/packages/b9/17/b13d50987b88b4520624514b305acfa9670161767086aa5fd94303991115/mongo_observer-0.0.1.tar.gz" } ] }