Skip to content

Instantly share code, notes, and snippets.

@Velrok
Created February 17, 2017 17:20
Show Gist options
  • Save Velrok/4e7f475ec19c1c67ecbd1a6e23830371 to your computer and use it in GitHub Desktop.
Save Velrok/4e7f475ec19c1c67ecbd1a6e23830371 to your computer and use it in GitHub Desktop.
Inject a different factory function that creates a fixed sized request queue.
(def jetty-req-q (java.util.concurrent.ArrayBlockingQueue. configuration/http-queue-length))
(defn create-threadpool [options]
(let [pool (org.eclipse.jetty.util.thread.QueuedThreadPool. (options :max-threads configuration/http-max-threads)
(options :min-threads configuration/http-min-threads)
0
jetty-req-q)]
(.setMinThreads pool (options :min-threads configuration/http-min-threads))
(when (:daemon? options false)
(.setDaemon pool true))
pool))
(alter-var-root #'ring.adapter.jetty/create-threadpool
(constantly create-threadpool))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment