Skip to content

Commit c8e6f99

Browse files
authored
fix availability (#4)
1 parent b4b66ec commit c8e6f99

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Sources/AsyncAlgorithms/Retry/Backoff.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public protocol BackoffStrategy<Duration> {
5050
@usableFromInline let factor: Int
5151
@usableFromInline init(factor: Int, initial: Duration) {
5252
precondition(initial >= .zero, "Initial must be greater than or equal to 0")
53-
precondition(factor >= 1, "Factor must be greater than or equal to 1")
53+
precondition(factor >= .zero, "Factor must be greater than or equal to 0")
5454
self.current = initial
5555
self.factor = factor
5656
}
@@ -154,6 +154,10 @@ public enum Backoff {
154154
@inlinable public static func exponential(factor: Int, initial: Duration) -> some BackoffStrategy<Duration> {
155155
return ExponentialBackoffStrategy(factor: factor, initial: initial)
156156
}
157+
}
158+
159+
@available(iOS 18.0, macCatalyst 18.0, macOS 15.0, tvOS 18.0, visionOS 2.0, watchOS 11.0, *)
160+
extension Backoff {
157161
@inlinable public static func decorrelatedJitter<RNG: RandomNumberGenerator>(factor: Int, base: Duration, using generator: RNG) -> some BackoffStrategy<Duration> {
158162
return DecorrelatedJitterBackoffStrategy(base: base, factor: factor, generator: generator)
159163
}

Sources/AsyncAlgorithms/Retry/Retry.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public struct RetryStrategy<Duration: DurationProtocol> {
1717
}
1818

1919
@available(iOS 16.0, macCatalyst 16.0, macOS 13.0, tvOS 16.0, visionOS 1.0, watchOS 9.0, *)
20-
@inlinable
21-
public func retry<Result, ErrorType, ClockType>(
20+
@inlinable public func retry<Result, ErrorType, ClockType>(
2221
maxAttempts: Int = 3,
2322
tolerance: ClockType.Instant.Duration? = nil,
2423
clock: ClockType,
@@ -45,8 +44,7 @@ public func retry<Result, ErrorType, ClockType>(
4544
}
4645

4746
@available(iOS 16.0, macCatalyst 16.0, macOS 13.0, tvOS 16.0, visionOS 1.0, watchOS 9.0, *)
48-
@inlinable
49-
public func retry<Result, ErrorType>(
47+
@inlinable public func retry<Result, ErrorType>(
5048
maxAttempts: Int = 3,
5149
tolerance: ContinuousClock.Instant.Duration? = nil,
5250
isolation: isolated (any Actor)? = #isolation,

0 commit comments

Comments
 (0)