You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Network.HTTP.Affjax.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,7 @@ A sensible default for retries: no timeout, maximum delay of 30s, initial delay
171
171
#### `retry`
172
172
173
173
```purescript
174
-
retry :: forall e a b. (Requestable a) => RetryPolicy -> (AffjaxRequest a -> Affjax (avar :: AVAR| e) b) -> AffjaxRequest a -> Affjax (avar :: AVAR | e) b
174
+
retry :: forall e a b. (Requestable a) => RetryPolicy -> (AffjaxRequest a -> Affjax (avar :: AVAR, ref :: REF | e) b) -> AffjaxRequest a -> Affjax (avar :: AVAR, ref :: REF | e) b
175
175
```
176
176
177
177
Retry a request using a `RetryPolicy`. After the timeout, the last received response is returned; if it was not possible to communicate with the server due to an error, then this is bubbled up.
-- | Retry a request using a `RetryPolicy`. After the timeout, the last received response is returned; if it was not possible to communicate with the server due to an error, then this is bubbled up.
152
-
retry::foralleab. (Requestablea) =>RetryPolicy-> (AffjaxRequesta->Affjax (avar::AVAR| e) b) -> (AffjaxRequesta->Affjax (avar::AVAR | e) b)
154
+
retry::foralleab. (Requestablea) =>RetryPolicy-> (AffjaxRequesta->Affjax (avar::AVAR, ref::REF| e) b) -> (AffjaxRequesta->Affjax (avar::AVAR, ref::REF | e) b)
153
155
retry policy run req = do
154
-
--failureVar is either an exception or a failed request
155
-
failureVar<-makeVar
156
-
let loop = go failureVar
156
+
--failureRef is either an exception or a failed request
157
+
failureRef<-liftEff $ newRef Nothing
158
+
let loop = go failureRef
157
159
case policy.timeout of
158
160
Nothing-> loop 1
159
161
Just timeout ->do
@@ -165,7 +167,11 @@ retry policy run req = do
165
167
loopHandle `cancel` error "Cancel"
166
168
result <- takeVar respVar
167
169
case result of
168
-
Nothing-> takeVar failureVar >>= either throwError pure
170
+
Nothing->do
171
+
failure <- liftEff $ readRef failureRef
172
+
case failure of
173
+
Nothing-> throwError $ error "Timeout"
174
+
Just failure -> either throwError pure failure
169
175
Just resp -> pure resp
170
176
where
171
177
retryState::Either__->RetryState__
@@ -179,12 +185,12 @@ retry policy run req = do
179
185
else
180
186
Right resp
181
187
182
-
go failureVar n = do
188
+
go failureRef n = do
183
189
result <- retryState <$> attempt (run req)
184
190
case result of
185
191
Left err ->do
186
-
putVar failureVar err
187
-
later' (policy.delayCurve n) $ go failureVar (n + 1)
192
+
liftEff $ writeRef failureRef $ Just err
193
+
later' (policy.delayCurve n) $ go failureRef (n + 1)
0 commit comments