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:
parent
1bf25dc1b2
commit
35c952e344
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue