Skip to content

Commit

Permalink
Merge pull request #49 from sunng87/feature/fail-fast
Browse files Browse the repository at this point in the history
(feat) added channel close handler to fail request fast
  • Loading branch information
sunng87 committed May 3, 2016
2 parents fb1d080 + 795115d commit 6d185e3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/slacker/client/common.clj
Expand Up @@ -315,7 +315,17 @@
(instance? ConnectException exc)
(instance? ClosedChannelException exc))
(log/warn "Failed to connect to server or connection lost.")
(log/error exc "Unexpected error in event loop")))))
(log/error exc "Unexpected error in event loop")))
(on-inactive [ch]
(let [rmap (-> ch
(channel-hostport)
(@server-requests)
:pendings)]
(doseq [handler (vals @rmap)]
(when (not-empty handler)
(deliver (:promise handler)
{:cause {:error :connection-broken}})))
(reset! rmap {})))))

(def ^:dynamic *options*
{:tcp-nodelay true
Expand Down

0 comments on commit 6d185e3

Please sign in to comment.