{"id":37230788,"url":"https://github.com/fireflycons/workerpool","last_synced_at":"2026-01-15T03:40:14.185Z","repository":{"id":332074810,"uuid":"1130878781","full_name":"fireflycons/workerpool","owner":"fireflycons","description":"Package workerpool provides a wrapper around github.com/cilium/workerpool to facilitate processing items from a concurrentqueue.Queue","archived":false,"fork":false,"pushed_at":"2026-01-12T12:43:23.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-12T18:39:55.238Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fireflycons.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-09T06:29:02.000Z","updated_at":"2026-01-12T12:42:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fireflycons/workerpool","commit_stats":null,"previous_names":["fireflycons/workerpool"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fireflycons/workerpool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fworkerpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fworkerpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fworkerpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fworkerpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireflycons","download_url":"https://codeload.github.com/fireflycons/workerpool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fworkerpool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28442310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"online","status_checked_at":"2026-01-15T02:00:08.019Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-01-15T03:40:13.655Z","updated_at":"2026-01-15T03:40:14.178Z","avatar_url":"https://github.com/fireflycons.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n# workerpool\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/fireflycons/workerpool.svg)](https://pkg.go.dev/github.com/fireflycons/workerpool) [![build](https://github.com/fireflycons/workerpool/actions/workflows/build.yml/badge.svg)](https://github.com/fireflycons/workerpool/actions/workflows/build.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/fireflycons/workerpool)](https://goreportcard.com/report/github.com/fireflycons/workerpool)\n\nPackage workerpool provides a wrapper around [github.com/cilium/workerpool](https://pkg.go.dev/github.com/cilium/workerpool) to facilitate processing items from a [concurrentqueue.Queue](https://pkg.go.dev/github.com/fireflycons/concurrentqueue) using a pool of workers.\n\n## Features\n* Generic\n* Uses [concurrentqueue](https://pkg.go.dev/github.com/fireflycons/concurrentqueue) to feed workers and as optional dead letter queue\n* Four run options\n* Mutex-free\n* Dead letter queue support\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"sync\"\n\n\tqueue \"github.com/fireflycons/concurrentqueue\"\n\t\"github.com/fireflycons/workerpool\"\n)\n\ntype result struct {\n\tinput  int\n\tsquare int\n}\n\nfunc (r result) String() string {\n\treturn fmt.Sprintf(\"input: %d, square: %d\", r.input, r.square)\n}\n\nfunc main() {\n\n\tq := queue.New[int]()\n\n\tfor i := range 100 {\n\t\terr := q.Enqueue(i)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Enqueue error: %v\\n\", err)\n\t\t}\n\t}\n\n\tq.Close()\n\n\tresultsChan := make(chan result, 10)\n\n\twg := sync.WaitGroup{}\n\tctx := context.Background() // You would use a more meaningful context\n\n\twg.Go(func() {\n\t\t_, err := workerpool.RunWorkersWithResults(\n\t\t\tfunc(ctx context.Context, in \u003c-chan int, out chan\u003c- result, _ *queue.Queue[int]) error {\n\t\t\t\tfor v := range in {\n\t\t\t\t\tselect {\n\t\t\t\t\tcase \u003c-ctx.Done():\n\t\t\t\t\t\treturn ctx.Err()\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// If a dead letter queue is provided (last argument), failed items would be sent there\n\t\t\t\t\t\tout \u003c- result{input: v, square: v * v}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tq,\n\t\t\tresultsChan,\n\t\t\tworkerpool.WithContext[int](ctx),  // Default is context.Background() if this option is not provided.\n\t\t\tworkerpool.WithNumWorkers[int](4), // Default is runtime.NumCPU() if this option is not provided.\n\t\t)\n\t\tclose(resultsChan)\n\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Error starting workers: %v\\n\", err))\n\t\t}\n\t})\n\n\twg.Go(func() {\n\t\tfor r := range resultsChan {\n\t\t\tfmt.Println(r)\n\t\t}\n\t})\n\n\twg.Wait()\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireflycons%2Fworkerpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireflycons%2Fworkerpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireflycons%2Fworkerpool/lists"}