Browse Source

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.
pull/3020/merge
gdmello 7 years ago committed by Julius Volz
parent
commit
35c952e344
  1. 7
      documentation/examples/remote_storage/remote_storage_adapter/main.go

7
documentation/examples/remote_storage/remote_storage_adapter/main.go

@ -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…
Cancel
Save