Skip to content

Commit

Permalink
better blocking logging (#2003)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing authored May 12, 2023
1 parent c6cdd1f commit 9a2e872
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Proto.Cluster/Member/MemberList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public MemberList(Cluster cluster)
{
SelfBlocked();
}
//only log if the member is known to us
if (TryGetMember(b.MemberId, out _)) {
Logger.LogInformation("Blocking member {MemberId} due to {Reason}", b.MemberId, b.Reason);
}
UpdateClusterTopology(_activeMembers.Members);
}, Dispatchers.DefaultDispatcher
Expand Down
5 changes: 2 additions & 3 deletions src/Proto.Remote/BlockList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Proto.Remote;

public record MemberBlocked(string MemberId);
public record MemberBlocked(string MemberId, string Reason);

/// <summary>
/// <see cref="BlockList" /> contains all members that have been blocked from communication, e.g. due to
Expand Down Expand Up @@ -47,14 +47,13 @@ internal void Block(IEnumerable<string> memberIds, string reason)

foreach (var member in newIds)
{
Logger.LogInformation("Blocking member {MemberId} due to {Reason}", member, reason);
_blockedMembers = _blockedMembers.ContainsKey(member) switch
{
false => _blockedMembers.Add(member, DateTime.UtcNow),
_ => _blockedMembers.SetItem(member, DateTime.UtcNow)
};

_system.EventStream.Publish(new MemberBlocked(member));
_system.EventStream.Publish(new MemberBlocked(member, reason));
}
}
}
Expand Down

0 comments on commit 9a2e872

Please sign in to comment.