{"id":17287412,"url":"https://github.com/adamslevy/retry","last_synced_at":"2025-10-13T09:41:22.818Z","repository":{"id":57501665,"uuid":"215743689","full_name":"AdamSLevy/retry","owner":"AdamSLevy","description":"Golang package for retrying operations with composable retry policies.","archived":false,"fork":false,"pushed_at":"2019-10-17T18:43:33.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T11:06:28.904Z","etag":null,"topics":[],"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/AdamSLevy.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":"2019-10-17T08:39:24.000Z","updated_at":"2021-01-06T13:32:34.000Z","dependencies_parsed_at":"2022-09-19T09:10:40.277Z","dependency_job_id":null,"html_url":"https://github.com/AdamSLevy/retry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fretry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fretry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fretry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fretry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdamSLevy","download_url":"https://codeload.github.com/AdamSLevy/retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868768,"owners_count":21174757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-15T10:02:15.852Z","updated_at":"2025-10-13T09:41:17.784Z","avatar_url":"https://github.com/AdamSLevy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# retry [![GoDoc](https://godoc.org/github.com/AdamSLevy/retry?status.svg)](http://godoc.org/github.com/AdamSLevy/retry) [![Report card](https://goreportcard.com/badge/github.com/AdamSLevy/retry)](https://goreportcard.com/report/github.com/AdamSLevy/retry) [![Travis-CI](https://travis-ci.org/AdamSLevy/retry.svg)](https://travis-ci.org/AdamSLevy/retry) [![Coverage Status](https://coveralls.io/repos/github/AdamSLevy/retry/badge.svg?branch=master)](https://coveralls.io/github/AdamSLevy/retry?branch=master)\n\nPackage retry provides a reliable, simple way to retry operations.\n\n`go get -u github.com/AdamSLevy/retry`\n\n```golang\n\t// The provided policies can be composed to a custom Policy.\n\tpolicy := retry.LimitTotal{25 * time.Minute,\n\t\tretry.LimitAttempts{10,\n\t\t\tretry.Max{10 * time.Minute,\n\t\t\t\tretry.Randomize{.5,\n\t\t\t\t\tretry.Exponential{5 * time.Second, 2}}}}}\n\n\t// A notify function is called before each wait period.\n\tnotify := func(err error, attempt uint, d time.Duration) {\n\t\tfmt.Printf(\"Attempt %v returned %v. Retrying in %v...\\n\",\n\t\t\tattempt, err, d)\n\t}\n\n\t// A filter function can be used to omit or wrap certain errors to tell\n\t// Run to stop immediately.\n\tfilter := func(err error) error {\n\t\tif errors.Is(err, errors.New(\"unrecoverable err\")) {\n\t\t\treturn retry.ErrorStop(err)\n\t\t}\n\t\treturn err\n\t}\n\n\t// A context.Context may be passed so that waits can be canceled.\n\tvar ctx = context.TODO()\n\n\terr := retry.Run(ctx, policy, filter, notify, func() error {\n\t\treturn tryWork(ctx)\n\t})\n\tif err != nil {\n\t\treturn\n\t}\n```\n\nThis package was inspired by\n[github.com/cenkalti/backoff](https://github.com/cenkalti/backoff) but improves\non the design by providing Policy types that are composable, re-usable and safe\nfor repeated or concurrent calls to Run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fretry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamslevy%2Fretry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fretry/lists"}