Documentation ¶
Index ¶
- func New(cfg Config, states ...StateSource) (*Raft, <-chan UnactionedMessage, *Peers)
- type Committer
- type Config
- type Peers
- type Raft
- func (r *Raft) Add(id, parentId uint64, name string, mode store.FileMode) (bool, func())
- func (r *Raft) Change(id, version, offset uint64, size int64) (bool, func())
- func (r *Raft) Delete(id, parentId uint64, name string) (bool, func())
- func (r *Raft) Rename(id, oldParentId, newParentId uint64, oldName, newName string) (bool, func())
- func (r *Raft) Shutdown()
- func (r *Raft) Step(ctx context.Context, e *etcdraftpb.Message) (*raftpb.Empty, error)
- type StateSource
- type UnactionedMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(cfg Config, states ...StateSource) (*Raft, <-chan UnactionedMessage, *Peers)
Types ¶
type Committer ¶
type Committer interface { Add(id, parentId uint64, name string, mode store.FileMode) (bool, func()) Change(id, version, offset uint64, size int64) (bool, func()) Rename(id, oldParentId, newParentId uint64, oldName, newName string) (bool, func()) Delete(id, parentId uint64, newName string) (bool, func()) }
Committer tries to commit the entry to raft. It returns true or false if the entry get completed in a timely manner. After proposing a change, which has been approved by raft, you need to invoke the callback function returned by the Committer's method. Even if you fail to action the result, you need to invoke the callback; otherwise bad things will happen. If the change wasn't approved you don't need to call the callback, and calling it will be a noop.
type Peers ¶
type Peers struct {
// contains filtered or unexported fields
}
func NewPeerList ¶
func (Peers) ForEach ¶
ForEach will call the function for every available peer. If the function returns a non-nil error, the iterations will be stopped immediately and the error will be returned directly.
func (Peers) GetPeerRaft ¶
GetPeerRaft is used for compliance with the type of raft id's being uint64 and 0 not being an acceptable peer id
func (Peers) IsLocalFile ¶
func (Peers) PeersWithFile ¶
PeersWithFile will return the peers which are supposed to hold the provided fileId. It will exclude this peer from that list
type Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
type StateSource ¶
type StateSource interface { Name() string // GetState should return a reader to a copy of the current state. If the state changes, after the call // to GetState, the Read() behaviour of the returned io.Reader shouldn't change. GetState() (io.Reader, error) SetState(io.Reader) error }
StateSource is an interface that may be implemented by sources of state for RAFT.