GitXplorerGitXplorer
g

retry-strategy-swift

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
ab8686d5529e162b68846c70c532f0414e59bf47

docs and some refactor

gganeshnj committed a year ago
Verified
f538a3fb8bcbe5391e9c7c96359bff5e01528c09

fixed delay

gganeshnj committed a year ago
Verified
0896628591968cdff359b9aaa4477bc2913a365b

extract error infor provider

gganeshnj committed a year ago
Verified
59856d34946ac31ddd096289024ea380283e0c94

indent

gganeshnj committed a year ago
Verified
c67faf17125e0edcf320212c21685311c0b589fc

fix typo and add readme

gganeshnj committed a year ago
Verified
f44c842e4374cb42776a8e4987eb871135a718b0

Initial

gganeshnj committed a year ago

README

The README file for this repository.

Implements retry strategy for executing a code of block (this focuses on HTTP request).

It uses token bucket and exponential backoff algorithm with jitter to control the rate of retry.

It uses learnings of AWS SDKs

Example usage

let tokenBucket = StandardRetryTokenBucket(configuration: .init())
let delayProvider = ExponentialBackoffWithJitter(configuration: .init())
let retryStrategy = StandardRetryStrategy(tokenBucket: tokenBucket, delayProvider: delayProvider)
let retryer = StandardRetryer(tokenBucket: tokenBucket, delayProvider: delayProvider, retryStrategy: retryStrategy, partition: "foobar")

let (data, _) = try await retryer.execute {
    let session = URLSession.shared
    let url = URL(string: "https://httpbin.org/get")!
    let (data, response) = try await session.data(from: url)
    let httpResponse = response as! HTTPURLResponse
    if httpResponse.statusCode != 200 {
        throw HTTPError(response: httpResponse, error: nil)
    }
    return (data, response)
}