Skip to content

Commit

Permalink
Migrate to pekko
Browse files Browse the repository at this point in the history
  • Loading branch information
dacr committed Oct 28, 2023
1 parent 78ed151 commit 6fb1870
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 81 deletions.
62 changes: 31 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packageBin / mainClass := Some("webecho.Main")

versionScheme := Some("semver-spec")

scalaVersion := "2.13.10"
scalaVersion := "2.13.12"

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature")

Expand All @@ -26,21 +26,21 @@ Test / testOptions += {

lazy val versions = new {
// client side dependencies
val swaggerui = "4.15.0"
val bootstrap = "5.2.2"
val jquery = "3.6.1"
val swaggerui = "4.19.1"
val bootstrap = "5.3.2"
val jquery = "3.7.1"

// server side dependencies
val pureConfig = "0.17.1"
val akka = "2.6.20"
val akkaHttp = "10.2.10"
val akkaHttpJson4s = "1.39.2"
val pureConfig = "0.17.4"
val pekko = "1.0.1"
val pekkoHttp = "1.0.0"
val akkaHttpJson4s = "2.1.1"
val json4s = "4.0.6"
val logback = "1.4.4"
val slf4j = "2.0.3"
val scalatest = "3.2.14"
val commonsio = "2.11.0"
val webjarsLocator = "0.45"
val logback = "1.4.11"
val slf4j = "2.0.9"
val scalatest = "3.2.17"
val commonsio = "2.15.0"
val webjarsLocator = "0.48"
}

// client side dependencies
Expand All @@ -52,24 +52,24 @@ libraryDependencies ++= Seq(

// server side dependencies
libraryDependencies ++= Seq(
"com.github.pureconfig" %% "pureconfig" % versions.pureConfig,
"org.json4s" %% "json4s-jackson" % versions.json4s,
"org.json4s" %% "json4s-ext" % versions.json4s,
"com.typesafe.akka" %% "akka-actor-typed" % versions.akka,
"com.typesafe.akka" %% "akka-http" % versions.akkaHttp,
"com.typesafe.akka" %% "akka-http-caching" % versions.akkaHttp,
"com.typesafe.akka" %% "akka-stream" % versions.akka,
"com.typesafe.akka" %% "akka-stream-typed" % versions.akka,
"com.typesafe.akka" %% "akka-slf4j" % versions.akka,
"com.typesafe.akka" %% "akka-testkit" % versions.akka % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % versions.akka % Test,
"com.typesafe.akka" %% "akka-http-testkit" % versions.akkaHttp % Test,
"de.heikoseeberger" %% "akka-http-json4s" % versions.akkaHttpJson4s,
"org.slf4j" % "slf4j-api" % versions.slf4j,
"ch.qos.logback" % "logback-classic" % versions.logback,
"commons-io" % "commons-io" % versions.commonsio,
"org.scalatest" %% "scalatest" % versions.scalatest % Test,
"org.webjars" % "webjars-locator" % versions.webjarsLocator
"com.github.pureconfig" %% "pureconfig" % versions.pureConfig,
"org.json4s" %% "json4s-jackson" % versions.json4s,
"org.json4s" %% "json4s-ext" % versions.json4s,
"org.apache.pekko" %% "pekko-actor-typed" % versions.pekko,
"org.apache.pekko" %% "pekko-http" % versions.pekkoHttp,
"org.apache.pekko" %% "pekko-http-caching" % versions.pekkoHttp,
"org.apache.pekko" %% "pekko-stream" % versions.pekko,
"org.apache.pekko" %% "pekko-stream-typed" % versions.pekko,
"org.apache.pekko" %% "pekko-slf4j" % versions.pekko,
"org.apache.pekko" %% "pekko-testkit" % versions.pekko % Test,
"org.apache.pekko" %% "pekko-stream-testkit" % versions.pekko % Test,
"org.apache.pekko" %% "pekko-http-testkit" % versions.pekkoHttp % Test,
"com.github.pjfanning" %% "pekko-http-json4s" % versions.akkaHttpJson4s,
"org.slf4j" % "slf4j-api" % versions.slf4j,
"ch.qos.logback" % "logback-classic" % versions.logback,
"commons-io" % "commons-io" % versions.commonsio,
"org.scalatest" %% "scalatest" % versions.scalatest % Test,
"org.webjars" % "webjars-locator" % versions.webjarsLocator
)

enablePlugins(JavaServerAppPackaging)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.7.2
sbt.version=1.9.7
10 changes: 5 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.13")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.3")
//addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.11")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")
//addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
//addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.0-M7")
addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.0-M6")
addSbtPlugin("com.typesafe.play" % "sbt-twirl" % "1.6.2")
8 changes: 4 additions & 4 deletions src/main/scala/webecho/Service.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package webecho

import akka.actor.ActorSystem
import akka.http.scaladsl._
import akka.stream.ActorMaterializer
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.http.scaladsl._
import org.apache.pekko.stream.ActorMaterializer
import com.typesafe.config.ConfigFactory
import org.slf4j.Logger

Expand All @@ -35,7 +35,7 @@ case class Service(dependencies: ServiceDependencies, servicesRoutes: ServiceRou
logger.info(s"$appCode service version $version is starting")

val config = ConfigFactory.load() // akka specific config is accessible under the path named 'web-echo'
implicit val system: ActorSystem = akka.actor.ActorSystem(s"akka-http-$appCode-system", config.getConfig("web-echo"))
implicit val system: ActorSystem = org.apache.pekko.actor.ActorSystem(s"akka-http-$appCode-system", config.getConfig("web-echo"))
implicit val executionContext: ExecutionContextExecutor = system.dispatcher

val bindingFuture: Future[Http.ServerBinding] = Http().newServerAt(interface = interface, port = port).bindFlow(servicesRoutes.routes)
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/webecho/ServiceRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package webecho

import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import webecho.routing.{AdminRouting, AssetsRouting, EchoRouting, HomeRouting, SwaggerRouting}

/** Prepare (reduce & prefix) service routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/
package webecho.dependencies.websocketsbot

import akka.Done
import akka.actor.typed.ActorRef
import akka.actor.typed.scaladsl.{ActorContext, Behaviors}
import akka.actor.typed.{ActorSystem, Behavior}
import akka.actor.typed.scaladsl.AskPattern._
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.ws.{BinaryMessage, Message, TextMessage, WebSocketRequest}
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.util.Timeout
import org.apache.pekko.Done
import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.typed.scaladsl.{ActorContext, Behaviors}
import org.apache.pekko.actor.typed.{ActorSystem, Behavior}
import org.apache.pekko.actor.typed.scaladsl.AskPattern._
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.model.StatusCodes
import org.apache.pekko.http.scaladsl.model.ws.{BinaryMessage, Message, TextMessage, WebSocketRequest}
import org.apache.pekko.stream.scaladsl.{Keep, Sink, Source}
import org.apache.pekko.util.Timeout
import org.json4s.{Extraction, JField, JObject}
import org.slf4j.LoggerFactory
import webecho.ServiceConfig
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/webecho/routing/AdminRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package webecho.routing

import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import com.github.pjfanning.pekkohttpjson4s.Json4sSupport._
import webecho.ServiceDependencies

case class Health(alive: Boolean = true, description: String = "alive")
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/webecho/routing/AssetsRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package webecho.routing

import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.directives.ContentTypeResolver.Default
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.server.directives.ContentTypeResolver.Default
import org.webjars.WebJarAssetLocator
import webecho.ServiceDependencies

Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/webecho/routing/EchoRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package webecho.routing

import akka.http.scaladsl.server.Directives.pathEndOrSingleSlash
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.stream.scaladsl.Source
import org.apache.pekko.http.scaladsl.server.Directives.pathEndOrSingleSlash
import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.stream.scaladsl.Source
import org.json4s.{Extraction, JField, JObject, JValue}
import webecho.ServiceDependencies
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
import com.github.pjfanning.pekkohttpjson4s.Json4sSupport._
import webecho.model.OperationOrigin
import webecho.tools.{DateTimeTools, JsonImplicits}

Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/webecho/routing/HomeRouting.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package webecho.routing

import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.model.MediaTypes.`text/html`
import org.apache.pekko.http.scaladsl.model.HttpCharsets._
import org.apache.pekko.http.scaladsl.model.{HttpEntity, HttpResponse}
import webecho.ServiceDependencies
import akka.http.scaladsl.model.MediaTypes.`text/html`
import akka.http.scaladsl.model.HttpCharsets._
import akka.http.scaladsl.model.{HttpEntity, HttpResponse}
import webecho.model.EchoesInfo
import webecho.templates.html.HomeTemplate

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/webecho/routing/Routing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package webecho.routing

import akka.http.scaladsl.model.HttpHeader
import akka.http.scaladsl.model.headers.CacheDirectives.{`max-age`, `must-revalidate`, `no-cache`, `no-store`, `proxy-revalidate`}
import akka.http.scaladsl.model.headers.`Cache-Control`
import akka.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.model.HttpHeader
import org.apache.pekko.http.scaladsl.model.headers.CacheDirectives.{`max-age`, `must-revalidate`, `no-cache`, `no-store`, `proxy-revalidate`}
import org.apache.pekko.http.scaladsl.model.headers.`Cache-Control`
import org.apache.pekko.http.scaladsl.server.Route
import webecho.tools.JsonImplicits

trait Routing extends JsonImplicits {
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/webecho/routing/SwaggerRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package webecho.routing

import akka.http.scaladsl.model.MediaTypes.{`application/json`, `text/html`}
import akka.http.scaladsl.model.HttpCharsets._
import akka.http.scaladsl.model.{HttpEntity, HttpResponse}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.model.MediaTypes.{`application/json`, `text/html`}
import org.apache.pekko.http.scaladsl.model.HttpCharsets._
import org.apache.pekko.http.scaladsl.model.{HttpEntity, HttpResponse}
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import webecho.ServiceDependencies
import webecho.templates.html.SwaggerUI
import webecho.templates.txt.SwaggerJson
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/webecho/ServiceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package webecho

import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.matchers._
import org.scalatest.wordspec._
import webecho.routing.Health
Expand All @@ -29,7 +29,7 @@ class ServiceTest extends AnyWordSpec with should.Matchers with ScalatestRouteTe
"Web Echo Service" should {
"Respond OK when pinged" in {
Get("/health") ~> routes ~> check {
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
import com.github.pjfanning.pekkohttpjson4s.Json4sSupport._
responseAs[Health] shouldBe Health(true, "alive")
}
}
Expand Down

0 comments on commit 6fb1870

Please sign in to comment.