提交 985133f1 编写于 作者: Y yangrui07

cube agent code format

上级 3da70904
...@@ -100,7 +100,7 @@ func handleRest(w http.ResponseWriter, r *http.Request) { ...@@ -100,7 +100,7 @@ func handleRest(w http.ResponseWriter, r *http.Request) {
if isJsonDict(s) { if isJsonDict(s) {
fmt.Fprintln(w, s) fmt.Fprintln(w, s)
}else { } else {
logex.Fatalf("invalid json: %v", s) logex.Fatalf("invalid json: %v", s)
} }
...@@ -128,7 +128,7 @@ func parseHttpKv(r *http.Request) map[string]string { ...@@ -128,7 +128,7 @@ func parseHttpKv(r *http.Request) map[string]string {
} }
// allow passing hostname for debug // allow passing hostname for debug
if _, ok := m["hostname"]; !ok{ if _, ok := m["hostname"]; !ok {
ip := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")] ip := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
m["hostname"], _ = getHostname(ip) m["hostname"], _ = getHostname(ip)
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
package agent package agent
import ( import (
"fmt"
"encoding/json" "encoding/json"
"fmt"
) )
func initGetHandlers() { func initGetHandlers() {
...@@ -13,7 +13,7 @@ func initGetHandlers() { ...@@ -13,7 +13,7 @@ func initGetHandlers() {
} }
func GetStatus(subpath string, m map[string]string, b []byte) (string, string, error) { func GetStatus(subpath string, m map[string]string, b []byte) (string, string, error) {
b, err := json.Marshal(BUILTIN_STATUS); b, err := json.Marshal(BUILTIN_STATUS)
if err != nil { if err != nil {
return quote(""), "", fmt.Errorf("json marshal failed, %v", err) return quote(""), "", fmt.Errorf("json marshal failed, %v", err)
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
package agent package agent
import ( import (
"fmt"
"encoding/json" "encoding/json"
"fmt"
"github.com/Badangel/logex" "github.com/Badangel/logex"
) )
......
...@@ -417,7 +417,7 @@ func (work *Work) CheckToReload() bool { ...@@ -417,7 +417,7 @@ func (work *Work) CheckToReload() bool {
} }
func (work *Work) Reload() (err error) { func (work *Work) Reload() (err error) {
if (work.Port == "") { if work.Port == "" {
err = errors.New("Reload with invalid port.") err = errors.New("Reload with invalid port.")
return return
} }
...@@ -632,7 +632,7 @@ func (work *Work) Pop() (err error) { ...@@ -632,7 +632,7 @@ func (work *Work) Pop() (err error) {
func writeStateFile(dictName string, shardSeq int, service, state string) { func writeStateFile(dictName string, shardSeq int, service, state string) {
stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq) stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq)
if service != "" { if service != "" {
stateFile = stateFile + "_" + service; stateFile = stateFile + "_" + service
} }
cmd := fmt.Sprintf("echo '%s' > %s/state/%s", state, Dir, stateFile) cmd := fmt.Sprintf("echo '%s' > %s/state/%s", state, Dir, stateFile)
...@@ -644,7 +644,7 @@ func writeStateFile(dictName string, shardSeq int, service, state string) { ...@@ -644,7 +644,7 @@ func writeStateFile(dictName string, shardSeq int, service, state string) {
func RemoveStateFile(dictName string, shardSeq int, service string) { func RemoveStateFile(dictName string, shardSeq int, service string) {
stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq) stateFile := fmt.Sprintf(".state_%s_%d", dictName, shardSeq)
if service != "" { if service != "" {
stateFile = stateFile + "_" + service; stateFile = stateFile + "_" + service
} }
cmd := fmt.Sprintf("rm -f %s/state/%s", Dir, stateFile) cmd := fmt.Sprintf("rm -f %s/state/%s", Dir, stateFile)
......
...@@ -3,8 +3,8 @@ package agent ...@@ -3,8 +3,8 @@ package agent
import ( import (
"errors" "errors"
"fmt" "fmt"
"sync/atomic"
"sync" "sync"
"sync/atomic"
) )
type ( type (
......
...@@ -3,8 +3,8 @@ package main ...@@ -3,8 +3,8 @@ package main
import ( import (
"agent" "agent"
"fmt" "fmt"
"github.com/docopt/docopt-go"
"github.com/Badangel/logex" "github.com/Badangel/logex"
"github.com/docopt/docopt-go"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册