Cong Ding 12 years ago
parent
commit
468bfedf34
4 changed files with 23 additions and 25 deletions
  1. 2 2
      server/config.go
  2. 1 3
      server/cors_handler.go
  3. 18 18
      server/peer_server.go
  4. 2 2
      tests/server_utils.go

+ 2 - 2
server/config.go

@@ -13,8 +13,8 @@ import (
 	"strconv"
 	"strings"
 
-	"github.com/coreos/etcd/log"
 	"github.com/BurntSushi/toml"
+	"github.com/coreos/etcd/log"
 )
 
 // The default location for the etcd configuration file.
@@ -69,7 +69,7 @@ type Config struct {
 	VeryVerbose      bool `toml:"very_verbose" env:"ETCD_VERY_VERBOSE"`
 	HeartbeatTimeout int  `toml:"peer_heartbeat_timeout" env:"ETCD_PEER_HEARTBEAT_TIMEOUT"`
 	ElectionTimeout  int  `toml:"peer_election_timeout" env:"ETCD_PEER_ELECTION_TIMEOUT"`
-	Peer struct {
+	Peer             struct {
 		Addr     string `toml:"addr" env:"ETCD_PEER_ADDR"`
 		BindAddr string `toml:"bind_addr" env:"ETCD_PEER_BIND_ADDR"`
 		CAFile   string `toml:"ca_file" env:"ETCD_PEER_CA_FILE"`

+ 1 - 3
server/cors_handler.go

@@ -25,7 +25,7 @@ import (
 )
 
 type corsHandler struct {
-	router *mux.Router
+	router      *mux.Router
 	corsOrigins map[string]bool
 }
 
@@ -74,5 +74,3 @@ func (h *corsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 
 	h.router.ServeHTTP(w, req)
 }
-
-

+ 18 - 18
server/peer_server.go

@@ -23,23 +23,23 @@ import (
 const retryInterval = 10
 
 type PeerServer struct {
-	raftServer     raft.Server
-	server         *Server
-	httpServer     *http.Server
-	listener       net.Listener
-	joinIndex      uint64
-	name           string
-	url            string
-	bindAddr       string
-	tlsConf        *TLSConfig
-	tlsInfo        *TLSInfo
-	followersStats *raftFollowersStats
-	serverStats    *raftServerStats
-	registry       *Registry
-	store          store.Store
-	snapConf       *snapshotConf
-	MaxClusterSize int
-	RetryTimes     int
+	raftServer       raft.Server
+	server           *Server
+	httpServer       *http.Server
+	listener         net.Listener
+	joinIndex        uint64
+	name             string
+	url              string
+	bindAddr         string
+	tlsConf          *TLSConfig
+	tlsInfo          *TLSInfo
+	followersStats   *raftFollowersStats
+	serverStats      *raftServerStats
+	registry         *Registry
+	store            store.Store
+	snapConf         *snapshotConf
+	MaxClusterSize   int
+	RetryTimes       int
 	HeartbeatTimeout time.Duration
 	ElectionTimeout  time.Duration
 }
@@ -81,7 +81,7 @@ func NewPeerServer(name string, path string, url string, bindAddr string, tlsCon
 			},
 		},
 		HeartbeatTimeout: defaultHeartbeatTimeout,
-		ElectionTimeout: defaultElectionTimeout,
+		ElectionTimeout:  defaultElectionTimeout,
 	}
 
 	// Create transporter for raft

+ 2 - 2
tests/server_utils.go

@@ -26,11 +26,11 @@ func RunServer(f func(*server.Server)) {
 	store := store.New()
 	registry := server.NewRegistry(store)
 
-	ps := server.NewPeerServer(testName, path, "http://" + testRaftURL, testRaftURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, registry, store, testSnapshotCount)
+	ps := server.NewPeerServer(testName, path, "http://"+testRaftURL, testRaftURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, registry, store, testSnapshotCount)
 	ps.MaxClusterSize = 9
 	ps.ElectionTimeout = testElectionTimeout
 	ps.HeartbeatTimeout = testHeartbeatTimeout
-	s := server.New(testName, "http://" + testClientURL, testClientURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, ps, registry, store)
+	s := server.New(testName, "http://"+testClientURL, testClientURL, &server.TLSConfig{Scheme: "http"}, &server.TLSInfo{}, ps, registry, store)
 	ps.SetServer(s)
 
 	// Start up peer server.