Remove ApplyFunc.

pull/820/head
Ben Johnson 2013-05-10 22:15:00 -06:00
parent 49f3a13fbc
commit 9cc40929ea
3 changed files with 1 additions and 18 deletions

View File

@ -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

View File

@ -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 {

View File

@ -58,7 +58,6 @@ func setupLog(content string) (*Log, string) {
func newTestServer(name string) *Server {
path, _ := ioutil.TempDir("", "raft-server-")
server, _ := NewServer(name, path)
server.ApplyFunc = func(s *Server, c Command) {}
return server
}