Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#760 Migrate from Akka to Pekko #762

Merged
merged 15 commits into from
Apr 17, 2024
Merged
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Shared._

ThisBuild / crossScalaVersions := Seq("2.13.7", "2.12.15")
ThisBuild / crossScalaVersions := Seq("2.13.13", "2.12.19")

ThisBuild / scalaVersion := crossScalaVersions.value.head

Expand Down
2 changes: 1 addition & 1 deletion docs/customizing-stream-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final Source aggregatedSource = new LifecycleManaged().source(inSource);

In the Scala API, the resulting source will be an aggregated source materialize to a `(M, () => ActorRef)` where `M` is the materialized type of `inSource` and `() => ActorRef` is the materialized type of the function for accessing the trigger actor which receives events from the Unicomplex, the squbs container.

In the Java API, the resulting source will be an aggregated source materialize to a `akka.japi.Pair<M, Supplier<ActorRef>>` where `M` is the materialized type of `inSource` and `Supplier<ActorRef>` is the materialized type of the function for accessing the trigger actor. Calling the `get()` method on the `Supplier` allows access to the `ActorRef`. This `ActorRef` receives events from the Unicomplex, the squbs container.
In the Java API, the resulting source will be an aggregated source materialize to a `org.apache.pekko.japi.Pair<M, Supplier<ActorRef>>` where `M` is the materialized type of `inSource` and `Supplier<ActorRef>` is the materialized type of the function for accessing the trigger actor. Calling the `get()` method on the `Supplier` allows access to the `ActorRef`. This `ActorRef` receives events from the Unicomplex, the squbs container.

The aggregated source does not emit from original source until lifecycle becomes `Active`, and stop emitting element and shuts down the stream after lifecycle state becomes `Stopping`.

Expand Down
2 changes: 1 addition & 1 deletion docs/flow-timeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class Timeout {
}
```

This `BidiFlow` can be joined with any flow that takes in a `akka.japi.Pair<In, Context>` and outputs a `akka.japi.Pair<Out, Context>`.
This `BidiFlow` can be joined with any flow that takes in a `org.apache.pekko.japi.Pair<In, Context>` and outputs a `org.apache.pekko.japi.Pair<Out, Context>`.

```java
final Duration duration = Duration.ofSeconds(1);
Expand Down
20 changes: 10 additions & 10 deletions docs/http-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Services can be defined in either Scala or Java, using either the high-level or
The high-level server-side API is represented by Akka HTTP's `Route` artifact and its directives. To use a `Route` to handle requests, just provide a class extending the `org.squbs.unicomplex.RouteDefinition` trait and provide the `route` function as follows:

```scala
import akka.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.server.Route
import org.squbs.unicomplex.RouteDefinition

class PingPongSvc extends RouteDefinition {
Expand Down Expand Up @@ -62,9 +62,9 @@ Please refer to the [Akka HTTP high-level API](http://doc.akka.io/docs/akka-http
Using the Scala low-level API, just extend `org.squbs.unicomplex.FlowDefinition` and override the `flow` function. The `flow` needs to be of type `Flow[HttpRequest, HttpResponse, NotUsed]` using the Scala DSL and model provided by Akka HTTP as follows:

```scala
import akka.http.scaladsl.model.Uri.Path
import akka.http.scaladsl.model._
import akka.stream.scaladsl.Flow
import org.apache.pekko.http.scaladsl.model.Uri.Path
import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.stream.scaladsl.Flow
import org.squbs.unicomplex.FlowDefinition

