Update low-level i'faces to reflect wireformats.

This commit fixes a critique of the old storage API design, whereby
the input parameters were always as raw bytes and never Protocol
Buffer messages that encapsulated the data, meaning every place a
read or mutation was conducted needed to manually perform said
translations on its own.  This is taxing.

Change-Id: I4786938d0d207cefb7782bd2bd96a517eead186f
This commit is contained in:
Matt T. Proud 2013-08-29 15:15:22 +02:00 committed by Matt T. Proud
parent 7910f6e863
commit 4a87c002e8
19 changed files with 1047 additions and 251 deletions

View file

@ -21,6 +21,9 @@ import (
"net/http"
"net/http/pprof"
"os"
"time"
pprof_runtime "runtime/pprof"
"code.google.com/p/gorest"
"github.com/golang/glog"
@ -63,6 +66,7 @@ func (w WebService) ServeForever() error {
exp.Handle("/databases", w.DatabasesHandler)
exp.Handle("/alerts", w.AlertsHandler)
exp.HandleFunc("/graph", graphHandler)
exp.HandleFunc("/heap", dumpHeap)
exp.Handle("/api/", compressionHandler{handler: gorest.Handle()})
exp.Handle("/metrics", prometheus.DefaultHandler)
@ -139,6 +143,18 @@ func executeTemplate(w http.ResponseWriter, name string, data interface{}) {
}
}
func dumpHeap(w http.ResponseWriter, r *http.Request) {
target := fmt.Sprintf("/tmp/%d.heap", time.Now().Unix())
f, err := os.Create(target)
if err != nil {
glog.Error("Could not dump heap: ", err)
}
fmt.Fprintf(w, "Writing to %s...", target)
defer f.Close()
pprof_runtime.WriteHeapProfile(f)
fmt.Fprintf(w, "Done")
}
func MustBuildServerUrl() string {
_, port, err := net.SplitHostPort(*listenAddress)
if err != nil {