Documentation ¶
Overview ¶
Package communication provides means for transactional communication.
Index ¶
- Constants
- Variables
- type BaseMembers
- type MemberlistAgent
- func NewMemberlistAgent(id string, port int, lc config.LogConfig, nodes ...string) *MemberlistAgent
- func NewMemberlistAgentAdvanced(id string, port int, cfg *memberlist.Config, delegate *MemberlistDelegate, ...) *MemberlistAgent
- func TestsNewMemberlistAgent(id string, port int, test int, nodes ...string) *MemberlistAgent
- func (a *MemberlistAgent) ForAll(payload []byte) error
- func (a *MemberlistAgent) IsRunning() bool
- func (a *MemberlistAgent) Join() error
- func (a *MemberlistAgent) ReceivedActions() (<-chan chan []byte, <-chan chan string)
- func (a *MemberlistAgent) SetLogLevel(l int)
- func (a *MemberlistAgent) Start() error
- func (a *MemberlistAgent) Stop() error
- func (a *MemberlistAgent) TestsHalt()
- type MemberlistDelegate
Constants ¶
const ( TestsNothing = iota TestsAbort TestsUnreliableSend // Halting TestsMidInterested TestsAfterInterested TestsMidFirst TestsAfterFirst TestsMidSecond )
Variables ¶
var TestsMidSends = 2
Functions ¶
This section is empty.
Types ¶
type BaseMembers ¶
type BaseMembers struct { // AgentID is the agent's identifier. AgentID string ListeningPort int List *memberlist.Memberlist Config *memberlist.Config ReceivedActions func() (<-chan chan []byte, <-chan chan string) Logger *zap.Logger }
type MemberlistAgent ¶
type MemberlistAgent struct {
// contains filtered or unexported fields
}
func NewMemberlistAgent ¶
NewMemberlistAgent creates a stopped MemberlistAgent which implements the goabu.Agent interface.
id must be a string uniquely identifying the new MemberlistAgent or "", if id == "" then a random identifier is arbitrarily chosen in its place.
port specifies on which port should the created MemberlistAgent listen for join request coming from other MemberlistAgents.
nodes is a list of strings of the form "host:port" and indicates to whom the created MemberlistAgent should send join request when the Join method is called.
func NewMemberlistAgentAdvanced ¶
func NewMemberlistAgentAdvanced(id string, port int, cfg *memberlist.Config, delegate *MemberlistDelegate, lc config.LogConfig, nodes ...string) *MemberlistAgent
NewMemberlistAgentAdvanced creates a stopped MemberlistAgent which implements the goabu.Agent interface. It is a more verbose and configurable version of NewMemberlistAgent.
cfg specifies the configuration of the underlying memberlist.Memberlist.
delegate consents to override the handling of the memberlist.Memberlist events, see file delegateDefault.go for the default implementation.
func TestsNewMemberlistAgent ¶
func TestsNewMemberlistAgent(id string, port int, test int, nodes ...string) *MemberlistAgent
TestsNewMemberlistAgent is used for testing purposes.
It behaves like NewMemberlistAgent when config.TestsLogConfig is passed as the lc argument with the difference that the returned MemberlistAgent simulates a crash failure upon the happening of a particular event specified through the test argument.
func (*MemberlistAgent) ForAll ¶
func (a *MemberlistAgent) ForAll(payload []byte) error
func (*MemberlistAgent) IsRunning ¶
func (a *MemberlistAgent) IsRunning() bool
func (*MemberlistAgent) Join ¶
func (a *MemberlistAgent) Join() error
func (*MemberlistAgent) ReceivedActions ¶
func (a *MemberlistAgent) ReceivedActions() (<-chan chan []byte, <-chan chan string)
func (*MemberlistAgent) SetLogLevel ¶
func (a *MemberlistAgent) SetLogLevel(l int)
func (*MemberlistAgent) Start ¶
func (a *MemberlistAgent) Start() error
func (*MemberlistAgent) Stop ¶
func (a *MemberlistAgent) Stop() error
func (*MemberlistAgent) TestsHalt ¶
func (a *MemberlistAgent) TestsHalt()
type MemberlistDelegate ¶
type MemberlistDelegate interface { Start(BaseMembers) Stop(BaseMembers) FilterParticipants(BaseMembers, []*memberlist.Node) []*memberlist.Node NotifyMsg(BaseMembers, []byte) GetBroadcasts(BaseMembers, int, int) [][]byte LocalState(BaseMembers, bool) []byte MergeRemoteState(BaseMembers, []byte, bool) NotifyJoin(BaseMembers, *memberlist.Node) NotifyLeave(BaseMembers, *memberlist.Node) NotifyUpdate(BaseMembers, *memberlist.Node) }