Skip to content

Commit

Permalink
replce deref of server with aleph.netty/wait-for-close, and make cont…
Browse files Browse the repository at this point in the history
…rol-period for connection-pools configurable, fixes #246
  • Loading branch information
ztellman committed May 10, 2016
1 parent fd27856 commit 0afe7db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject aleph "0.4.2-alpha3"
(defproject aleph "0.4.2-alpha4"
:description "a framework for asynchronous communication"
:repositories {"jboss" "http://repository.jboss.org/nexus/content/groups/public/"
"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
Expand Down
3 changes: 3 additions & 0 deletions src/aleph/http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@
connection-options
stats-callback
response-executor
control-period
middleware]
:or {connections-per-host 8
total-connections 1024
target-utilization 0.9
control-period 60000
response-executor default-response-executor
middleware middleware/wrap-request}}]
(let [p (promise)
Expand All @@ -126,6 +128,7 @@
(d/chain' c
first
client/close-connection))
:control-period control-period
:controller (Pools/utilizationController
target-utilization
connections-per-host
Expand Down
14 changes: 7 additions & 7 deletions src/aleph/netty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@
;;;

(defprotocol AlephServer
(port [_] "Returns the port the server is listening on."))
(port [_] "Returns the port the server is listening on.")
(wait-for-close [_] "Blocks until the server has been closed."))

(defn epoll-available? []
(Epoll/isAvailable))
Expand Down Expand Up @@ -725,14 +726,13 @@
(when on-close (on-close))
(-> ch .close .sync)
(-> group .shutdownGracefully))
clojure.lang.IDeref
(deref [_]
(-> ch .closeFuture .await)
(-> group .terminationFuture .await)
nil)
AlephServer
(port [_]
(-> ch .localAddress .getPort))))
(-> ch .localAddress .getPort))
(wait-for-close [_]
(-> ch .closeFuture .await)
(-> group .terminationFuture .await)
nil)))

(catch Exception e
@(.shutdownGracefully group)
Expand Down
2 changes: 1 addition & 1 deletion test/aleph/http_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
(finally
(.close ^java.io.Closeable server#)
(.shutdown *pool*)
@server#)))))
(netty/wait-for-close server#))))))

(defmacro with-handler [handler & body]
`(with-server (http/start-server ~handler {:port port})
Expand Down

0 comments on commit 0afe7db

Please sign in to comment.