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

Unified Diff: appengine/cmd/dm/distributor/notify_execution.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fix imports and make dummy.go a real file Created 4 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
« no previous file with comments | « appengine/cmd/dm/distributor/handlers.go ('k') | appengine/cmd/dm/distributor/pubsub.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/dm/distributor/notify_execution.go
diff --git a/appengine/cmd/dm/distributor/notify_execution.go b/appengine/cmd/dm/distributor/notify_execution.go
new file mode 100644
index 0000000000000000000000000000000000000000..0470b2413a3735654ba3d8fb772b9b4326aba11f
--- /dev/null
+++ b/appengine/cmd/dm/distributor/notify_execution.go
@@ -0,0 +1,56 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package distributor
+
+import (
+ "github.com/luci/gae/service/datastore"
+ "github.com/luci/luci-go/appengine/cmd/dm/model"
+ "github.com/luci/luci-go/appengine/tumble"
+ "github.com/luci/luci-go/common/logging"
+ "golang.org/x/net/context"
+)
+
+// NotifyExecution is used to finish an execution. Specifically it allows the
+// appropriate distributor to HandleNotification, and then when that concludes,
+// invokes DM's FinishExecution (see mutate.FinishExecution).
+type NotifyExecution struct {
+ CfgName string
+ Notification *Notification
+}
+
+// Root implements tumble.Mutation.
+func (f *NotifyExecution) Root(c context.Context) *datastore.Key {
+ return model.ExecutionKeyFromID(c, f.Notification.ID)
+}
+
+// RollForward implements tumble.Mutation.
+func (f *NotifyExecution) RollForward(c context.Context) (muts []tumble.Mutation, err error) {
+ reg := GetRegistry(c)
+ dist, _, err := reg.MakeDistributor(c, f.CfgName)
+ if err != nil {
+ logging.Fields{
+ logging.ErrorKey: err,
+ "cfg": f.CfgName,
+ }.Errorf(c, "Failed to make distributor")
+ return
+ }
+ rslt, err := dist.HandleNotification(f.Notification)
+ if err != nil {
+ // TODO(riannucci): check for transient/non-transient
+ logging.Fields{
+ logging.ErrorKey: err,
+ "cfg": f.CfgName,
+ }.Errorf(c, "Failed to handle notification")
+ return
+ }
+ if rslt != nil {
+ return reg.FinishExecution(c, f.Notification.ID, rslt)
+ }
+ return
+}
+
+func init() {
+ tumble.Register((*NotifyExecution)(nil))
+}
« no previous file with comments | « appengine/cmd/dm/distributor/handlers.go ('k') | appengine/cmd/dm/distributor/pubsub.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698