Skip to content

Commit 0d2d39b

Browse files
authored
feat: Add support for more TCP channel options (#607)
1 parent 3a119fc commit 0d2d39b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerConfig.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ object Http4sBlazeServerConfig {
2727

2828
def localhost8080: Http4sBlazeServerConfig = Http4sBlazeServerConfig("127.0.0.1", 8080)
2929

30-
final case class SocketOptions(tcpNoDelay: Boolean = true)
30+
final case class SocketOptions(
31+
tcpNoDelay: Boolean = true,
32+
soKeepAlive: Boolean = true,
33+
soReuseAddr: Boolean = true,
34+
soReusePort: Boolean = true
35+
)
3136

3237
}

http4s-server-blaze/src/main/scala/com/avast/sst/http4s/server/Http4sBlazeServerModule.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ object Http4sBlazeServerModule {
4242
.withConnectorPoolSize(config.connectorPoolSize)
4343
.withMaxConnections(config.maxConnections)
4444
.withChannelOption[java.lang.Boolean](StandardSocketOptions.TCP_NODELAY, config.socketOptions.tcpNoDelay)
45+
.withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_KEEPALIVE, config.socketOptions.soKeepAlive)
46+
.withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_REUSEADDR, config.socketOptions.soReuseAddr)
47+
.withChannelOption[java.lang.Boolean](StandardSocketOptions.SO_REUSEPORT, config.socketOptions.soReusePort)
4548
.resource
4649
} yield server
4750
}

0 commit comments

Comments
 (0)