Documentation
¶
Index ¶
- Constants
- Variables
- func DispatchCommand(handler CommandHandler, sender PeerAddr, cmd Command)
- func GetInterfaceIPv4Addr(iface *net.Interface) (net.IP, error)
- func GetInterfaceNames() string
- func GetTransmissionInfoString(source, from, to, destination PeerAddr) string
- func IsTimeoutError(err error) bool
- func PickRandomName() string
- type ActionHandler
- type Command
- func NewChangRobertIdCmd(id int) Command
- func NewGetRequestCommand() Command
- func NewGetResponseCommand(value int) Command
- func NewLeaderDistanceRequestCommand() Command
- func NewLeaderDistanceResponseCommand(distance int, direction int) Command
- func NewPeerInfoRequestCommand(name string, leader PeerAddr) Command
- func NewPeerInfoResponseCommand(name string) Command
- func NewPingCmd() Command
- func NewPongCmd() Command
- func NewRemovePeerCommand(peer PeerAddr, direction int) Command
- func NewReportPeerCommand(peer PeerAddr) Command
- func NewSetLeaderCommand(leader PeerAddr, value int) Command
- func NewSetRequestCommand(value int) Command
- func NewSetResponseCommand() Command
- func NewSyncPeersCmd(peers map[PeerAddr]PeerInfo) Command
- type CommandHandler
- type Context
- func (ctx *Context) AddNewPeer(name string, addr PeerAddr)
- func (ctx *Context) CASState(current, new State) bool
- func (ctx *Context) GetState() State
- func (ctx *Context) RemovePeer(addr PeerAddr)
- func (ctx *Context) ResolvePeerName(addr PeerAddr) string
- func (ctx *Context) SetKnownPeers(peers map[PeerAddr]PeerInfo)
- func (ctx *Context) SetState(new State)
- func (ctx *Context) UpdateLinkedPeers()
- type LamportClock
- type PeerAddr
- type PeerInfo
- type State
- type Tee
Constants ¶
View Source
const ( PEER_INFO_REQUEST_CMD = iota PEER_INFO_RESPONSE_CMD SET_LEADER_CMD REPORT_PEER_CMD REMOVE_PEER_CMD LEADER_DISTANCE_REQUEST_CMD LEADER_DISTANCE_RESPONSE_CMD SYNC_PEERS_CMD PING_CMD PONG_CMD CHANG_ROBERTS_ID_CMD GET_REQUEST_CMD GET_RESPONSE_CMD SET_REQUEST_CMD SET_RESPONSE_CMD MAX_CMD )
Variables ¶
View Source
var NAMES = []string{}/* 201 elements not displayed */
Functions ¶
func DispatchCommand ¶
func DispatchCommand(handler CommandHandler, sender PeerAddr, cmd Command)
func GetInterfaceNames ¶
func GetInterfaceNames() string
func IsTimeoutError ¶
func PickRandomName ¶
func PickRandomName() string
Types ¶
type ActionHandler ¶
type Command ¶
type Command struct {
Op int
Sarg []string
Iarg []int
Source PeerAddr
Destination PeerAddr
From PeerAddr
Ttl int
Clock LamportClock
}
func NewChangRobertIdCmd ¶
func NewGetRequestCommand ¶
func NewGetRequestCommand() Command
func NewGetResponseCommand ¶
func NewLeaderDistanceRequestCommand ¶
func NewLeaderDistanceRequestCommand() Command
func NewPingCmd ¶
func NewPingCmd() Command
func NewPongCmd ¶
func NewPongCmd() Command
func NewRemovePeerCommand ¶
func NewReportPeerCommand ¶
func NewSetLeaderCommand ¶
func NewSetRequestCommand ¶
func NewSetResponseCommand ¶
func NewSetResponseCommand() Command
func NewSyncPeersCmd ¶
type CommandHandler ¶
type CommandHandler interface {
NewPeer(sender PeerAddr, addr PeerAddr, name string, shouldReply bool)
LeaderChanged(sender PeerAddr, leader PeerAddr, value int)
PeerReported(reportedPeer PeerAddr)
PeerRemoved(sender PeerAddr, reportedPeer PeerAddr, direction int)
DistanceRequested(sender PeerAddr, source PeerAddr)
DistanceReceived(sender PeerAddr, distance int, direction int)
SyncPeers(sender PeerAddr, values []string)
Ping(sender PeerAddr, source PeerAddr)
Pong(sender PeerAddr, source PeerAddr)
ChRoIdReceived(sender PeerAddr, id int)
ValueGetRequested(sender PeerAddr, source PeerAddr)
GotValue(sender PeerAddr, value int)
ValueSetRequested(sender PeerAddr, source PeerAddr, value int)
ValueSetConfirmed(sender PeerAddr)
}
type Context ¶
type Context struct {
Name string
ServerAddr PeerAddr
PeerId int
LinkedPeers [2]PeerAddr
Leader PeerAddr
LeaderDistance [2]int
KnownPeers map[PeerAddr]PeerInfo
SendNumRetries int
SendRetryPause time.Duration
ChRoTimerDur time.Duration
StateSync sync.Mutex
Sync sync.Mutex
StartedChRoTimer int32
Clock LamportClock
StopFlag bool
// contains filtered or unexported fields
}
func NewContext ¶
func (*Context) AddNewPeer ¶
func (*Context) RemovePeer ¶
func (*Context) ResolvePeerName ¶
func (*Context) SetKnownPeers ¶
func (*Context) UpdateLinkedPeers ¶
func (ctx *Context) UpdateLinkedPeers()
type LamportClock ¶
type LamportClock struct {
Value uint64
}
func (LamportClock) String ¶
func (l LamportClock) String() string
func (*LamportClock) SyncAfter ¶
func (l *LamportClock) SyncAfter(remoteClock LamportClock, delta uint64)
type State ¶
type State interface {
CommandHandler
ActionHandler
Name() string
Init()
}
Click to show internal directories.
Click to hide internal directories.