Merge pull request #1 from xiangli-cmu/refactoring

fix server/server.go accept name when creating a when server; gofmt
This commit is contained in:
Ben Johnson 2013-10-13 13:53:34 -07:00
commit 2b9c4bc90d
24 changed files with 897 additions and 907 deletions

View File

@ -32,7 +32,6 @@ func TestSingleNode(t *testing.T) {
time.Sleep(time.Second)
etcd.OpenDebug()
c := etcd.NewClient()
c.SyncCluster()

View File

@ -48,7 +48,6 @@ type snapshotConf struct {
writesThr uint64
}
func NewPeerServer(name string, path string, url string, listenHost string, tlsConf *TLSConfig, tlsInfo *TLSInfo, registry *Registry, store *store.Store) *PeerServer {
s := &PeerServer{
name: name,
@ -463,7 +462,6 @@ func (s *PeerServer) joinByMachine(server *raft.Server, machine string, scheme s
}
}
return fmt.Errorf("Unable to join: %v", err)
}
func (s *PeerServer) Stats() []byte {
@ -545,4 +543,3 @@ func (s *PeerServer) dispatch(c raft.Command, w http.ResponseWriter, req *http.R
return nil
}
}

View File

@ -1,8 +1,8 @@
package server
import (
"fmt"
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
@ -38,6 +38,7 @@ func New(name string, urlStr string, listenHost string, tlsConf *TLSConfig, tlsI
TLSConfig: &tlsConf.Server,
Addr: listenHost,
},
name: name,
store: store,
registry: registry,
url: urlStr,
@ -134,7 +135,7 @@ func (s *Server) handleFunc(path string, f func(http.ResponseWriter, *http.Reque
// Wrap the standard HandleFunc interface to pass in the server reference.
return r.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) {
// Log request.
log.Debugf("[recv] %s %s [%s]", req.Method, s.url, req.URL.Path, req.RemoteAddr)
log.Debugf("[recv] %s %s %s [%s]", req.Method, s.url, req.URL.Path, req.RemoteAddr)
// Write CORS header.
if s.OriginAllowed("*") {

View File

@ -24,4 +24,3 @@ func redirect(hostname string, w http.ResponseWriter, req *http.Request) {
log.Debugf("Redirect to %s", url)
http.Redirect(w, req, url, http.StatusTemporaryRedirect)
}

View File

@ -1,9 +1,9 @@
package v1
import (
"net/http"
"github.com/coreos/etcd/store"
"github.com/gorilla/mux"
"net/http"
)
// Removes a key from the store.

View File

@ -1,9 +1,9 @@
package v1
import (
"net/http"
"github.com/coreos/etcd/store"
"github.com/coreos/go-raft"
"net/http"
)
// The Server interface provides all the methods required for the v1 API.

View File

@ -1,9 +1,9 @@
package v2
import (
"net/http"
"github.com/coreos/etcd/store"
"github.com/coreos/go-raft"
"net/http"
)
// The Server interface provides all the methods required for the v2 API.

View File

@ -77,5 +77,3 @@ func (event *Event) Response() interface{} {
return responses
}
}

View File

@ -1,6 +1,5 @@
package store
type eventQueue struct {
Events []*Event
Size int

View File

@ -18,4 +18,3 @@ func TTL(duration string) (time.Time, error) {
return Permanent, nil
}
}

View File

@ -14,7 +14,6 @@ import (
// HTTP Utilities
//--------------------------------------
// sanitizeURL will cleanup a host string in the format hostname:port and
// attach a schema.
func sanitizeURL(host string, defaultScheme string) string {
@ -87,4 +86,3 @@ func runCPUProfile() {
}
}()
}