Skip to content

Commit

Permalink
force wait for join (#2051)
Browse files Browse the repository at this point in the history
* force wait for join
  • Loading branch information
rogeralsing committed Sep 17, 2023
1 parent 83a9cfd commit eaa9006
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Proto.Cluster/DefaultClusterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ namespace Proto.Cluster;

public class DefaultClusterContext : IClusterContext
{
#pragma warning disable CS0618 // Type or member is obsolete
private static readonly ILogger Logger = Log.CreateLogger<DefaultClusterContext>();
#pragma warning restore CS0618 // Type or member is obsolete

private readonly IIdentityLookup _identityLookup;

private readonly PidCache _pidCache;
private readonly ShouldThrottle _requestLogThrottle;
private readonly ActorSystem _system;
private static readonly ILogger Logger = Log.CreateLogger<DefaultClusterContext>();
private readonly int _requestTimeoutSeconds;
private readonly bool _legacyTimeouts;
private readonly Cluster _cluster;

public DefaultClusterContext(Cluster cluster)
{
_identityLookup = cluster.IdentityLookup;
_pidCache = cluster.PidCache;
var config = cluster.Config;
_system = cluster.System;
_cluster = cluster;

_requestLogThrottle = Throttle.Create(
config.MaxNumberOfEventsInRequestLogThrottlePeriod,
Expand All @@ -48,6 +52,11 @@ public DefaultClusterContext(Cluster cluster)
public async Task<T?> RequestAsync<T>(ClusterIdentity clusterIdentity, object message, ISenderContext context,
CancellationToken ct)
{
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)
{
await _cluster.JoinedCluster;
}

var i = 0;

var future = context.GetFuture();
Expand Down
2 changes: 2 additions & 0 deletions src/Proto.Cluster/Gossip/Gossiper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ internal Task StartAsync()

private async Task GossipLoop()
{
Logger.LogInformation("Gossip is waiting for cluster to join");
await _cluster.JoinedCluster;
Logger.LogInformation("Starting gossip loop");
await Task.Yield();

Expand Down

0 comments on commit eaa9006

Please sign in to comment.