Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: perf/server/perf.go

Issue 335833002: Start loading the BigQuery data and serving it to the UI. (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: y Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« perf/server/data.go ('K') | « perf/server/data.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: perf/server/perf.go
diff --git a/perf/server/perf.go b/perf/server/perf.go
index 0d12dc5dbf015296f7aab4d59f4647aa7e216160..e70011e700594f9bc880c0760c42b82713bdcc44 100644
--- a/perf/server/perf.go
+++ b/perf/server/perf.go
@@ -1,3 +1,7 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be found
+// in the LICENSE file.
+
package main
import (
@@ -30,7 +34,13 @@ var (
// flags
var (
- port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
+ port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
+ doOauth = flag.Bool("oauth", true, "Run through the OAuth 2.0 flow on startup.")
+ gitRepoDir = flag.String("git_repo_dir", "../../../skia", "Directory location for the Skia repo.")
+)
+
+var (
+ data *Data
mtklein 2014/06/15 15:12:12 Having data global smells a little to me. I think
jcgregorio 2014/06/16 02:46:25 Data will be protected with a Mutex once the auto
)
func init() {
@@ -96,6 +106,15 @@ func reportError(w http.ResponseWriter, r *http.Request, err error, message stri
http.Error(w, message, 500)
}
+// jsonHandler handles the GET for the JSON requests.
+func jsonHandler(w http.ResponseWriter, r *http.Request) {
+ log.Printf("Main Handler: %q\n", r.URL.Path)
mtklein 2014/06/15 15:12:12 -> JSON Handler: ?
jcgregorio 2014/06/16 02:46:25 Done.
jcgregorio 2014/06/16 02:46:25 Done.
+ if r.Method == "GET" {
+ w.Header().Set("Content-Type", "application/json")
+ data.AsJSON(w)
+ }
+}
+
// mainHandler handles the GET and POST of the main page.
func mainHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Main Handler: %q\n", r.URL.Path)
@@ -109,9 +128,20 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {
func main() {
flag.Parse()
+
+ log.Println("Begin loading data.")
+ var err error
+ data, err = NewData(*doOauth, *gitRepoDir)
+ if err != nil {
+ log.Fatalln("Failed initial load of data from BigQuery: ", err)
+ }
+
// Resources are served directly.
http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./"))))
http.HandleFunc("/", autogzip.HandleFunc(mainHandler))
+ http.HandleFunc("/json/", autogzip.HandleFunc(jsonHandler))
+
+ log.Println("Ready to serve.")
log.Fatal(http.ListenAndServe(*port, nil))
}
« perf/server/data.go ('K') | « perf/server/data.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698