Refactor commands.
This commit is contained in:
19
command/command.go
Normal file
19
command/command.go
Normal file
@ -0,0 +1,19 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"github.com/coreos/go-raft"
|
||||
)
|
||||
|
||||
// A command represents an action to be taken on the replicated state machine.
|
||||
type Command interface {
|
||||
CommandName() string
|
||||
Apply(server *raft.Server) (interface{}, error)
|
||||
}
|
||||
|
||||
// Registers commands to the Raft library.
|
||||
func Register() {
|
||||
raft.RegisterCommand(&DeleteCommand{})
|
||||
raft.RegisterCommand(&TestAndSetCommand{})
|
||||
raft.RegisterCommand(&CreateCommand{})
|
||||
raft.RegisterCommand(&UpdateCommand{})
|
||||
}
|
Reference in New Issue
Block a user