Skip to content

Commit ea30dd1

Browse files
committed
default on-error-retry-fn? now considers java.net.http.HttpTimeoutException. v0.1.0
1 parent fd50466 commit ea30dd1

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 0.1.0 - 2022-10-15
4+
### Changed
5+
- default `on-error-retry-fn?` now also considers `java.net.http.HttpTimeoutException`
6+
37
## 0.0.2 - 2022-09-30
48
### Changed
59
- `reconnector` docstring now includes `get-url` and `get-opts` docs. No functional changes.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ JDK11 Clojure WebSocket client with core.async API
1616
## Install
1717
### **Leiningen/Boot**
1818
```clojure
19-
[io.github.bortexz/resocket "0.0.2"]
19+
[io.github.bortexz/resocket "0.1.0"]
2020
```
2121

2222
### **Clojure CLI/deps.edn**
2323
```clojure
24-
io.github.bortexz/resocket {:mvn/version "0.0.2"}
24+
io.github.bortexz/resocket {:mvn/version "0.1.0"}
2525
```
2626

2727
## Usage
@@ -32,6 +32,8 @@ See the [docs](https://cljdoc.org/d/io.github.bortexz/resocket) for more detaile
3232

3333
Connection:
3434
```Clojure
35+
(require '[bortexz.resocket :as resocket])
36+
3537
(let [{:keys [input output closed error]} (a/<!! (resocket/connection "ws://<service>" {}))]
3638
(when-not error
3739
(a/<!! input) ;; Take new messages

build.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(:require [org.corfield.build :as bb]))
44

55
(def lib 'io.github.bortexz/resocket)
6-
(def version "0.0.2")
6+
(def version "0.1.0")
77

88
(defn- gha-output
99
[k v]

src/bortexz/resocket.clj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,17 @@
272272
- `retry-ms-fn` unary fn called with the current attempt at reconnecting, starting at 1. It must return a numer of
273273
milliseconds to wait before retrying a new connection, or nil to close the reconnector. Defaults to 5000 (5 secs).
274274
- `on-error-retry-fn?` unary fn called with error when creating a new connection. Must return true to start a retry
275-
timeout to retry, otherwise the reconnector will be closed. Note: It is called with the original Exception unwrapped,
276-
which will probably be an ExecutionException from the CompletableFuture returned by creating a new Websocket in JDK11.
277-
You might want to get the wrapped exception for more details `(ex-cause <error>)`. Defaults to returning true
278-
when the wrapped exception is a java.net.ConnectException, false otherwise."
275+
timeout to retry, otherwise the reconnector will be closed.
276+
Note: It is called with the original Exception unwrapped, which will be an ExecutionException from the
277+
CompletableFuture returned by creating a new Websocket in JDK11. You might want to get the wrapped exception for
278+
more details `(ex-cause <error>)`. Defaults to returning logical true when the wrapped exception is either a
279+
java.net.ConnectException or java.net.http.HttpTimeoutException, false otherwise."
279280
[{:keys [retry-ms-fn on-error-retry-fn? get-url get-opts]
280281
:or {retry-ms-fn (constantly 5000)
281-
on-error-retry-fn? (fn [err] (instance? ConnectException (ex-cause err)))
282+
on-error-retry-fn? (fn [err]
283+
(let [ex (ex-cause err)]
284+
(or (instance? java.net.ConnectException ex)
285+
(instance? java.net.http.HttpTimeoutException ex))))
282286
get-opts (constantly nil)}}]
283287
(let [connections (a/chan)
284288
close (a/promise-chan)]

0 commit comments

Comments
 (0)