{"id":19169048,"url":"https://github.com/dreamph/workerpool","last_synced_at":"2026-02-05T20:34:08.898Z","repository":{"id":223256612,"uuid":"759741829","full_name":"dreamph/workerpool","owner":"dreamph","description":"Golang Worker Pool","archived":false,"fork":false,"pushed_at":"2025-01-13T03:14:03.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T14:52:17.126Z","etag":null,"topics":["golang","worker","workerpool"],"latest_commit_sha":null,"homepage":"","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/dreamph.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,"zenodo":null}},"created_at":"2024-02-19T08:50:47.000Z","updated_at":"2025-01-13T03:14:07.000Z","dependencies_parsed_at":"2025-04-19T23:31:34.508Z","dependency_job_id":"c3af7751-1873-4eb3-b7ff-ce5aaad3b588","html_url":"https://github.com/dreamph/workerpool","commit_stats":null,"previous_names":["dreamph/workerpool"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dreamph/workerpool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fworkerpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fworkerpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fworkerpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fworkerpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreamph","download_url":"https://codeload.github.com/dreamph/workerpool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Fworkerpool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29133400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T19:36:52.185Z","status":"ssl_error","status_checked_at":"2026-02-05T19:35:40.941Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["golang","worker","workerpool"],"created_at":"2024-11-09T09:44:49.805Z","updated_at":"2026-02-05T20:34:08.873Z","avatar_url":"https://github.com/dreamph.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Basic Usage\n\n\n# Example Worker Pool\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/signal\"\n\t\"time\"\n\n\t\"github.com/dreamph/workerpool\"\n)\n\nfunc main() {\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\tpool := workerpool.NewPool(ctx, 20, 10)\n\n\t// Submit 20 tasks\n\tfor i := 0; i \u003c 20; i++ {\n\t\tn := i\n\t\tpool.Submit(func() {\n\t\t\tTestFn(n)\n\t\t})\n\t}\n\n\t// Stop the pool and wait for all submitted tasks to complete\n\tpool.Wait()\n\n\t// Output:\n\t/*\n\t\tEnd of task #0\n\t\tEnd of task #10\n\t\tEnd of task #5\n\t\tEnd of task #13\n\t\tEnd of task #8\n\t\tEnd of task #4\n\t\tEnd of task #9\n\t\tEnd of task #11\n\t\tEnd of task #12\n\t\tEnd of task #19\n\t\tEnd of task #7\n\t\tEnd of task #15\n\t\tEnd of task #16\n\t\tEnd of task #17\n\t\tEnd of task #6\n\t\tEnd of task #18\n\t\tEnd of task #3\n\t\tEnd of task #1\n\t\tEnd of task #14\n\t\tEnd of task #2\n\t*/\n\n}\n\nfunc TestFn(n int) {\n\ttime.Sleep(3 * time.Second)\n\tfmt.Println(fmt.Sprintf(\"End of task #%d\", n))\n}\n\n\n\n```\n# Example Worker Pool with Result\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"os/signal\"\n\t\"time\"\n\n\t\"fmt\"\n\n\t\"github.com/dreamph/workerpool\"\n)\n\ntype Result struct {\n\tSuccess bool   `json:\"success\"`\n\tData    string `json:\"data\"`\n}\n\nfunc main() {\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\tpool := workerpool.NewResultPool[int, Result](ctx, 20, 10)\n\n\t// Submit 20 tasks\n\tfor i := 0; i \u003c 20; i++ {\n\t\tn := i\n\t\tpool.Submit(n, func() (Result, error) {\n\t\t\treturn TestFn(n)\n\t\t})\n\t}\n\n\t// Stop the pool and wait for all submitted tasks to complete\n\tpoolResponse := pool.Wait()\n\n\tpoolResults := poolResponse.Result()\n\n\tfor key, value := range poolResults {\n\t\tfmt.Println(fmt.Sprintf(\"%d : [%v,%s]\", key, value.Data.Success, value.Data.Data))\n\t}\n\n\t// Output:\n\t/*\n\t\t0 : [true,Result of task #0]\n\t\t2 : [true,Result of task #2]\n\t\t15 : [true,Result of task #15]\n\t\t3 : [true,Result of task #3]\n\t\t12 : [true,Result of task #12]\n\t\t8 : [true,Result of task #8]\n\t\t6 : [true,Result of task #6]\n\t\t11 : [true,Result of task #11]\n\t\t1 : [true,Result of task #1]\n\t\t9 : [true,Result of task #9]\n\t\t18 : [true,Result of task #18]\n\t\t4 : [true,Result of task #4]\n\t\t13 : [true,Result of task #13]\n\t\t19 : [true,Result of task #19]\n\t\t10 : [true,Result of task #10]\n\t\t7 : [true,Result of task #7]\n\t\t14 : [true,Result of task #14]\n\t\t16 : [true,Result of task #16]\n\t\t17 : [true,Result of task #17]\n\t\t5 : [true,Result of task #5]\n\t*/\n}\n\nfunc TestFn(n int) (Result, error) {\n\tv := fmt.Sprintf(\"Result of task #%d\", n)\n\t//fmt.Println(v)\n\ttime.Sleep(3 * time.Second)\n\treturn Result{Success: true, Data: v}, nil\n}\n\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Fworkerpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreamph%2Fworkerpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Fworkerpool/lists"}