From 5f7f836a432eb07b586ced8bd2cb610ce993ec1f Mon Sep 17 00:00:00 2001 From: Martin Mauch Date: Sun, 24 May 2020 02:34:13 +0200 Subject: [PATCH] Massive dependency updates --- .../kagera/akka/actor/PetriNetInstance.scala | 8 +++---- .../akka/actor/PetriNetInstanceApi.scala | 23 +++++++++---------- .../scala/io/kagera/execution/package.scala | 4 ++-- .../io/kagera/akka/PetriNetInstanceSpec.scala | 5 ++-- .../test/scala/io/kagera/akka/QuerySpec.scala | 4 ++-- .../api/colored/TransitionExecutor.scala | 10 ++++---- .../kagera/api/colored/dsl/SequenceNet.scala | 4 ++-- .../api/colored/dsl/StateTransitionNet.scala | 4 ++-- .../io/kagera/api/colored/dsl/package.scala | 4 ++-- .../scala/io/kagera/api/colored/package.scala | 5 ++-- .../transitions/UncoloredTransition.scala | 4 ++-- build.sbt | 10 ++++---- .../main/scala/io/kagera/frontend/Api.scala | 1 + .../scala/io/kagera/frontend/Client.scala | 4 ++-- .../kagera/frontend/cytoscape/CytoScape.scala | 4 ++-- .../main/scala/io/kagera/demo/Queries.scala | 6 ++--- .../scala/io/kagera/demo/http/Routes.scala | 1 + .../scala/io/kagera/demo/model/package.scala | 14 +++++++++++ project/Dependencies.scala | 20 ++++++++-------- 19 files changed, 74 insertions(+), 61 deletions(-) diff --git a/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstance.scala b/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstance.scala index 2c0a0547..0475ab3d 100644 --- a/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstance.scala +++ b/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstance.scala @@ -3,7 +3,6 @@ package io.kagera.akka.actor import akka.actor.{ ActorLogging, ActorRef, PoisonPill, Props } import akka.pattern.pipe import akka.persistence.PersistentActor -import fs2.Strategy import io.kagera.akka.actor.PetriNetInstance.Settings import io.kagera.akka.actor.PetriNetInstanceProtocol._ import io.kagera.api.colored.ExceptionStrategy.RetryWithDelay @@ -12,15 +11,16 @@ import io.kagera.api.colored._ import io.kagera.execution.EventSourcing._ import io.kagera.execution._ +import scala.concurrent.ExecutionContext import scala.concurrent.duration._ import scala.language.existentials object PetriNetInstance { - case class Settings(evaluationStrategy: Strategy, idleTTL: Option[FiniteDuration]) + case class Settings(evaluationStrategy: ExecutionContext, idleTTL: Option[FiniteDuration]) val defaultSettings: Settings = - Settings(evaluationStrategy = Strategy.fromCachedDaemonPool("Kagera.CachedThreadPool"), idleTTL = Some(5 minutes)) + Settings(evaluationStrategy = ExecutionContext.Implicits.global, idleTTL = Some(5 minutes)) private case class IdleStop(seq: Long) @@ -152,7 +152,7 @@ class PetriNetInstance[S]( } def executeJob[E](job: Job[S, E], originalSender: ActorRef) = - runJobAsync(job, executor)(settings.evaluationStrategy).unsafeRunAsyncFuture().pipeTo(context.self)(originalSender) + runJobAsync(job, executor)(settings.evaluationStrategy).unsafeToFuture().pipeTo(context.self)(originalSender) override def onRecoveryCompleted(instance: Instance[S]) = step(instance) } diff --git a/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstanceApi.scala b/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstanceApi.scala index 4096d467..5e19b231 100644 --- a/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstanceApi.scala +++ b/akka/src/main/scala/io/kagera/akka/actor/PetriNetInstanceApi.scala @@ -6,7 +6,6 @@ import akka.pattern.ask import akka.stream.scaladsl.{ Sink, Source, SourceQueueWithComplete } import akka.stream.{ Materializer, OverflowStrategy } import akka.util.Timeout -import cats.data.Xor import io.kagera.akka.actor.PetriNetInstanceProtocol._ import io.kagera.api.colored.ExceptionStrategy.RetryWithDelay import io.kagera.api.colored.{ Transition, _ } @@ -87,14 +86,14 @@ class PetriNetInstanceApi[S](topology: ExecutablePetriNet[S], actor: ActorRef)(i /** * Fires a transition and confirms (waits) for the result of that transition firing. */ - def askAndConfirmFirst(msg: Any)(implicit timeout: Timeout): Future[Xor[UnexpectedMessage, InstanceState[S]]] = { + def askAndConfirmFirst(msg: Any)(implicit timeout: Timeout): Future[Either[UnexpectedMessage, InstanceState[S]]] = { actor.ask(msg).map { - case e: TransitionFired[_] => Xor.Right(e.result.asInstanceOf[InstanceState[S]]) - case msg @ _ => Xor.Left(UnexpectedMessage(s"Received unexepected message: $msg")) + case e: TransitionFired[_] => Right(e.result.asInstanceOf[InstanceState[S]]) + case msg @ _ => Left(UnexpectedMessage(s"Received unexepected message: $msg")) } } - def askAndConfirmFirstSync(msg: Any)(implicit timeout: Timeout): Xor[UnexpectedMessage, InstanceState[S]] = { + def askAndConfirmFirstSync(msg: Any)(implicit timeout: Timeout): Either[UnexpectedMessage, InstanceState[S]] = { Await.result(askAndConfirmFirst(topology, msg), timeout.duration) } @@ -103,15 +102,15 @@ class PetriNetInstanceApi[S](topology: ExecutablePetriNet[S], actor: ActorRef)(i */ def askAndConfirmAll(msg: Any, waitForRetries: Boolean = false)(implicit timeout: Timeout - ): Future[Xor[ErrorResponse, InstanceState[S]]] = { + ): Future[Either[ErrorResponse, InstanceState[S]]] = { val futureMessages = askAndCollectAll(msg, waitForRetries).runWith(Sink.seq) futureMessages.map { _.lastOption match { - case Some(e: TransitionFired[_]) => Xor.Right(e.result.asInstanceOf[InstanceState[S]]) - case Some(msg) => Xor.Left(UnexpectedMessage(s"Received unexpected message: $msg")) - case None => Xor.Left(UnknownProcessId) + case Some(e: TransitionFired[_]) => Right(e.result.asInstanceOf[InstanceState[S]]) + case Some(msg) => Left(UnexpectedMessage(s"Received unexpected message: $msg")) + case None => Left(UnknownProcessId) } } } @@ -140,10 +139,10 @@ class PetriNetInstanceApi[S](topology: ExecutablePetriNet[S], actor: ActorRef)(i def askAndCollectAll(msg: Any, waitForRetries: Boolean = false): Source[TransitionResponse, NotUsed] = { askSource[Any](actor, msg, takeWhileNotFailed(topology, waitForRetries)) .map { - case e: TransitionResponse => Xor.Right(e) - case msg @ _ => Xor.Left(s"Received unexpected message: $msg") + case e: TransitionResponse => Right(e) + case msg @ _ => Left(s"Received unexpected message: $msg") } .takeWhile(_.isRight) - .map(_.asInstanceOf[Xor.Right[TransitionResponse]].b) + .map(_.asInstanceOf[Right[NotUsed, TransitionResponse]].value) } } diff --git a/akka/src/main/scala/io/kagera/execution/package.scala b/akka/src/main/scala/io/kagera/execution/package.scala index eb54dc19..76767c30 100644 --- a/akka/src/main/scala/io/kagera/execution/package.scala +++ b/akka/src/main/scala/io/kagera/execution/package.scala @@ -3,13 +3,13 @@ package io.kagera import java.io.{ PrintWriter, StringWriter } import cats.data.State -import fs2.{ Strategy, Task } +import cats.effect.IO import io.kagera.api._ import io.kagera.api.colored._ import io.kagera.execution.EventSourcing._ import scala.collection.Set -import scala.util.Random +import scala.concurrent.ExecutionContext package object execution { diff --git a/akka/src/test/scala/io/kagera/akka/PetriNetInstanceSpec.scala b/akka/src/test/scala/io/kagera/akka/PetriNetInstanceSpec.scala index 31ee6a00..cf9c1814 100644 --- a/akka/src/test/scala/io/kagera/akka/PetriNetInstanceSpec.scala +++ b/akka/src/test/scala/io/kagera/akka/PetriNetInstanceSpec.scala @@ -3,7 +3,6 @@ package io.kagera.akka import java.util.UUID import akka.actor.{ ActorSystem, PoisonPill, Terminated } -import fs2.Strategy import io.kagera.akka.PetriNetInstanceSpec._ import io.kagera.akka.actor.PetriNetInstance import io.kagera.akka.actor.PetriNetInstance.Settings @@ -13,6 +12,7 @@ import io.kagera.api.colored._ import io.kagera.api.colored.dsl._ import org.scalatest.time.{ Milliseconds, Span } +import scala.concurrent.ExecutionContext import scala.concurrent.duration._ object PetriNetInstanceSpec { @@ -226,8 +226,7 @@ class PetriNetInstanceSpec extends AkkaTestBase { val ttl = 500 milliseconds - val customSettings = - Settings(evaluationStrategy = Strategy.fromCachedDaemonPool("Kagera.CachedThreadPool"), idleTTL = Some(ttl)) + val customSettings = Settings(evaluationStrategy = ExecutionContext.Implicits.global, idleTTL = Some(ttl)) override val sequence = Seq(transition(automated = false)(_ => Added(1)), transition(automated = false)(_ => Added(2))) diff --git a/akka/src/test/scala/io/kagera/akka/QuerySpec.scala b/akka/src/test/scala/io/kagera/akka/QuerySpec.scala index 5296f505..ef291e51 100644 --- a/akka/src/test/scala/io/kagera/akka/QuerySpec.scala +++ b/akka/src/test/scala/io/kagera/akka/QuerySpec.scala @@ -2,7 +2,7 @@ package io.kagera.akka import akka.actor.ActorSystem import akka.persistence.query.PersistenceQuery -import akka.persistence.query.scaladsl.{ AllPersistenceIdsQuery, CurrentEventsByPersistenceIdQuery, ReadJournal } +import akka.persistence.query.scaladsl.{ CurrentEventsByPersistenceIdQuery, ReadJournal } import akka.stream.ActorMaterializer import akka.stream.scaladsl.Sink import akka.testkit.{ ImplicitSender, TestKit } @@ -35,7 +35,7 @@ class QuerySpec override def readJournal = PersistenceQuery(system) .readJournalFor("inmemory-read-journal") - .asInstanceOf[ReadJournal with CurrentEventsByPersistenceIdQuery with AllPersistenceIdsQuery] + .asInstanceOf[ReadJournal with CurrentEventsByPersistenceIdQuery] val p1 = Place[Unit](id = 1) val p2 = Place[Unit](id = 2) diff --git a/api/src/main/scala/io/kagera/api/colored/TransitionExecutor.scala b/api/src/main/scala/io/kagera/api/colored/TransitionExecutor.scala index 500fdc3a..22a30096 100644 --- a/api/src/main/scala/io/kagera/api/colored/TransitionExecutor.scala +++ b/api/src/main/scala/io/kagera/api/colored/TransitionExecutor.scala @@ -1,6 +1,6 @@ package io.kagera.api.colored -import fs2.Task +import cats.effect.IO import io.kagera.api._ trait TransitionExecutor[State] { @@ -26,16 +26,16 @@ class TransitionExecutorImpl[State](topology: ColoredPetriNet) extends Transitio def fireTransition[Input, Output](t: Transition[Input, Output, State]): TransitionFunction[Input, Output, State] = { (consume, state, input) => - def handleFailure: PartialFunction[Throwable, Task[(Marking, Output)]] = { case e: Throwable => - Task.fail(e) + def handleFailure: PartialFunction[Throwable, IO[(Marking, Output)]] = { case e: Throwable => + IO.raiseError(e).asInstanceOf[IO[(Marking, Output)]] } if (consume.multiplicities != topology.inMarking(t)) { - Task.fail(new IllegalArgumentException(s"Transition $t may not consume $consume")) + IO.raiseError(new IllegalArgumentException(s"Transition $t may not consume $consume")) } try { - transitionFunction(t)(consume, state, input).handleWith { handleFailure } + transitionFunction(t)(consume, state, input).handleErrorWith { handleFailure } } catch { handleFailure } } } diff --git a/api/src/main/scala/io/kagera/api/colored/dsl/SequenceNet.scala b/api/src/main/scala/io/kagera/api/colored/dsl/SequenceNet.scala index 9ca91018..97c077a7 100644 --- a/api/src/main/scala/io/kagera/api/colored/dsl/SequenceNet.scala +++ b/api/src/main/scala/io/kagera/api/colored/dsl/SequenceNet.scala @@ -1,6 +1,6 @@ package io.kagera.api.colored.dsl -import fs2.Task +import cats.effect.IO import io.kagera.api.colored.ExceptionStrategy.BlockTransition import io.kagera.api.colored._ import io.kagera.api.colored.transitions.{ AbstractTransition, UncoloredTransition } @@ -13,7 +13,7 @@ case class TransitionBehaviour[S, E](automated: Boolean, exceptionHandler: Trans with UncoloredTransition[Unit, E, S] { override val toString = label override val updateState = eventSource - override def produceEvent(consume: Marking, state: S, input: Unit): Task[E] = Task.delay { (fn(state)) } + override def produceEvent(consume: Marking, state: S, input: Unit): IO[E] = IO.delay { (fn(state)) } } } diff --git a/api/src/main/scala/io/kagera/api/colored/dsl/StateTransitionNet.scala b/api/src/main/scala/io/kagera/api/colored/dsl/StateTransitionNet.scala index c317762d..e5271e17 100644 --- a/api/src/main/scala/io/kagera/api/colored/dsl/StateTransitionNet.scala +++ b/api/src/main/scala/io/kagera/api/colored/dsl/StateTransitionNet.scala @@ -1,6 +1,6 @@ package io.kagera.api.colored.dsl -import fs2.Task +import cats.effect.IO import io.kagera.api.colored.ExceptionStrategy.BlockTransition import io.kagera.api.colored.transitions.{ AbstractTransition, UncoloredTransition } import io.kagera.api.colored.{ Marking, Transition, _ } @@ -22,7 +22,7 @@ trait StateTransitionNet[S, E] { with UncoloredTransition[Unit, E, S] { override val toString = label override val updateState = eventSourcing - override def produceEvent(consume: Marking, state: S, input: Unit): Task[E] = Task.delay { (fn(state)) } + override def produceEvent(consume: Marking, state: S, input: Unit): IO[E] = IO.delay { (fn(state)) } } def createPetriNet(arcs: Arc*) = process[S](arcs: _*) diff --git a/api/src/main/scala/io/kagera/api/colored/dsl/package.scala b/api/src/main/scala/io/kagera/api/colored/dsl/package.scala index 996c4da2..7630ddb0 100644 --- a/api/src/main/scala/io/kagera/api/colored/dsl/package.scala +++ b/api/src/main/scala/io/kagera/api/colored/dsl/package.scala @@ -1,6 +1,6 @@ package io.kagera.api.colored -import fs2.Task +import cats.effect.IO import io.kagera.api._ import io.kagera.api.colored.transitions.{ AbstractTransition, IdentityTransition } import io.kagera.api.multiset._ @@ -47,7 +47,7 @@ package object dsl { override def apply(inAdjacent: MultiSet[Place[_]], outAdjacent: MultiSet[Place[_]]) = (marking, state, input) => - Task.delay { + IO.delay { val produced = outAdjacent.map { case (place, weight) => place -> Map(constant -> weight) }.toMarking diff --git a/api/src/main/scala/io/kagera/api/colored/package.scala b/api/src/main/scala/io/kagera/api/colored/package.scala index 3b91d65f..9ad99dd3 100644 --- a/api/src/main/scala/io/kagera/api/colored/package.scala +++ b/api/src/main/scala/io/kagera/api/colored/package.scala @@ -1,9 +1,10 @@ package io.kagera.api -import fs2.Task +import cats.effect.IO import io.kagera.api.multiset._ import scala.language.existentials +import scala.language.higherKinds import scalax.collection.Graph import scalax.collection.edge.WLDiEdge @@ -37,7 +38,7 @@ package object colored { * @tparam State * The state the transition closes over. */ - type TransitionFunction[Input, Output, State] = (Marking, State, Input) => Task[(Marking, Output)] + type TransitionFunction[Input, Output, State] = (Marking, State, Input) => IO[(Marking, Output)] /** * An exception handler function associated with a transition. diff --git a/api/src/main/scala/io/kagera/api/colored/transitions/UncoloredTransition.scala b/api/src/main/scala/io/kagera/api/colored/transitions/UncoloredTransition.scala index 9ddc5973..9e70007a 100644 --- a/api/src/main/scala/io/kagera/api/colored/transitions/UncoloredTransition.scala +++ b/api/src/main/scala/io/kagera/api/colored/transitions/UncoloredTransition.scala @@ -1,6 +1,6 @@ package io.kagera.api.colored.transitions -import fs2.Task +import cats.effect.IO import io.kagera.api.colored._ import io.kagera.api.multiset.{ MultiSet, _ } @@ -16,5 +16,5 @@ trait UncoloredTransition[Input, Output, State] extends Transition[Input, Output } } - def produceEvent(consume: Marking, state: State, input: Input): Task[Output] + def produceEvent(consume: Marking, state: State, input: Input): IO[Output] } diff --git a/build.sbt b/build.sbt index b56afe68..edad2338 100644 --- a/build.sbt +++ b/build.sbt @@ -32,7 +32,7 @@ lazy val akka = Project("akka", file("akka")) defaultProjectSettings ++ Seq( name := "kagera-akka", libraryDependencies ++= Seq( - scalaReflect, + "org.scala-lang" % "scala-reflect" % scalaVersion.value, akkaActor, akkaPersistence, akkaSlf4j, @@ -56,7 +56,7 @@ lazy val demo = (crossProject(JSPlatform, JVMPlatform) in file("demo")) .settings(defaultProjectSettings: _*) .settings( unmanagedSourceDirectories in Compile += baseDirectory.value / "shared" / "main" / "scala", - libraryDependencies ++= Seq("com.lihaoyi" %%% "scalatags" % "0.4.6", "com.lihaoyi" %%% "upickle" % "0.4.2") + libraryDependencies ++= Seq("com.lihaoyi" %%% "scalatags" % "0.9.1", "com.lihaoyi" %%% "upickle" % "1.1.0") ) .jsSettings( jsDependencies ++= Seq( @@ -65,13 +65,13 @@ lazy val demo = (crossProject(JSPlatform, JVMPlatform) in file("demo")) minified s"$cytoscapeVersion/dist/cytoscape.min.js" commonJSName "cytoscape" ), - libraryDependencies ++= Seq("org.scala-js" %%% "scalajs-dom" % "0.8.0") + libraryDependencies ++= Seq("org.scala-js" %%% "scalajs-dom" % "1.0.0") ) .jvmSettings( libraryDependencies ++= Seq( - "de.heikoseeberger" %% "akka-http-upickle" % "1.10.1", + "de.heikoseeberger" %% "akka-http-upickle" % "1.32.0", akkaHttp, - akkaPersistenceQuery, + akkaQuery, akkaPersistenceCassandra ), name := "demo-app", diff --git a/demo/js/src/main/scala/io/kagera/frontend/Api.scala b/demo/js/src/main/scala/io/kagera/frontend/Api.scala index ac0e7dc6..614d60aa 100644 --- a/demo/js/src/main/scala/io/kagera/frontend/Api.scala +++ b/demo/js/src/main/scala/io/kagera/frontend/Api.scala @@ -3,6 +3,7 @@ package io.kagera.frontend import io.kagera.demo.model.{ PetriNetModel, ProcessState } import org.scalajs.dom.ext.Ajax import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue +import upickle.default._ import scala.concurrent.Future diff --git a/demo/js/src/main/scala/io/kagera/frontend/Client.scala b/demo/js/src/main/scala/io/kagera/frontend/Client.scala index 60b44fdd..10013e89 100644 --- a/demo/js/src/main/scala/io/kagera/frontend/Client.scala +++ b/demo/js/src/main/scala/io/kagera/frontend/Client.scala @@ -4,10 +4,10 @@ import io.kagera.frontend.cytoscape._ import org.scalajs.dom.html import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue -import scala.scalajs.js.annotation.JSExport +import scala.scalajs.js.annotation.{ JSExport, JSExportTopLevel } import scalatags.JsDom.all._ -@JSExport +@JSExportTopLevel("Client") object Client extends { @JSExport diff --git a/demo/js/src/main/scala/io/kagera/frontend/cytoscape/CytoScape.scala b/demo/js/src/main/scala/io/kagera/frontend/cytoscape/CytoScape.scala index 6708449a..8930ae4c 100644 --- a/demo/js/src/main/scala/io/kagera/frontend/cytoscape/CytoScape.scala +++ b/demo/js/src/main/scala/io/kagera/frontend/cytoscape/CytoScape.scala @@ -3,9 +3,9 @@ package io.kagera.frontend.cytoscape import org.scalajs.dom.html import scala.scalajs.js -import scala.scalajs.js.annotation.JSName +import scala.scalajs.js.annotation.{ JSExportTopLevel, JSGlobal, JSName } -@JSName("cytoscape") +@JSGlobal("cytoscape") @js.native protected object CytoScapeJS extends js.Object { diff --git a/demo/jvm/src/main/scala/io/kagera/demo/Queries.scala b/demo/jvm/src/main/scala/io/kagera/demo/Queries.scala index 8f868333..40b8c149 100644 --- a/demo/jvm/src/main/scala/io/kagera/demo/Queries.scala +++ b/demo/jvm/src/main/scala/io/kagera/demo/Queries.scala @@ -5,9 +5,9 @@ import akka.actor.Actor import akka.persistence.cassandra.query.scaladsl.CassandraReadJournal import akka.persistence.query.PersistenceQuery import akka.stream.scaladsl.Source -import io.kagera.akka.persistence.TransitionFired import io.kagera.api.colored._ import io.kagera.api.multiset._ +import io.kagera.persistence.messages.TransitionFired trait Queries { @@ -16,7 +16,7 @@ trait Queries { // obtain read journal val readJournal = PersistenceQuery(system).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier) - def allProcessIds: Source[String, NotUsed] = readJournal.allPersistenceIds() + def allProcessIds: Source[String, NotUsed] = readJournal.currentPersistenceIds() def journalFor(id: String): Source[String, NotUsed] = { readJournal.currentEventsByPersistenceId(s"process-$id", 0, Long.MaxValue).map { e => @@ -32,7 +32,7 @@ class AggregateMarking[S](topology: ExecutablePetriNet[S]) extends Actor { def updateMarking(aggregateMarking: MultiSet[Long]): Receive = { - case TransitionFired(_, Some(tid), Some(started), Some(completed), consumed, produced, data) => + case TransitionFired(_, _, Some(tid), Some(started), Some(completed), consumed, produced, data) => val minusConsumed = consumed.foldLeft(aggregateMarking) { case (aggregate, token) => aggregate.multisetDecrement(token.placeId.get, token.count.get) } diff --git a/demo/jvm/src/main/scala/io/kagera/demo/http/Routes.scala b/demo/jvm/src/main/scala/io/kagera/demo/http/Routes.scala index 97f9df53..5488d058 100644 --- a/demo/jvm/src/main/scala/io/kagera/demo/http/Routes.scala +++ b/demo/jvm/src/main/scala/io/kagera/demo/http/Routes.scala @@ -12,6 +12,7 @@ import io.kagera.akka.actor.PetriNetInstance import io.kagera.akka.actor.PetriNetInstanceProtocol._ import io.kagera.api.colored.{ ExecutablePetriNet, Generators, Marking } import io.kagera.demo.{ ConfiguredActorSystem, Queries } +import upickle.default._ trait Routes extends Directives with Queries with UpickleSupport { diff --git a/demo/shared/src/main/scala/io/kagera/demo/model/package.scala b/demo/shared/src/main/scala/io/kagera/demo/model/package.scala index ec1ef8ba..9258d0d0 100644 --- a/demo/shared/src/main/scala/io/kagera/demo/model/package.scala +++ b/demo/shared/src/main/scala/io/kagera/demo/model/package.scala @@ -1,17 +1,31 @@ package io.kagera.demo +import upickle.default._ + package object model { case class Place(id: Long, label: String) + object Place { + implicit val rw: ReadWriter[Place] = macroRW[Place] + } case class Transition(id: Long, label: String, code: String = "", input: Option[String] = None) + object Transition { + implicit val rw: ReadWriter[Transition] = macroRW[Transition] + } case class Edge(source: String, target: String, weigth: Int = 1) + object Edge { + implicit val rw: ReadWriter[Edge] = macroRW[Edge] + } case class PetriNetModel(places: Set[Place], transitions: Set[Transition], edges: Set[Edge]) { def nodes: Set[Either[Place, Transition]] = places.map(p => Left(p)) ++ transitions.map(t => Right(t)) } + object PetriNetModel { + implicit val rw: ReadWriter[PetriNetModel] = macroRW[PetriNetModel] + } case class ProcessState(marking: Map[Long, Int], data: Map[String, String]) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index b4ca43fe..c1e08d3a 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -14,26 +14,24 @@ object Dependencies { val akkaTestkit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion - val akkaQuery = "com.typesafe.akka" %% "akka-persistence-query-experimental" % akkaVersion - val akkaHttp = "com.typesafe.akka" %% "akka-http-experimental" % akkaHttpVersion - val akkaInmemoryJournal = "com.github.dnvriend" %% "akka-persistence-inmemory" % "1.3.14" + val akkaQuery = "com.typesafe.akka" %% "akka-persistence-query" % akkaVersion + val akkaHttp = "com.typesafe.akka" %% "akka-http" % "10.1.12" + val akkaInmemoryJournal = "com.github.dnvriend" %% "akka-persistence-inmemory" % "2.5.15.2" val akkaAnalyticsCassandra = "com.github.krasserm" %% "akka-analytics-cassandra" % "0.3.1" val akkaAnalyticsKafka = "com.github.krasserm" %% "akka-analytics-kafka" % "0.3.1" val scalazCore = "org.scalaz" %% "scalaz-core" % "7.2.6" - val akkaPersistenceCassandra = "com.typesafe.akka" %% "akka-persistence-cassandra" % "0.18" - val akkaPersistenceQuery = "com.typesafe.akka" %% "akka-persistence-query-experimental" % akkaVersion + val akkaPersistenceCassandra = "com.typesafe.akka" %% "akka-persistence-cassandra" % "0.103" - val scalaGraph = "com.assembla.scala-incubator" %% "graph-core" % "1.10.1" - val scalaGraphDot = "com.assembla.scala-incubator" %% "graph-dot" % "1.10.1" + val scalaGraph = "org.scala-graph" %% "graph-core" % "1.12.5" + val scalaGraphDot = "org.scala-graph" %% "graph-dot" % "1.11.5" - val fs2Core = "co.fs2" %% "fs2-core" % "0.9.1" - val catsCore = "org.typelevel" %% "cats-core" % "0.7.2" + val fs2Core = "co.fs2" %% "fs2-core" % "2.1.0" + val catsCore = "org.typelevel" %% "cats-core" % "2.0.0" val logback = "ch.qos.logback" % "logback-classic" % "1.1.2" val ficus = "net.ceedubs" %% "ficus" % "1.1.2" - val scalaReflect = "org.scala-lang" % "scala-reflect" % "2.11.12" - val scalatest = "org.scalatest" %% "scalatest" % "2.2.1" + val scalatest = "org.scalatest" %% "scalatest" % "3.0.8" }