Skip to content

Commit

Permalink
minimal config, from latest Akka changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren committed Feb 26, 2024
1 parent 8523b0d commit 3d35a28
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 85 deletions.
6 changes: 5 additions & 1 deletion native-image-tests/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ fork := true
enablePlugins(NativeImagePlugin)
nativeImageJvm := "graalvm-community"
nativeImageVersion := "21.0.2"
nativeImageOptions := Seq("--no-fallback", "--verbose", "-Dakka.native-image.debug=true")
nativeImageOptions := Seq(
"--no-fallback",
"--verbose",
"--initialize-at-build-time=ch.qos.logback",
"-Dakka.native-image.debug=true")

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ import akka.persistence.typed.PersistenceId
import akka.persistence.typed.state.scaladsl.DurableStateBehavior
import akka.persistence.typed.state.scaladsl.Effect
import akka.serialization.jackson.JsonSerializable
import com.fasterxml.jackson.annotation.JsonCreator

import scala.concurrent.duration.DurationInt

object DurableStateCounter {
sealed trait Command extends JsonSerializable
final case class Increase(amount: Int, replyTo: ActorRef[Increased]) extends Command

// FIXME why doesn't @JsonCreator work as usual? is it something missing from the jackson feature?
final case class GetState @JsonCreator() (replyTo: ActorRef[State]) extends Command
final case class GetState(replyTo: ActorRef[State]) extends Command

final case class Increased @JsonCreator() (newValue: Int) extends JsonSerializable
final case class Increased(newValue: Int) extends JsonSerializable

final case class State @JsonCreator() (value: Int) extends JsonSerializable
final case class State(value: Int) extends JsonSerializable
def apply(id: String): Behavior[Command] =
DurableStateBehavior[Command, State](
PersistenceId("DSCounter", id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ import akka.persistence.typed.PersistenceId
import akka.persistence.typed.scaladsl.Effect
import akka.persistence.typed.scaladsl.EventSourcedBehavior
import akka.serialization.jackson.JsonSerializable
import com.fasterxml.jackson.annotation.JsonCreator

import scala.concurrent.duration.DurationInt

object EventSourcedCounter {
sealed trait Command extends JsonSerializable

final case class Increase(amount: Int, replyTo: ActorRef[StatusReply[Increased]]) extends Command
final case class GetValue @JsonCreator() (replyTo: ActorRef[StatusReply[GetValueResponse]]) extends Command
final case class GetValue(replyTo: ActorRef[StatusReply[GetValueResponse]]) extends Command
final case class GetValueResponse(value: Int)

sealed trait Event extends JsonSerializable

final case class Increased @JsonCreator() (amount: Int) extends Event
final case class Increased(amount: Int) extends Event

final case class State @JsonCreator() (value: Int) extends JsonSerializable
final case class State(value: Int) extends JsonSerializable

def apply(id: String): Behavior[Command] = EventSourcedBehavior[Command, Event, State](
PersistenceId("EventSourcedHelloWorld", id),
Expand Down

0 comments on commit 3d35a28

Please sign in to comment.