class SampleFlowSvc extends FlowDefinition {
Expand All @@ -84,9 +84,9 @@ This provides access to the `Flow` representation of the Akka HTTP low-level ser
The high-level server-side API is represented by Akka HTTP's `Route` artifact and its directives. To use a `Route` to handle requests, just provide a class extending the `org.squbs.unicomplex.RouteDefinition` trait and provide the `route` method as follows:

```java
import akka.http.javadsl.server.ExceptionHandler;
import akka.http.javadsl.server.RejectionHandler;
import akka.http.javadsl.server.Route;
import org.apache.pekko.http.javadsl.server.ExceptionHandler;
import org.apache.pekko.http.javadsl.server.RejectionHandler;
import org.apache.pekko.http.javadsl.server.Route;
import org.squbs.unicomplex.AbstractRouteDefinition;

import java.util.Optional;
Expand Down Expand Up @@ -133,9 +133,9 @@ Please refer to the [Akka HTTP high-level API](http://doc.akka.io/docs/akka-http
To use the Java low-level API, just extend `org.squbs.unicomplex.AbstractFlowDefinition` and override the `flow` method. The `flow` needs to be of type `Flow[HttpRequest, HttpResponse, NotUsed]` using the Java DSL and model provided by Akka HTTP. Note the imports in the following:

```java
import akka.NotUsed;
import akka.http.javadsl.model.*;
import akka.stream.javadsl.Flow;
import org.apache.pekko.NotUsed;
import org.apache.pekko.http.javadsl.model.*;
import org.apache.pekko.stream.javadsl.Flow;
import org.squbs.unicomplex.AbstractFlowDefinition;

public class JavaFlowSvc extends AbstractFlowDefinition {
Expand Down
30 changes: 15 additions & 15 deletions docs/marshalling.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ JacksonMapperSupport.register[MyScalaClass](
The marshallers and unmarshallers can be obtained from the `marshaller` and `unmarshaller` methods in `JacksonMapperSupport`, passing the class instance of the type to marshal/unmarshal as follows:

```java
import akka.http.javadsl.marshalling.Marshaller;
import akka.http.javadsl.model.HttpEntity;
import akka.http.javadsl.model.RequestEntity;
import akka.http.javadsl.unmarshalling.Unmarshaller;
import org.apache.pekko.http.javadsl.marshalling.Marshaller;
import org.apache.pekko.http.javadsl.model.HttpEntity;
import org.apache.pekko.http.javadsl.model.RequestEntity;
import org.apache.pekko.http.javadsl.unmarshalling.Unmarshaller;

import static org.squbs.marshallers.json.JacksonMapperSupport.*;

Expand Down Expand Up @@ -194,10 +194,10 @@ XLangJsonSupport.register[MyOtherClass](DefaultFormats + MySerializer)
The marshallers and unmarshallers can be obtained from the `marshaller` and `unmarshaller` methods in `XLangJsonSupport`, passing the class instance of the type to marshal/unmarshal as follows:

```java
import akka.http.javadsl.marshalling.Marshaller;
import akka.http.javadsl.model.HttpEntity;
import akka.http.javadsl.model.RequestEntity;
import akka.http.javadsl.unmarshalling.Unmarshaller;
import org.apache.pekko.http.javadsl.marshalling.Marshaller;
import org.apache.pekko.http.javadsl.model.HttpEntity;
import org.apache.pekko.http.javadsl.model.RequestEntity;
import org.apache.pekko.http.javadsl.unmarshalling.Unmarshaller;

import static org.squbs.marshallers.json.XLangJsonSupport.*;

Expand Down Expand Up @@ -254,10 +254,10 @@ Besides using marshallers and marshallers as part of Akka HTTP Routing DSL, manu
Akka provides a great [Scala DSL for marshalling and unmarshalling](http://doc.akka.io/docs/akka-http/current/scala/http/common/marshalling.html#using-marshallers). Its use can be seen in the example below:

```scala
import akka.actor.ActorSystem
import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model.MessageEntity
import akka.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.http.scaladsl.marshalling.Marshal
import org.apache.pekko.http.scaladsl.model.MessageEntity
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal

// We need the ActorSystem and Materializer to marshal/unmarshal
implicit val system = ActorSystem()
Expand All @@ -274,9 +274,9 @@ Unmarshal(entity).to[MyType]
The `MarshalUnmarshal` utility class is used for manually marshalling and unmarshalling objects using any `Marshaller` and `Unmarshaller` defined in Akka HTTP's JavaDSL. It's use can be seen in the example below:

```java
import akka.actor.ActorSystem;
import akka.http.javadsl.model.RequestEntity;
import akka.stream.Materializer;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.http.javadsl.model.RequestEntity;
import org.apache.pekko.stream.Materializer;

import org.squbs.marshallers.MarshalUnmarshal;

Expand Down
2 changes: 1 addition & 1 deletion docs/perpetualstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ override def decider: Supervision.Decider = { t =>

```java
@Override
public akka.japi.function.Function<Throwable, Supervision.Directive> decider() {
public org.apache.pekko.japi.function.Function<Throwable, Supervision.Directive> decider() {
return t -> {
log().error("Uncaught error {} from stream", t);
t.printStackTrace();
Expand Down
16 changes: 8 additions & 8 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Optionally, you should also include the following dependencies based upon whethe

```scala
// Testing RouteDefinition...
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "test",
"org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpVersion % "test",

// Using JUnit...
"junit" % "junit" % junitV % "test",
Expand Down Expand Up @@ -215,12 +215,12 @@ JUnit creates an instance of the class for every individual test in the class. T

Note: If you construct the `CustomTestKit` passing a `UnicomplexBoot` object on the `super(boot)` call, use caution how and when to shutdown. If the `UnicomplexBoot` instance is created per-class, meaning one single instance is used for all test methods, the shutdown also needs to happen only once. Use JUnit's `@AfterClass` annotation to annotate a static shutdown method. But if the `UnicomplexBoot` instance is created per test method - the default behavior, the `@After` annotation should be used similar to default construction of `CustomTestKit`.

## Testing Akka Http Routes using Akka Http TestKit
## Testing Pekko Http Routes using Akka Http TestKit

The `akka-http-testkit` needs to be added to the dependencies in order to test routes. Please add the followings to your dependencies:
The `pekko-http-testkit` needs to be added to the dependencies in order to test routes. Please add the followings to your dependencies:

```
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV % "test"
"org.apache.pekko" %% "pekko-http-testkit" % pekkoHttpV % "test"
```

### Usage
Expand Down Expand Up @@ -255,7 +255,7 @@ class MyRoute extends RouteDefinition {
Implementing the test, obtaining route from `TestRoute[MyRoute]`:

```scala
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.apache.pekko.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{Matchers, FlatSpecLike}
import org.squbs.testkit.TestRoute

Expand Down Expand Up @@ -358,7 +358,7 @@ class MyRouteTest extends CustomRouteTestKit with FlatSpecLike with Matchers {
}

class ReverserRoute extends RouteDefinition {
import akka.pattern.ask
import org.apache.pekko.pattern.ask
import Timeouts._
import context.dispatcher

Expand Down Expand Up @@ -392,7 +392,7 @@ public class MyRouteTest extends TestNGCustomRouteTestKit {
And the corresponding route to test would be as follows:

```java
import akka.http.javadsl.server.Route;
import org.apache.pekko.http.javadsl.server.Route;
import org.squbs.unicomplex.AbstractRouteDefinition;

public class ReverserRoute extends AbstractRouteDefinition {
Expand All @@ -411,7 +411,7 @@ public class ReverserRoute extends AbstractRouteDefinition {

```

**Note:** To use `CustomRouteTestKit`, please ensure Akka Http testkit is in your dependencies as described [above](#testing-akka-http-routes-using-akka-http-testkit).
**Note:** To use `CustomRouteTestKit`, please ensure Akka Http testkit is in your dependencies as described [above](#testing-pekko-http-routes-using-pekko-http-testkit).

#### Shutting Down

Expand Down
12 changes: 6 additions & 6 deletions project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
*/

object Versions {
val akkaV = "2.6.17"
val akkaHttpV = "10.2.6"
val pekkoV = "1.0.1"
val pekkoHttpV = "1.0.1"
val akkaKryoV = "2.3.0"
val scalaCompatV = "2.6.0"
val scalaCompatV = "2.11.0"
val scalatestV = "3.2.3"
val scalatestplusV = "3.2.3.0"
val flexmarkV = "0.35.10"
val mockitoV = "2.28.2"
val scalaLoggingV = "3.9.2"
val scalaLoggingV = "3.9.5"
val slf4jV = "1.7.25"
val jacksonV = "2.10.4"
val json4sV = "4.0.3"
val heikoseebergerAkkaHttpJsonV = "1.38.2"
val json4sV = "4.0.4"
val heikoseebergerAkkaHttpJsonV = "2.4.0"
val metricsV = "4.0.5"
val junitInterfaceV = "0.11"
val junitV = "4.12"
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.5.8
sbt.version=1.9.9
4 changes: 2 additions & 2 deletions squbs-actormonitor/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Test / javaOptions += "-Xmx512m"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalatest" %% "scalatest" % scalatestV % Test,
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV % Test,
"org.apache.pekko" %% "pekko-actor" % pekkoV,
"org.apache.pekko" %% "pekko-testkit" % pekkoV % Test,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.vladsch.flexmark" % "flexmark-all" % flexmarkV % Test,
"ch.qos.logback" % "logback-classic" % logbackInTestV % Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.squbs.actormonitor

import akka.actor._
import org.apache.pekko.actor._
import org.squbs.actormonitor.ActorMonitorBean._
import org.squbs.lifecycle.GracefulStopHelper
import org.squbs.unicomplex.JMX._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.lang.management.ManagementFactory
import javax.management.MXBean
import scala.language.existentials

import akka.actor.{ActorContext, ActorRef, Props}
import org.apache.pekko.actor.{ActorContext, ActorRef, Props}
import org.squbs.unicomplex.JMX._

import scala.annotation.tailrec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.squbs.actormonitor

import akka.actor._
import org.apache.pekko.actor._
import com.typesafe.scalalogging.LazyLogging
import org.squbs.lifecycle.ExtensionLifecycle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package org.squbs.actormonitor

import java.lang.management.ManagementFactory
import javax.management.ObjectName
import akka.actor._
import akka.pattern.ask
import akka.testkit.{ImplicitSender, TestKit}
import org.apache.pekko.actor._
import org.apache.pekko.pattern.ask
import org.apache.pekko.testkit.{ImplicitSender, TestKit}
import com.typesafe.config.ConfigFactory
import com.typesafe.scalalogging.LazyLogging
import org.scalatest.BeforeAndAfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.squbs.actormonitor.testcube

import akka.actor.Actor
import org.apache.pekko.actor.Actor


class TestActor extends Actor {
Expand Down
4 changes: 2 additions & 2 deletions squbs-actorregistry/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalatest" %% "scalatest" % scalatestV % Test,
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingV,
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV % Test,
"org.apache.pekko" %% "pekko-actor" % pekkoV,
"org.apache.pekko" %% "pekko-testkit" % pekkoV % Test,
"com.vladsch.flexmark" % "flexmark-all" % flexmarkV % Test,
"ch.qos.logback" % "logback-classic" % logbackInTestV % Test,
"junit" % "junit" % junitV % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package org.squbs.actorregistry

import akka.actor._
import akka.pattern.AskSupport
import akka.util.Timeout
import org.apache.pekko.actor._
import org.apache.pekko.pattern.AskSupport
import org.apache.pekko.util.Timeout

import scala.concurrent.{ExecutionContext, Promise, Future}
import scala.concurrent.duration.FiniteDuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.squbs.actorregistry


import akka.actor._
import org.apache.pekko.actor._
import org.squbs.actorregistry.ActorRegistryBean._
import org.squbs.unicomplex.Initialized
import org.squbs.unicomplex.JMX._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.squbs.actorregistry
import java.lang.management.ManagementFactory
import javax.management.MXBean

import akka.actor.{ActorContext, ActorRef}
import org.apache.pekko.actor.{ActorContext, ActorRef}
import org.squbs.unicomplex.JMX._


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.squbs.actorregistry


import akka.actor._
import org.apache.pekko.actor._
import com.typesafe.config.Config
import com.typesafe.scalalogging.LazyLogging
import org.squbs.lifecycle.ExtensionLifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package org.squbs.actorregistry.japi
import java.util.Optional
import java.util.concurrent.CompletionStage

import akka.actor.{ActorRef, ActorRefFactory}
import akka.util.Timeout
import org.apache.pekko.actor.{ActorRef, ActorRefFactory}
import org.apache.pekko.util.Timeout
import org.squbs.actorregistry.{ActorLookup => SActorLookup}

import scala.compat.java8.FutureConverters._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package org.squbs.actorregistry.japi;

import akka.actor.ActorIdentity;
import akka.actor.ActorRef;
import akka.actor.Identify;
import akka.actor.PoisonPill;
import org.apache.pekko.actor.ActorIdentity;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.Identify;
import org.apache.pekko.actor.PoisonPill;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import org.junit.AfterClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.squbs.actorregistry

import akka.actor.{ActorIdentity, ActorRef, ActorSystem, Identify, PoisonPill}
import akka.testkit.{ImplicitSender, TestKit}
import org.apache.pekko.actor.{ActorIdentity, ActorRef, ActorSystem, Identify, PoisonPill}
import org.apache.pekko.testkit.{ImplicitSender, TestKit}

import java.lang.management.ManagementFactory
import javax.management.ObjectName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.squbs.actorregistry

import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.testkit.{ImplicitSender, TestKit}
import com.typesafe.config.ConfigFactory
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funspec.AnyFunSpecLike
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.squbs.actorregistry.testcube

import akka.actor.Actor
import org.apache.pekko.actor.Actor

case class TestRequest(msg: String)
case class TestRequest1(msg: String)
Expand Down
Loading
Loading