Added logging for remote storage adapter (#3106)

* Added logging for remote storage adapter on startup and on any error condition during /read or /write.

* CR feedback.
This commit is contained in:
gdmello 2017-08-29 09:22:56 -04:00 committed by Julius Volz
parent 1bf25dc1b2
commit 35c952e344
1 changed files with 7 additions and 0 deletions

View File

@ -179,6 +179,7 @@ func buildClients(cfg *config) ([]writer, []reader) {
writers = append(writers, c)
readers = append(readers, c)
}
log.Info("Starting up... ")
return writers, readers
}
@ -186,18 +187,21 @@ func serve(addr string, writers []writer, readers []reader) error {
http.HandleFunc("/write", func(w http.ResponseWriter, r *http.Request) {
compressed, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Errorln("Read error:", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
reqBuf, err := snappy.Decode(nil, compressed)
if err != nil {
log.Errorln("Decode error:", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
var req remote.WriteRequest
if err := proto.Unmarshal(reqBuf, &req); err != nil {
log.Errorln("Unmarshal error:", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@ -219,18 +223,21 @@ func serve(addr string, writers []writer, readers []reader) error {
http.HandleFunc("/read", func(w http.ResponseWriter, r *http.Request) {
compressed, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Errorln("Read error:", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
reqBuf, err := snappy.Decode(nil, compressed)
if err != nil {
log.Errorln("Decode error:", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
var req remote.ReadRequest
if err := proto.Unmarshal(reqBuf, &req); err != nil {
log.Errorln("Unmarshal error:", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}