Skip to content

Commit

Permalink
add receive timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing committed Aug 5, 2024
1 parent 5c29d6b commit 26a8052
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Proto.Cluster/Gossip/GossipActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public async Task ReceiveAsync(IContext context)
// Logger.LogInformation("GossipActor Received {MessageType}", context.Message.GetMessageTypeName());
var t = context.Message switch
{
Started => OnStarted(context),
ReceiveTimeout => OnReceiveTimeout(context),
SetGossipStateKey setState => OnSetGossipStateKey(context, setState),
GetGossipStateRequest getState => OnGetGossipStateKey(context, getState),
GetGossipStateEntryRequest getState => OnGetGossipStateEntryKey(context, getState),
Expand All @@ -62,6 +64,18 @@ public async Task ReceiveAsync(IContext context)
}
}

private Task OnReceiveTimeout(IContext context)
{
Logger.LogCritical("GossipActor received timeout, report bug");
return Task.CompletedTask;
}

private Task OnStarted(IContext context)
{
context.SetReceiveTimeout(TimeSpan.FromSeconds(5));
return Task.CompletedTask;
}

private Task OnGetGossipStateEntryKey(IContext context, GetGossipStateEntryRequest getState)
{
var state = _internal.GetStateEntry(getState.Key);
Expand Down

0 comments on commit 26a8052

Please sign in to comment.