github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/cluster/gossip.go (about) 1 // Copyright (C) 2015-2022 Asynkton AB All rights reserved 2 3 package cluster 4 5 import ( 6 "google.golang.org/protobuf/proto" 7 ) 8 9 // customary type that defines a states sender callback. 10 type LocalStateSender func(memberStateDelta *MemberStateDelta, member *Member) 11 12 // This interface must be implemented by any value that. 13 // wants to be used as a gossip state storage 14 type GossipStateStorer interface { 15 GetState(key string) map[string]*GossipKeyValue 16 SetState(key string, value proto.Message) 17 } 18 19 // This interface must be implemented by any value that 20 // wants to add or remove consensus checkers 21 type GossipConsensusChecker interface { 22 AddConsensusCheck(id string, check *ConsensusCheck) 23 RemoveConsensusCheck(id string) 24 } 25 26 // This interface must be implemented by any value that 27 // wants to react to cluster topology events 28 type GossipCore interface { 29 UpdateClusterTopology(topology *ClusterTopology) 30 ReceiveState(remoteState *GossipState) []*GossipUpdate 31 SendState(sendStateToMember LocalStateSender) 32 GetMemberStateDelta(targetMemberID string) *MemberStateDelta 33 } 34 35 // The Gossip interface must be implemented by any value 36 // that pretends to participate with-in the Gossip protocol 37 type Gossip interface { 38 GossipStateStorer 39 GossipConsensusChecker 40 GossipCore 41 }