{"id":19637853,"url":"https://github.com/n-r-w/retrypool","last_synced_at":"2026-06-18T14:31:33.192Z","repository":{"id":231093929,"uuid":"780812504","full_name":"n-r-w/retrypool","owner":"n-r-w","description":"Go worker pool with error control","archived":false,"fork":false,"pushed_at":"2024-11-25T18:37:36.000Z","size":29,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T22:17:05.735Z","etag":null,"topics":["go","workerpool"],"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/n-r-w.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-04-02T07:53:30.000Z","updated_at":"2024-04-18T10:00:13.000Z","dependencies_parsed_at":"2024-04-02T13:06:20.270Z","dependency_job_id":"9eaaa835-8cdf-41a7-8b95-d45168a85c13","html_url":"https://github.com/n-r-w/retrypool","commit_stats":null,"previous_names":["n-r-w/retrypool"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/n-r-w/retrypool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-r-w%2Fretrypool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-r-w%2Fretrypool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-r-w%2Fretrypool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-r-w%2Fretrypool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n-r-w","download_url":"https://codeload.github.com/n-r-w/retrypool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n-r-w%2Fretrypool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34495377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"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":["go","workerpool"],"created_at":"2024-11-11T12:36:30.752Z","updated_at":"2026-06-18T14:31:33.175Z","avatar_url":"https://github.com/n-r-w.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/n-r-w/retrypool.svg)](https://pkg.go.dev/github.com/n-r-w/retrypool)\n[![Go Coverage](https://github.com/n-r-w/retrypool/wiki/coverage.svg)](https://raw.githack.com/wiki/n-r-w/retrypool/coverage.html)\n![CI Status](https://github.com/n-r-w/retrypool/actions/workflows/go.yml/badge.svg)\n[![Stability](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n[![Go Report](https://goreportcard.com/badge/github.com/n-r-w/retrypool)](https://goreportcard.com/badge/github.com/n-r-w/retrypool)\n\n# RetryPool\n\nThe RetryPool package provides a mechanism for executing tasks with automatic retry and error handling capabilities. It allows you to define a work function that performs the actual task, an error handling function that determines whether to retry or stop based on the error, and a success handling function that is called when the task is successfully completed.\n\nThe RetryPool is created with a specified number of worker goroutines and a maximum number of tasks that can be queued. Tasks are added to the pool using the Add method, and the pool executes them concurrently. The pool automatically retries failed tasks based on the error handling function and configurable retry settings.\n\nIts also supports various configuration options, such as maximum age for a task, retry delay, maximum retry delay, and processing delay. These options allow you to fine-tune the behavior of the RetryPool according to your specific requirements.\n\n## Installation\n\n```bash\ngo get github.com/n-r-w/retrypool\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/n-r-w/retrypool\"\n)\n\ntype Data struct {\n    Value int\n}\n\nfunc main() {\n    // Define your work function\n    workFunc := func(ctx context.Context, v Data, age time.Duration) error {\n        if age \u003c time.Second/2 {\n            fmt.Printf(\"Processing with error: %v after %v\\n\", v, age)\n            return fmt.Errorf(\"error %v\", v)\n        }\n\n        fmt.Printf(\"Processing: %v after %v\\n\", v, age)\n        return nil\n    }\n\n    // Define your error handling function\n    errorFunc := func(err error, v Data, age time.Duration, closing bool) bool {\n        fmt.Printf(\"Error: %v after %v\\n\", v, age)\n\n        if closing {\n            fmt.Printf(\"Closing: %v after %v\\n\", v, age)\n        }\n\n        return age \u003c time.Minute // Retry for a minute\n    }\n\n    // Define your success handling function\n    successFunc := func(v Data, age time.Duration) {\n        fmt.Printf(\"Success: %v after %v\\n\", v, age)\n    }\n\n    // Create a new RetryPool\n    pool := retrypool.New(100, 100, 2, workFunc, errorFunc,\n        retrypool.WithMaxAge[Data](time.Minute*10),\n        retrypool.WithRetryDelay[Data](time.Second/2),\n        retrypool.WithMaxRetryDelay[Data](time.Second),\n        retrypool.WithProcessingDelay[Data](time.Hour),\n        retrypool.WithSuccessFunc[Data](successFunc))\n\n    // Add tasks to the pool\n    pool.Add(Data{Value: 1})\n    \n    time.Sleep(time.Second * 2)\n\n    pool.Stop()\n}\n```\n\nOutput:\n\n```\nProcessing with error: {1} after 19.191µs\nError: {1} after 36.772µs\nProcessing: {1} after 1.000079775s\nSuccess: {1} after 1.000079775s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn-r-w%2Fretrypool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn-r-w%2Fretrypool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn-r-w%2Fretrypool/lists"}