{"id":22477737,"url":"https://github.com/swiftuiux/retry-policy-service","last_synced_at":"2026-03-09T19:12:34.960Z","repository":{"id":121460109,"uuid":"610645611","full_name":"swiftuiux/retry-policy-service","owner":"swiftuiux","description":"Retry policies for network requests in swift DispatchTimeInterval to Duration swift retry swift Retry strategies library Retry policies for network requests Retry strategies for API calls Configurable retry strategies for REST Exponential backoff algorithm","archived":false,"fork":false,"pushed_at":"2024-11-30T13:10:24.000Z","size":26,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T00:56:05.713Z","etag":null,"topics":["concurrency","duration","ios","retry-intervals","retry-pattern","retry-policy","retry-strategies","retry-swift","retrying","swift","timeinterval"],"latest_commit_sha":null,"homepage":"","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/swiftuiux.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,"zenodo":null}},"created_at":"2023-03-07T07:36:13.000Z","updated_at":"2025-01-08T15:01:57.000Z","dependencies_parsed_at":"2024-08-22T06:10:57.078Z","dependency_job_id":"21f2b8a2-9638-4236-ab64-d192ee7b8076","html_url":"https://github.com/swiftuiux/retry-policy-service","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"d008989260e5968217d82efe7db781378cdeac90"},"previous_names":["igor11191708/retry-policy-service","the-igor/retry-policy-service","igor111917180/retry-policy-service","swiftuiux/retry-policy-service"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/swiftuiux/retry-policy-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fretry-policy-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fretry-policy-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fretry-policy-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fretry-policy-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftuiux","download_url":"https://codeload.github.com/swiftuiux/retry-policy-service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftuiux%2Fretry-policy-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30308870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T17:35:44.120Z","status":"ssl_error","status_checked_at":"2026-03-09T17:35:43.707Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["concurrency","duration","ios","retry-intervals","retry-pattern","retry-policy","retry-strategies","retry-swift","retrying","swift","timeinterval"],"created_at":"2024-12-06T14:12:05.466Z","updated_at":"2026-03-09T19:12:34.943Z","avatar_url":"https://github.com/swiftuiux.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Retry service provides policy for how often some operation should happen with the timeout limit and delay between events\n\nThe service creates sequence of the delays (nanoseconds) according to chosen strategy \n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fswiftuiux%2Fretry-policy-service%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/swiftuiux/retry-policy-service)\n\nThere are two strategies\n\n| type | description |\n| --- | --- |\n| constant | The strategy implements constant backoff  |\n| exponential [default] | Exponential backoff is a strategy in which you increase the delays between retries  |\n\n```swift\n        /// Constant delay between retries\n        case constant(\n            retry : UInt = 5,\n            duration: DispatchTimeInterval,\n            timeout: DispatchTimeInterval \n        )\n        \n        /// Exponential backoff is a strategy in which you increase the delays between retries\n        case exponential(\n            retry : UInt = 3,\n            multiplier: Double = 2.0, // power exponent\n            duration: DispatchTimeInterval,\n            timeout: DispatchTimeInterval \n        )\n\n```\n\n## SwiftUI example\n\n[example for retry service](https://github.com/swiftuiux/retry-policy-service-example)\n\n## Packages using the package\n\n[Async http client](https://github.com/swiftuiux/async-http-client)\n\n## How to use\n\n```swift\nfinal class ViewModel : ObservableObject{\n    \n    func constant() async {\n        let policy = RetryService(strategy: .constant())\n        for delay in policy{\n            try? await Task.sleep(nanoseconds: delay)\n            // do something\n        }\n    }\n    \n    func exponential() async {\n        let policy = RetryService(\n                strategy: .exponential(\n                retry: 5, \n                multiplier: 2, \n                duration: .seconds(1), \n                timeout: .seconds(5)\n               )\n             )\n                \n        for delay in policy{\n            try? await Task.sleep(nanoseconds: delay)\n            // do something\n        }\n    }\n}\n\nstruct ContentView: View {\n    \n    @StateObject var model = ViewModel()\n    \n    var body: some View {\n        VStack {\n            Button(\"constatnt\") { Task { await model.constant() } }\n            Button(\"exponential\") { Task { await model.exponential() } }\n        }\n        .padding()\n        .task {\n            await model.exponential()\n        }\n        \n    }\n}\n```\n\n## TODO:\n\nExponential backoff with jitter. Jitter adds some amount of randomness to the backoff to spread the retries around in time.\nFor more information [Exponential Backoff And Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftuiux%2Fretry-policy-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftuiux%2Fretry-policy-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftuiux%2Fretry-policy-service/lists"}