Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jflinter/sweetry
Retry things!
https://github.com/jflinter/sweetry
Last synced: 2 months ago
JSON representation
Retry things!
- Host: GitHub
- URL: https://github.com/jflinter/sweetry
- Owner: jflinter
- Created: 2015-12-13T06:12:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-13T06:14:55.000Z (about 9 years ago)
- Last Synced: 2023-03-22T19:55:59.793Z (almost 2 years ago)
- Language: Swift
- Size: 7.81 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sweetry
===Sweetry is a small Swift framework that allows for retrying operations that might fail. It depends on the (excellent) [BrightFutures](https://github.com/Thomvis/BrightFutures) library by @thomvis.
Installation
---To install via Carthage, add the following to your `Cartfile`:
```
github "jflinter/sweetry", ~> 0.1
```Example usage
---```swift
Retry(maxAttempts: 3, operation: {
let promise = Promise()
doSomeWorkThatMightFail({ result in
promise.complete(result)
})
return promise.future
}).start()```
Backoff strategy
---You can customize the schedule at which a Retry will re-attempt its work by passing it a `BackoffStrategy` in its initializer. The library implements two concrete implementations of this protocol, `Linear` and `Exponential`.