提交 8e6db691 编写于 作者: S Shengliang Guan

[None-Jira]response ealier to improve writing speed

上级 b78e160d
...@@ -184,6 +184,7 @@ func main() { ...@@ -184,6 +184,7 @@ func main() {
} }
http.HandleFunc("/receive", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/receive", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
addr := strings.Split(r.RemoteAddr, ":") addr := strings.Split(r.RemoteAddr, ":")
idx := TAOShashID([]byte(addr[0])) idx := TAOShashID([]byte(addr[0]))
...@@ -192,7 +193,7 @@ func main() { ...@@ -192,7 +193,7 @@ func main() {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
r.Body.Close()
reqBuf, err := snappy.Decode(nil, compressed) reqBuf, err := snappy.Decode(nil, compressed)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
...@@ -205,7 +206,7 @@ func main() { ...@@ -205,7 +206,7 @@ func main() {
return return
} }
nodeChans[idx%httpworkers] <- req nodeChans[idx%httpworkers] <- req
w.WriteHeader(http.StatusAccepted)
}) })
http.HandleFunc("/check", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/check", func(w http.ResponseWriter, r *http.Request) {
......
...@@ -149,6 +149,7 @@ func main() { ...@@ -149,6 +149,7 @@ func main() {
} }
http.HandleFunc("/telegraf", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/telegraf", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusAccepted)
addr := strings.Split(r.RemoteAddr, ":") addr := strings.Split(r.RemoteAddr, ":")
idx := TAOShashID([]byte(addr[0])) idx := TAOShashID([]byte(addr[0]))
...@@ -157,7 +158,7 @@ func main() { ...@@ -157,7 +158,7 @@ func main() {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
r.Body.Close()
var req Metrics var req Metrics
if err := json.Unmarshal(reqBuf, &req); err != nil { if err := json.Unmarshal(reqBuf, &req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
...@@ -166,7 +167,7 @@ func main() { ...@@ -166,7 +167,7 @@ func main() {
req.HostIP = addr[0] req.HostIP = addr[0]
nodeChans[idx%httpworkers] <- req nodeChans[idx%httpworkers] <- req
w.WriteHeader(http.StatusAccepted) //w.WriteHeader(http.StatusAccepted)
}) })
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册