diff --git a/etcd.go b/etcd.go index dc373fff3..7ca271473 100644 --- a/etcd.go +++ b/etcd.go @@ -118,18 +118,18 @@ func main() { // Calculate all of our timeouts heartbeatTimeout := time.Duration(config.Peer.HeartbeatTimeout) * time.Millisecond - electionTimeout := time.Duration(config.Peer.ElectionTimeout) * time.Millisecond + electionTimeout := time.Duration(config.Peer.ElectionTimeout) * time.Millisecond dialTimeout := (3 * heartbeatTimeout) + electionTimeout responseHeaderTimeout := (3 * heartbeatTimeout) + electionTimeout // Create peer server. psConfig := server.PeerServerConfig{ - Name: info.Name, - Scheme: peerTLSConfig.Scheme, - URL: info.RaftURL, - SnapshotCount: config.SnapshotCount, - MaxClusterSize: config.MaxClusterSize, - RetryTimes: config.MaxRetryAttempts, + Name: info.Name, + Scheme: peerTLSConfig.Scheme, + URL: info.RaftURL, + SnapshotCount: config.SnapshotCount, + MaxClusterSize: config.MaxClusterSize, + RetryTimes: config.MaxRetryAttempts, } ps := server.NewPeerServer(psConfig, registry, store, &mb, followersStats, serverStats) diff --git a/metrics/standard.go b/metrics/standard.go index c77ef1218..42277dda5 100644 --- a/metrics/standard.go +++ b/metrics/standard.go @@ -19,7 +19,6 @@ const ( GraphitePublishInterval = time.Duration(2) * time.Second ) - type standardBucket struct { sync.Mutex name string diff --git a/mod/dashboard/resources/bindata-file.go b/mod/dashboard/resources/bindata-file.go index 82dd5aaa9..ea8770af5 100644 --- a/mod/dashboard/resources/bindata-file.go +++ b/mod/dashboard/resources/bindata-file.go @@ -1,11 +1,11 @@ package resources func File(name string) ([]byte, bool) { - data, ok := go_bindata[name] + data, ok := go_bindata[name] - if ok == false { - return nil, false - } + if ok == false { + return nil, false + } - return data(), true + return data(), true } diff --git a/mod/dashboard/resources/bindata-toc.go b/mod/dashboard/resources/bindata-toc.go index 261416f47..c2018cea9 100644 --- a/mod/dashboard/resources/bindata-toc.go +++ b/mod/dashboard/resources/bindata-toc.go @@ -4,4 +4,4 @@ package resources // After startup of the program, all generated data files will // put themselves in this map. The key is the full filename, as // supplied to go-bindata. -var go_bindata = make(map[string]func() []byte) \ No newline at end of file +var go_bindata = make(map[string]func() []byte) diff --git a/mod/dashboard/resources/browser.html.go b/mod/dashboard/resources/browser.html.go index 3e0c851eb..698e8fedc 100644 --- a/mod/dashboard/resources/browser.html.go +++ b/mod/dashboard/resources/browser.html.go @@ -33,7 +33,6 @@ func browser_html() []byte { return buf.Bytes() } - func init() { go_bindata["/browser.html"] = browser_html } diff --git a/mod/dashboard/resources/index.html.go b/mod/dashboard/resources/index.html.go index 4118b77e3..7d109f8d1 100644 --- a/mod/dashboard/resources/index.html.go +++ b/mod/dashboard/resources/index.html.go @@ -33,7 +33,6 @@ func index_html() []byte { return buf.Bytes() } - func init() { go_bindata["/index.html"] = index_html } diff --git a/mod/dashboard/resources/scripts-browser-modules.js.go b/mod/dashboard/resources/scripts-browser-modules.js.go index 53deaff8e..7315083d4 100644 --- a/mod/dashboard/resources/scripts-browser-modules.js.go +++ b/mod/dashboard/resources/scripts-browser-modules.js.go @@ -33,7 +33,6 @@ func scripts_browser_modules_js() []byte { return buf.Bytes() } - func init() { go_bindata["/scripts/browser-modules.js"] = scripts_browser_modules_js } diff --git a/mod/dashboard/resources/scripts-browser-scripts.js.go b/mod/dashboard/resources/scripts-browser-scripts.js.go index 44aa42e6d..9fcf3a370 100644 --- a/mod/dashboard/resources/scripts-browser-scripts.js.go +++ b/mod/dashboard/resources/scripts-browser-scripts.js.go @@ -33,7 +33,6 @@ func scripts_browser_scripts_js() []byte { return buf.Bytes() } - func init() { go_bindata["/scripts/browser-scripts.js"] = scripts_browser_scripts_js } diff --git a/mod/dashboard/resources/scripts-stats-modules.js.go b/mod/dashboard/resources/scripts-stats-modules.js.go index 795bb34db..af3c7b5e2 100644 --- a/mod/dashboard/resources/scripts-stats-modules.js.go +++ b/mod/dashboard/resources/scripts-stats-modules.js.go @@ -33,7 +33,6 @@ func scripts_stats_modules_js() []byte { return buf.Bytes() } - func init() { go_bindata["/scripts/stats-modules.js"] = scripts_stats_modules_js } diff --git a/mod/dashboard/resources/scripts-stats-scripts.js.go b/mod/dashboard/resources/scripts-stats-scripts.js.go index e4ed02d7a..59aa3480a 100644 --- a/mod/dashboard/resources/scripts-stats-scripts.js.go +++ b/mod/dashboard/resources/scripts-stats-scripts.js.go @@ -33,7 +33,6 @@ func scripts_stats_scripts_js() []byte { return buf.Bytes() } - func init() { go_bindata["/scripts/stats-scripts.js"] = scripts_stats_scripts_js } diff --git a/mod/dashboard/resources/stats.html.go b/mod/dashboard/resources/stats.html.go index 517d79511..bd795d759 100644 --- a/mod/dashboard/resources/stats.html.go +++ b/mod/dashboard/resources/stats.html.go @@ -33,7 +33,6 @@ func stats_html() []byte { return buf.Bytes() } - func init() { go_bindata["/stats.html"] = stats_html } diff --git a/mod/dashboard/resources/styles-main.css.go b/mod/dashboard/resources/styles-main.css.go index cac162938..564fa64b4 100644 --- a/mod/dashboard/resources/styles-main.css.go +++ b/mod/dashboard/resources/styles-main.css.go @@ -33,7 +33,6 @@ func styles_main_css() []byte { return buf.Bytes() } - func init() { go_bindata["/styles/main.css"] = styles_main_css } diff --git a/mod/dashboard/resources/views-browser.html.go b/mod/dashboard/resources/views-browser.html.go index e8f7c2c40..ccbfdf2e0 100644 --- a/mod/dashboard/resources/views-browser.html.go +++ b/mod/dashboard/resources/views-browser.html.go @@ -33,7 +33,6 @@ func views_browser_html() []byte { return buf.Bytes() } - func init() { go_bindata["/views/browser.html"] = views_browser_html } diff --git a/mod/dashboard/resources/views-stats.html.go b/mod/dashboard/resources/views-stats.html.go index f9eaa8bc0..53b79ec0a 100644 --- a/mod/dashboard/resources/views-stats.html.go +++ b/mod/dashboard/resources/views-stats.html.go @@ -33,7 +33,6 @@ func views_stats_html() []byte { return buf.Bytes() } - func init() { go_bindata["/views/stats.html"] = views_stats_html } diff --git a/mod/leader/v2/delete_handler.go b/mod/leader/v2/delete_handler.go index 278ae34b2..eb192e268 100644 --- a/mod/leader/v2/delete_handler.go +++ b/mod/leader/v2/delete_handler.go @@ -6,8 +6,8 @@ import ( "net/http" "net/url" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // deleteHandler remove a given leader. diff --git a/mod/leader/v2/handler.go b/mod/leader/v2/handler.go index 665692b27..192d42477 100644 --- a/mod/leader/v2/handler.go +++ b/mod/leader/v2/handler.go @@ -3,8 +3,8 @@ package v2 import ( "net/http" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // prefix is appended to the lock's prefix since the leader mod uses the lock mod. @@ -13,19 +13,19 @@ const prefix = "/_mod/leader" // handler manages the leader HTTP request. type handler struct { *mux.Router - client *http.Client + client *http.Client transport *http.Transport - addr string + addr string } // NewHandler creates an HTTP handler that can be registered on a router. -func NewHandler(addr string) (http.Handler) { +func NewHandler(addr string) http.Handler { transport := &http.Transport{DisableKeepAlives: false} h := &handler{ - Router: mux.NewRouter(), - client: &http.Client{Transport: transport}, + Router: mux.NewRouter(), + client: &http.Client{Transport: transport}, transport: transport, - addr: addr, + addr: addr, } h.StrictSlash(false) h.handleFunc("/{key:.*}", h.getHandler).Methods("GET") diff --git a/mod/leader/v2/set_handler.go b/mod/leader/v2/set_handler.go index dd2e29702..c66b07970 100644 --- a/mod/leader/v2/set_handler.go +++ b/mod/leader/v2/set_handler.go @@ -6,8 +6,8 @@ import ( "net/http" "net/url" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // setHandler attempts to set the current leader. diff --git a/mod/leader/v2/tests/mod_leader_test.go b/mod/leader/v2/tests/mod_leader_test.go index 238805ce3..2e941ffce 100644 --- a/mod/leader/v2/tests/mod_leader_test.go +++ b/mod/leader/v2/tests/mod_leader_test.go @@ -66,8 +66,6 @@ func TestModLeaderRenew(t *testing.T) { }) } - - func testSetLeader(s *server.Server, key string, name string, ttl int) (string, int, error) { resp, err := tests.PutForm(fmt.Sprintf("%s/mod/v2/leader/%s?name=%s&ttl=%d", s.URL(), key, name, ttl), nil) ret := tests.ReadBody(resp) diff --git a/mod/lock/v2/acquire_handler.go b/mod/lock/v2/acquire_handler.go index 1fd6aeadf..ced295472 100644 --- a/mod/lock/v2/acquire_handler.go +++ b/mod/lock/v2/acquire_handler.go @@ -8,9 +8,9 @@ import ( "strconv" "time" - "github.com/gorilla/mux" - "github.com/coreos/go-etcd/etcd" etcdErr "github.com/coreos/etcd/error" + "github.com/coreos/go-etcd/etcd" + "github.com/gorilla/mux" ) // acquireHandler attempts to acquire a lock on the given key. @@ -75,7 +75,7 @@ func (h *handler) acquireHandler(w http.ResponseWriter, req *http.Request) error } // createNode creates a new lock node and watches it until it is acquired or acquisition fails. -func (h *handler) createNode(keypath string, value string, ttl int, closeChan <- chan bool, stopChan chan bool) (int, error) { +func (h *handler) createNode(keypath string, value string, ttl int, closeChan <-chan bool, stopChan chan bool) (int, error) { // Default the value to "-" if it is blank. if len(value) == 0 { value = "-" @@ -133,7 +133,7 @@ func (h *handler) findExistingNode(keypath string, value string) (*etcd.Node, in func (h *handler) ttlKeepAlive(k string, value string, ttl int, stopChan chan bool) { for { select { - case <-time.After(time.Duration(ttl / 2) * time.Second): + case <-time.After(time.Duration(ttl/2) * time.Second): h.client.Update(k, value, uint64(ttl)) case <-stopChan: return @@ -143,14 +143,14 @@ func (h *handler) ttlKeepAlive(k string, value string, ttl int, stopChan chan bo // watch continuously waits for a given lock index to be acquired or until lock fails. // Returns a boolean indicating success. -func (h *handler) watch(keypath string, index int, closeChan <- chan bool) error { +func (h *handler) watch(keypath string, index int, closeChan <-chan bool) error { // Wrap close chan so we can pass it to Client.Watch(). stopWatchChan := make(chan bool) go func() { select { - case <- closeChan: + case <-closeChan: stopWatchChan <- true - case <- stopWatchChan: + case <-stopWatchChan: } }() defer close(stopWatchChan) diff --git a/mod/lock/v2/get_index_handler.go b/mod/lock/v2/get_index_handler.go index a9fd4c551..ac8bdf255 100644 --- a/mod/lock/v2/get_index_handler.go +++ b/mod/lock/v2/get_index_handler.go @@ -4,8 +4,8 @@ import ( "net/http" "path" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // getIndexHandler retrieves the current lock index. diff --git a/mod/lock/v2/handler.go b/mod/lock/v2/handler.go index 10f838635..7d17acb63 100644 --- a/mod/lock/v2/handler.go +++ b/mod/lock/v2/handler.go @@ -3,9 +3,9 @@ package v2 import ( "net/http" - "github.com/gorilla/mux" - "github.com/coreos/go-etcd/etcd" etcdErr "github.com/coreos/etcd/error" + "github.com/coreos/go-etcd/etcd" + "github.com/gorilla/mux" ) const prefix = "/_etcd/mod/lock" @@ -17,7 +17,7 @@ type handler struct { } // NewHandler creates an HTTP handler that can be registered on a router. -func NewHandler(addr string) (http.Handler) { +func NewHandler(addr string) http.Handler { h := &handler{ Router: mux.NewRouter(), client: etcd.NewClient([]string{addr}), diff --git a/mod/lock/v2/release_handler.go b/mod/lock/v2/release_handler.go index 5a648c3f3..1e68134a6 100644 --- a/mod/lock/v2/release_handler.go +++ b/mod/lock/v2/release_handler.go @@ -1,11 +1,11 @@ package v2 import ( - "path" "net/http" + "path" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // releaseLockHandler deletes the lock. @@ -45,4 +45,3 @@ func (h *handler) releaseLockHandler(w http.ResponseWriter, req *http.Request) e return nil } - diff --git a/mod/lock/v2/renew_handler.go b/mod/lock/v2/renew_handler.go index c44ed51c5..64a0eaee4 100644 --- a/mod/lock/v2/renew_handler.go +++ b/mod/lock/v2/renew_handler.go @@ -1,12 +1,12 @@ package v2 import ( - "path" "net/http" + "path" "strconv" - "github.com/gorilla/mux" etcdErr "github.com/coreos/etcd/error" + "github.com/gorilla/mux" ) // renewLockHandler attempts to update the TTL on an existing lock. diff --git a/mod/lock/v2/tests/mod_lock_test.go b/mod/lock/v2/tests/mod_lock_test.go index dd47a040d..9bd79247e 100644 --- a/mod/lock/v2/tests/mod_lock_test.go +++ b/mod/lock/v2/tests/mod_lock_test.go @@ -52,7 +52,7 @@ func TestModLockBlockUntilAcquire(t *testing.T) { assert.Equal(t, body, "2") c <- true }() - <- c + <-c // Acquire lock #2. waiting := true @@ -64,7 +64,7 @@ func TestModLockBlockUntilAcquire(t *testing.T) { assert.Equal(t, body, "4") waiting = false }() - <- c + <-c time.Sleep(1 * time.Second) @@ -114,7 +114,7 @@ func TestModLockExpireAndRelease(t *testing.T) { assert.Equal(t, body, "2") c <- true }() - <- c + <-c // Acquire lock #2. go func() { @@ -124,7 +124,7 @@ func TestModLockExpireAndRelease(t *testing.T) { assert.Equal(t, status, 200) assert.Equal(t, body, "4") }() - <- c + <-c time.Sleep(1 * time.Second) @@ -215,8 +215,6 @@ func TestModLockAcquireAndReleaseByValue(t *testing.T) { }) } - - func testAcquireLock(s *server.Server, key string, value string, ttl int) (string, int, error) { resp, err := tests.PostForm(fmt.Sprintf("%s/mod/v2/lock/%s?value=%s&ttl=%d", s.URL(), key, value, ttl), nil) ret := tests.ReadBody(resp) diff --git a/mod/mod.go b/mod/mod.go index 14fe61c98..6aa3129c8 100644 --- a/mod/mod.go +++ b/mod/mod.go @@ -6,15 +6,15 @@ import ( "path" "github.com/coreos/etcd/mod/dashboard" - lock2 "github.com/coreos/etcd/mod/lock/v2" leader2 "github.com/coreos/etcd/mod/leader/v2" + lock2 "github.com/coreos/etcd/mod/lock/v2" "github.com/gorilla/mux" ) var ServeMux *http.Handler func addSlash(w http.ResponseWriter, req *http.Request) { - http.Redirect(w, req, path.Join("mod", req.URL.Path) + "/", 302) + http.Redirect(w, req, path.Join("mod", req.URL.Path)+"/", 302) return } diff --git a/server/peer_server.go b/server/peer_server.go index 4fc880334..84b4db482 100644 --- a/server/peer_server.go +++ b/server/peer_server.go @@ -25,12 +25,12 @@ const retryInterval = 10 const ThresholdMonitorTimeout = 5 * time.Second type PeerServerConfig struct { - Name string - Scheme string - URL string - SnapshotCount int - MaxClusterSize int - RetryTimes int + Name string + Scheme string + URL string + SnapshotCount int + MaxClusterSize int + RetryTimes int } type PeerServer struct { @@ -65,11 +65,11 @@ type snapshotConf struct { func NewPeerServer(psConfig PeerServerConfig, registry *Registry, store store.Store, mb *metrics.Bucket, followersStats *raftFollowersStats, serverStats *raftServerStats) *PeerServer { s := &PeerServer{ - Config: psConfig, - registry: registry, - store: store, + Config: psConfig, + registry: registry, + store: store, followersStats: followersStats, - serverStats: serverStats, + serverStats: serverStats, timeoutThresholdChan: make(chan interface{}, 1), diff --git a/server/release_version.go b/server/release_version.go index 6bdafaca3..ae4653908 100644 --- a/server/release_version.go +++ b/server/release_version.go @@ -1,2 +1,3 @@ package server + const ReleaseVersion = "v0.2.1-pre" diff --git a/server/server.go b/server/server.go index 6a55ca2f2..e408ec33a 100644 --- a/server/server.go +++ b/server/server.go @@ -29,9 +29,9 @@ type Server struct { peerServer *PeerServer registry *Registry store store.Store - metrics *metrics.Bucket + metrics *metrics.Bucket - trace bool + trace bool } // Creates a new Server. @@ -42,7 +42,7 @@ func New(name, url string, peerServer *PeerServer, registry *Registry, store sto store: store, registry: registry, peerServer: peerServer, - metrics: mb, + metrics: mb, } return s diff --git a/server/v2/tests/post_handler_test.go b/server/v2/tests/post_handler_test.go index 92acfc90a..8681ec3fe 100644 --- a/server/v2/tests/post_handler_test.go +++ b/server/v2/tests/post_handler_test.go @@ -2,8 +2,8 @@ package v2 import ( "fmt" - "testing" "net/http" + "testing" "github.com/coreos/etcd/server" "github.com/coreos/etcd/tests" diff --git a/tests/functional/kill_random_test.go b/tests/functional/kill_random_test.go index d5f8efc0a..f8af96e23 100644 --- a/tests/functional/kill_random_test.go +++ b/tests/functional/kill_random_test.go @@ -51,7 +51,7 @@ func TestKillRandom(t *testing.T) { } - for num, _ := range toKill { + for num := range toKill { err := etcds[num].Kill() if err != nil { panic(err) @@ -63,7 +63,7 @@ func TestKillRandom(t *testing.T) { <-leaderChan - for num, _ := range toKill { + for num := range toKill { etcds[num], err = os.StartProcess(EtcdBinPath, argGroup[num], procAttr) } diff --git a/tests/functional/util.go b/tests/functional/util.go index 9ceff0e70..d59544d7f 100644 --- a/tests/functional/util.go +++ b/tests/functional/util.go @@ -100,7 +100,7 @@ func CreateCluster(size int, procAttr *os.ProcAttr, ssl bool) ([][]string, []*os etcds := make([]*os.Process, size) - for i, _ := range etcds { + for i := range etcds { var err error etcds[i], err = os.StartProcess(EtcdBinPath, append(argGroup[i], "-f"), procAttr) if err != nil { diff --git a/tests/server_utils.go b/tests/server_utils.go index f3dc05af6..a59c517fc 100644 --- a/tests/server_utils.go +++ b/tests/server_utils.go @@ -33,10 +33,10 @@ func RunServer(f func(*server.Server)) { followersStats := server.NewRaftFollowersStats(testName) psConfig := server.PeerServerConfig{ - Name: testName, - URL: "http://"+testRaftURL, - Scheme: "http", - SnapshotCount: testSnapshotCount, + Name: testName, + URL: "http://" + testRaftURL, + Scheme: "http", + SnapshotCount: testSnapshotCount, MaxClusterSize: 9, } ps := server.NewPeerServer(psConfig, registry, store, nil, followersStats, serverStats) @@ -48,7 +48,7 @@ func RunServer(f func(*server.Server)) { // Create Raft transporter and server dialTimeout := (3 * testHeartbeatTimeout) + testElectionTimeout responseHeaderTimeout := (3 * testHeartbeatTimeout) + testElectionTimeout - raftTransporter := server.NewTransporter(followersStats, serverStats, registry, testHeartbeatTimeout, dialTimeout, responseHeaderTimeout) + raftTransporter := server.NewTransporter(followersStats, serverStats, registry, testHeartbeatTimeout, dialTimeout, responseHeaderTimeout) raftServer, err := raft.NewServer(testName, path, raftTransporter, store, ps, "") if err != nil { panic(err) diff --git a/third_party.go b/third_party.go index 6c4bc9971..66d7b783b 100644 --- a/third_party.go +++ b/third_party.go @@ -292,8 +292,7 @@ func bump(pkg, version string) { // validPkg uses go list to decide if the given path is a valid go package. // This is used by the bumpAll walk to bump all of the existing packages. func validPkg(pkg string) bool { - env := append(os.Environ(), - ) + env := append(os.Environ()) cmd := exec.Command("go", "list", pkg) cmd.Env = env