{"id":18770173,"url":"https://github.com/lotuc/backoff","last_synced_at":"2025-12-11T11:30:38.751Z","repository":{"id":206231487,"uuid":"716170380","full_name":"lotuc/backoff","owner":"lotuc","description":"Backoff \u0026 retries for Clojure/Script","archived":false,"fork":false,"pushed_at":"2023-11-13T16:08:33.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T07:40:57.568Z","etag":null,"topics":["backoff","clojure","clojurescript","retry-library"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/lotuc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-11-08T15:27:49.000Z","updated_at":"2023-11-13T16:00:53.000Z","dependencies_parsed_at":"2023-11-12T11:20:25.246Z","dependency_job_id":"9aae8bcc-61db-449c-9713-2d715de15d48","html_url":"https://github.com/lotuc/backoff","commit_stats":null,"previous_names":["lotuc/backoff"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lotuc%2Fbackoff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lotuc%2Fbackoff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lotuc%2Fbackoff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lotuc%2Fbackoff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lotuc","download_url":"https://codeload.github.com/lotuc/backoff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239675843,"owners_count":19678680,"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","clojure","clojurescript","retry-library"],"created_at":"2024-11-07T19:18:26.581Z","updated_at":"2025-12-11T11:30:33.454Z","avatar_url":"https://github.com/lotuc.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Clojars Project](https://img.shields.io/clojars/v/org.lotuc/backoff.svg)](https://clojars.org/org.lotuc/backoff)\n\n# Backoff\n\nThis library mimics the go package\n[github.com/cenkalti/backoff/v4](https://github.com/cenkalti/backoff).\n\n## Usage\n\nCheckout more use case [here](./test/lotuc/backoff_test.cljc).\n\n### Backoff\n\n```clojure\n(require '[lotuc.backoff :as b])\n\n;; nil represents *stop* backoff\n(-\u003e nil b/backoff)  ; =\u003e nil\n\n;; integer/long as constant backoff\n(-\u003e 2 b/backoff)       ; =\u003e 2\n(-\u003e 2 b/nxt b/backoff) ; =\u003e 2\n;; negative value *stops* backoff\n(-\u003e -1 b/backoff)      ; =\u003e nil\n\n;; integer/long sequence as backoff\n(-\u003e (range 1 5) b/backoff)       ; =\u003e 1\n(-\u003e (range 1 5) b/nxt b/backoff) ; =\u003e 2\n(-\u003e '() b/backoff)               ; =\u003e nil\n\n;; exponential backoff\n(def b0 (b/make-exponential-backoff))\n[(-\u003e b0 b/backoff) (-\u003e b0 b/nxt b/backoff) (-\u003e b0 b/nxt b/nxt b/backoff)] ; =\u003e [503 1099 1128]\n```\n\n### Retries\n\n```clojure\n(require '[lotuc.backoff :as b])\n\n(let [i (atom 0)\n      f (fn [] (if (\u003c (Math/random) 0.5) @i\n                   (do (swap! i inc)\n                       (throw (ex-info \"error\" {:i @i})))))\n      notify (fn [err b] (println \"i:\" (:i (ex-data err)) \", backoff:\" (b/backoff b)))]\n  (b/retry\u003c!! f (b/make-exponential-backoff) {:notify notify}))\ni: 1 , backoff: 595\ni: 2 , backoff: 1108\ni: 3 , backoff: 2303\n;; =\u003e 3\n\n;; setup max-retries with `with-max-retries`\n(let [i (atom 0)\n      f (fn [] (do (swap! i inc)\n                   (throw (ex-info \"error\" {:i @i}))))\n      notify (fn [err b] (println \"i:\" (:i (ex-data err)) \", backoff:\" (b/backoff b)))]\n  (b/retry\u003c!! f (b/with-max-retries 100 5) {:notify notify}))\ni: 1 , backoff: 100\ni: 2 , backoff: 100\ni: 3 , backoff: 100\ni: 4 , backoff: 100\ni: 5 , backoff: 100\n;; =\u003e throws error\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flotuc%2Fbackoff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flotuc%2Fbackoff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flotuc%2Fbackoff/lists"}