Navigation Menu

Skip to content

jflinter/Sweetry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sweetry

Sweetry is a small Swift framework that allows for retrying operations that might fail. It depends on the (excellent) BrightFutures library by @thomvis.

Installation

To install via Carthage, add the following to your Cartfile:

github "jflinter/sweetry", ~> 0.1

Example usage

Retry(maxAttempts: 3, operation: {
  let promise = Promise<MyValue, MyError>()
  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.