{"id":27253468,"url":"https://github.com/marselester/backoff","last_synced_at":"2025-04-11T01:27:42.938Z","repository":{"id":54211094,"uuid":"522093750","full_name":"marselester/backoff","owner":"marselester","description":"Go port of the exponential backoff algorithm recommended in Polly project.","archived":false,"fork":false,"pushed_at":"2022-08-07T02:00:57.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T00:41:38.883Z","etag":null,"topics":["backoff","golang","retry"],"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/marselester.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":"2022-08-07T01:53:22.000Z","updated_at":"2022-08-07T11:42:47.000Z","dependencies_parsed_at":"2022-08-13T09:20:13.843Z","dependency_job_id":null,"html_url":"https://github.com/marselester/backoff","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbackoff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbackoff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbackoff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbackoff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marselester","download_url":"https://codeload.github.com/marselester/backoff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248324348,"owners_count":21084693,"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":["backoff","golang","retry"],"created_at":"2025-04-11T01:27:42.296Z","updated_at":"2025-04-11T01:27:42.930Z","avatar_url":"https://github.com/marselester.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backoff 🤚 [![Documentation](https://godoc.org/github.com/marselester/backoff?status.svg)](https://pkg.go.dev/github.com/marselester/backoff) [![Go Report Card](https://goreportcard.com/badge/github.com/marselester/backoff)](https://goreportcard.com/report/github.com/marselester/backoff)\n\nThis package generates sleep durations in an exponentially backing-off,\njittered manner, making sure to mitigate any correlations.\nIt is a Go port of the exponential backoff algorithm\n[recommended in Polly project](https://github.com/Polly-Contrib/Polly.Contrib.WaitAndRetry#new-jitter-recommendation).\n\n\u003e a new jitter formula characterised by very smooth and even distribution of retry intervals,\n\u003e a well-controlled median initial retry delay, and broadly exponential backoff.\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/marselester/backoff\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tr := backoff.NewDecorrJitter(\n\t\tbackoff.WithMaxRetries(5),\n\t)\n\n\terr := backoff.Run(ctx, r, func(attempt int) error {\n\t\tfmt.Printf(\"%d attempt\\n\", attempt)\n\t\treturn fmt.Errorf(\"timeout\")\n\t})\n\tif err != nil {\n\t\tfmt.Printf(\"all the attempts failed: %v\\n\", err)\n\t}\n}\n```\n\nThere are 6 calls to a function: the first attempt and 5 retries.\n\n```\n1 attempt\n2 attempt\n3 attempt\n4 attempt\n5 attempt\n6 attempt\nall the attempts failed: timeout\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbackoff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarselester%2Fbackoff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbackoff/lists"}