{"id":17651989,"url":"https://github.com/sadlil/workgroup","last_synced_at":"2026-02-07T07:04:49.588Z","repository":{"id":257812091,"uuid":"868105510","full_name":"sadlil/workgroup","owner":"sadlil","description":"Enhanced errgroup.Group for managing collections of goroutines","archived":false,"fork":false,"pushed_at":"2024-10-06T14:55:48.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T07:18:41.020Z","etag":null,"topics":["golang","goroutine-pool"],"latest_commit_sha":null,"homepage":"","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/sadlil.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":"2024-10-05T13:46:29.000Z","updated_at":"2025-03-08T12:11:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"d147fd3b-419a-4ef5-bc53-692014bb67e1","html_url":"https://github.com/sadlil/workgroup","commit_stats":null,"previous_names":["sadlil/workgroup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sadlil/workgroup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadlil%2Fworkgroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadlil%2Fworkgroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadlil%2Fworkgroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadlil%2Fworkgroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sadlil","download_url":"https://codeload.github.com/sadlil/workgroup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadlil%2Fworkgroup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29188322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T05:07:31.176Z","status":"ssl_error","status_checked_at":"2026-02-07T05:06:15.227Z","response_time":63,"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","goroutine-pool"],"created_at":"2024-10-23T11:44:21.386Z","updated_at":"2026-02-07T07:04:49.583Z","avatar_url":"https://github.com/sadlil.png","language":"Go","readme":"# workgroup\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/sadlil/workgroup)](https://goreportcard.com/report/github.com/sadlil/workgroup)\n[![Go Reference](https://pkg.go.dev/badge/github.com/sadlil/workgroup.svg)](https://pkg.go.dev/github.com/sadlil/workgroup)\n[![Go Coverage](https://github.com/sadlil/workgroup/wiki/coverage.svg)](https://raw.githack.com/wiki/sadlil/workgroup/coverage.html)\n\n**workgroup** is a Go library designed for managing collections of goroutines\nthat work on subtasks of a common task.\n\nThis library is inspired by the [errgroup.Group](https://cs.opensource.google/go/x/sync/+/master:errgroup/)\nfrom the golang.org/x/sync, with additional features and modified behavior for\nhandling errors and cancellation.\n\n## Features\n\n- **Different Failure Modes**\n  - **Collect**: Allows all goroutines to complete, collects all errors, and returns a combined error.\n  - **FailFast**: Cancels all remaining goroutines as soon as the first error is encountered and returns that error.\n- **Retry**: Support for automated and configurable retries for individual tasks in the group.\n- **Concurrency Control**: Configure the maximum number of goroutines that can execute concurrently.\n\n## Acknowledgements\n\nGo Team: This project builds upon the foundation of the errgroup.Group implementation from the golang.org/x/sync package.\nThe core idea of managing goroutine lifecycle and errors originates from their work.\n\n## Installation\n\nTo get the workgroup package, run:\n\n```bash\ngo get github.com/sadlil/workgroup\n```\n\n## Examples\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"errors\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/sadlil/workgroup\"\n)\n\nfunc main() {\n    ctx := context.Background()\n    \n    // Create a new workgroup with Collect failure mode\n    ctx, g := workgroup.New(ctx, workgroup.Collect)\n\n    g.Go(ctx, func() error {\n        // Simulate a task\n        time.Sleep(100 * time.Millisecond)\n        return errors.New(\"task 1 failed\")\n    })\n\n    g.Go(ctx, func() error {\n        time.Sleep(200 * time.Millisecond)\n        return errors.New(\"task 2 failed\")\n    })\n\n    // Wait for all goroutines to complete\n    if err := g.Wait(); err != nil {\n        fmt.Printf(\"Workgroup completed with error: %v\\n\", err)\n    }\n}\n```\n\n### Example with FailFast Mode\n\nIn FailFast mode, the first error cancels all running goroutines and returns that error:\n\n```go\nctx, g := workgroup.New(ctx, workgroup.FailFast)\n\ng.Go(ctx, func() error {\n    time.Sleep(100 * time.Millisecond)\n    return errors.New(\"this error cancels all other tasks\")\n})\n\ng.Go(ctx, func() error {\n    // This will be canceled before it completes\n    time.Sleep(200 * time.Millisecond)\n    return nil\n})\n\nerr := g.Wait()\nfmt.Printf(\"Error encountered: %v\\n\", err)\n```\n\n### Workgroup with Limit\n\n```go\nctx, g := workgroup.New(ctx, workgroup.Collect, workgroup.WithLimit(2))\n\nfor i := 0; i \u003c 5; i++ {\n    g.Go(ctx, func() error {\n        // Simulate a task\n        time.Sleep(100 * time.Millisecond)\n        return nil\n    })\n}\n\ng.Wait()\n```\n\n### Workgroup with Retry\n\n```go\nctx, group := workgroup.New(ctx, \n    workgroup.Collect, \n    workgroup.WithRetry(\n        retry.Attempts(10), \n        retry.Delay(1*time.Second),\n    ))\n\nfor i := 0; i \u003c 5; i++ {\n    group.Go(ctx, func() error {\n        // Simulate a task\n        time.Sleep(100 * time.Millisecond)\n        return nil\n    })\n}\n\ngroup.Wait()\n```\n\nCheckout the unit tests for more examples.\n\n## API Documentation\n\nDetailed API documentation can be found at [Godoc](https://pkg.go.dev/github.com/sadlil/workgroup).\n\n## Contributing\n\nContributions are welcome! Feel free to open an issue or submit a pull request with improvements.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadlil%2Fworkgroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsadlil%2Fworkgroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadlil%2Fworkgroup/lists"}