100% non-blocking, Java NIO only( inspired by zio-nio) , JSON HTTP server based on Scala ZIO library. Everything including TLS encryption modeled as ZIO effects, convenient route DSL similar to https4s, up to 30K TPS local JSON transaction with 25 threads on 6 cores(i7) with ZIO fibers.
Web Server has its own implementation of TLS protocol layer based on JAVA NIO and standard JDK SSLEngine. Everything is modeled as ZIO effects and processed as async routines with Java NIO. Java NIO and Application ZIO space uses same thread pool for non-blocking operations. Server implements a DSL for route matching, it's very similar (but a bit simplified) to the one which is used in HTTP4s. Server implements pluggable pre-filters and post-filters. The goal is to provide small and simple HTTP JSON server with all the benefits of async monadic non-blocking JAVA NIO calls wrapped up into ZIO interpreter with minimal number of dependencies.
Our new HTTP/2 server can talk HTTP/1.1 now!
Please, check it out. Simplified, streamlined, massivley parallel with nothing but ZIO Streams and HTTP/2, for client and server. HTTP/2 client available as ZIO Service.
https://github.com/ollls/zio-quartz-h2
Necessary dependencies(check hello-http template):
"dev.zio" %% "zio" % "2.0.x",
"io.github.ollls" %% "zio-tls-http" % "2.0.0",
Appreciate any feedback, please use, my email or open issue, or use
https://discord.com/channels/629491597070827530/817042692554489886 ( #zio-tls-http )
Also: Please check out https://github.com/ollls/quartz-h2 https://github.com/ollls/zio-quartz-h2
To run from sbt: "sbt example/run".
Example file: https://github.com/ollls/zio-tls-http/blob/master_zio2/examples/start/src/main/scala/MyServer.scala
package example
import zio.logging.backend.SLF4J
import zio.{ZIO, Chunk}
import zhttp.Method._
import zhttp.dsl._
import zhttp.{TLSServer, TcpServer, HttpRoutes}
import zhttp.{MultiPart, Headers, ContentType, Response, FileUtils}
object MyApp extends zio.ZIOAppDefault {
override val bootstrap =
zio.Runtime.removeDefaultLoggers ++ SLF4J.slf4j ++ zio.Runtime.enableWorkStealing
val r = HttpRoutes.of { case GET -> Root / "health" =>
ZIO.attempt(Response.Ok().asTextBody("Health Check Ok"))
}
val myHttp =
new TcpServer[Any](port = 8080, keepAlive = 2000, serverIP = "0.0.0.0")
val run = myHttp.run(r)
}
To enable more detailed logging, use logback-test.xml with "debug" or "trace" levels
<root level="debug">
<appender-ref ref="STDOUT" />
</root>