Documentation ¶
Index ¶
- Constants
- func NewCommandHandler(controller *Controller) channel.TypedReceiveHandler
- func NewHcLogrusLogger() hclog.Logger
- func NewJoinHandler(controller *Controller) channel.TypedReceiveHandler
- func NewRemoveHandler(controller *Controller) channel.TypedReceiveHandler
- type BoltDbFsm
- func (self *BoltDbFsm) Apply(log *raft.Log) interface{}
- func (self *BoltDbFsm) GetCurrentState(raft *raft.Raft) (uint64, *raft.Configuration)
- func (self *BoltDbFsm) GetDb() boltz.Db
- func (self *BoltDbFsm) Init() error
- func (self *BoltDbFsm) RaftInitialized()
- func (self *BoltDbFsm) Restore(snapshot io.ReadCloser) error
- func (self *BoltDbFsm) Snapshot() (raft.FSMSnapshot, error)
- func (self *BoltDbFsm) StoreConfiguration(index uint64, configuration raft.Configuration)
- type Config
- type Controller
- func (self *Controller) ApplyEncodedCommand(encoded []byte) (uint64, error)
- func (self *Controller) ApplyWithTimeout(log []byte, timeout time.Duration) (interface{}, uint64, error)
- func (self *Controller) Bootstrap() error
- func (self *Controller) CtrlAddresses() (uint64, []string)
- func (self *Controller) Dispatch(cmd command.Command) error
- func (self *Controller) GetDb() boltz.Db
- func (self *Controller) GetLeaderAddr() string
- func (self *Controller) GetMesh() mesh.Mesh
- func (self *Controller) GetRaft() *raft.Raft
- func (self *Controller) HandleJoin(req *JoinRequest) error
- func (self *Controller) HandleJoinAsLeader(req *JoinRequest) error
- func (self *Controller) HandleRemove(req *RemoveRequest) error
- func (self *Controller) HandleRemoveAsLeader(req *RemoveRequest) error
- func (self *Controller) Init() error
- func (self *Controller) IsLeader() bool
- func (self *Controller) IsLeaderOrLeaderless() bool
- func (self *Controller) Join(req *JoinRequest) error
- func (self *Controller) ListMembers() ([]*Member, error)
- func (self *Controller) RemoveServer(id string) error
- type IndexTracker
- type JoinRequest
- type Member
- type MemberModel
- type MigrationManager
- type RemoveRequest
- type RouterDispatchCallback
Constants ¶
const ( NewLogEntryType = 2050 ErrorResponseType = 2051 SuccessResponseType = 2052 JoinRequestType = 2053 RemoveRequestType = 2054 HeaderErrorCode = 1000 IndexHeader = 1001 ErrorCodeBadMessage = 1 ErrorCodeNotLeader = 2 ErrorCodeApiError = 3 ErrorCodeGeneric = 4 )
Variables ¶
This section is empty.
Functions ¶
func NewCommandHandler ¶
func NewCommandHandler(controller *Controller) channel.TypedReceiveHandler
func NewHcLogrusLogger ¶
func NewHcLogrusLogger() hclog.Logger
func NewJoinHandler ¶
func NewJoinHandler(controller *Controller) channel.TypedReceiveHandler
func NewRemoveHandler ¶
func NewRemoveHandler(controller *Controller) channel.TypedReceiveHandler
Types ¶
type BoltDbFsm ¶
type BoltDbFsm struct {
// contains filtered or unexported fields
}
func NewFsm ¶
func NewFsm(dataDir string, decoders command.Decoders, indexTracker IndexTracker, routerDispatchCallback RouterDispatchCallback) *BoltDbFsm
func (*BoltDbFsm) GetCurrentState ¶ added in v0.22.15
func (*BoltDbFsm) RaftInitialized ¶
func (self *BoltDbFsm) RaftInitialized()
func (*BoltDbFsm) StoreConfiguration ¶ added in v0.22.15
func (self *BoltDbFsm) StoreConfiguration(index uint64, configuration raft.Configuration)
type Controller ¶
type Controller struct { Id *identity.TokenId Config *Config Mesh mesh.Mesh Raft *raft.Raft Fsm *BoltDbFsm // contains filtered or unexported fields }
Controller manages RAFT related state and operations
func NewController ¶
func NewController(id *identity.TokenId, version string, config *Config, metricsRegistry metrics.Registry, migrationMgr MigrationManager, routerDispatchCallback RouterDispatchCallback) *Controller
func (*Controller) ApplyEncodedCommand ¶
func (self *Controller) ApplyEncodedCommand(encoded []byte) (uint64, error)
ApplyEncodedCommand applies the command to the RAFT distributed log
func (*Controller) ApplyWithTimeout ¶
func (self *Controller) ApplyWithTimeout(log []byte, timeout time.Duration) (interface{}, uint64, error)
ApplyWithTimeout applies the given command to the RAFT distributed log with the given timeout
func (*Controller) Bootstrap ¶ added in v0.22.4
func (self *Controller) Bootstrap() error
func (*Controller) CtrlAddresses ¶ added in v0.22.15
func (self *Controller) CtrlAddresses() (uint64, []string)
func (*Controller) Dispatch ¶
func (self *Controller) Dispatch(cmd command.Command) error
Dispatch dispatches the given command to the current leader. If the current node is the leader, the command will be applied and the result returned
func (*Controller) GetLeaderAddr ¶
func (self *Controller) GetLeaderAddr() string
GetLeaderAddr returns the current leader address, which may be blank if there is no leader currently
func (*Controller) GetMesh ¶
func (self *Controller) GetMesh() mesh.Mesh
GetMesh returns the related Mesh instance
func (*Controller) GetRaft ¶
func (self *Controller) GetRaft() *raft.Raft
GetRaft returns the managed raft instance
func (*Controller) HandleJoin ¶
func (self *Controller) HandleJoin(req *JoinRequest) error
func (*Controller) HandleJoinAsLeader ¶
func (self *Controller) HandleJoinAsLeader(req *JoinRequest) error
func (*Controller) HandleRemove ¶
func (self *Controller) HandleRemove(req *RemoveRequest) error
func (*Controller) HandleRemoveAsLeader ¶
func (self *Controller) HandleRemoveAsLeader(req *RemoveRequest) error
func (*Controller) Init ¶
func (self *Controller) Init() error
Init sets up the Mesh and Raft instances
func (*Controller) IsLeader ¶
func (self *Controller) IsLeader() bool
IsLeader returns true if the current node is the RAFT leader
func (*Controller) IsLeaderOrLeaderless ¶ added in v0.22.7
func (self *Controller) IsLeaderOrLeaderless() bool
func (*Controller) Join ¶
func (self *Controller) Join(req *JoinRequest) error
Join adds the given node to the raft cluster
func (*Controller) ListMembers ¶
func (self *Controller) ListMembers() ([]*Member, error)
func (*Controller) RemoveServer ¶
func (self *Controller) RemoveServer(id string) error
RemoveServer removes the node specified by the given id from the raft cluster
type IndexTracker ¶ added in v0.19.54
type IndexTracker interface { Index() uint64 WaitForIndex(index uint64, deadline time.Time) error NotifyOfIndex(index uint64) }
func NewIndexTracker ¶ added in v0.19.54
func NewIndexTracker() IndexTracker
type JoinRequest ¶
func (*JoinRequest) Decode ¶
func (self *JoinRequest) Decode(msg *channel.Message) error
func (*JoinRequest) Encode ¶
func (self *JoinRequest) Encode() (*channel.Message, error)
type MemberModel ¶
type MemberModel interface { // ListMembers returns the current set of raft members ListMembers() ([]*Member, error) // HandleJoin adds a node to the raft cluster HandleJoin(req *JoinRequest) error // HandleRemove removes a node from the raft cluster HandleRemove(req *RemoveRequest) error }
MemberModel presents information about and operations on RAFT membership
type MigrationManager ¶ added in v0.22.4
type RemoveRequest ¶
type RemoveRequest struct {
Id string
}
func (*RemoveRequest) Decode ¶
func (self *RemoveRequest) Decode(msg *channel.Message) error
func (*RemoveRequest) Encode ¶
func (self *RemoveRequest) Encode() (*channel.Message, error)
type RouterDispatchCallback ¶ added in v0.22.15
type RouterDispatchCallback func(*raft.Configuration) error