{"id":17739020,"url":"https://github.com/pierrekieffer/mongostream","last_synced_at":"2026-04-21T03:31:47.166Z","repository":{"id":57562040,"uuid":"313905259","full_name":"PierreKieffer/mongoStream","owner":"PierreKieffer","description":"MongoDB streaming service  to launch async streams in parallel","archived":false,"fork":false,"pushed_at":"2021-04-02T09:00:59.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T15:50:52.735Z","etag":null,"topics":["async","asynchronous-programming","change-streams","mongodb","mongodb-streaming-service","streaming"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PierreKieffer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-18T10:52:28.000Z","updated_at":"2021-04-02T09:01:01.000Z","dependencies_parsed_at":"2022-09-16T13:50:15.635Z","dependency_job_id":null,"html_url":"https://github.com/PierreKieffer/mongoStream","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/PierreKieffer%2FmongoStream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreKieffer%2FmongoStream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreKieffer%2FmongoStream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreKieffer%2FmongoStream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PierreKieffer","download_url":"https://codeload.github.com/PierreKieffer/mongoStream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246531986,"owners_count":20792735,"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":["async","asynchronous-programming","change-streams","mongodb","mongodb-streaming-service","streaming"],"created_at":"2024-10-26T02:06:58.797Z","updated_at":"2025-11-01T11:04:04.133Z","avatar_url":"https://github.com/PierreKieffer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoStream \n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.png\"\u003e\n\u003c/p\u003e\n\nmongoStream is a mongodb streaming service based on mongodb change streams feature. \n\nThe service allows to launch asynchronous streams in parallel.  \n\n\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Usage](#usage)\n* [Example](#example)\n\n\n## Requirements \n\n* System requirements:\n\t- mongodb 4.2 or higher\n\t- mongodb replica set available\n\n* Dependencies : \n\t- mongodb driver `go get go.mongodb.org/mongo-driver/mongo`\n\n## Installation \n\n`go get github.com/PierreKieffer/mongoStream`\n\n## Usage \n\nTo get started, import `mongoStream` package\n\n```go \nimport (\n        \"github.com/PierreKieffer/mongoStream/services\"\n)\n\n```\n\nSet up the mongo connection string \n\n```go \nmongoUri := \"mongodb://localhost:27017\"\n```\n\nInitialize messages buffer : \n\nThe buffer is a channel and allows to accumulate messages generated by the streaming service. The initialization takes the size of the buffer as a parameter (ie the number of messages that the buffer can contain).\n\n```go\nvar buffer = services.InitBuffer(10) \n```\n\nStart one or more workers in parallel :\n\nParameters : \n- mongodb connection string \n- database name \n- collection name \n- buffer \n- stream options [optional]\n\n```go \ngo services.ListenerWorker(mongoUri, \"database\", \"collection1\", buffer)\ngo services.ListenerWorker(mongoUri, \"database\", \"collection2\", buffer)\n```\n\nStructure of messages generated by workers and received by the buffer : \n\n```json\n{\n    \"DocumentKey\": {           \n        \"DocumentId\": \"string type\"       \n    },\n    \"Namespace\": {\n        \"Database\": \"string type\",        \n        \"Collection\": \"string type\"\n    },\n    \"OperationType\": \"string type\",\n    \"UpdateDescription\": {\n        \"updatedFields\": \"map[string]interface{} type\"\n    }\n}\n\n```\n\nTo resume a stream from a timestamp : \n\n```go \ncso := services.SetOptions(true, 1586360547)\ngo services.ListenerWorker(mongoUri, \"database\", \"collection1\", buffer,cso)\n```\n\n## Example \n```go\npackage main\n\nimport (\n        \"github.com/PierreKieffer/mongoStream/dataModel\"\n        \"github.com/PierreKieffer/mongoStream/services\"\n        \"log\"\n)\n\nvar exit = make(chan bool)\n\nfunc main() {\n\n        mongoUri := \"mongodb://localhost:27017\"\n\n        // Init oplog buffer channel\n        var buffer = services.InitBuffer(10)\n\n        // Start consumer\n        go Consumer(buffer)\n\n        // Start producers\n        go services.ListenerWorker(mongoUri, \"database\", \"collection1\", buffer)\n        go services.ListenerWorker(mongoUri, \"database\", \"collection2\", buffer)\n\n        \u003c-exit\n}\n\nfunc Consumer(logBuffer chan dataModel.Oplog) {\n        for {\n                log.Println(\"reveived data : \", \u003c-logBuffer)\n        }\n\n}\n\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierrekieffer%2Fmongostream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierrekieffer%2Fmongostream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierrekieffer%2Fmongostream/lists"}