public Copy ( ImmutableSortedSet |
||
members | ImmutableSortedSet |
|
unreachable | ImmutableHashSet |
|
seenBy | ImmutableHashSet | |
leader | Akka.Actor.Address | |
roleLeaderMap | Address>.ImmutableDictionary | |
Результат | CurrentClusterState |
public EventBusListener(Cluster cluster, ClusterReadView readView) { _cluster = cluster; _readView = readView; Receive <ClusterEvent.IClusterDomainEvent>(clusterDomainEvent => { clusterDomainEvent.Match() .With <ClusterEvent.SeenChanged>(changed => { State = State.Copy(seenBy: changed.SeenBy); }) .With <ClusterEvent.ReachabilityChanged>(changed => { _readView._reachability = changed.Reachability; }) .With <ClusterEvent.MemberRemoved>(removed => { State = State.Copy(members: State.Members.Remove(removed.Member), unreachable: State.Unreachable.Remove(removed.Member)); }) .With <ClusterEvent.UnreachableMember>(member => { // replace current member with new member (might have different status, only address is used in == comparison) State = State.Copy(unreachable: State.Unreachable.Remove(member.Member).Add(member.Member)); }) .With <ClusterEvent.ReachableMember>(member => { State = State.Copy(unreachable: State.Unreachable.Remove(member.Member)); }) .With <ClusterEvent.IMemberEvent>(memberEvent => { var newUnreachable = State.Unreachable; // replace current member with new member (might have different status, only address is used in == comparison) if (State.Unreachable.Contains(memberEvent.Member)) { newUnreachable = State.Unreachable.Remove(memberEvent.Member).Add(memberEvent.Member); } State = State.Copy( members: State.Members.Remove(memberEvent.Member).Add(memberEvent.Member), unreachable: newUnreachable); }) .With <ClusterEvent.LeaderChanged>(changed => { State = State.Copy(leader: changed.Leader); }) .With <ClusterEvent.RoleLeaderChanged>(changed => { State = State.Copy(roleLeaderMap: State.RoleLeaderMap.SetItem(changed.Role, changed.Leader)); }) .With <ClusterEvent.CurrentInternalStats>(stats => { readView._latestStats = stats; }) .With <ClusterEvent.ClusterShuttingDown>(_ => { }); }); Receive <ClusterEvent.CurrentClusterState>(state => { State = state; }); }