{"id":14008163,"url":"https://github.com/guumaster/mongodb-change-stream","last_synced_at":"2026-01-02T23:37:23.874Z","repository":{"id":67988930,"uuid":"234894178","full_name":"guumaster/mongodb-change-stream","owner":"guumaster","description":"Watch mongo changes with Golang","archived":false,"fork":false,"pushed_at":"2022-01-24T15:38:43.000Z","size":15213,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T09:31:38.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/guumaster.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-19T12:10:46.000Z","updated_at":"2023-03-08T05:11:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c13b75d-51e9-47e0-9282-1e1e6b232c20","html_url":"https://github.com/guumaster/mongodb-change-stream","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/guumaster%2Fmongodb-change-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guumaster%2Fmongodb-change-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guumaster%2Fmongodb-change-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guumaster%2Fmongodb-change-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guumaster","download_url":"https://codeload.github.com/guumaster/mongodb-change-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945648,"owners_count":20372906,"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-08-10T11:01:18.693Z","updated_at":"2026-01-02T23:37:23.835Z","avatar_url":"https://github.com/guumaster.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Mongo Change Stream POC\n\nThis repo shows how to watch changes in a collection with the ChangeStream API.\n\nIt consists of a mongo database with two nodes in replicaset, a watcher container that prints all documents inserted into the \"logs\" collection, and a generator container that generate random messages and make bulk inserts into the same \"logs\" collection. The generator container can be started with multiple replicas.\n\n\n## Requirements\n\n- Docker and Docker compose installed\n- A copy of [Nats Streaming UI](https://gitlab.com/united-travel-tickets/common/nats-streaming-ui)\n\n## Usage\n\n### Setup Mongo replica set\n\n1. First you need to start mongo in replicaset. Start the nodes: \n\n`docker-compose up -d mongo0 mongo1`\n\n2. Connect to one nodo and set the configuration:\n\n`docker exec -it mongo0 mongo`\n\n3. Once inside Mongo shell console, set the config and initiate the replicaset: \n\n```\nconfig={\"_id\":\"rs0\",\"members\":[{\"_id\":0,\"host\":\"mongo0:27017\"},{\"_id\":1,\"host\":\"mongo1:27017\"}]}\nrs.initiate()\n```\n\n### Clone nats-streaming-ui\n\n```\ngit clone --depth=1 git@gitlab.com:united-travel-tickets/common/nats-streaming-ui.git \n```\n\n### Start the watcher\n\nStart the ChangeStream watcher container:\n\n`docker-compose up mongo-watcher-socket`\n\n### Start the generators\n\nYou can start multiple generators with the scale command:\n\n`docker scale nats-generator=10`\n\nSet scale to 0 if you want to stop inserting messages into the logs collection\n\n### Open logs UI\n\n[http://localhost:5000](http://localhost:5000)\n\n\n\n## References\n\n* [How to simply set up Mongo's replica set locally with Docker](https://37yonub.ru/articles/mongo-replica-set-docker-localhost)\n* [go - Watch for MongoDB Change Streams - Stack Overflow](https://stackoverflow.com/questions/49151104/watch-for-mongodb-change-streams)\n* [Using the official MongoDB Go driver](https://vkt.sh/go-mongodb-driver-cookbook/)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguumaster%2Fmongodb-change-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguumaster%2Fmongodb-change-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguumaster%2Fmongodb-change-stream/lists"}