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
Expresses a policy for retrying Affjax requests with backoff.
162
+
163
+
#### `defaultRetryPolicy`
164
+
165
+
```purescript
166
+
defaultRetryPolicy :: RetryPolicy
167
+
```
168
+
169
+
A sensible default for retries: no timeout, maximum delay of 30s, initial delay of 0.1s, exponential backoff, and no status code triggers a retry.
170
+
147
171
#### `retry`
148
172
149
173
```purescript
150
-
retry :: forall e a b. (Requestable a) => Maybe Int -> (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
151
175
```
152
176
153
-
Retry a request with exponential backoff, timing out optionally after a specified number of milliseconds. 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.
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.
@@ -124,48 +129,68 @@ delete u = affjax $ defaultRequest { method = DELETE, url = u }
124
129
delete_::foralle. URL->AffjaxeUnit
125
130
delete_ = delete
126
131
132
+
-- | A sequence of retry delays, in milliseconds.
133
+
typeRetryDelayCurve=Int->Int
134
+
135
+
-- | Expresses a policy for retrying Affjax requests with backoff.
136
+
typeRetryPolicy
137
+
={timeout::MaybeInt-- ^ the timeout in milliseconds, optional
138
+
, delayCurve::RetryDelayCurve
139
+
, shouldRetryWithStatusCode::StatusCode->Boolean-- ^ whether a non-200 status code should trigger a retry
140
+
}
141
+
142
+
-- | A sensible default for retries: no timeout, maximum delay of 30s, initial delay of 0.1s, exponential backoff, and no status code triggers a retry.
-- | Either we have a failure (which may be an exception or a failed response), or we have a successful response.
128
151
typeRetryStateea=Either (Eitherea) a
129
152
130
-
-- | Retry a request with exponential backoff, timing out optionally after a specified number of milliseconds. 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.
131
-
retry::foralleab. (Requestablea) =>MaybeInt-> (AffjaxRequesta->Affjax (avar::AVAR| e) b) -> (AffjaxRequesta->Affjax (avar::AVAR | e) b)
132
-
retry milliseconds run req = do
133
-
--failureVar is either an exception or a failed request
134
-
failureVar<-makeVar
135
-
let loop = go failureVar
136
-
casemillisecondsof
153
+
-- | 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.
154
+
retry::foralleab. (Requestablea) =>RetryPolicy-> (AffjaxRequesta->Affjax (avar::AVAR, ref::REF| e) b) -> (AffjaxRequesta->Affjax (avar::AVAR, ref::REF | e) b)
155
+
retry policy run req = do
156
+
--failureRef is either an exception or a failed request
0 commit comments