An open API service indexing awesome lists of open source software.

https://github.com/space-code/typhoon

Typhoon is a service for retry policies
https://github.com/space-code/typhoon

exponential-backoff retry retry-strategies swift

Last synced: 5 months ago
JSON representation

Typhoon is a service for retry policies

Awesome Lists containing this project

README

          

![Typhoon: a service for retry policies](https://raw.githubusercontent.com/space-code/typhoon/dev/Resources/typhoon.png)

typhoon


License
Swift Compatibility
Platform Compatibility
CI


## Description
`Typhoon` is a service for retry policies.

- [Usage](#usage)
- [Requirements](#requirements)
- [Installation](#installation)
- [Communication](#communication)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)

## Usage

`Typhoon` provides three retry policy strategies:

```swift
/// A retry strategy with a constant number of attempts and fixed duration between retries.
case constant(retry: Int, duration: DispatchTimeInterval)

/// A retry strategy with an exponential increase in duration between retries.
case exponential(retry: Int, multiplier: Double = 2.0, duration: DispatchTimeInterval)

/// A retry strategy with exponential increase in duration between retries and added jitter.
case exponentialWithJitter(retry: Int, jitterFactor: Double = 0.1, maxInterval: UInt64? = 60, multiplier: Double = 2.0, duration: DispatchTimeInterval)
```

Create a `RetryPolicyService` instance and pass a desired strategy like this:

```swift
import Typhoon

let retryPolicyService = RetryPolicyService(strategy: .constant(retry: 10, duration: .seconds(1)))

do {
_ = try await retryPolicyService.retry {
// Some logic here ...
}
} catch {
// Catch an error here ...
}
```

## Requirements

- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ / visionOS 1.0+
- Xcode 14.0
- Swift 5.7

## Installation
### Swift Package Manager

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.

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`.

```swift
dependencies: [
.package(url: "https://github.com/space-code/typhoon.git", .upToNextMajor(from: "1.0.0"))
]
```

## Communication
- If you **found a bug**, open an issue.
- If you **have a feature request**, open an issue.
- If you **want to contribute**, submit a pull request.

## Contributing
Bootstrapping development environment

```
make bootstrap
```

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!

## Author
Nikita Vasilev, nv3212@gmail.com

## License
typhoon is available under the MIT license. See the LICENSE file for more info.