Skip to content

Update Akka to latest version (2.5.23) #1

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ version := "0.1"
scalaVersion := "2.12.4"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-persistence-typed" % "2.5-SNAPSHOT",
"com.typesafe.akka" %% "akka-persistence-typed" % "2.5.23",
"org.fusesource.leveldbjni" % "leveldbjni-all" % "1.8"
)
)
30 changes: 13 additions & 17 deletions src/main/scala/com/ojha/persistence/typedExample.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ojha.persistence

import akka.actor.typed.Behavior
import akka.persistence.typed.scaladsl.PersistentActor
import akka.persistence.typed.scaladsl.PersistentActor.Effect
import akka.persistence.typed.PersistenceId
import akka.persistence.typed.scaladsl.{Effect, EventSourcedBehavior}

sealed trait TypedExampleCommand extends Serializable
case class TypedExampleWriteCommand(data: String) extends TypedExampleCommand
Expand All @@ -27,22 +27,18 @@ object TypedExampleMain extends App {
}

object TypedExample {

def behavior: Behavior[TypedExampleCommand] =
PersistentActor.immutable[TypedExampleCommand, TypedEvent, TypedExampleState](
persistenceId = "example-id",
initialState = new TypedExampleState,
commandHandler = PersistentActor.CommandHandler {
(_, state, cmd) ⇒
cmd match {
case TypedExampleWriteCommand(data) => Effect.persist(TypedEvent(s"$data ${state.size}"))
case TypedExamplePrint => println(state); Effect.none
}
},
def behavior: Behavior[TypedExampleCommand] = {
EventSourcedBehavior[TypedExampleCommand, TypedEvent, TypedExampleState](
persistenceId = PersistenceId("example-id"),
emptyState = new TypedExampleState,
commandHandler =
(state, cmd) => cmd match {
case TypedExampleWriteCommand(data) => Effect.persist(TypedEvent(s"$data ${state.size}"))
case TypedExamplePrint => println(state); Effect.none
},
eventHandler = (state, event) ⇒ event match {
case TypedEvent(_) => state.updated(event)
}
},
)

}
}