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

Side by Side Diff: dm/appengine/mutate/add_deps.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package mutate 5 package mutate
6 6
7 import ( 7 import (
8 ds "github.com/luci/gae/service/datastore" 8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/luci-go/common/data/bit_field" 9 "github.com/luci/luci-go/common/data/bit_field"
10 "github.com/luci/luci-go/common/errors"
10 "github.com/luci/luci-go/common/logging" 11 "github.com/luci/luci-go/common/logging"
11 "github.com/luci/luci-go/dm/api/service/v1" 12 "github.com/luci/luci-go/dm/api/service/v1"
12 "github.com/luci/luci-go/dm/appengine/model" 13 "github.com/luci/luci-go/dm/appengine/model"
13 "github.com/luci/luci-go/grpc/grpcutil" 14 "github.com/luci/luci-go/grpc/grpcutil"
14 "github.com/luci/luci-go/tumble" 15 "github.com/luci/luci-go/tumble"
15 "golang.org/x/net/context" 16 "golang.org/x/net/context"
16 "google.golang.org/grpc/codes" 17 "google.golang.org/grpc/codes"
17 ) 18 )
18 19
19 // AddDeps transactionally stops the current execution and adds one or more 20 // AddDeps transactionally stops the current execution and adds one or more
(...skipping 23 matching lines...) Expand all
43 if err != nil { 44 if err != nil {
44 return 45 return
45 } 46 }
46 47
47 if err = ResetExecutionTimeout(c, ex); err != nil { 48 if err = ResetExecutionTimeout(c, ex); err != nil {
48 logging.WithError(err).Errorf(c, "could not reset timeout") 49 logging.WithError(err).Errorf(c, "could not reset timeout")
49 return 50 return
50 } 51 }
51 52
52 fwdDeps, err := filterExisting(c, model.FwdDepsFromList(c, a.Auth.Id.Att emptID(), a.Deps)) 53 fwdDeps, err := filterExisting(c, model.FwdDepsFromList(c, a.Auth.Id.Att emptID(), a.Deps))
53 » err = grpcutil.Annotate(err, codes.Internal).Reason("while filtering dep s").Err() 54 » err = errors.Annotate(err).Tag(grpcutil.Tag.With(codes.Internal)).
55 » » Reason("while filtering deps").Err()
54 if err != nil || len(fwdDeps) == 0 { 56 if err != nil || len(fwdDeps) == 0 {
55 return 57 return
56 } 58 }
57 59
58 logging.Fields{"aid": atmpt.ID, "count": len(fwdDeps)}.Infof(c, "added d eps") 60 logging.Fields{"aid": atmpt.ID, "count": len(fwdDeps)}.Infof(c, "added d eps")
59 atmpt.DepMap = bit_field.Make(uint32(len(fwdDeps))) 61 atmpt.DepMap = bit_field.Make(uint32(len(fwdDeps)))
60 62
61 for i, fdp := range fwdDeps { 63 for i, fdp := range fwdDeps {
62 fdp.BitIndex = uint32(i) 64 fdp.BitIndex = uint32(i)
63 fdp.ForExecution = atmpt.CurExecution 65 fdp.ForExecution = atmpt.CurExecution
64 } 66 }
65 67
66 if err = ds.Put(c, fwdDeps, atmpt, ex); err != nil { 68 if err = ds.Put(c, fwdDeps, atmpt, ex); err != nil {
67 » » err = grpcutil.Annotate(err, codes.Internal).Reason("putting stu ff").Err() 69 » » err = errors.Annotate(err).Tag(grpcutil.Tag.With(codes.Internal) ).
70 » » » Reason("putting stuff").Err()
68 return 71 return
69 } 72 }
70 73
71 mergeQuestMap := map[string]*MergeQuest(nil) 74 mergeQuestMap := map[string]*MergeQuest(nil)
72 if len(a.Quests) > 0 { 75 if len(a.Quests) > 0 {
73 mergeQuestMap = make(map[string]*MergeQuest, len(a.Quests)) 76 mergeQuestMap = make(map[string]*MergeQuest, len(a.Quests))
74 for _, q := range a.Quests { 77 for _, q := range a.Quests {
75 mergeQuestMap[q.ID] = &MergeQuest{Quest: q} 78 mergeQuestMap[q.ID] = &MergeQuest{Quest: q}
76 } 79 }
77 } 80 }
(...skipping 25 matching lines...) Expand all
103 for _, mut := range mergeQuestMap { 106 for _, mut := range mergeQuestMap {
104 muts = append(muts, mut) 107 muts = append(muts, mut)
105 } 108 }
106 109
107 return 110 return
108 } 111 }
109 112
110 func init() { 113 func init() {
111 tumble.Register((*AddDeps)(nil)) 114 tumble.Register((*AddDeps)(nil))
112 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698