Documentation ¶
Index ¶
- Constants
- Variables
- type PeerAddress
- type RaftMemoryStorage
- func (raftStorage *RaftMemoryStorage) Append(entries []raftpb.Entry) error
- func (raftStorage *RaftMemoryStorage) ApplyAll(hs raftpb.HardState, ents []raftpb.Entry, snap raftpb.Snapshot) error
- func (raftStorage *RaftMemoryStorage) ApplySnapshot(snap raftpb.Snapshot) error
- func (raftStorage *RaftMemoryStorage) Close() error
- func (raftStorage *RaftMemoryStorage) CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error)
- func (raftStorage *RaftMemoryStorage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)
- func (raftStorage *RaftMemoryStorage) FirstIndex() (uint64, error)
- func (raftStorage *RaftMemoryStorage) InitialState() (raftpb.HardState, raftpb.ConfState, error)
- func (raftStorage *RaftMemoryStorage) IsDecommissioning() (bool, error)
- func (raftStorage *RaftMemoryStorage) IsEmpty() bool
- func (raftStorage *RaftMemoryStorage) LastIndex() (uint64, error)
- func (raftStorage *RaftMemoryStorage) NodeID() (uint64, error)
- func (raftStorage *RaftMemoryStorage) Open() error
- func (raftStorage *RaftMemoryStorage) SetDecommissioningFlag() error
- func (raftStorage *RaftMemoryStorage) SetHardState(st raftpb.HardState) error
- func (raftStorage *RaftMemoryStorage) SetIsEmpty(b bool)
- func (raftStorage *RaftMemoryStorage) SetNodeID(id uint64) error
- func (raftStorage *RaftMemoryStorage) Snapshot() (raftpb.Snapshot, error)
- func (raftStorage *RaftMemoryStorage) Term(i uint64) (uint64, error)
- type RaftNode
- func (raftNode *RaftNode) AddNode(ctx context.Context, nodeID uint64, context []byte) error
- func (raftNode *RaftNode) CommittedEntries() ([]raftpb.Entry, error)
- func (raftNode *RaftNode) ID() uint64
- func (raftNode *RaftNode) LastSnapshot() (raftpb.Snapshot, error)
- func (raftNode *RaftNode) OnCommittedEntry(cb func(raftpb.Entry) error)
- func (raftNode *RaftNode) OnError(cb func(error) error)
- func (raftNode *RaftNode) OnMessages(cb func([]raftpb.Message) error)
- func (raftNode *RaftNode) OnReplayDone(cb func() error)
- func (raftNode *RaftNode) OnSnapshot(cb func(raftpb.Snapshot) error)
- func (raftNode *RaftNode) Propose(ctx context.Context, proposition []byte) error
- func (raftNode *RaftNode) Receive(ctx context.Context, msg raftpb.Message) error
- func (raftNode *RaftNode) RemoveNode(ctx context.Context, nodeID uint64, context []byte) error
- func (raftNode *RaftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus)
- func (raftNode *RaftNode) ReportUnreachable(id uint64)
- func (raftNode *RaftNode) Start() error
- func (raftNode *RaftNode) Stop()
- type RaftNodeConfig
- type RaftNodeStorage
- type RaftStorage
- func (raftStorage *RaftStorage) Append(entries []raftpb.Entry) error
- func (raftStorage *RaftStorage) ApplyAll(hs raftpb.HardState, ents []raftpb.Entry, snap raftpb.Snapshot) error
- func (raftStorage *RaftStorage) ApplySnapshot(snap raftpb.Snapshot) error
- func (raftStorage *RaftStorage) Close() error
- func (raftStorage *RaftStorage) CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error)
- func (raftStorage *RaftStorage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)
- func (raftStorage *RaftStorage) FirstIndex() (uint64, error)
- func (raftStorage *RaftStorage) InitialState() (raftpb.HardState, raftpb.ConfState, error)
- func (raftStorage *RaftStorage) IsDecommissioning() (bool, error)
- func (raftStorage *RaftStorage) IsEmpty() bool
- func (raftStorage *RaftStorage) LastIndex() (uint64, error)
- func (raftStorage *RaftStorage) NodeID() (uint64, error)
- func (raftStorage *RaftStorage) Open() error
- func (raftStorage *RaftStorage) SetDecommissioningFlag() error
- func (raftStorage *RaftStorage) SetHardState(st raftpb.HardState) error
- func (raftStorage *RaftStorage) SetNodeID(id uint64) error
- func (raftStorage *RaftStorage) Snapshot() (raftpb.Snapshot, error)
- func (raftStorage *RaftStorage) Term(i uint64) (uint64, error)
- type TransportHub
- func (hub *TransportHub) AddPeer(peerAddress PeerAddress)
- func (hub *TransportHub) Attach(router *mux.Router)
- func (hub *TransportHub) OnReceive(cb func(context.Context, raftpb.Message) error)
- func (hub *TransportHub) PeerAddress(nodeID uint64) *PeerAddress
- func (hub *TransportHub) RemovePeer(peerAddress PeerAddress)
- func (hub *TransportHub) Send(ctx context.Context, msg raftpb.Message, proxy bool) error
- func (hub *TransportHub) SetDefaultRoute(host string, port int)
- func (hub *TransportHub) SetLocalPeerID(id uint64)
- func (hub *TransportHub) UpdatePeer(peerAddress PeerAddress)
Constants ¶
View Source
const (
RequestTimeoutSeconds = 10
)
Variables ¶
View Source
var ECancelConfChange = errors.New("Conf change cancelled")
View Source
var EReceiverUnknown = errors.New("The sender does not know the receiver")
View Source
var ESenderUnknown = errors.New("The receiver does not know who we are")
View Source
var ETimeout = errors.New("The sender timed out while trying to send the message to the receiver")
View Source
var KeyHardState = []byte{1}
View Source
var KeyIsDecommissioning = []byte{4}
View Source
var KeyNodeID = []byte{3}
View Source
var KeyPrefixEntry = []byte{2}
View Source
var KeySnapshot = []byte{0}
View Source
var LogCompactionSize int = 1000
Limit on the number of entries that can accumulate before a snapshot and compaction occurs
Functions ¶
This section is empty.
Types ¶
type PeerAddress ¶
func (*PeerAddress) IsEmpty ¶
func (peerAddress *PeerAddress) IsEmpty() bool
func (*PeerAddress) ToHTTPURL ¶
func (peerAddress *PeerAddress) ToHTTPURL(endpoint string) string
type RaftMemoryStorage ¶
type RaftMemoryStorage struct {
// contains filtered or unexported fields
}
func NewRaftMemoryStorage ¶
func NewRaftMemoryStorage() *RaftMemoryStorage
func (*RaftMemoryStorage) Append ¶
func (raftStorage *RaftMemoryStorage) Append(entries []raftpb.Entry) error
func (*RaftMemoryStorage) ApplySnapshot ¶
func (raftStorage *RaftMemoryStorage) ApplySnapshot(snap raftpb.Snapshot) error
func (*RaftMemoryStorage) Close ¶
func (raftStorage *RaftMemoryStorage) Close() error
func (*RaftMemoryStorage) CreateSnapshot ¶
func (*RaftMemoryStorage) Entries ¶
func (raftStorage *RaftMemoryStorage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)
func (*RaftMemoryStorage) FirstIndex ¶
func (raftStorage *RaftMemoryStorage) FirstIndex() (uint64, error)
func (*RaftMemoryStorage) InitialState ¶
func (*RaftMemoryStorage) IsDecommissioning ¶
func (raftStorage *RaftMemoryStorage) IsDecommissioning() (bool, error)
func (*RaftMemoryStorage) IsEmpty ¶
func (raftStorage *RaftMemoryStorage) IsEmpty() bool
func (*RaftMemoryStorage) LastIndex ¶
func (raftStorage *RaftMemoryStorage) LastIndex() (uint64, error)
func (*RaftMemoryStorage) NodeID ¶
func (raftStorage *RaftMemoryStorage) NodeID() (uint64, error)
func (*RaftMemoryStorage) Open ¶
func (raftStorage *RaftMemoryStorage) Open() error
func (*RaftMemoryStorage) SetDecommissioningFlag ¶
func (raftStorage *RaftMemoryStorage) SetDecommissioningFlag() error
func (*RaftMemoryStorage) SetHardState ¶
func (raftStorage *RaftMemoryStorage) SetHardState(st raftpb.HardState) error
func (*RaftMemoryStorage) SetIsEmpty ¶
func (raftStorage *RaftMemoryStorage) SetIsEmpty(b bool)
func (*RaftMemoryStorage) SetNodeID ¶
func (raftStorage *RaftMemoryStorage) SetNodeID(id uint64) error
type RaftNode ¶
type RaftNode struct {
// contains filtered or unexported fields
}
func NewRaftNode ¶
func NewRaftNode(config *RaftNodeConfig) *RaftNode
func (*RaftNode) CommittedEntries ¶
func (*RaftNode) OnCommittedEntry ¶
func (*RaftNode) OnReplayDone ¶
func (*RaftNode) RemoveNode ¶
func (*RaftNode) ReportSnapshot ¶
func (raftNode *RaftNode) ReportSnapshot(id uint64, status raft.SnapshotStatus)
func (*RaftNode) ReportUnreachable ¶
type RaftNodeConfig ¶
type RaftNodeStorage ¶
type RaftNodeStorage interface { raft.Storage IsEmpty() bool Open() error Close() error SetDecommissioningFlag() error IsDecommissioning() (bool, error) SetNodeID(id uint64) error NodeID() (uint64, error) SetHardState(st raftpb.HardState) error ApplySnapshot(snap raftpb.Snapshot) error CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error) Append(entries []raftpb.Entry) error ApplyAll(hs raftpb.HardState, ents []raftpb.Entry, snap raftpb.Snapshot) error }
type RaftStorage ¶
type RaftStorage struct {
// contains filtered or unexported fields
}
func NewRaftStorage ¶
func NewRaftStorage(storageDriver StorageDriver) *RaftStorage
func (*RaftStorage) ApplyAll ¶
func (raftStorage *RaftStorage) ApplyAll(hs raftpb.HardState, ents []raftpb.Entry, snap raftpb.Snapshot) error
This should apply the entries, then the hard state, then the snapshot atomically to both in memory and persistent storage This means that if any part fails no change occurs and the error is reported. If persisting the state to disk encounters an error then the operation is aborted and no change occurs.
func (*RaftStorage) ApplySnapshot ¶
func (raftStorage *RaftStorage) ApplySnapshot(snap raftpb.Snapshot) error
func (*RaftStorage) Close ¶
func (raftStorage *RaftStorage) Close() error
func (*RaftStorage) CreateSnapshot ¶
func (raftStorage *RaftStorage) CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error)
Atomically take a snapshot of the current state and compact the entries up to the point that the snapshot was taken
func (*RaftStorage) Entries ¶
func (raftStorage *RaftStorage) Entries(lo, hi, maxSize uint64) ([]raftpb.Entry, error)
func (*RaftStorage) FirstIndex ¶
func (raftStorage *RaftStorage) FirstIndex() (uint64, error)
func (*RaftStorage) InitialState ¶
START raft.Storage interface methods
func (*RaftStorage) IsDecommissioning ¶
func (raftStorage *RaftStorage) IsDecommissioning() (bool, error)
func (*RaftStorage) IsEmpty ¶
func (raftStorage *RaftStorage) IsEmpty() bool
func (*RaftStorage) LastIndex ¶
func (raftStorage *RaftStorage) LastIndex() (uint64, error)
func (*RaftStorage) NodeID ¶
func (raftStorage *RaftStorage) NodeID() (uint64, error)
func (*RaftStorage) Open ¶
func (raftStorage *RaftStorage) Open() error
func (*RaftStorage) SetDecommissioningFlag ¶
func (raftStorage *RaftStorage) SetDecommissioningFlag() error
func (*RaftStorage) SetHardState ¶
func (raftStorage *RaftStorage) SetHardState(st raftpb.HardState) error
func (*RaftStorage) SetNodeID ¶
func (raftStorage *RaftStorage) SetNodeID(id uint64) error
type TransportHub ¶
type TransportHub struct {
// contains filtered or unexported fields
}
func NewTransportHub ¶
func NewTransportHub(localPeerID uint64) *TransportHub
func (*TransportHub) AddPeer ¶
func (hub *TransportHub) AddPeer(peerAddress PeerAddress)
func (*TransportHub) Attach ¶
func (hub *TransportHub) Attach(router *mux.Router)
func (*TransportHub) PeerAddress ¶
func (hub *TransportHub) PeerAddress(nodeID uint64) *PeerAddress
func (*TransportHub) RemovePeer ¶
func (hub *TransportHub) RemovePeer(peerAddress PeerAddress)
func (*TransportHub) SetDefaultRoute ¶
func (hub *TransportHub) SetDefaultRoute(host string, port int)
func (*TransportHub) SetLocalPeerID ¶
func (hub *TransportHub) SetLocalPeerID(id uint64)
func (*TransportHub) UpdatePeer ¶
func (hub *TransportHub) UpdatePeer(peerAddress PeerAddress)
Click to show internal directories.
Click to hide internal directories.