Skip to content

Commit eaa9006

Browse files
authored
force wait for join (#2051)
* force wait for join
1 parent 83a9cfd commit eaa9006

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Proto.Cluster/DefaultClusterContext.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,25 @@ namespace Proto.Cluster;
1919

2020
public class DefaultClusterContext : IClusterContext
2121
{
22+
#pragma warning disable CS0618 // Type or member is obsolete
23+
private static readonly ILogger Logger = Log.CreateLogger<DefaultClusterContext>();
24+
#pragma warning restore CS0618 // Type or member is obsolete
25+
2226
private readonly IIdentityLookup _identityLookup;
23-
2427
private readonly PidCache _pidCache;
2528
private readonly ShouldThrottle _requestLogThrottle;
2629
private readonly ActorSystem _system;
27-
private static readonly ILogger Logger = Log.CreateLogger<DefaultClusterContext>();
2830
private readonly int _requestTimeoutSeconds;
2931
private readonly bool _legacyTimeouts;
32+
private readonly Cluster _cluster;
3033

3134
public DefaultClusterContext(Cluster cluster)
3235
{
3336
_identityLookup = cluster.IdentityLookup;
3437
_pidCache = cluster.PidCache;
3538
var config = cluster.Config;
3639
_system = cluster.System;
40+
_cluster = cluster;
3741

3842
_requestLogThrottle = Throttle.Create(
3943
config.MaxNumberOfEventsInRequestLogThrottlePeriod,
@@ -48,6 +52,11 @@ public DefaultClusterContext(Cluster cluster)
4852
public async Task<T?> RequestAsync<T>(ClusterIdentity clusterIdentity, object message, ISenderContext context,
4953
CancellationToken ct)
5054
{
55+
if (!_cluster.JoinedCluster.IsCompletedSuccessfully)
56+
{
57+
await _cluster.JoinedCluster;
58+
}
59+
5160
var i = 0;
5261

5362
var future = context.GetFuture();

src/Proto.Cluster/Gossip/Gossiper.cs

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ internal Task StartAsync()
203203

204204
private async Task GossipLoop()
205205
{
206+
Logger.LogInformation("Gossip is waiting for cluster to join");
207+
await _cluster.JoinedCluster;
206208
Logger.LogInformation("Starting gossip loop");
207209
await Task.Yield();
208210

0 commit comments

Comments
 (0)