communication

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package communication provides means for transactional communication.

Index

Constants

View Source
const (
	TestsNothing = iota
	TestsAbort
	TestsUnreliableSend
	// Halting
	TestsMidInterested
	TestsAfterInterested
	TestsMidFirst
	TestsAfterFirst
	TestsMidSecond
)

Variables

View Source
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

func NewMemberlistAgent(id string, port int, lc config.LogConfig, nodes ...string) *MemberlistAgent

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 allows overriding the handling of memberlist's 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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL