Skip to content

Commit 236a2d1

Browse files
authored
feat: Make RetryStrategyOptions initializer public (#571)
1 parent 24100df commit 236a2d1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Sources/ClientRuntime/Retries/ExponentialBackoffStrategy.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
import func Foundation.pow
99
import struct Foundation.TimeInterval
1010

11-
struct ExponentialBackoffStrategy: RetryBackoffStrategy {
11+
public struct ExponentialBackoffStrategy: RetryBackoffStrategy {
1212
let options: ExponentialBackoffStrategyOptions
1313

1414
var random: () -> Double = { Double.random(in: 0.0...1.0) }
1515

1616
// values set by Retry Behavior 2.0 SEP
1717
let r = 2.0
1818

19-
init(options: ExponentialBackoffStrategyOptions = ExponentialBackoffStrategyOptions()) {
19+
public init() {
20+
self.init(options: ExponentialBackoffStrategyOptions())
21+
}
22+
23+
init(options: ExponentialBackoffStrategyOptions) {
2024
self.options = options
2125
}
2226

23-
func computeNextBackoffDelay(attempt: Int) -> TimeInterval {
27+
public func computeNextBackoffDelay(attempt: Int) -> TimeInterval {
2428
min(random() * pow(r, Double(attempt)), options.maxBackoff)
2529
}
2630
}

Sources/ClientRuntime/Retries/RetryStrategyOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct RetryStrategyOptions {
4949
/// - maxRetriesBase: The number of times to retry the initial request. Defaults to 2.
5050
/// - availableCapacity: The number of available tokens in a retry quota. Defaults to 500.
5151
/// - maxCapacity: The max number of tokens in a retry quota. Defaults to 500.
52-
init(
52+
public init(
5353
backoffStrategy: RetryBackoffStrategy = ExponentialBackoffStrategy(),
5454
maxRetriesBase: Int = 2,
5555
availableCapacity: Int = 500,

0 commit comments

Comments
 (0)