perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.64k stars 1.56k forks source link

Support for configurable ThreadPoolExecutor #1076

Open fernandezpablo85 opened 5 years ago

fernandezpablo85 commented 5 years ago

Right now spark supports partial configuration of it's underlying ThreadPool via:

and

Though convenient, these fall short when more fine tuning is needed, like configuring a blocking queue or a custom ThreadFactory.

I'd be great to have something like threadPool(ThreadPoolExecutor executor) or equivalent.

toyg commented 5 years ago

You can achieve finer-level control by adding this to main() before everything else:

EmbeddedServers.add(
        EmbeddedServers.Identifiers.JETTY,
        new EmbeddedJettyFactory().withThreadPool(yourCustomThreadPool)
);

Note the ThreadPool is actually Jetty's org.eclipse.jetty.util.thread.ThreadPool, rather than anything in JDK.