Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
enable `ChannelTaskScheduler` to work inside Akka.Cluster without causing errors inside `/system` actors
  • Loading branch information
Aaronontheweb committed Apr 21, 2022
1 parent 5233233 commit 7b2fe34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/ClusterDaemon.cs
Expand Up @@ -895,7 +895,7 @@ private void CreateChildren(Cluster cluster)
_cluster = cluster;
_coreSupervisor = Context.ActorOf(Props.Create<ClusterCoreSupervisor>(), "core");

Context.ActorOf(ClusterHeartbeatReceiver.Props(() => _cluster), "heartbeatReceiver");
Context.ActorOf(ClusterHeartbeatReceiver.Props(cluster), "heartbeatReceiver");
}

protected override void PostStop()
Expand Down
14 changes: 7 additions & 7 deletions src/core/Akka.Cluster/ClusterHeartbeat.cs
Expand Up @@ -26,16 +26,16 @@ internal sealed class ClusterHeartbeatReceiver : UntypedActor
{
// Important - don't use Cluster.Get(Context.System) in constructor because that would
// cause deadlock. See startup sequence in ClusterDaemon.
private readonly Lazy<Cluster> _cluster;
private readonly Cluster _cluster;

public bool VerboseHeartbeat => _cluster.Value.Settings.VerboseHeartbeatLogging;
public bool VerboseHeartbeat => _cluster.Settings.VerboseHeartbeatLogging;

/// <summary>
/// TBD
/// </summary>
public ClusterHeartbeatReceiver(Func<Cluster> getCluster)
public ClusterHeartbeatReceiver(Cluster cluster)
{
_cluster = new Lazy<Cluster>(getCluster);
_cluster = cluster;
}

protected override void OnReceive(object message)
Expand All @@ -44,8 +44,8 @@ protected override void OnReceive(object message)
{
case ClusterHeartbeatSender.Heartbeat hb:
// TODO log the sequence nr once serializer is enabled
if(VerboseHeartbeat) _cluster.Value.CurrentInfoLogger.LogDebug("Heartbeat from [{0}]", hb.From);
Sender.Tell(new ClusterHeartbeatSender.HeartbeatRsp(_cluster.Value.SelfUniqueAddress,
if(VerboseHeartbeat) _cluster.CurrentInfoLogger.LogDebug("Heartbeat from [{0}]", hb.From);
Sender.Tell(new ClusterHeartbeatSender.HeartbeatRsp(_cluster.SelfUniqueAddress,
hb.SequenceNr, hb.CreationTimeNanos));
break;
default:
Expand All @@ -54,7 +54,7 @@ protected override void OnReceive(object message)
}
}

public static Props Props(Func<Cluster> getCluster)
public static Props Props(Cluster getCluster)
{
return Akka.Actor.Props.Create(() => new ClusterHeartbeatReceiver(getCluster));
}
Expand Down

0 comments on commit 7b2fe34

Please sign in to comment.