Add interceptors for interpretUnstashedMessage and onReplayingSnapshot.

This commit is contained in:
Yury Gribkov 2019-11-18 18:53:42 -05:00
parent 548b3589f2
commit 9fabd36fb5
3 changed files with 35 additions and 14 deletions

View file

@ -45,6 +45,8 @@ private[akka] class ReplayingSnapshot[C, E, S](override val setup: BehaviorSetup
import InternalProtocol._
onRecoveryStart(setup.context)
def createBehavior(receivedPoisonPillInPreviousPhase: Boolean): Behavior[InternalProtocol] = {
// protect against snapshot stalling forever because of journal overloaded and such
setup.startRecoveryTimer(snapshot = true)
@ -100,6 +102,8 @@ private[akka] class ReplayingSnapshot[C, E, S](override val setup: BehaviorSetup
throw new JournalFailureException(msg, cause)
}
@InternalStableApi
def onRecoveryStart(@unused context: ActorContext[_]): Unit = ()
@InternalStableApi
def onRecoveryFailed(@unused context: ActorContext[_], @unused reason: Throwable): Unit = ()

View file

@ -6,8 +6,9 @@ package akka.persistence.typed.internal
import akka.actor.typed.Behavior
import akka.actor.typed.internal.PoisonPill
import akka.actor.typed.scaladsl.Behaviors
import akka.annotation.InternalApi
import akka.actor.typed.scaladsl.{ ActorContext, Behaviors }
import akka.annotation.{ InternalApi, InternalStableApi }
import akka.util.unused
/**
* INTERNAL API
@ -33,6 +34,8 @@ private[akka] class RequestingRecoveryPermit[C, E, S](override val setup: Behavi
with JournalInteractions[C, E, S]
with SnapshotInteractions[C, E, S] {
onRequestingRecoveryPermit(setup.context)
def createBehavior(): Behavior[InternalProtocol] = {
// request a permit, as only once we obtain one we can start replaying
requestRecoveryPermit()
@ -65,6 +68,9 @@ private[akka] class RequestingRecoveryPermit[C, E, S](override val setup: Behavi
stay(receivedPoisonPill = false)
}
@InternalStableApi
def onRequestingRecoveryPermit(@unused context: ActorContext[_]): Unit = ()
private def becomeReplaying(receivedPoisonPill: Boolean): Behavior[InternalProtocol] = {
setup.log.debug(s"Initializing snapshot recovery: {}", setup.recovery)