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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package distributor
6
7 import (
8 "github.com/luci/gae/service/datastore"
9 "github.com/luci/luci-go/appengine/cmd/dm/model"
10 "github.com/luci/luci-go/appengine/tumble"
11 "github.com/luci/luci-go/common/logging"
12 "golang.org/x/net/context"
13 )
14
15 // NotifyExecution is used to finish an execution. Specifically it allows the
16 // appropriate distributor to HandleNotification, and then when that concludes,
17 // invokes DM's FinishExecution (see mutate.FinishExecution).
18 type NotifyExecution struct {
19 CfgName string
20 Notification *Notification
21 }
22
23 // Root implements tumble.Mutation.
24 func (f *NotifyExecution) Root(c context.Context) *datastore.Key {
25 return model.ExecutionKeyFromID(c, f.Notification.ID)
26 }
27
28 // RollForward implements tumble.Mutation.
29 func (f *NotifyExecution) RollForward(c context.Context) (muts []tumble.Mutation , err error) {
30 reg := GetRegistry(c)
31 dist, _, err := reg.MakeDistributor(c, f.CfgName)
32 if err != nil {
33 logging.Fields{
34 logging.ErrorKey: err,
35 "cfg": f.CfgName,
36 }.Errorf(c, "Failed to make distributor")
37 return
38 }
39 rslt, err := dist.HandleNotification(f.Notification)
40 if err != nil {
41 // TODO(riannucci): check for transient/non-transient
42 logging.Fields{
43 logging.ErrorKey: err,
44 "cfg": f.CfgName,
45 }.Errorf(c, "Failed to handle notification")
46 return
47 }
48 if rslt != nil {
49 return reg.FinishExecution(c, f.Notification.ID, rslt)
50 }
51 return
52 }
53
54 func init() {
55 tumble.Register((*NotifyExecution)(nil))
56 }
OLDNEW
« 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