-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance tests for loom-based backends (#3611)
- Loading branch information
1 parent
f166f16
commit 3f7d730
Showing
5 changed files
with
89 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
perf-tests/src/main/scala/sttp/tapir/perf/netty/loom/NettyId.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,32 @@ | ||
package sttp.tapir.perf.netty.loom | ||
|
||
import cats.effect.IO | ||
import sttp.tapir.perf.apis._ | ||
import sttp.tapir.perf.Common._ | ||
import sttp.tapir.server.netty.loom._ | ||
import sttp.tapir.server.ServerEndpoint | ||
|
||
object Tapir extends Endpoints | ||
|
||
object NettyId { | ||
|
||
def runServer(endpoints: List[ServerEndpoint[Any, Id]], withServerLog: Boolean = false): IO[ServerRunner.KillSwitch] = { | ||
val declaredPort = Port | ||
val declaredHost = "0.0.0.0" | ||
val serverOptions = buildOptions(NettyIdServerOptions.customiseInterceptors, withServerLog) | ||
// Starting netty server | ||
val serverBinding: NettyIdServerBinding = | ||
NettyIdServer(serverOptions) | ||
.port(declaredPort) | ||
.host(declaredHost) | ||
.addEndpoints(endpoints) | ||
.start() | ||
IO(IO(serverBinding.stop())) | ||
} | ||
} | ||
|
||
object TapirServer extends ServerRunner { override def start = NettyId.runServer(Tapir.genEndpointsId(1)) } | ||
object TapirMultiServer extends ServerRunner { override def start = NettyId.runServer(Tapir.genEndpointsId(128)) } | ||
object TapirInterceptorMultiServer extends ServerRunner { | ||
override def start = NettyId.runServer(Tapir.genEndpointsId(128), withServerLog = true) | ||
} |
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,39 @@ | ||
package sttp.tapir.perf.nima | ||
|
||
import cats.effect.IO | ||
import io.helidon.webserver.WebServer | ||
import sttp.tapir.perf.apis._ | ||
import sttp.tapir.perf.Common._ | ||
import sttp.tapir.server.nima.{Id, NimaServerInterpreter, NimaServerOptions} | ||
import sttp.tapir.server.ServerEndpoint | ||
|
||
object Tapir extends Endpoints { | ||
def genEndpointsNId(count: Int): List[ServerEndpoint[Any, Id]] = genServerEndpoints[Id](count)(x => x: Id[String]) | ||
} | ||
|
||
object Nima { | ||
|
||
def runServer(endpoints: List[ServerEndpoint[Any, Id]], withServerLog: Boolean = false): IO[ServerRunner.KillSwitch] = { | ||
val declaredPort = Port | ||
val serverOptions = buildOptions(NimaServerOptions.customiseInterceptors, withServerLog) | ||
// Starting Nima server | ||
|
||
val handler = NimaServerInterpreter(serverOptions).toHandler(endpoints) | ||
val server = WebServer | ||
.builder() | ||
.routing { builder => | ||
builder.any(handler) | ||
() | ||
} | ||
.port(declaredPort) | ||
.build() | ||
.start() | ||
IO(IO { val _ = server.stop() }) | ||
} | ||
} | ||
|
||
object TapirServer extends ServerRunner { override def start = Nima.runServer(Tapir.genEndpointsNId(1)) } | ||
object TapirMultiServer extends ServerRunner { override def start = Nima.runServer(Tapir.genEndpointsNId(128)) } | ||
object TapirInterceptorMultiServer extends ServerRunner { | ||
override def start = Nima.runServer(Tapir.genEndpointsNId(128), withServerLog = true) | ||
} |