Skip to content

Commit f60881f

Browse files
authored
Merge pull request #602 from Yneth/feature/http-pool-customization
add pool customization options
2 parents b414715 + 607a20f commit f60881f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/aleph/http.clj

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
| `control-period` | the interval, in milliseconds, between use of the controller to adjust the size of the pool, defaults to `60000`
104104
| `dns-options` | an optional map with async DNS resolver settings, for more information check `aleph.netty/dns-resolver-group`. When set, ignores `name-resolver` setting from `connection-options` in favor of shared DNS resolver instance
105105
| `middleware` | a function to modify request before sending, defaults to `aleph.http.client-middleware/wrap-request`
106+
| `pool-builder-fn` | an optional one arity function which returns a `io.aleph.dirigiste.IPool` from a map containing the following keys: `generate`, `destroy`, `control-period`, `max-queue-length` and `stats-callback`.
107+
| `pool-controller-builder-fn` | an optional zero arity function which returns a `io.aleph.dirigiste.IPool$Controller`.
106108
107109
the `connection-options` are a map describing behavior across all connections:
108110
@@ -144,7 +146,9 @@
144146
stats-callback
145147
control-period
146148
middleware
147-
max-queue-size]
149+
max-queue-size
150+
pool-builder-fn
151+
pool-controller-builder-fn]
148152
:or {connections-per-host 8
149153
total-connections 1024
150154
target-utilization 0.9
@@ -170,7 +174,11 @@
170174
(some? log-activity)
171175
(assoc :log-activity (netty/activity-logger "aleph-client" log-activity)))
172176
p (promise)
173-
pool (flow/instrumented-pool
177+
create-pool-fn (or pool-builder-fn
178+
flow/instrumented-pool)
179+
create-pool-ctrl-fn (or pool-controller-builder-fn
180+
#(Pools/utilizationController target-utilization connections-per-host total-connections))
181+
pool (create-pool-fn
174182
{:generate (fn [host]
175183
(let [c (promise)
176184
conn (create-connection
@@ -186,10 +194,7 @@
186194
client/close-connection))
187195
:control-period control-period
188196
:max-queue-size max-queue-size
189-
:controller (Pools/utilizationController
190-
target-utilization
191-
connections-per-host
192-
total-connections)
197+
:controller (create-pool-ctrl-fn)
193198
:stats-callback stats-callback})]
194199
@(deliver p pool)))
195200

0 commit comments

Comments
 (0)