{"id":32149302,"url":"https://github.com/fumoboy007/swift-retry","last_synced_at":"2026-03-02T05:31:17.097Z","repository":{"id":211694511,"uuid":"729755624","full_name":"fumoboy007/swift-retry","owner":"fumoboy007","description":"Retries in Swift with sensible defaults and powerful flexibility.","archived":false,"fork":false,"pushed_at":"2024-06-05T16:39:38.000Z","size":86,"stargazers_count":139,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-03T10:33:30.104Z","etag":null,"topics":["async-await","backoff-algorithms","backoff-strategy","exponential-backoff","jitter","retries","retry","retrying","swift","swift-concurrency"],"latest_commit_sha":null,"homepage":"https://fumoboy007.github.io/swift-retry/documentation/retry/","language":"Swift","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/fumoboy007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-10T08:52:45.000Z","updated_at":"2026-01-31T07:33:46.000Z","dependencies_parsed_at":"2023-12-22T22:32:04.113Z","dependency_job_id":"0e6844f3-79b2-4239-b526-711b0cb9708b","html_url":"https://github.com/fumoboy007/swift-retry","commit_stats":null,"previous_names":["fumoboy007/swift-retry"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fumoboy007/swift-retry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumoboy007%2Fswift-retry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumoboy007%2Fswift-retry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumoboy007%2Fswift-retry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumoboy007%2Fswift-retry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fumoboy007","download_url":"https://codeload.github.com/fumoboy007/swift-retry/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumoboy007%2Fswift-retry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29993376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"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":["async-await","backoff-algorithms","backoff-strategy","exponential-backoff","jitter","retries","retry","retrying","swift","swift-concurrency"],"created_at":"2025-10-21T09:53:35.093Z","updated_at":"2026-03-02T05:31:17.078Z","avatar_url":"https://github.com/fumoboy007.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swift-retry\n\nRetries in Swift with sensible defaults and powerful flexibility.\n\n![Swift 5.9](https://img.shields.io/badge/swift-v5.9-%23F05138)\n![Linux, visionOS 1, macOS 13, iOS 16, tvOS 16, watchOS 9](https://img.shields.io/badge/platform-Linux%20%7C%20visionOS%201%20%7C%20macOS%2013%20%7C%20iOS%2016%20%7C%20tvOS%2016%20%7C%20watchOS%209-blue)\n![MIT License](https://img.shields.io/github/license/fumoboy007/swift-retry)\n![Automated Tests Workflow Status](https://img.shields.io/github/actions/workflow/status/fumoboy007/swift-retry/tests.yml?event=push\u0026label=tests)\n\n## Basic Usage\n\n```swift\ntry await retry {\n   try await doSomething()\n}\n```\n\nSee the [documentation](https://fumoboy007.github.io/swift-retry/documentation/retry/) for examples of more advanced use cases.\n\n## Overview\n\n### Designed for Swift Concurrency\n\nThe `retry` function is an `async` function that runs the given `async` closure repeatedly until it succeeds or until the failure is no longer retryable. The function sleeps in between attempts while respecting task cancellation.\n\n### Sensible Defaults\n\nThe library uses similar defaults as [Amazon Web Services](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html) and [Google Cloud](https://github.com/googleapis/gax-go/blob/465d35f180e8dc8b01979d09c780a10c41f15136/v2/call_option.go#L181-L205).\n\nAn important but often overlooked default is the choice of backoff algorithm, which determines how long to sleep in between attempts. This library chooses an [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) algorithm by default, which is suitable for most use cases. Most retry use cases involve a resource, such as a server, with potentially many clients where an exponential backoff algorithm would be ideal to avoid [DDoSing the resource](https://cloud.google.com/blog/products/gcp/how-to-avoid-a-self-inflicted-ddos-attack-cre-life-lessons).\n\n### Powerful Flexibility\n\nThe API provides several customization points to accommodate any use case:\n- Retries can be selectively enabled or disabled for specific error cases by providing a custom `recoverFromFailure` closure. Retries can also be selectively enabled or disabled for specific code paths by wrapping thrown errors with `Retryable` or `NotRetryable`. \n- The `RetryConfiguration` type encapsulates the retry behavior so that it can be reused across multiple call sites without duplicating code.\n- The `Backoff` type represents the choice of algorithm that will be used to determine how long to sleep in between attempts. It has built-in support for common algorithms but can be initialized with a custom `BackoffAlgorithm` implementation if needed.\n- The clock that is used to sleep in between attempts can be replaced. For example, one might use a fake `Clock` implementation in automated tests to ensure the tests are deterministic and efficient.\n\n### Safe Retries\n\nThe module exposes a `RetryableRequest` protocol to add safe retry methods to a conforming request type. The retry methods in the protocol are similar to the top-level retry functions, but safer. The retry methods in the protocol enforce that the request is idempotent since it is unsafe to retry a non-idempotent request.\n\nTo retry HTTP requests, consider using the [`swift-http-error-handling`](https://swiftpackageindex.com/fumoboy007/swift-http-error-handling) package, which adds `RetryableRequest` conformance to the standard `HTTPRequest` type.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumoboy007%2Fswift-retry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffumoboy007%2Fswift-retry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumoboy007%2Fswift-retry/lists"}