Refactor commands.

This commit is contained in:
Ben Johnson
2013-10-11 01:02:38 -06:00
parent 594c2cab47
commit 89334df5ae
25 changed files with 886 additions and 820 deletions

View File

@ -1,16 +1,19 @@
package server
import (
"github.com/gorilla/mux"
"net/http"
"net/url"
"github.com/coreos/etcd/command"
"github.com/coreos/go-raft"
"github.com/gorilla/mux"
)
// The Server provides an HTTP interface to the underlying store.
type Server interface {
CommitIndex() uint64
Term() uint64
Dispatch(Command, http.ResponseWriter, *http.Request)
CommitIndex() uint64
Term() uint64
Dispatch(command.Command, http.ResponseWriter, *http.Request)
}
// This is the default implementation of the Server interface.
@ -55,11 +58,6 @@ func (s *server) Term() uint64 {
return c.raftServer.Term()
}
// Executes a command against the Raft server.
func (s *server) Do(c Command, localOnly bool) (interface{}, error) {
return c.raftServer.Do(s.RaftServer().Server)
}
func (s *server) installV1() {
s.handleFunc("/v1/keys/{key:.*}", v1.GetKeyHandler).Methods("GET")
s.handleFunc("/v1/keys/{key:.*}", v1.SetKeyHandler).Methods("POST", "PUT")