{"id":34857374,"url":"https://github.com/mtfelian/dispatcher","last_synced_at":"2026-05-22T22:33:58.653Z","repository":{"id":57542857,"uuid":"118021131","full_name":"mtfelian/dispatcher","owner":"mtfelian","description":"go-routine based dispatcher","archived":false,"fork":false,"pushed_at":"2020-06-05T11:19:09.000Z","size":1876,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T05:05:34.305Z","etag":null,"topics":["conveyor","dispatcher","go-routine","worker-pool"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtfelian.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":"2018-01-18T18:24:29.000Z","updated_at":"2020-06-05T11:19:11.000Z","dependencies_parsed_at":"2022-09-26T18:31:23.673Z","dependency_job_id":null,"html_url":"https://github.com/mtfelian/dispatcher","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mtfelian/dispatcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfelian%2Fdispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfelian%2Fdispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfelian%2Fdispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfelian%2Fdispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtfelian","download_url":"https://codeload.github.com/mtfelian/dispatcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtfelian%2Fdispatcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33374368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-22T21:56:13.512Z","status":"ssl_error","status_checked_at":"2026-05-22T21:56:10.769Z","response_time":265,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["conveyor","dispatcher","go-routine","worker-pool"],"created_at":"2025-12-25T20:11:57.033Z","updated_at":"2026-05-22T22:33:58.648Z","avatar_url":"https://github.com/mtfelian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/mtfelian/dispatcher)](https://goreportcard.com/report/github.com/mtfelian/dispatcher)\n[![GoDoc](https://godoc.org/github.com/mtfelian/dispatcher?status.png)](http://godoc.org/github.com/mtfelian/dispatcher)\n[![Build status](https://travis-ci.org/mtfelian/dispatcher.svg?branch=master)](https://travis-ci.org/mtfelian/dispatcher)\n\n# Dispatcher\n\nDispatcher provides a concurrent tasks treating functionality based\non go-routines.\n\nAfter you initialize and run dispatcher it is ready to perform tasks.\n\nYou can add tasks via `AddWork()` func. Both `Run()` and `AddWork()`\nmust be called in separate go-routines. Tasks will be treated\nconcurrently but amount of workers will be limited to the parameter\nspecified at the dispatcher initialization call `New()`.\n\nTo stop the dispatcher you can use the `Stop()` func. But you should\nbe careful with it: just after this call the dispatcher stops\nreceiving new work and stops returning results even if the task was\nalready processed but result were not yet sent into appropriate channel.\nWhen `Stop()` was called, dispatcher flushes channels and exits.\n\nIf you need just to do tons of work with dispatcher and quit after\nwithout waiting for next portions of work, you can use the\n`WaitUntilNoTasks(period)` func. It checks the number of currently\nprocessing tasks each period of seconds. If it seems that dispatcher\nis not processing any task, it stops.\n\nThe `Treat()` by default is not thread-safe and one dispatcher performs\nmultiple of `Treat` at a time. Be careful using shared memory in it\nto avoid data races. The `onResultFunc` also is not thread-safe.\nYou should control safety by yourself.\n\nYou can use the second dispatcher and organize two dispatchers in\na conveyor pattern using `Treat` in first dispatcher to treat first\nstage data, and in the `onResultFunc` of the first dispatcher you may\ncall `go AddWork(...)` to send the result to the second dispatcher.\nThe second dispatcher will treat the data from the first's\n`onResultFunc` in it's own `Treat` of the returned element and return it\nin it's own  `onResultFunc`, this one of a second stage dispatcher.\nAnd so on: you can organize it in more stages.\n\nFor example of one-staged using please look into the tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtfelian%2Fdispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtfelian%2Fdispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtfelian%2Fdispatcher/lists"}