bump(github.com/benbjohnson/go-raft): d46748244f1f1830a002b8f645342426c5d73e81
This commit is contained in:
27
third_party/github.com/benbjohnson/go-raft/leave_command.go
vendored
Normal file
27
third_party/github.com/benbjohnson/go-raft/leave_command.go
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
package raft
|
||||
|
||||
// Leave command interface
|
||||
type LeaveCommand interface {
|
||||
CommandName() string
|
||||
Apply(server *Server) (interface{}, error)
|
||||
NodeName() string
|
||||
}
|
||||
|
||||
// Leave command
|
||||
type DefaultLeaveCommand struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// The name of the Leave command in the log
|
||||
func (c *DefaultLeaveCommand) CommandName() string {
|
||||
return "raft:leave"
|
||||
}
|
||||
|
||||
func (c *DefaultLeaveCommand) Apply(server *Server) (interface{}, error) {
|
||||
err := server.RemovePeer(c.Name)
|
||||
|
||||
return []byte("leave"), err
|
||||
}
|
||||
func (c *DefaultLeaveCommand) NodeName() string {
|
||||
return c.Name
|
||||
}
|
Reference in New Issue
Block a user