-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize netty integration and default config (#3114)
- Loading branch information
1 parent
b900d12
commit 188ff2e
Showing
12 changed files
with
223 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
zio-http/jvm/src/main/scala/zio/http/netty/server/ServerEventLoopGroups.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package zio.http.netty.server | ||
|
||
import zio._ | ||
import zio.stacktracer.TracingImplicits.disableAutoTrace | ||
|
||
import zio.http.netty.{EventLoopGroups, NettyConfig} | ||
|
||
import io.netty.channel.EventLoopGroup | ||
|
||
final case class ServerEventLoopGroups( | ||
boss: EventLoopGroup, | ||
worker: EventLoopGroup, | ||
) | ||
|
||
object ServerEventLoopGroups { | ||
private implicit val trace: Trace = Trace.empty | ||
|
||
private def groupLayer(cfg: EventLoopGroups.Config): ULayer[EventLoopGroup] = | ||
(ZLayer.succeed(cfg) >>> EventLoopGroups.live).fresh | ||
|
||
val live: ZLayer[NettyConfig, Nothing, ServerEventLoopGroups] = ZLayer.fromZIO { | ||
ZIO.serviceWith[NettyConfig] { cfg => | ||
val boss = groupLayer(cfg.bossGroup) | ||
val worker = groupLayer(cfg) | ||
boss.zipWithPar(worker) { (boss, worker) => | ||
ZEnvironment(ServerEventLoopGroups(boss.get, worker.get)) | ||
} | ||
} | ||
}.flatten | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.