File tree Expand file tree Collapse file tree
Snippets/Common Use Cases Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,20 +7,23 @@ import Retry
77
88// snippet.show
99
10- extension RetryConfiguration < ContinuousClock > {
11- static let standard = RetryConfiguration (
12- recoverFromFailure: { $0. isRetryable ? . retry : . throw }
13- )
10+ extension RetryConfiguration where ClockType. Duration == Duration {
11+ static func standard( using clock: ClockType = ContinuousClock ( ) ) -> Self {
12+ return RetryConfiguration (
13+ clock: clock,
14+ recoverFromFailure: { $0. isRetryable ? . retry : . throw }
15+ )
16+ }
1417
15- static let highTolerance = (
16- Self . standard
18+ static func highTolerance( using clock : ClockType = ContinuousClock ( ) ) -> Self {
19+ return standard ( using : clock )
1720 . withMaxAttempts ( 10 )
1821 . withBackoff ( . default( baseDelay: . seconds( 1 ) ,
1922 maxDelay: nil ) )
20- )
23+ }
2124}
2225
23- try await retry ( with: . highTolerance. withLogger ( myLogger) ) {
26+ try await retry ( with: . highTolerance( ) . withLogger ( myLogger) ) {
2427 try await doSomething ( )
2528}
2629
You can’t perform that action at this time.
0 commit comments