{"id":13502514,"url":"https://github.com/patrys/pymongo-pubsub","last_synced_at":"2025-03-29T12:31:59.457Z","repository":{"id":2682582,"uuid":"3675019","full_name":"patrys/pymongo-pubsub","owner":"patrys","description":"a publish-subscribe pattern implementation for pymongo","archived":true,"fork":false,"pushed_at":"2017-01-11T07:02:43.000Z","size":6,"stargazers_count":29,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T22:32:05.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://room-303.com/blog/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patrys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-09T21:30:25.000Z","updated_at":"2023-07-09T05:49:39.000Z","dependencies_parsed_at":"2022-07-21T11:29:18.679Z","dependency_job_id":null,"html_url":"https://github.com/patrys/pymongo-pubsub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrys%2Fpymongo-pubsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrys%2Fpymongo-pubsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrys%2Fpymongo-pubsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrys%2Fpymongo-pubsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrys","download_url":"https://codeload.github.com/patrys/pymongo-pubsub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246186788,"owners_count":20737453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:16.414Z","updated_at":"2025-03-29T12:31:59.225Z","avatar_url":"https://github.com/patrys.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"pymongo-pubsub — a publish-subscribe pattern implementation for pymongo\n=======================================================================\n\nEver wished you could use your MongoDB to drive an event-driven environment?\n\nNow you can.\n\npymongo-pubsub uses a round-robin *capped* collection to store its data on one\nend and a *tailable* cursor to catch it as it is inserted on the other.\n\nThe publisher\n-------------\n\nA publisher is a piece of code responsible for pumping data into the database:\n\n\n```python\nimport pymongo\nfrom pymongo_pubsub import Publisher\n\nconnection = pymongo.Connection()\ndatabase = connection.pubsub_db\n\npublisher = Publisher(database, 'test_event')\npublisher.push({'message': 'hello world', 'answer': 42})\n```\n\nA `Publisher` will take care of setting up the underlying collection. You can\npass it optional `max_size` and `max_length` parameters to define storage\nlimits of the collection at the time it is created. The default size is\n`1000000` bytes and the default length limit is `None`.\n\nMake sure your queue is big enough to never overflow or you're going to start\nlosing data. You care about your data, right?\n\nThe subscriber\n--------------\n\nA subscriber is a piece of code responsible for processing data as it is pulled\nfrom the database:\n\n```python\nimport pymongo\nfrom pymongo_pubsub import Subscriber\n\nconnection = pymongo.Connection()\ndatabase = connection.pubsub_db\n\ndef test_cb(data):\n    print '{0:f}: {1:s}'.format(data['_id'], data['message'])\n\nsubscriber = Subscriber(database, 'test_event', callback=test_cb,\n                        matching={'answer': 42})\nsubscriber.listen()\n```\n\nA `Subscriber` will never create any collections in the database and in case\nthe collections is missing it will cowardly raise a `KeyError` exception.\nThis is not a bug. This is to avoid having to synchronize collection limits\nbetween the publisher and all of the subscribers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrys%2Fpymongo-pubsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrys%2Fpymongo-pubsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrys%2Fpymongo-pubsub/lists"}