Skip to content

Commit

Permalink
(feat) added channel close handler to fail request fast
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Sun <sunng@about.me>
  • Loading branch information
sunng87 committed Apr 23, 2016
1 parent b817bc2 commit 795115d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/slacker/client/common.clj
Expand Up @@ -314,7 +314,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 795115d

Please sign in to comment.