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

Unified Diff: go/src/infra/tricium/service/workflow-launcher/handlers.go

Issue 2125603002: Adds initial Tricium service GAE configs (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Adds copyright comments and infra testing files Created 4 years, 5 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
Index: go/src/infra/tricium/service/workflow-launcher/handlers.go
diff --git a/go/src/infra/tricium/service/workflow-launcher/handlers.go b/go/src/infra/tricium/service/workflow-launcher/handlers.go
new file mode 100644
index 0000000000000000000000000000000000000000..6be1d5f5c04b30e02cba033c74a1f71be06050fe
--- /dev/null
+++ b/go/src/infra/tricium/service/workflow-launcher/handlers.go
@@ -0,0 +1,42 @@
+// Copyright 2016 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 handlers implements HTTP handlers for the workflow-launcher module.
+package handlers
+
+import (
+ "html/template"
+ "net/http"
+
+ "google.golang.org/appengine"
+ "google.golang.org/appengine/taskqueue"
+)
+
+func init() {
+ http.HandleFunc("/workflow-launcher/status", statusPageHandler)
+ http.HandleFunc("/workflow-launcher/queue-handler", queueHandler)
+}
+
+var basePage = template.Must(template.ParseFiles("templates/base.html"))
+
+func statusPageHandler(w http.ResponseWriter, r *http.Request) {
+ // TODO(emso): Add workflow launcher stats
+ data := map[string]interface{}{
+ "Msg": "Status of the Workflow Launcher ...",
+ }
+ basePage.Execute(w, data)
+}
+
+func queueHandler(w http.ResponseWriter, r *http.Request) {
+ ctx := appengine.NewContext(r)
+
+ // TODO(emso): Process request (merge configs, compute workflow) and launch workflow
+
+ // Enqueue workflow listener task
+ t := taskqueue.NewPOSTTask("/workflow-listener/queue-handler", map[string][]string{"name": {"Workflow Launched"}})
+ if _, err := taskqueue.Add(ctx, t, "workflow-listener-queue"); err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698