@@ -27,7 +27,8 @@ module Network.Wait (
27
27
waitSocketWith ,
28
28
29
29
-- * Utility
30
- recoveringWith
30
+ recoveringWith ,
31
+ recoveringWithStatus
31
32
) where
32
33
33
34
-------------------------------------------------------------------------------
@@ -164,7 +165,7 @@ waitSocketWith
164
165
=> [RetryStatus -> Handler m Bool ] -> RetryPolicyM m -> AddrInfo
165
166
-> m Socket
166
167
waitSocketWith hs policy addr =
167
- recoveringWith hs policy $ \ retryStatus ->
168
+ recoveringWithStatus hs policy $ \ retryStatus ->
168
169
-- all of the networking code runs in IO
169
170
liftIO $
170
171
-- we want to make sure that we close the socket after every attempt;
@@ -194,8 +195,28 @@ waitSocketWith hs policy addr =
194
195
-- the standard output or a logger.
195
196
recoveringWith
196
197
:: (MonadIO m , MonadMask m )
197
- => [RetryStatus -> Handler m Bool ] -> RetryPolicyM m -> (RetryStatus -> m a ) -> m a
198
- recoveringWith hs policy action =
198
+ => [RetryStatus -> Handler m Bool ] -> RetryPolicyM m -> m a -> m a
199
+ recoveringWith hs policy =
200
+ recoveringWithStatus hs policy . const
201
+
202
+
203
+ -- | `recoveringWithStatus` @extraHandlers retryPolicy action@ will attempt to
204
+ -- run @action@. If the @action@ fails, @retryPolicy@ is used
205
+ -- to determine whether (and how often) this function should attempt to
206
+ -- retry @action@. The `RetryStatus` is given to @action@ as argument.
207
+ -- By default, this function will retry after all
208
+ -- exceptions (except for those given by `skipAsyncExceptions`). This
209
+ -- behaviour may be customised with @extraHandlers@ which are installed
210
+ -- after `skipAsyncExceptions`, but before the default exception handler.
211
+ -- The @extraHandlers@ may also be used to report retry attempts to e.g.
212
+ -- the standard output or a logger.
213
+ recoveringWithStatus
214
+ :: (MonadIO m , MonadMask m )
215
+ => [RetryStatus -> Handler m Bool ]
216
+ -> RetryPolicyM m
217
+ -> (RetryStatus -> m a )
218
+ -> m a
219
+ recoveringWithStatus hs policy action =
199
220
-- apply the retry policy to the following code, with the combinations of
200
221
-- the `skipAsyncExceptions`, given, and default handlers. The order of
201
222
-- the handlers matters as they are checked in order.
0 commit comments