mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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:
commit
2b9c4bc90d
@ -32,7 +32,6 @@ func TestSingleNode(t *testing.T) {
|
|||||||
|
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
etcd.OpenDebug()
|
|
||||||
c := etcd.NewClient()
|
c := etcd.NewClient()
|
||||||
|
|
||||||
c.SyncCluster()
|
c.SyncCluster()
|
||||||
|
@ -48,7 +48,6 @@ type snapshotConf struct {
|
|||||||
writesThr uint64
|
writesThr uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewPeerServer(name string, path string, url string, listenHost string, tlsConf *TLSConfig, tlsInfo *TLSInfo, registry *Registry, store *store.Store) *PeerServer {
|
func NewPeerServer(name string, path string, url string, listenHost string, tlsConf *TLSConfig, tlsInfo *TLSInfo, registry *Registry, store *store.Store) *PeerServer {
|
||||||
s := &PeerServer{
|
s := &PeerServer{
|
||||||
name: name,
|
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 {
|
func (s *PeerServer) Stats() []byte {
|
||||||
@ -545,4 +543,3 @@ func (s *PeerServer) dispatch(c raft.Command, w http.ResponseWriter, req *http.R
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@ -38,6 +38,7 @@ func New(name string, urlStr string, listenHost string, tlsConf *TLSConfig, tlsI
|
|||||||
TLSConfig: &tlsConf.Server,
|
TLSConfig: &tlsConf.Server,
|
||||||
Addr: listenHost,
|
Addr: listenHost,
|
||||||
},
|
},
|
||||||
|
name: name,
|
||||||
store: store,
|
store: store,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
url: urlStr,
|
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.
|
// Wrap the standard HandleFunc interface to pass in the server reference.
|
||||||
return r.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) {
|
return r.HandleFunc(path, func(w http.ResponseWriter, req *http.Request) {
|
||||||
// Log 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.
|
// Write CORS header.
|
||||||
if s.OriginAllowed("*") {
|
if s.OriginAllowed("*") {
|
||||||
|
@ -24,4 +24,3 @@ func redirect(hostname string, w http.ResponseWriter, req *http.Request) {
|
|||||||
log.Debugf("Redirect to %s", url)
|
log.Debugf("Redirect to %s", url)
|
||||||
http.Redirect(w, req, url, http.StatusTemporaryRedirect)
|
http.Redirect(w, req, url, http.StatusTemporaryRedirect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"github.com/coreos/etcd/store"
|
"github.com/coreos/etcd/store"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Removes a key from the store.
|
// Removes a key from the store.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"github.com/coreos/etcd/store"
|
"github.com/coreos/etcd/store"
|
||||||
"github.com/coreos/go-raft"
|
"github.com/coreos/go-raft"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The Server interface provides all the methods required for the v1 API.
|
// The Server interface provides all the methods required for the v1 API.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package v2
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"github.com/coreos/etcd/store"
|
"github.com/coreos/etcd/store"
|
||||||
"github.com/coreos/go-raft"
|
"github.com/coreos/go-raft"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The Server interface provides all the methods required for the v2 API.
|
// The Server interface provides all the methods required for the v2 API.
|
||||||
|
@ -77,5 +77,3 @@ func (event *Event) Response() interface{} {
|
|||||||
return responses
|
return responses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
|
|
||||||
type eventQueue struct {
|
type eventQueue struct {
|
||||||
Events []*Event
|
Events []*Event
|
||||||
Size int
|
Size int
|
||||||
|
@ -18,4 +18,3 @@ func TTL(duration string) (time.Time, error) {
|
|||||||
return Permanent, nil
|
return Permanent, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
util.go
2
util.go
@ -14,7 +14,6 @@ import (
|
|||||||
// HTTP Utilities
|
// HTTP Utilities
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// sanitizeURL will cleanup a host string in the format hostname:port and
|
// sanitizeURL will cleanup a host string in the format hostname:port and
|
||||||
// attach a schema.
|
// attach a schema.
|
||||||
func sanitizeURL(host string, defaultScheme string) string {
|
func sanitizeURL(host string, defaultScheme string) string {
|
||||||
@ -87,4 +86,3 @@ func runCPUProfile() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user