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
9efba81c09
commit
fad972304c
4
etcd.go
4
etcd.go
@ -176,7 +176,7 @@ func main() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
debug("%s bad snapshot", raftServer.Name())
|
debug("%s bad snapshot", raftServer.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
raftServer.Initialize()
|
raftServer.Initialize()
|
||||||
debug("%s finished init", raftServer.Name())
|
debug("%s finished init", raftServer.Name())
|
||||||
raftServer.SetElectionTimeout(ELECTIONTIMTOUT)
|
raftServer.SetElectionTimeout(ELECTIONTIMTOUT)
|
||||||
@ -234,8 +234,6 @@ func main() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func createTransporter(st int) transporter {
|
func createTransporter(st int) transporter {
|
||||||
t := transporter{}
|
t := transporter{}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func VoteHttpHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
func AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request) {
|
func AppendEntriesHttpHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
aereq := &raft.AppendEntriesRequest{}
|
aereq := &raft.AppendEntriesRequest{}
|
||||||
err := decodeJsonRequest(req, aereq)
|
err := decodeJsonRequest(req, aereq)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
debug("[recv] POST http://%s/log/append [%d]", raftServer.Name(), len(aereq.Entries))
|
debug("[recv] POST http://%s/log/append [%d]", raftServer.Name(), len(aereq.Entries))
|
||||||
if resp := raftServer.AppendEntries(aereq); resp != nil {
|
if resp := raftServer.AppendEntries(aereq); resp != nil {
|
||||||
@ -77,7 +77,7 @@ func clientHttpHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
w.Write([]byte(client))
|
w.Write([]byte(client))
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
func JoinHttpHandler(w http.ResponseWriter, req *http.Request) {
|
func JoinHttpHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
command := &JoinCommand{}
|
command := &JoinCommand{}
|
||||||
|
@ -4,15 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"github.com/coreos/go-raft"
|
"github.com/coreos/go-raft"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Transporter layer for communication between raft nodes
|
// Transporter layer for communication between raft nodes
|
||||||
type transporter struct {
|
type transporter struct {
|
||||||
name string
|
name string
|
||||||
// If https is used for server internal communcation,
|
// If https is used for server internal communcation,
|
||||||
// we will have a http client. Or it will be nil.
|
// we will have a http client. Or it will be nil.
|
||||||
client *http.Client
|
client *http.Client
|
||||||
@ -84,7 +84,7 @@ func (t transporter) SendSnapshotRequest(server *raft.Server, peer *raft.Peer, r
|
|||||||
|
|
||||||
// Get the the client address of the leader in the cluster
|
// Get the the client address of the leader in the cluster
|
||||||
func (t transporter) GetLeaderClientAddress() string {
|
func (t transporter) GetLeaderClientAddress() string {
|
||||||
resp, _ := t.Get(raftServer.Leader()+"/client")
|
resp, _ := t.Get(raftServer.Leader() + "/client")
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
@ -105,7 +105,6 @@ func (t transporter) Post(path string, body io.Reader) (*http.Response, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send server side GET request
|
// Send server side GET request
|
||||||
func (t transporter) Get(path string) (*http.Response, error) {
|
func (t transporter) Get(path string) (*http.Response, error) {
|
||||||
if t.client != nil {
|
if t.client != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user