akka-typed

How to make recursive calls within Behaviors.receive?

纵饮孤独 提交于 2021-01-28 04:12:50
问题 This code is from akka documentation. It impelements an actor using the recommended functional style: import akka.actor.typed.Behavior import akka.actor.typed.scaladsl.ActorContext import akka.actor.typed.scaladsl.Behaviors object Counter { sealed trait Command case object Increment extends Command final case class GetValue(replyTo: ActorRef[Value]) extends Command final case class Value(n: Int) def apply(): Behavior[Command] = counter(0) private def counter(n: Int): Behavior[Command] =

Scala : Syntactic Sugar

我的梦境 提交于 2019-12-08 12:35:34
问题 I have been scratching my head to understand how to read this function: private def greeterBehavior(currentGreeting: String): Behavior[Command] = Actor.immutable[Command] { (ctx, msg) => msg match { case WhoToGreet(who) => greeterBehavior(s"hello, $who") case Greet => println(currentGreeting) Actor.same } } Questions: 1 ) function takes string and returns Behavior[Command] . ( understood) But .. what is Actor.immutable[Command] ? Is this a type casting ? or is it an object ? 2) if I have to