Skip to content

Commit

Permalink
refactor: Replace Akka with Pekko
Browse files Browse the repository at this point in the history
Apache Pekko is a fork of Akka 2.6.x, prior to the Akka project’s adoption of the Business Source License.
Version 1.0.0 is a direct replacement of Akka 2.6.x and has support for Scala 3 already.
https://pekko.apache.org/
  • Loading branch information
seakayone committed Sep 15, 2023
1 parent f3861e8 commit 71f76fa
Show file tree
Hide file tree
Showing 143 changed files with 788 additions and 545 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@

### Maintenance

* **dependencies:** update akka-http-cors to 1.1.3 ([#2103](https://www.github.com/dasch-swiss/dsp-api/issues/2103)) ([5d0d522](https://www.github.com/dasch-swiss/dsp-api/commit/5d0d52267ce9e702215c7b2a6527df7e0eb822ef))
* **dependencies:** update pekko-http-cors to 1.1.3 ([#2103](https://www.github.com/dasch-swiss/dsp-api/issues/2103)) ([5d0d522](https://www.github.com/dasch-swiss/dsp-api/commit/5d0d52267ce9e702215c7b2a6527df7e0eb822ef))
* **dependencies:** update jwt-spray-json to 9.0.2 ([#2111](https://www.github.com/dasch-swiss/dsp-api/issues/2111)) ([6e54443](https://www.github.com/dasch-swiss/dsp-api/commit/6e54443e4c2234e432d54ca25b7ecbd3a8656a2f))
* **dependencies:** update Saxon-HE to 11.4 ([#2137](https://www.github.com/dasch-swiss/dsp-api/issues/2137)) ([08c9f68](https://www.github.com/dasch-swiss/dsp-api/commit/08c9f68d427b230327aea149192c907cc3387092))
* **dependencies:** update scalatest to 3.2.13 ([#2138](https://www.github.com/dasch-swiss/dsp-api/issues/2138)) ([a345079](https://www.github.com/dasch-swiss/dsp-api/commit/a345079999de24cabed8235f055bab46cdf6094b))
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
buildInfoKeys ++= Seq[BuildInfoKey](
name,
version,
"akkaHttp" -> Dependencies.AkkaHttpVersion,
"sipi" -> Dependencies.sipiImage,
"fuseki" -> Dependencies.fusekiImage
"fuseki" -> Dependencies.fusekiImage,
"akkaHttp" -> Dependencies.pekkoHttp
),
buildInfoPackage := "org.knora.webapi.http.version"
)
Expand Down
2 changes: 1 addition & 1 deletion docs/03-endpoints/instrumentation/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ zio_fiber_lifetimes_bucket{le="2.0"} 17.0 1671021037947

Metrics of all routes served by ZIO-HTTP (default: port `5555`) are exposed through a default metrics middleware.
However, instead of `http_concurrent_requests_total` etc. they are labeled `zio_http_concurrent_requests_total` etc.
with `zio` prepended, so that they are clearly distinguishable while we still run ZIO-HTTP and Akka-HTTP in parallel.
with `zio` prepended, so that they are clearly distinguishable while we still run ZIO-HTTP and pekko-HTTP in parallel.

To prevent excessive amounts of labels, it is considered good practice,
to replace dynamic path segments with slugs (e.g. `/projects/shortcode/0000` with `/projects/shortcode/:shortcode`).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ADR-0002 Change Cache Service Manager from Akka-Actor to ZLayer
# ADR-0002 Change Cache Service Manager from pekko-Actor to ZLayer

Date: 2022-04-06

Expand All @@ -8,7 +8,7 @@ Accepted

## Context

The `org.knora.webapi.store.cacheservice.CacheServiceManager` was implemented as an `Akka-Actor`.
The `org.knora.webapi.store.cacheservice.CacheServiceManager` was implemented as an `pekko-Actor`.

## Decision

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Accepted
## Context

Both `org.knora.webapi.store.iiif.IIIFServiceManager` and `org.knora.webapi.store.iiif.impl.IIIFServiceSipiImpl`
where implemented as Akka-Actors
where implemented as pekko-Actors

## Decision

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Accepted
## Context

Both `org.knora.webapi.store.triplestore.TriplestoreServiceManager` and `org.knora.webapi.store.triplestore.impl.TriplestoreServiceHttpConnectorImpl`
where implemented as Akka-Actors.
where implemented as pekko-Actors.

## Decision

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Accepted

## Context

The `org.knora.webapi.responders.ResponderManager` was implemented as an Akka-Actor.
The `org.knora.webapi.responders.ResponderManager` was implemented as an pekko-Actor.

## Decision

Expand Down
2 changes: 1 addition & 1 deletion docs/05-internals/design/api-v1/how-to-add-a-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See [Futures with Akka](../principles/futures-with-akka.md) and
## Write a Route

Add a class to the `org.knora.webapi.routing.v1` package for your
route, using the Akka HTTP [Routing DSL](https://doc.akka.io/docs/akka-http/current/routing-dsl/index.html).
route, using the Akka HTTP [Routing DSL](https://doc.akka.io/docs/pekko-http/current/routing-dsl/index.html).
See the routes in that package for examples. Typically, each route
route will construct a responder request message and pass it to
`RouteUtilV1.runRdfRouteWithFuture` to handle the request.
Expand Down
2 changes: 1 addition & 1 deletion docs/05-internals/design/api-v2/how-to-add-a-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See [Futures with Akka](../principles/futures-with-akka.md) and
## Write a Route

Add a class to the `org.knora.webapi.routing.v2` package for your
route, using the Akka HTTP [Routing DSL](https://doc.akka.io/docs/akka-http/current/routing-dsl/index.html).
route, using the Akka HTTP [Routing DSL](https://doc.akka.io/docs/pekko-http/current/routing-dsl/index.html).
See the routes in that package for examples. Typically, each route
route will construct a responder request message and pass it to
`RouteUtilV2.runRdfRouteWithFuture` to handle the request.
Expand Down
4 changes: 2 additions & 2 deletions docs/05-internals/design/principles/design-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ If you want to add a new exception class, see the comments in
### Transformation of Exception to Client Responses

The `org.knora.webapi.KnoraExceptionHandler` is brought implicitly into
scope of `akka-http`, and by doing so registered and used to handle the
scope of `pekko-http`, and by doing so registered and used to handle the
transformation of all `KnoraExceptions` into `HttpResponses`. This
handler handles only exceptions thrown inside the route and not the
actors. However, the design of reply message passing from actors (by
Expand All @@ -105,7 +105,7 @@ See also [Futures with Akka](futures-with-akka.md).

The API routes in the `routing` package are defined using the DSL
provided by the
[akka-http](https://doc.akka.io/docs/akka-http/current/index.html)
[pekko-http](https://doc.akka.io/docs/pekko-http/current/index.html)
library. A routing function has to do the following:

1. Authenticate the client.
Expand Down
2 changes: 1 addition & 1 deletion docs/05-internals/design/principles/http-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

The http module holds only a convenience method for adding CORS support
to api routes. The CORS implementation uses the
[akka-http-cors](https://github.com/lomigmegard/akka-http-cors)
[pekko-http-cors](https://github.com/lomigmegard/pekko-http-cors)
directives implementation.
2 changes: 1 addition & 1 deletion docs/05-internals/development/third-party.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ All third party dependencies need to be declared there.
There is an object `Dependencies` where each library should be declared in a `val`.

```scala
val akkaHttpCors = "ch.megard" %% "akka-http-cors" % "1.0.0"
val akkaHttpCors = "ch.megard" %% "pekko-http-cors" % "1.0.0"
```

The first string corresponds to the group/organization in the library's maven artefact,
Expand Down
8 changes: 5 additions & 3 deletions integration/src/test/scala/org/knora/webapi/CoreSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

package org.knora.webapi

import akka.actor
import akka.testkit.ImplicitSender
import akka.testkit.TestKitBase
import com.typesafe.scalalogging.Logger
import org.apache.pekko
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand All @@ -27,6 +25,10 @@ import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject
import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.util.LogAspect

import pekko.actor
import pekko.testkit.ImplicitSender
import pekko.testkit.TestKitBase

abstract class CoreSpec
extends AnyWordSpec
with TestKitBase
Expand Down
10 changes: 6 additions & 4 deletions integration/src/test/scala/org/knora/webapi/E2ESpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

package org.knora.webapi

import akka.http.scaladsl.client.RequestBuilding
import akka.http.scaladsl.model._
import akka.testkit.TestKitBase
import com.typesafe.scalalogging._
import org.apache.pekko
import org.scalatest.BeforeAndAfterAll
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.matchers.should.Matchers
Expand Down Expand Up @@ -41,6 +39,10 @@ import org.knora.webapi.testservices.TestClientService
import org.knora.webapi.util.FileUtil
import org.knora.webapi.util.LogAspect

import pekko.http.scaladsl.client.RequestBuilding
import pekko.http.scaladsl.model._
import pekko.testkit.TestKitBase

/**
* This class can be used in End-to-End testing. It starts the DSP stack
* and provides access to settings and logging.
Expand Down Expand Up @@ -96,7 +98,7 @@ abstract class E2ESpec
.getOrThrowFiberFailure()
}

implicit lazy val system: akka.actor.ActorSystem = router.system
implicit lazy val system: pekko.actor.ActorSystem = router.system
implicit lazy val executionContext: ExecutionContext = system.dispatcher
lazy val rdfDataObjects = List.empty[RdfDataObject]
val log: Logger = Logger(this.getClass())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

package org.knora.webapi

import akka.http.scaladsl.client.RequestBuilding
import akka.http.scaladsl.model._
import akka.testkit.TestKitBase
import com.typesafe.scalalogging.LazyLogging
import com.typesafe.scalalogging.Logger
import org.apache.pekko
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down Expand Up @@ -37,6 +35,10 @@ import org.knora.webapi.testservices.FileToUpload
import org.knora.webapi.testservices.TestClientService
import org.knora.webapi.util.LogAspect

import pekko.http.scaladsl.client.RequestBuilding
import pekko.http.scaladsl.model._
import pekko.testkit.TestKitBase

/**
* This class can be used in End-to-End testing. It starts the DSP stack and
* provides access to configuration and logging.
Expand Down Expand Up @@ -86,7 +88,7 @@ abstract class ITKnoraLiveSpec
val (router: AppRouter, config: AppConfig) =
Unsafe.unsafe(implicit u => runtime.unsafe.run(routerAndConfig).getOrThrowFiberFailure())

implicit lazy val system: akka.actor.ActorSystem = router.system
implicit lazy val system: pekko.actor.ActorSystem = router.system
implicit lazy val executionContext: ExecutionContext = system.dispatcher
lazy val rdfDataObjects = List.empty[RdfDataObject]
val log: Logger = Logger(this.getClass())
Expand Down
12 changes: 7 additions & 5 deletions integration/src/test/scala/org/knora/webapi/R2RSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@

package org.knora.webapi

import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.testkit.RouteTestTimeout
import akka.http.scaladsl.testkit.ScalatestRouteTest
import com.typesafe.scalalogging.Logger
import org.apache.pekko
import org.scalatest.BeforeAndAfterAll
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand All @@ -36,6 +32,12 @@ import org.knora.webapi.routing.KnoraRouteData
import org.knora.webapi.util.FileUtil
import org.knora.webapi.util.LogAspect

import pekko.actor.ActorRef
import pekko.actor.ActorSystem
import pekko.http.scaladsl.model.HttpResponse
import pekko.http.scaladsl.testkit.RouteTestTimeout
import pekko.http.scaladsl.testkit.ScalatestRouteTest

/**
* R(oute)2R(esponder) Spec base class. Please, for any new E2E tests, use E2ESpec.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@

package org.knora.webapi.core

import org.apache.pekko
import zio._

import org.knora.webapi.config.AppConfig
import org.knora.webapi.store.cache.settings.CacheServiceSettings

object ActorSystemTest {

def layer(sys: akka.actor.ActorSystem): ZLayer[AppConfig, Nothing, ActorSystem] =
def layer(sys: pekko.actor.ActorSystem): ZLayer[AppConfig, Nothing, ActorSystem] =
ZLayer.scoped {
for {
appConfig <- ZIO.service[AppConfig]
context <- ZIO.executor.map(_.asExecutionContext)
} yield new ActorSystem {
override val system: akka.actor.ActorSystem = sys
override val system: pekko.actor.ActorSystem = sys
override val cacheServiceSettings: CacheServiceSettings = new CacheServiceSettings(appConfig)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.knora.webapi.core

import org.apache.pekko
import zio._

import org.knora.webapi.config.AppConfig.AppConfigurations
Expand Down Expand Up @@ -220,11 +221,11 @@ object LayersTest {
/**
* Provides a layer for integration tests which depend on Fuseki as Testcontainers.
* Sipi/IIIFService will be mocked with the [[IIIFServiceMockImpl]]
* @param system An optional [[akka.actor.ActorSystem]] for use with Akka's [[akka.testkit.TestKit]]
* @param system An optional [[pekko.actor.ActorSystem]] for use with Akka's [[pekko.testkit.TestKit]]
* @return a [[ULayer]] with the [[DefaultTestEnvironmentWithoutSipi]]
*/
def integrationTestsWithFusekiTestcontainers(
system: Option[akka.actor.ActorSystem] = None
system: Option[pekko.actor.ActorSystem] = None
): ULayer[DefaultTestEnvironmentWithoutSipi] = {
// Due to bug in Scala 2 compiler invoking methods with by-name parameters in provide/provideSome method does not work
// assign the layer to a temp val and use it in the ZLayer.make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@

package org.knora.webapi.e2e

import akka.actor.ActorSystem
import akka.http.scaladsl.model.HttpMethods._
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers._
import akka.http.scaladsl.testkit.RouteTestTimeout
import org.apache.pekko

import scala.concurrent.duration.FiniteDuration
import scala.concurrent.duration.NANOSECONDS

import org.knora.webapi.E2ESpec
import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject

import pekko.actor.ActorSystem
import pekko.http.scaladsl.model.HttpMethods._
import pekko.http.scaladsl.model.HttpResponse
import pekko.http.scaladsl.model.StatusCodes
import pekko.http.scaladsl.model.headers._
import pekko.http.scaladsl.testkit.RouteTestTimeout

/**
* End-to-end test specification for testing [[CORSSupport]].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

package org.knora.webapi.e2e

import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import org.apache.pekko

import dsp.errors._
import org.knora.webapi._
import org.knora.webapi.http.handler

import pekko.http.scaladsl.model._
import pekko.http.scaladsl.server.Directives._
import pekko.http.scaladsl.server.Route

/**
* Route (R2R) test specification for testing exception handling.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

package org.knora.webapi.e2e

import akka.actor.ActorSystem
import akka.http.scaladsl.model._
import akka.http.scaladsl.testkit.RouteTestTimeout
import org.apache.pekko
import zio.Unsafe
import zio.ZIO

Expand All @@ -18,6 +16,10 @@ import org.knora.webapi.E2ESpec
import org.knora.webapi.core.State
import org.knora.webapi.core.domain.AppState

import pekko.actor.ActorSystem
import pekko.http.scaladsl.model._
import pekko.http.scaladsl.testkit.RouteTestTimeout

/**
* End-to-End (E2E) test specification for testing route rejections.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

package org.knora.webapi.e2e

import akka.actor.ActorSystem
import akka.http.scaladsl.testkit.RouteTestTimeout
import org.apache.pekko

import java.nio.file.Paths
import scala.concurrent.duration.FiniteDuration
Expand All @@ -18,6 +17,9 @@ import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.util.FileUtil

import pekko.actor.ActorSystem
import pekko.http.scaladsl.testkit.RouteTestTimeout

/**
* Tests [[InstanceChecker]].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

package org.knora.webapi.e2e

import akka.http.scaladsl.model._
import org.apache.pekko

import org.knora.webapi.E2ESpec

import pekko.http.scaladsl.model._

/**
* End-to-End (E2E) test specification for testing route rejections.
*/
Expand Down

0 comments on commit 71f76fa

Please sign in to comment.