From 0d2d39b25e1bfe249485a5a75541a2f404acff49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jane=C4=8Dek?= Date: Wed, 7 Jul 2021 21:33:37 +0200 Subject: [PATCH] feat: Add support for more TCP channel options (#607) --- .../avast/sst/http4s/server/Http4sBlazeServerConfig.scala | 7 ++++++- .../avast/sst/http4s/server/Http4sBlazeServerModule.scala | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerConfig.scala b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerConfig.scala index f34423f3..8fcbab33 100644 --- a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerConfig.scala +++ b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerConfig.scala @@ -27,6 +27,11 @@ object Http4sBlazeServerConfig { def localhost8080: Http4sBlazeServerConfig = Http4sBlazeServerConfig("127.0.0.1", 8080) - final case class SocketOptions(tcpNoDelay: Boolean = true) + final case class SocketOptions( + tcpNoDelay: Boolean = true, + soKeepAlive: Boolean = true, + soReuseAddr: Boolean = true, + soReusePort: Boolean = true + ) } diff --git a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala index 13afe144..90a2b222 100644 --- a/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala +++ b/http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala @@ -42,6 +42,9 @@ object Http4sBlazeServerModule { .withConnectorPoolSize(config.connectorPoolSize) .withMaxConnections(config.maxConnections) .withChannelOption[java.lang.Boolean](StandardSocketOptions.TCP_NODELAY, config.socketOptions.tcpNoDelay) + .withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_KEEPALIVE, config.socketOptions.soKeepAlive) + .withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_REUSEADDR, config.socketOptions.soReuseAddr) + .withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_REUSEPORT, config.socketOptions.soReusePort) .resource } yield server }