{"id":18581921,"url":"https://github.com/coder/retry","last_synced_at":"2025-04-10T11:35:40.367Z","repository":{"id":45381184,"uuid":"112229966","full_name":"coder/retry","owner":"coder","description":"A tiny retry package for Go.","archived":false,"fork":false,"pushed_at":"2023-11-11T23:27:02.000Z","size":89,"stargazers_count":41,"open_issues_count":0,"forks_count":2,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-02T22:35:29.994Z","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":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.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":"2017-11-27T18:01:43.000Z","updated_at":"2025-02-16T02:57:18.000Z","dependencies_parsed_at":"2023-11-12T00:23:41.918Z","dependency_job_id":null,"html_url":"https://github.com/coder/retry","commit_stats":null,"previous_names":["cdr/retry","codercom/retry"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fretry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fretry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fretry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fretry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/retry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208688,"owners_count":21065205,"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-11-07T00:08:23.072Z","updated_at":"2025-04-10T11:35:35.350Z","avatar_url":"https://github.com/coder.png","language":"Go","readme":"# retry\n\nAn exponentially backing off retry package for Go.\n\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/coder/retry)\n\n```\ngo get github.com/coder/retry@latest\n```\n\n`retry` promotes control flow using `for`/`goto` instead of callbacks.\n\n## Examples\n\nWait for connectivity to google.com, checking at most once every\nsecond:\n\n```go\nfunc pingGoogle(ctx context.Context) error {\n\tvar err error\n\n\tr := retry.New(time.Second, time.Second*10);\n\n\t// Jitter is useful when the majority of clients to a service use\n\t// the same backoff policy.\n\t//\n\t// It is provided as a standard deviation.\n\tr.Jitter = 0.1\n\n  retry:\n\t_, err = http.Get(\"https://google.com\")\n\tif err != nil {\n\t\tif r.Wait(ctx) {\n\t\t\tgoto retry\n\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}\n```\n\nWait for connectivity to google.com, checking at most 10 times:\n```go\nfunc pingGoogle(ctx context.Context) error {\n\tvar err error\n\t\n\tfor r := retry.New(time.Second, time.Second*10); n := 0; r.Wait(ctx) \u0026\u0026 n \u003c 10; n++ {\n\t\t_, err = http.Get(\"https://google.com\")\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tbreak\n\t}\n\treturn err\n}\n```","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fretry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fretry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fretry/lists"}