command.go 463 B

12345678910111213141516171819
  1. package command
  2. import (
  3. "github.com/coreos/go-raft"
  4. )
  5. // A command represents an action to be taken on the replicated state machine.
  6. type Command interface {
  7. CommandName() string
  8. Apply(server *raft.Server) (interface{}, error)
  9. }
  10. // Registers commands to the Raft library.
  11. func Register() {
  12. raft.RegisterCommand(&DeleteCommand{})
  13. raft.RegisterCommand(&TestAndSetCommand{})
  14. raft.RegisterCommand(&CreateCommand{})
  15. raft.RegisterCommand(&UpdateCommand{})
  16. }