{"id":16931862,"url":"https://github.com/maxgio92/go-mpsc-queue","last_synced_at":"2025-03-21T03:27:47.264Z","repository":{"id":65271066,"uuid":"589177214","full_name":"maxgio92/go-mpsc-queue","owner":"maxgio92","description":"A simple implementation of a multiple producers, single consumer, messages queue","archived":false,"fork":false,"pushed_at":"2023-06-05T15:44:12.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T00:16:42.575Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxgio92.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-15T10:33:43.000Z","updated_at":"2023-01-15T10:34:25.000Z","dependencies_parsed_at":"2024-11-26T10:22:15.114Z","dependency_job_id":"cba74713-542a-4da2-b63c-9f3bf653f9f1","html_url":"https://github.com/maxgio92/go-mpsc-queue","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"9115797c8ee1f292681baa239199002fa2ee4d8c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgio92%2Fgo-mpsc-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgio92%2Fgo-mpsc-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgio92%2Fgo-mpsc-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxgio92%2Fgo-mpsc-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxgio92","download_url":"https://codeload.github.com/maxgio92/go-mpsc-queue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244731132,"owners_count":20500596,"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-10-13T20:44:52.674Z","updated_at":"2025-03-21T03:27:47.245Z","avatar_url":"https://github.com/maxgio92.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPSC queue in Go\n\nThis is a simple implementation of a multiple producers, single consumer queue in Go.\n\nIt provides a queue for messages and a queue for errors, and simple helpers to manage synchronization.\n\nIt leverages `sync.WaitGroup` and `channel`s. Producers are synchronized through `sync.WaitGroup`.\nSynchronization with the consumer happens through a dedicated `channel`.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\n\tgompscqueue \"github.com/maxgio92/go-mpsc-queue\"\n)\n\nfunc main() {\n\tparallelism := 10\n\n\tqueue := gompscqueue.NewMPSCQueue(parallelism)\n\n\tfor i := 0; i \u003c parallelism; i++ {\n\t\tgo func() {\n\t\t\tdefer queue.SigProducerCompletion()\n\n\t\t\t// Here you do your work.\n\n\t\t\tqueue.SendMessage(\"Hello world from producer!\")\n\t\t}()\n\t}\n\n\tgo queue.Consume(\n\t\tfunc(msg interface{}) {\n\t\t\tfmt.Printf(\"new message: %s\\n\", msg)\n\t\t},\n\t\tfunc(err error) {\n\t\t\tfmt.Errorf(\"error: %s\\n\", err.Error())\n\t\t},\n\t)\n\n\tqueue.WaitAndClose()\n}\n```\n\n## Similarities\n\nOther packages do something similar, like:\n- [run](https://github.com/oklog/run)\n- [errgroup](https://pkg.go.dev/golang.org/x/sync/errgroup)\n- [tomb](https://pkg.go.dev/gopkg.in/tomb.v2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxgio92%2Fgo-mpsc-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxgio92%2Fgo-mpsc-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxgio92%2Fgo-mpsc-queue/lists"}