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 2917b27 commit 5df6107
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 279 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.6.0
version = 3.7.15
runner.dialect = scala3
align.preset = most
maxColumn = 200
Expand Down
331 changes: 130 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions LICENSE-ADDON

This file was deleted.

64 changes: 32 additions & 32 deletions built.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "spy"
organization := "fr.janalyse"
homepage := Some(new URL("https://github.com/dacr/spy"))

licenses += "Apache 2" -> url(s"http://www.apache.org/licenses/LICENSE-2.0.txt")
licenses += "NON-AI-APACHE2" -> url(s"https://github.com/non-ai-licenses/non-ai-licenses/blob/main/NON-AI-APACHE2")

scmInfo := Some(ScmInfo(url(s"https://github.com/dacr/spy.git"), s"git@github.com:dacr/spy.git"))

Expand All @@ -11,7 +11,7 @@ packageBin / mainClass := Some("spy.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 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 pureConfig = "0.17.4"
val pekko = "1.0.1"
val pekkoHttp = "1.0.0"
val pekkoHttpJson4s = "2.1.1"
val json4s = "4.0.6"
val logback = "1.4.11"
val slf4j = "2.0.9"
val scalatest = "3.2.17"
val webjarsLocator = "0.48"
val commonsio = "2.11.0"
}

// client side dependencies
Expand All @@ -52,23 +52,23 @@ 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-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-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.pekkoHttpJson4s,
"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/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ spy {
}

// ----------------------------------------------------------------
// Akka & akka-http framework configuration
// pekko & pekko-http framework configuration
// This configuration is used when this project is used as an app and not as a lib

akka {
pekko {
daemonic = off
http {
server {
Expand All @@ -67,9 +67,9 @@ spy {
max-connections = 100
}
}
loggers = ["akka.event.slf4j.Slf4jLogger"]
loggers = ["org.apache.pekko.event.slf4j.Slf4jLogger"]
loglevel = "INFO"
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
logging-filter = "org.apache.pekko.event.slf4j.Slf4jLoggingFilter"
}

}
6 changes: 3 additions & 3 deletions src/main/scala/spy/Service.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package spy

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

Expand All @@ -34,7 +34,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 'spy'
implicit val system: ActorSystem = akka.actor.ActorSystem(s"akka-http-$appCode-system", config.getConfig("spy"))
implicit val system: ActorSystem = org.apache.pekko.actor.ActorSystem(s"akka-http-$appCode-system", config.getConfig("spy"))
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/spy/ServiceRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package spy

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 spy.routing.{AdminRouting, AssetsRouting, HomeRouting, SpyRouting, SwaggerRouting}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/spy/routing/AdminRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
package spy.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 spy.ServiceDependencies


case class Health(alive: Boolean = true, description: String = "alive")

object AdminRouting {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/spy/routing/AssetsRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package spy.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 spy.ServiceDependencies

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

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

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

import akka.http.scaladsl.model.{DateTime, HttpHeader}
import akka.http.scaladsl.model.headers.CacheDirectives.{`max-age`, `must-revalidate`, `no-cache`, `no-store`, `proxy-revalidate`}
import akka.http.scaladsl.model.headers.{Expires, `Cache-Control`, `Last-Modified`}
import akka.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.model.{DateTime, 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.{Expires, `Cache-Control`, `Last-Modified`}
import org.apache.pekko.http.scaladsl.server.Route
import spy.tools.JsonImplicits

import java.util.Date
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/spy/routing/SpyRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package spy.routing

import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import de.heikoseeberger.akkahttpjson4s.Json4sSupport._
import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.http.scaladsl.server.Directives._
import org.apache.pekko.http.scaladsl.server.Route
import com.github.pjfanning.pekkohttpjson4s.Json4sSupport._
import org.slf4j.LoggerFactory
import spy.ServiceDependencies
import spy.tools.DateTimeTools
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/spy/routing/SwaggerRouting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*/
package spy.routing

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

import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.matchers._
import org.scalatest.wordspec._
import spy.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 5df6107

Please sign in to comment.