Documentation ¶
Index ¶
- type Config
- type DefaultPeerFinder
- type HTTPApi
- type HTTPClient
- type IdMap
- type JoinRequest
- type JoinResponse
- type LeaveRequest
- type LeaveResponse
- type Metrics
- type PeerFinder
- type Population
- type PruneMap
- type QuorumNode
- func (q *QuorumNode) Apply(l *raft.Log) interface{}
- func (q *QuorumNode) GetLeader() (string, error)
- func (q *QuorumNode) GetPopulation() Population
- func (q *QuorumNode) IsSplitBrain() bool
- func (q *QuorumNode) Join(serverId string, serverAddress string) error
- func (q *QuorumNode) Remove(serverId string) error
- func (q *QuorumNode) Restore(rc io.ReadCloser) error
- func (q *QuorumNode) Shutdown(ctx context.Context) error
- func (q *QuorumNode) Snapshot() (raft.FSMSnapshot, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Address which other nodes can reach this one from IP string // Port to expose HTTP API on Port string // Config to pass into Memberlist MemberlistConfig *memberlist.Config // Directory to store persistent raft data RaftDir string // Port for the raft library to listen on RaftPort string // Pool size of the underlying TCP Transport layer RaftPoolSize int // Timeout for each request of the underlying TCP Transport layer RaftTimeout time.Duration // Number of snapshots to retain RaftRetain int // Config to pass into Raft RaftConfig *raft.Config // Interface that will return the set of peers to join. This is also // used when trying to rejoin the cluster when we have been removed // or we are in split brain. PeerFinder PeerFinder // If the ratio of memberlist members to raft members is less than or // equal to this ratio, we are in split-brain. Typical this is set to // 0.5 which allows a majority of nodes to keep operating. QuorumRatio float64 // How often to check the state of the quorum cluster and detect // split-brain CheckStatePeriod time.Duration // How often the leader checks membership info and removes dead servers // from the raft configuration LeaderLoopPeriod time.Duration // Timeout for requests to the cluster using the HTTP API APIRequestTimeout time.Duration // How long after a node is dead in memberlist do we prune it from the // raft group PruneDuration time.Duration // User specified FSM for the underlying raft layer FSM raft.FSM }
func NewDefaultConfig ¶
type DefaultPeerFinder ¶
type DefaultPeerFinder struct {
InitialPeerSet []string
}
func NewDefaultPeerFinder ¶
func NewDefaultPeerFinder(initialPeerSet []string) *DefaultPeerFinder
func (*DefaultPeerFinder) Peers ¶
func (d *DefaultPeerFinder) Peers() []string
type HTTPApi ¶
type HTTPApi struct {
// contains filtered or unexported fields
}
func NewHTTPApi ¶
func NewHTTPApi(quorumNode *QuorumNode) *HTTPApi
func (*HTTPApi) Join ¶
func (h *HTTPApi) Join(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*HTTPApi) Leave ¶
func (h *HTTPApi) Leave(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*HTTPApi) Start ¶
func (h *HTTPApi) Start(router *httprouter.Router)
Register any endpoints to the router
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient() *HTTPClient
func (*HTTPClient) Join ¶
func (d *HTTPClient) Join(ctx context.Context, target string, jreq *JoinRequest) (*JoinResponse, error)
func (*HTTPClient) Leave ¶
func (d *HTTPClient) Leave(ctx context.Context, target string, lreq *LeaveRequest) (*LeaveResponse, error)
type JoinRequest ¶
type JoinResponse ¶
type LeaveRequest ¶
type LeaveRequest struct {
ServerID string `json:"server_id"`
}
type LeaveResponse ¶
type LeaveResponse struct {
OK bool `json:"ok"`
}
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
NewMetrics returns a populated, and registered *Metrics, or an error.
func (*Metrics) MemberlistMembers ¶
func (*Metrics) RaftMembers ¶
func (*Metrics) SplitBrain ¶
type PeerFinder ¶
type PeerFinder interface {
Peers() []string
}
type Population ¶
func (*Population) Ratio ¶
func (p *Population) Ratio() float64
type QuorumNode ¶
type QuorumNode struct { Config *Config Memberlist *memberlist.Memberlist Raft *raft.Raft APIClient *HTTPClient JoinRequest *JoinRequest Population *atomic.Value SplitBrain *int32 // contains filtered or unexported fields }
func NewQuorumNode ¶
func NewQuorumNode(config *Config) (*QuorumNode, error)
func (*QuorumNode) Apply ¶
func (q *QuorumNode) Apply(l *raft.Log) interface{}
func (*QuorumNode) GetLeader ¶
func (q *QuorumNode) GetLeader() (string, error)
func (*QuorumNode) GetPopulation ¶
func (q *QuorumNode) GetPopulation() Population
func (*QuorumNode) IsSplitBrain ¶
func (q *QuorumNode) IsSplitBrain() bool
func (*QuorumNode) Remove ¶
func (q *QuorumNode) Remove(serverId string) error
func (*QuorumNode) Restore ¶
func (q *QuorumNode) Restore(rc io.ReadCloser) error
func (*QuorumNode) Snapshot ¶
func (q *QuorumNode) Snapshot() (raft.FSMSnapshot, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.