mdedetrich commented on code in PR #1919: URL: https://github.com/apache/pekko/pull/1919#discussion_r2182503945
########## persistence-typed/src/main/scala/org/apache/pekko/persistence/typed/internal/Running.scala: ########## @@ -268,15 +288,43 @@ private[pekko] object Running { else Behaviors.unhandled } - def onCommand(state: RunningState[S], cmd: C): Behavior[InternalProtocol] = { - val effect = setup.commandHandler(state.state, cmd) - val (next, doUnstash) = applyEffects(cmd, state, effect.asInstanceOf[EffectImpl[E, S]]) // TODO can we avoid the cast? - if (doUnstash) tryUnstashOne(next) - else next + def onCommand(state: RunningState[S, C], cmd: C): Behavior[InternalProtocol] = { + def callApplyEffects(rs: RunningState[S, C], c: C) = { + val effect = setup.commandHandler(rs.state, c) + + applyEffects(c, rs, effect.asInstanceOf[EffectImpl[E, S]]) // TODO can we avoid the cast? + } + + var applyEffectsRetval: (Behavior[InternalProtocol], Boolean) = callApplyEffects(state, cmd) + + var retVal: Option[Behavior[InternalProtocol]] = None + + while (retVal.isEmpty) { Review Comment: I am looking at this briefly and maybe it makes sense to write this code using recursion style with the `@tailrec` annotation (which confirms at compile time whether the scala compiler can unroll the recursion into a loop)? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For additional commands, e-mail: notifications-h...@pekko.apache.org