You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ahref="https://github.com/apple/swift-package-manager"alt="typhoon on Swift Package Manager"title="typhoon on Swift Package Manager"><imgsrc="https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg" /></a>
Typhoon is a modern, lightweight Swift framework that provides elegant and robust retry policies for asynchronous operations. Built with Swift's async/await concurrency model, it helps you handle transient failures gracefully with configurable retry strategies.
16
+
17
+
## Features
18
+
19
+
✨ **Multiple Retry Strategies** - Constant, exponential, and exponential with jitter
20
+
⚡ **Async/Await Native** - Built for modern Swift concurrency
21
+
🎯 **Type-Safe** - Leverages Swift's type system for compile-time safety
22
+
🔧 **Configurable** - Flexible retry parameters for any use case
23
+
📱 **Cross-Platform** - Works on iOS, macOS, tvOS, watchOS, and visionOS
24
+
⚡ **Lightweight** - Minimal footprint with zero dependencies
25
+
🧪 **Well Tested** - Comprehensive test coverage
26
+
27
+
## Table of Contents
16
28
17
-
-[Usage](#usage)
18
29
-[Requirements](#requirements)
19
30
-[Installation](#installation)
31
+
-[Quick Start](#quick-start)
32
+
-[Usage](#usage)
33
+
-[Retry Strategies](#retry-strategies)
34
+
-[Constant Strategy](#constant-strategy)
35
+
-[Exponential Strategy](#exponential-strategy)
36
+
-[Exponential with Jitter Strategy](#exponential-with-jitter-strategy)
37
+
-[Common Use Cases](#common-use-cases)
38
+
-[Error Handling](#error-handling)
20
39
-[Communication](#communication)
21
40
-[Contributing](#contributing)
41
+
-[Development Setup](#development-setup)
22
42
-[Author](#author)
23
43
-[License](#license)
24
44
45
+
## Requirements
46
+
47
+
| Platform | Minimum Version |
48
+
|-----------|----------------|
49
+
| iOS | 13.0+ |
50
+
| macOS | 10.15+ |
51
+
| tvOS | 13.0+ |
52
+
| watchOS | 6.0+ |
53
+
| visionOS | 1.0+ |
54
+
| Xcode | 15.3+ |
55
+
| Swift | 5.10+ |
56
+
57
+
## Installation
58
+
59
+
### Swift Package Manager
60
+
61
+
Add the following dependency to your `Package.swift`:
Ideal for avoiding overwhelming a failing service by progressively increasing wait times:
64
148
65
-
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but `typhoon` does support its use on supported platforms.
149
+
```swift
150
+
importTyphoon
66
151
67
-
Once you have your Swift package set up, adding `typhoon` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
152
+
// Retry up to 4 times with exponentially increasing delays
153
+
let service =RetryPolicyService(
154
+
strategy: .exponential(
155
+
retry: 4,
156
+
multiplier: 2.0,
157
+
duration: .seconds(1)
158
+
)
159
+
)
160
+
161
+
do {
162
+
let response =tryawait service.retry {
163
+
tryawaitperformNetworkRequest()
164
+
}
165
+
} catch {
166
+
print("Request failed after exponential backoff")
167
+
}
168
+
```
169
+
170
+
**Retry Timeline:**
171
+
- Attempt 1: Immediate
172
+
- Attempt 2: After 1 second (1 × 2⁰)
173
+
- Attempt 3: After 2 seconds (1 × 2¹)
174
+
- Attempt 4: After 4 seconds (1 × 2²)
175
+
176
+
### Exponential with Jitter Strategy
177
+
178
+
The most sophisticated strategy, adding randomization to prevent thundering herd problems:
- If you **have a feature request**, open an issue.
78
-
- If you **want to contribute**, submit a pull request.
319
+
320
+
- 🐛 **Found a bug?**[Open an issue](https://github.com/space-code/typhoon/issues/new)
321
+
- 💡 **Have a feature request?**[Open an issue](https://github.com/space-code/typhoon/issues/new)
322
+
- ❓ **Questions?**[Start a discussion](https://github.com/space-code/typhoon/discussions)
323
+
- 🔒 **Security issue?** Email nv3212@gmail.com
79
324
80
325
## Contributing
81
-
Bootstrapping development environment
82
326
83
-
```
327
+
We love contributions! Please feel free to help out with this project. If you see something that could be made better or want a new feature, open up an issue or send a Pull Request.
328
+
329
+
### Development Setup
330
+
331
+
Bootstrap the development environment:
332
+
333
+
```bash
84
334
make bootstrap
85
335
```
86
336
87
-
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!
0 commit comments