Remove ApplyFunc.
parent
49f3a13fbc
commit
9cc40929ea
11
server.go
11
server.go
|
@ -34,7 +34,6 @@ const (
|
|||
// A server is involved in the consensus protocol and can act as a follower,
|
||||
// candidate or a leader.
|
||||
type Server struct {
|
||||
ApplyFunc func(*Server, Command)
|
||||
DoHandler func(*Server, *Peer, Command) error
|
||||
RequestVoteHandler func(*Server, *Peer, *RequestVoteRequest) (*RequestVoteResponse, error)
|
||||
AppendEntriesHandler func(*Server, *Peer, *AppendEntriesRequest) (*AppendEntriesResponse, error)
|
||||
|
@ -74,15 +73,7 @@ func NewServer(name string, path string) (*Server, error) {
|
|||
|
||||
// Setup apply function.
|
||||
s.log.ApplyFunc = func(c Command) {
|
||||
// Apply Raft commands internally. External commands get delegated.
|
||||
if _, ok := c.(InternalCommand); ok {
|
||||
c.Apply(s)
|
||||
} else {
|
||||
if s.ApplyFunc == nil {
|
||||
panic("raft.Server: Apply function not set")
|
||||
}
|
||||
s.ApplyFunc(s, c)
|
||||
}
|
||||
c.Apply(s)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
|
|
|
@ -19,13 +19,6 @@ type Servers []*Server
|
|||
// Handlers
|
||||
//--------------------------------------
|
||||
|
||||
// Sets the ApplyFunc handler for a set of servers.
|
||||
func (s Servers) SetApplyFunc(f func(*Server, Command)) {
|
||||
for _, server := range s {
|
||||
server.ApplyFunc = f
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the RequestVoteHandler for a set of servers.
|
||||
func (s Servers) SetRequestVoteHandler(f func(*Server, *Peer, *RequestVoteRequest) (*RequestVoteResponse, error)) {
|
||||
for _, server := range s {
|
||||
|
|
Loading…
Reference in New Issue