diff --git a/src/Proto.Cluster/Cluster.cs b/src/Proto.Cluster/Cluster.cs index 2a5f7140e2..83cf7d952d 100644 --- a/src/Proto.Cluster/Cluster.cs +++ b/src/Proto.Cluster/Cluster.cs @@ -164,9 +164,10 @@ private void SubscribeToTopologyEvents() => /// public async Task StartMemberAsync() { + await Gossip.StartGossipActorAsync().ConfigureAwait(false); await BeginStartAsync(false).ConfigureAwait(false); //gossiper must be started whenever any topology events starts flowing - await Gossip.StartAsync().ConfigureAwait(false); + await Gossip.StartgossipLoopAsync().ConfigureAwait(false); MemberList.InitializeTopologyConsensus(); await Provider.StartMemberAsync(this).ConfigureAwait(false); Logger.LogInformation("Started as cluster member"); diff --git a/src/Proto.Cluster/Gossip/Gossiper.cs b/src/Proto.Cluster/Gossip/Gossiper.cs index 096e53f5a6..77bbd1081f 100644 --- a/src/Proto.Cluster/Gossip/Gossiper.cs +++ b/src/Proto.Cluster/Gossip/Gossiper.cs @@ -49,7 +49,9 @@ public class Gossiper { public const string GossipActorName = "$gossip"; +#pragma warning disable CS0618 // Type or member is obsolete private static readonly ILogger Logger = Log.CreateLogger(); +#pragma warning restore CS0618 // Type or member is obsolete private readonly Cluster _cluster; private readonly IRootContext _context; private PID _pid = null!; @@ -143,6 +145,7 @@ public void SetState(string key, IMessage value) if (_pid == null) { + Logger.LogError("Gossiper is not started, cannot set state"); return; } @@ -178,7 +181,7 @@ public async Task SetStateAsync(string key, IMessage value) } } - internal Task StartAsync() + internal Task StartGossipActorAsync() { var props = Props.FromProducer(() => new GossipActor( _cluster.System, @@ -195,6 +198,13 @@ internal Task StartAsync() tmp.Left.Clear(); _context.Send(_pid, tmp); }); + + return Task.CompletedTask; + } + + internal Task StartgossipLoopAsync() + { + Logger.LogInformation("Started Cluster Gossip"); _ = SafeTask.Run(GossipLoop);