gofmt
This commit is contained in:
parent
a3173bfd31
commit
5271da3d19
@ -259,12 +259,12 @@ func WatchHttpHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert string duration to time format
|
// Convert string duration to time format
|
||||||
func durationToExpireTime(strDuration string) (time.Time, error){
|
func durationToExpireTime(strDuration string) (time.Time, error) {
|
||||||
if strDuration != "" {
|
if strDuration != "" {
|
||||||
duration, err := strconv.Atoi(strDuration)
|
duration, err := strconv.Atoi(strDuration)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Unix(0, 0),err
|
return time.Unix(0, 0), err
|
||||||
}
|
}
|
||||||
return time.Now().Add(time.Second * (time.Duration)(duration)), nil
|
return time.Now().Add(time.Second * (time.Duration)(duration)), nil
|
||||||
} else {
|
} else {
|
||||||
|
9
etcd.go
9
etcd.go
@ -147,7 +147,6 @@ func main() {
|
|||||||
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
|
fatal("Please specify cert and key file or cert and key file and CAFile or none of the three")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create transporter for raft
|
// Create transporter for raft
|
||||||
raftTransporter = createTransporter(st)
|
raftTransporter = createTransporter(st)
|
||||||
|
|
||||||
@ -306,10 +305,10 @@ func startRaftTransport(port int, st int) {
|
|||||||
// Start to listen and response client command
|
// Start to listen and response client command
|
||||||
func startClientTransport(port int, st int) {
|
func startClientTransport(port int, st int) {
|
||||||
// external commands
|
// external commands
|
||||||
http.HandleFunc("/" + version + "/keys/", Multiplexer)
|
http.HandleFunc("/"+version+"/keys/", Multiplexer)
|
||||||
http.HandleFunc("/" + version + "/watch/", WatchHttpHandler)
|
http.HandleFunc("/"+version+"/watch/", WatchHttpHandler)
|
||||||
http.HandleFunc("/" + version + "/list/", ListHttpHandler)
|
http.HandleFunc("/"+version+"/list/", ListHttpHandler)
|
||||||
http.HandleFunc("/" + version + "/testAndSet/", TestAndSetHttpHandler)
|
http.HandleFunc("/"+version+"/testAndSet/", TestAndSetHttpHandler)
|
||||||
http.HandleFunc("/leader", LeaderHttpHandler)
|
http.HandleFunc("/leader", LeaderHttpHandler)
|
||||||
|
|
||||||
switch st {
|
switch st {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/coreos/go-raft"
|
"github.com/coreos/go-raft"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
@ -19,7 +19,6 @@ func GetLogHttpHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
json.NewEncoder(w).Encode(raftServer.LogEntries())
|
json.NewEncoder(w).Encode(raftServer.LogEntries())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Response to vote request
|
// Response to vote request
|
||||||
func VoteHttpHandler(w http.ResponseWriter, req *http.Request) {
|
func VoteHttpHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
rvreq := &raft.RequestVoteRequest{}
|
rvreq := &raft.RequestVoteRequest{}
|
||||||
|
Loading…
Reference in New Issue
Block a user