mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
gofmt
This commit is contained in:
parent
434b0045db
commit
d3649d3254
4
etcd.go
4
etcd.go
@ -364,7 +364,7 @@ func newTransporter(scheme string, tlsConf tls.Config) transporter {
|
|||||||
t.scheme = scheme
|
t.scheme = scheme
|
||||||
|
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
Dial: dialTimeout,
|
Dial: dialTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
if scheme == "https" {
|
if scheme == "https" {
|
||||||
@ -594,7 +594,7 @@ func joinCluster(s *raft.Server, raftURL string) error {
|
|||||||
joinURL := url.URL{Host: raftURL, Scheme: raftTransporter.scheme, Path: "/join"}
|
joinURL := url.URL{Host: raftURL, Scheme: raftTransporter.scheme, Path: "/join"}
|
||||||
|
|
||||||
debugf("Send Join Request to %s", raftURL)
|
debugf("Send Join Request to %s", raftURL)
|
||||||
|
|
||||||
resp, err := t.Post(joinURL.String(), &b)
|
resp, err := t.Post(joinURL.String(), &b)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -109,7 +109,7 @@ func DeleteHttpHandler(w *http.ResponseWriter, req *http.Request) {
|
|||||||
func dispatch(c Command, w *http.ResponseWriter, req *http.Request, etcd bool) {
|
func dispatch(c Command, w *http.ResponseWriter, req *http.Request, etcd bool) {
|
||||||
if raftServer.State() == "leader" {
|
if raftServer.State() == "leader" {
|
||||||
if body, err := raftServer.Do(c); err != nil {
|
if body, err := raftServer.Do(c); err != nil {
|
||||||
|
|
||||||
if _, ok := err.(store.NotFoundError); ok {
|
if _, ok := err.(store.NotFoundError); ok {
|
||||||
(*w).WriteHeader(http.StatusNotFound)
|
(*w).WriteHeader(http.StatusNotFound)
|
||||||
(*w).Write(newJsonError(100, err.Error()))
|
(*w).Write(newJsonError(100, err.Error()))
|
||||||
|
14
snapshot.go
14
snapshot.go
@ -1,25 +1,25 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type snapshotConf struct {
|
type snapshotConf struct {
|
||||||
// basic
|
// basic
|
||||||
checkingInterval time.Duration
|
checkingInterval time.Duration
|
||||||
lastWrites uint64
|
lastWrites uint64
|
||||||
writesThr uint64
|
writesThr uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
var snapConf *snapshotConf
|
var snapConf *snapshotConf
|
||||||
|
|
||||||
func newSnapshotConf() *snapshotConf {
|
func newSnapshotConf() *snapshotConf {
|
||||||
return &snapshotConf {time.Second*3, etcdStore.TotalWrites(), 20*1000}
|
return &snapshotConf{time.Second * 3, etcdStore.TotalWrites(), 20 * 1000}
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorSnapshot() {
|
func monitorSnapshot() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(snapConf.checkingInterval)
|
time.Sleep(snapConf.checkingInterval)
|
||||||
currentWrites := etcdStore.TotalWrites() - snapConf.lastWrites
|
currentWrites := etcdStore.TotalWrites() - snapConf.lastWrites
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ func monitorSnapshot() {
|
|||||||
fmt.Println(currentWrites)
|
fmt.Println(currentWrites)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,4 @@ func (s *Store) TotalWrites() uint64 {
|
|||||||
bs := s.BasicStats
|
bs := s.BasicStats
|
||||||
|
|
||||||
return bs.Deletes + bs.Sets + bs.TestAndSets
|
return bs.Deletes + bs.Sets + bs.TestAndSets
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user