Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force wait for join #2051

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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