Skip to content

Commit

Permalink
Careful call blocking calls in vertx
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Feb 27, 2024
1 parent e49c58e commit b32ce53
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
10 changes: 5 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ object Dependencies {
lazy val jansi = "org.fusesource.jansi" % "jansi" % "2.4.0"
lazy val javaJwt = "com.auth0" % "java-jwt" % "4.4.0"

val logbackVersion = "1.4.14"
val logbackVersion = "1.5.0"
lazy val logbackClassic = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val logbackCore = "ch.qos.logback" % "logback-core" % logbackVersion

lazy val mssqlJdbc = "com.microsoft.sqlserver" % "mssql-jdbc" % "12.6.0.jre11"
lazy val mssqlJdbc = "com.microsoft.sqlserver" % "mssql-jdbc" % "12.6.1.jre11"
lazy val munit = "org.scalameta" %% "munit" % "1.0.0-M11"
lazy val oracleJdbc = "com.oracle.ojdbc" % "ojdbc8" % "19.3.0.0"
lazy val postgresql = "org.postgresql" % "postgresql" % "42.7.1"
lazy val postgresql = "org.postgresql" % "postgresql" % "42.7.2"
lazy val scalatest = "org.scalatest" %% "scalatest" % "3.2.18"

val slf4jVersion = "2.0.12"
lazy val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion
lazy val slf4jLog4j = "org.slf4j" % "log4j-over-slf4j" % slf4jVersion
lazy val slf4jSystem = "org.slf4j" % "slf4j-jdk-platform-logging" % slf4jVersion

private val tapirVersion = "1.9.9"
private val tapirVersion = "1.9.10"
lazy val tapirSttpCirce = "com.softwaremill.sttp.client3" %% "circe" % "3.9.3"
lazy val tapirCirce = "com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion
lazy val tapirPrometheus = "com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % tapirVersion
lazy val tapirServerStub = "com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % tapirVersion
lazy val tapirSwagger = "com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % tapirVersion
lazy val tapirVertex = "com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % tapirVersion

val testcontainersVersion = "1.19.5"
val testcontainersVersion = "1.19.6"
lazy val testcontainersCore = "org.testcontainers" % "testcontainers" % testcontainersVersion
lazy val testcontainersSqlserver = "org.testcontainers" % "mssqlserver" % testcontainersVersion
lazy val testcontainersOracle = "org.testcontainers" % "oracle-xe" % testcontainersVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,28 @@ object Endpoints:
val videoEndpoints = new VideoEndpoints(videoController, videoSequenceController)
val videoReferenceEndpoints = new VideoReferenceEndpoints(videoReferenceController)

val apiEndpoints =
mediaEndpoints.allImpl ++
authEndpoints.allImpl ++
healthEndpoints.allImpl ++
videoSequenceEndpoints.allImpl ++
videoEndpoints.allImpl ++
videoReferenceEndpoints.allImpl
// For VertX, we need to separate the non-blocking endpoints from the blocking ones
val nonBlockingEndpoints = List(
authEndpoints.allImpl,
healthEndpoints.allImpl
).flatten

val blockingEndpoints = List(
mediaEndpoints.allImpl,
videoSequenceEndpoints.allImpl,
videoEndpoints.allImpl,
videoReferenceEndpoints.allImpl
).flatten

val apiEndpoints = nonBlockingEndpoints ++ blockingEndpoints

// val apiEndpoints =
// mediaEndpoints.allImpl ++
// authEndpoints.allImpl ++
// healthEndpoints.allImpl ++
// videoSequenceEndpoints.allImpl ++
// videoEndpoints.allImpl ++
// videoReferenceEndpoints.allImpl

val docEndpoints: List[ServerEndpoint[Any, Future]] = SwaggerInterpreter()
.fromServerEndpoints[Future](apiEndpoints, AppConfig.Name, AppConfig.Version)
Expand Down
23 changes: 20 additions & 3 deletions vampire-squid/src/main/scala/org/mbari/vampiresquid/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,30 @@ def run(): Unit =
// NOTE: Don't add a handler. It will intercept all requests (Originally: Log all requests)
// router.route().handler(ctx => log.atInfo.log(s"${ctx.request().method()} ${ctx.request().path()}"))

Endpoints
.all
val intepreter = VertxFutureServerInterpreter(serverOptions)

// For VertX, we need to separate the non-blocking endpoints from the blocking ones
Endpoints.nonBlockingEndpoints
.foreach(endpoint =>
VertxFutureServerInterpreter(serverOptions)
intepreter
.route(endpoint)
.apply(router)
)

Endpoints.blockingEndpoints
.foreach(endpoint =>
intepreter
.blockingRoute(endpoint)
.apply(router)
)

// Endpoints
// .all
// .foreach(endpoint =>
// VertxFutureServerInterpreter(serverOptions)
// .route(endpoint)
// .apply(router)
// )

router
.getRoutes()
Expand Down

0 comments on commit b32ce53

Please sign in to comment.