From cee250174d145cb78d2079eb1a23711171ad10f8 Mon Sep 17 00:00:00 2001 From: Bendix Saeltz Date: Fri, 25 Feb 2022 11:16:38 +0100 Subject: [PATCH] #56: Use Akka Typed --- build.sbt | 26 +++++++++---------- .../scala/io/moia/itkit/samples/Main.scala | 7 ++--- .../io/moia/itkit/OneClientPerSuite.scala | 9 +++++-- .../io/moia/itkit/OneServerPerTest.scala | 9 +++++-- .../fixture/OneServerPerTestWithClient.scala | 9 +++++-- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/build.sbt b/build.sbt index 18d95d9..32cdff4 100644 --- a/build.sbt +++ b/build.sbt @@ -67,19 +67,19 @@ lazy val library = val scalaLogging = "3.9.4" val scalaTest = "3.2.11" } - val akkaActor = "com.typesafe.akka" %% "akka-actor" % Version.akka - val akkaHttp = "com.typesafe.akka" %% "akka-http" % Version.akkaHttp - val akkaHttpTestkit = "com.typesafe.akka" %% "akka-http-testkit" % Version.akkaHttp - val akkaStream = "com.typesafe.akka" %% "akka-stream" % Version.akka - val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % Version.akka - val log4jApi = "org.apache.logging.log4j" % "log4j-api" % Version.log4j - val log4jCore = "org.apache.logging.log4j" % "log4j-core" % Version.log4j - val logJulOverLog4j = "org.apache.logging.log4j" % "log4j-jul" % Version.log4j - val logSlfOverLog4j = "org.apache.logging.log4j" % "log4j-slf4j-impl" % Version.log4j - val pureConfig = "com.github.pureconfig" %% "pureconfig" % Version.pureConfig - val scalaCheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck - val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % Version.scalaLogging - val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest + val akkaActor = "com.typesafe.akka" %% "akka-actor-typed" % Version.akka + val akkaHttp = "com.typesafe.akka" %% "akka-http" % Version.akkaHttp + val akkaHttpTestkit = "com.typesafe.akka" %% "akka-http-testkit" % Version.akkaHttp + val akkaStream = "com.typesafe.akka" %% "akka-stream-typed" % Version.akka + val akkaTestkit = "com.typesafe.akka" %% "akka-actor-testkit-typed" % Version.akka + val log4jApi = "org.apache.logging.log4j" % "log4j-api" % Version.log4j + val log4jCore = "org.apache.logging.log4j" % "log4j-core" % Version.log4j + val logJulOverLog4j = "org.apache.logging.log4j" % "log4j-jul" % Version.log4j + val logSlfOverLog4j = "org.apache.logging.log4j" % "log4j-slf4j-impl" % Version.log4j + val pureConfig = "com.github.pureconfig" %% "pureconfig" % Version.pureConfig + val scalaCheck = "org.scalacheck" %% "scalacheck" % Version.scalaCheck + val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % Version.scalaLogging + val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest } // ***************************************************************************** diff --git a/samples/src/main/scala/io/moia/itkit/samples/Main.scala b/samples/src/main/scala/io/moia/itkit/samples/Main.scala index a490ca3..c1541fc 100644 --- a/samples/src/main/scala/io/moia/itkit/samples/Main.scala +++ b/samples/src/main/scala/io/moia/itkit/samples/Main.scala @@ -1,6 +1,7 @@ package io.moia.itkit.samples -import akka.actor.ActorSystem +import akka.actor.typed.ActorSystem +import akka.actor.typed.scaladsl.Behaviors import akka.http.scaladsl.Http import akka.http.scaladsl.settings.ServerSettings import io.moia.itkit.Logger @@ -9,8 +10,8 @@ import scala.util.{Failure, Success} object Main extends Logger { def main(args: Array[String]): Unit = { - implicit val system: ActorSystem = ActorSystem() - import system.dispatcher + implicit val system: ActorSystem[Nothing] = ActorSystem(Behaviors.empty, "itkit") + import system.executionContext type OptionMap = Map[Symbol, String] diff --git a/src/main/scala/io/moia/itkit/OneClientPerSuite.scala b/src/main/scala/io/moia/itkit/OneClientPerSuite.scala index c3270b4..63bd369 100644 --- a/src/main/scala/io/moia/itkit/OneClientPerSuite.scala +++ b/src/main/scala/io/moia/itkit/OneClientPerSuite.scala @@ -4,7 +4,8 @@ package io.moia.itkit -import akka.actor.ActorSystem +import akka.actor.typed.ActorSystem +import akka.actor.typed.scaladsl.Behaviors import akka.http.scaladsl.model.Uri import akka.http.scaladsl.{Http, HttpExt} import akka.stream.Materializer @@ -18,7 +19,11 @@ trait OneClientPerSuite extends AsyncTestSuiteMixin with ClientProvider { this: } """) - implicit private val system: ActorSystem = ActorSystem(s"itkit-client-${suiteId.hashCode().toString}", ConfigFactory.load(clientConfig)) + implicit private val system: ActorSystem[Nothing] = ActorSystem( + guardianBehavior = Behaviors.empty, + name = s"itkit-client-${suiteId.hashCode().toString}", + config = ConfigFactory.load(clientConfig) + ) implicit protected val actorMaterializer: Materializer = implicitly[Materializer] diff --git a/src/main/scala/io/moia/itkit/OneServerPerTest.scala b/src/main/scala/io/moia/itkit/OneServerPerTest.scala index cfb9233..64c865c 100644 --- a/src/main/scala/io/moia/itkit/OneServerPerTest.scala +++ b/src/main/scala/io/moia/itkit/OneServerPerTest.scala @@ -5,7 +5,8 @@ package io.moia package itkit -import akka.actor.ActorSystem +import akka.actor.typed.ActorSystem +import akka.actor.typed.scaladsl.Behaviors import akka.http.scaladsl.model.Uri import akka.http.scaladsl.{Http, HttpExt} import akka.stream.Materializer @@ -24,7 +25,11 @@ trait OneServerPerTest extends AsyncTestSuiteMixin { this: AsyncTestSuite => } """) - implicit private val system: ActorSystem = ActorSystem(s"itkit-client-${suiteId.hashCode().toString}", ConfigFactory.load(clientConfig)) + implicit private val system: ActorSystem[Nothing] = ActorSystem( + guardianBehavior = Behaviors.empty, + name = s"itkit-client-${suiteId.hashCode().toString}", + config = ConfigFactory.load(clientConfig) + ) implicit protected val materializer: Materializer = implicitly[Materializer] private lazy val suiteHttp: HttpExt = Http() diff --git a/src/main/scala/io/moia/itkit/fixture/OneServerPerTestWithClient.scala b/src/main/scala/io/moia/itkit/fixture/OneServerPerTestWithClient.scala index ccbe53e..fc26d08 100644 --- a/src/main/scala/io/moia/itkit/fixture/OneServerPerTestWithClient.scala +++ b/src/main/scala/io/moia/itkit/fixture/OneServerPerTestWithClient.scala @@ -4,7 +4,8 @@ package io.moia.itkit.fixture -import akka.actor.ActorSystem +import akka.actor.typed.ActorSystem +import akka.actor.typed.scaladsl.Behaviors import akka.http.scaladsl.model.Uri import akka.http.scaladsl.{Http, HttpExt} import akka.stream.Materializer @@ -22,7 +23,11 @@ trait OneServerPerTestWithClient extends AsyncTestSuiteMixin with ProcessProvide } """) - implicit private val system: ActorSystem = ActorSystem(s"itkit-client-${suiteId.hashCode().toString}", ConfigFactory.load(clientConfig)) + implicit private val system: ActorSystem[Nothing] = ActorSystem( + guardianBehavior = Behaviors.empty, + name = s"itkit-client-${suiteId.hashCode().toString}", + config = ConfigFactory.load(clientConfig) + ) implicit protected val actorMaterializer: Materializer = implicitly[Materializer]