influxdb/leave_command.go

28 lines
569 B
Go
Raw Normal View History

package raft
2013-07-26 20:33:58 +00:00
// Leave command interface
2013-07-26 23:47:51 +00:00
type LeaveCommand interface {
2013-07-26 20:33:58 +00:00
CommandName() string
Apply(server *Server) (interface{}, error)
NodeName() string
}
// Leave command
2013-07-26 20:33:58 +00:00
type DefaultLeaveCommand struct {
Name string `json:"name"`
}
// The name of the Leave command in the log
2013-07-26 20:33:58 +00:00
func (c *DefaultLeaveCommand) CommandName() string {
return "raft:leave"
}
2013-07-26 20:33:58 +00:00
func (c *DefaultLeaveCommand) Apply(server *Server) (interface{}, error) {
err := server.RemovePeer(c.Name)
return []byte("leave"), err
2013-07-25 22:40:20 +00:00
}
2013-07-26 20:33:58 +00:00
func (c *DefaultLeaveCommand) NodeName() string {
return c.Name
}