Documentation ¶
Index ¶
- func NewHcLogrusLogger() hclog.Logger
- 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) Restore(snapshot io.ReadCloser) error
- func (self *BoltDbFsm) Snapshot() (raft.FSMSnapshot, error)
- func (self *BoltDbFsm) StoreConfiguration(index uint64, configuration raft.Configuration)
- type ClusterEvent
- type ClusterState
- 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) ConfigureMeshHandlers(bindHandler channel.BindHandler)
- func (self *Controller) CtrlAddresses() (uint64, []string)
- func (self *Controller) Dispatch(cmd command.Command) error
- func (self *Controller) GetCloseNotify() <-chan struct{}
- func (self *Controller) GetDb() boltz.Db
- func (self *Controller) GetLeaderAddr() string
- func (self *Controller) GetMesh() mesh.Mesh
- func (self *Controller) GetMetricsRegistry() metrics.Registry
- func (self *Controller) GetPeers() map[string]channel.Channel
- func (self *Controller) GetRaft() *raft.Raft
- func (self *Controller) HandleAddPeer(req *cmd_pb.AddPeerRequest) error
- func (self *Controller) HandleAddPeerAsLeader(req *cmd_pb.AddPeerRequest) error
- func (self *Controller) HandleRemovePeer(req *cmd_pb.RemovePeerRequest) error
- func (self *Controller) HandleRemovePeerAsLeader(req *cmd_pb.RemovePeerRequest) error
- func (self *Controller) HandleTransferLeadership(req *cmd_pb.TransferLeadershipRequest) error
- func (self *Controller) HandleTransferLeadershipAsLeader(req *cmd_pb.TransferLeadershipRequest) error
- func (self *Controller) Init() error
- func (self *Controller) IsDistributed() bool
- func (self *Controller) IsLeader() bool
- func (self *Controller) IsLeaderOrLeaderless() bool
- func (self *Controller) IsReadOnlyMode() bool
- func (self *Controller) Join(req *cmd_pb.AddPeerRequest) error
- func (self *Controller) ListMembers() ([]*Member, error)
- func (self *Controller) ObserveLeaderChanges()
- func (self *Controller) RegisterClusterEventHandler(f func(event ClusterEvent, state ClusterState))
- func (self *Controller) RemoveServer(id string) error
- func (self *Controller) RenderJsonConfig() (string, error)
- type Env
- type IndexTracker
- type Member
- type MigrationManager
- type RouterDispatchCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHcLogrusLogger ¶
func NewHcLogrusLogger() hclog.Logger
Types ¶
type BoltDbFsm ¶
type BoltDbFsm struct {
// contains filtered or unexported fields
}
func NewFsm ¶
func NewFsm(dataDir string, decoders command.Decoders, indexTracker IndexTracker, eventDispatcher event2.Dispatcher) *BoltDbFsm
func (*BoltDbFsm) GetCurrentState ¶ added in v0.22.15
func (*BoltDbFsm) StoreConfiguration ¶ added in v0.22.15
func (self *BoltDbFsm) StoreConfiguration(index uint64, configuration raft.Configuration)
type ClusterEvent ¶ added in v0.22.23
type ClusterEvent uint32
const ( ClusterEventReadOnly ClusterEvent = 0 ClusterEventReadWrite ClusterEvent = 1 ClusterEventLeadershipGained ClusterEvent = 2 ClusterEventLeadershipLost ClusterEvent = 3 )
func (ClusterEvent) String ¶ added in v0.22.23
func (self ClusterEvent) String() string
type ClusterState ¶ added in v0.22.23
type ClusterState uint8
func (ClusterState) IsLeader ¶ added in v0.22.23
func (c ClusterState) IsLeader() bool
func (ClusterState) IsReadWrite ¶ added in v0.22.23
func (c ClusterState) IsReadWrite() bool
func (ClusterState) String ¶ added in v0.22.23
func (c ClusterState) String() string
type Config ¶
type Config struct { Recover bool DataDir string MinClusterSize uint32 AdvertiseAddress transport.Address BootstrapMembers []string CommandHandlerOptions struct { MaxQueueSize uint16 MaxWorkers uint16 } SnapshotInterval *time.Duration SnapshotThreshold *uint32 TrailingLogs *uint32 MaxAppendEntries *uint32 HeartbeatTimeout *time.Duration ElectionTimeout *time.Duration LeaderLeaseTimeout *time.Duration LogLevel *string Logger hclog.Logger }
func (*Config) ConfigureReloadable ¶ added in v0.22.29
func (self *Config) ConfigureReloadable(conf *raft.ReloadableConfig)
type Controller ¶
type Controller struct { 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(env Env, migrationMgr MigrationManager) *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) ConfigureMeshHandlers ¶ added in v0.22.29
func (self *Controller) ConfigureMeshHandlers(bindHandler channel.BindHandler)
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) GetCloseNotify ¶ added in v0.22.29
func (self *Controller) GetCloseNotify() <-chan struct{}
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) GetMetricsRegistry ¶ added in v0.22.29
func (self *Controller) GetMetricsRegistry() metrics.Registry
func (*Controller) GetPeers ¶ added in v0.22.29
func (self *Controller) GetPeers() map[string]channel.Channel
func (*Controller) GetRaft ¶
func (self *Controller) GetRaft() *raft.Raft
GetRaft returns the managed raft instance
func (*Controller) HandleAddPeer ¶ added in v0.22.29
func (self *Controller) HandleAddPeer(req *cmd_pb.AddPeerRequest) error
func (*Controller) HandleAddPeerAsLeader ¶ added in v0.22.29
func (self *Controller) HandleAddPeerAsLeader(req *cmd_pb.AddPeerRequest) error
func (*Controller) HandleRemovePeer ¶ added in v0.22.29
func (self *Controller) HandleRemovePeer(req *cmd_pb.RemovePeerRequest) error
func (*Controller) HandleRemovePeerAsLeader ¶ added in v0.22.29
func (self *Controller) HandleRemovePeerAsLeader(req *cmd_pb.RemovePeerRequest) error
func (*Controller) HandleTransferLeadership ¶ added in v0.22.31
func (self *Controller) HandleTransferLeadership(req *cmd_pb.TransferLeadershipRequest) error
func (*Controller) HandleTransferLeadershipAsLeader ¶ added in v0.22.31
func (self *Controller) HandleTransferLeadershipAsLeader(req *cmd_pb.TransferLeadershipRequest) error
func (*Controller) Init ¶
func (self *Controller) Init() error
Init sets up the Mesh and Raft instances
func (*Controller) IsDistributed ¶ added in v0.22.23
func (self *Controller) IsDistributed() bool
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) IsReadOnlyMode ¶ added in v0.22.23
func (self *Controller) IsReadOnlyMode() bool
func (*Controller) Join ¶
func (self *Controller) Join(req *cmd_pb.AddPeerRequest) error
Join adds the given node to the raft cluster
func (*Controller) ListMembers ¶
func (self *Controller) ListMembers() ([]*Member, error)
func (*Controller) ObserveLeaderChanges ¶ added in v0.22.23
func (self *Controller) ObserveLeaderChanges()
func (*Controller) RegisterClusterEventHandler ¶ added in v0.22.23
func (self *Controller) RegisterClusterEventHandler(f func(event ClusterEvent, state ClusterState))
func (*Controller) RemoveServer ¶
func (self *Controller) RemoveServer(id string) error
RemoveServer removes the node specified by the given id from the raft cluster
func (*Controller) RenderJsonConfig ¶ added in v0.22.29
func (self *Controller) RenderJsonConfig() (string, error)
type Env ¶ added in v0.22.32
type Env interface { GetId() *identity.TokenId GetVersionProvider() versions.VersionProvider GetRaftConfig() *Config GetMetricsRegistry() metrics.Registry GetEventDispatcher() event.Dispatcher }
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 MigrationManager ¶ added in v0.22.4
type RouterDispatchCallback ¶ added in v0.22.15
type RouterDispatchCallback func(*raft.Configuration) error