Skip to content

Commit

Permalink
Patch static persistence ID in suicide actor (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Dec 22, 2022
1 parent 4739530 commit 44eb993
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Akka.HealthCheck.Persistence/AkkaPersistenceLivenessProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public class AkkaPersistenceLivenessProbe : ActorBase, IWithUnboundedStash
private int _probeCounter;
private bool _snapshotStoreLive;
private readonly TimeSpan _delay;
private readonly string _id;

public AkkaPersistenceLivenessProbe(TimeSpan delay)
{
_delay = delay;
_id = Guid.NewGuid().ToString("N");
}
public AkkaPersistenceLivenessProbe() : this(TimeSpan.FromSeconds(10))
{
Expand Down Expand Up @@ -121,7 +123,7 @@ protected override void PreStart()

private void CreateProbe(bool firstTime)
{
_probe = Context.ActorOf(Props.Create(() => new SuicideProbe(Self, firstTime)));
_probe = Context.ActorOf(Props.Create(() => new SuicideProbe(Self, firstTime, _id)));
if(firstTime)
{
_probe.Tell("hit" + _probeCounter++);
Expand Down Expand Up @@ -168,11 +170,11 @@ public class SuicideProbe : ReceivePersistentActor
private bool _recoveredJournal;
private bool _recoveredSnapshotStore;

public SuicideProbe(IActorRef probe, bool firstAttempt)
public SuicideProbe(IActorRef probe, bool firstAttempt, string id)
{
_probe = probe;
_firstAttempt = firstAttempt;
PersistenceId = "Akka.HealthCheck";
PersistenceId = $"Akka.HealthCheck-{id}";

Recover<string>(str =>
{
Expand Down Expand Up @@ -202,7 +204,7 @@ public SuicideProbe(IActorRef probe, bool firstAttempt)
if (!_firstAttempt)
{
DeleteMessages(save.Metadata.SequenceNr - 1);
DeleteSnapshots(new SnapshotSelectionCriteria(save.Metadata.SequenceNr - 1));
DeleteSnapshots(new SnapshotSelectionCriteria(save.Metadata.SequenceNr - 1));
}
Context.Stop(Self);
Expand Down

0 comments on commit 44eb993

Please sign in to comment.