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

Side by Side Diff: dm/appengine/mutate/schedule_execution.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 "fmt" 8 "fmt"
9 9
10 ds "github.com/luci/gae/service/datastore" 10 ds "github.com/luci/gae/service/datastore"
11 "github.com/luci/luci-go/common/errors"
12 "github.com/luci/luci-go/common/logging" 11 "github.com/luci/luci-go/common/logging"
13 "github.com/luci/luci-go/common/proto/google" 12 "github.com/luci/luci-go/common/proto/google"
13 "github.com/luci/luci-go/common/retry/transient"
14 dm "github.com/luci/luci-go/dm/api/service/v1" 14 dm "github.com/luci/luci-go/dm/api/service/v1"
15 "github.com/luci/luci-go/dm/appengine/distributor" 15 "github.com/luci/luci-go/dm/appengine/distributor"
16 "github.com/luci/luci-go/dm/appengine/model" 16 "github.com/luci/luci-go/dm/appengine/model"
17 "github.com/luci/luci-go/tumble" 17 "github.com/luci/luci-go/tumble"
18 18
19 "golang.org/x/net/context" 19 "golang.org/x/net/context"
20 ) 20 )
21 21
22 // ScheduleExecution is a placeholder mutation that will be an entry into the 22 // ScheduleExecution is a placeholder mutation that will be an entry into the
23 // Distributor scheduling state-machine. 23 // Distributor scheduling state-machine.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 exAuth := &dm.Execution_Auth{Id: eid, Token: e.Token} 80 exAuth := &dm.Execution_Auth{Id: eid, Token: e.Token}
81 81
82 var distTok distributor.Token 82 var distTok distributor.Token
83 distTok, e.TimeToStop, err = dist.Run(&q.Desc, exAuth, prevResult) 83 distTok, e.TimeToStop, err = dist.Run(&q.Desc, exAuth, prevResult)
84 if e.TimeToStop <= 0 { 84 if e.TimeToStop <= 0 {
85 e.TimeToStop = google.DurationFromProto(q.Desc.Meta.Timeouts.Sto p) 85 e.TimeToStop = google.DurationFromProto(q.Desc.Meta.Timeouts.Sto p)
86 } 86 }
87 e.DistributorToken = string(distTok) 87 e.DistributorToken = string(distTok)
88 if err != nil { 88 if err != nil {
89 » » if errors.IsTransient(err) { 89 » » if transient.Tag.In(err) {
90 // tumble will retry us later 90 // tumble will retry us later
91 logging.WithError(err).Errorf(c, "got transient error in ScheduleExecution") 91 logging.WithError(err).Errorf(c, "got transient error in ScheduleExecution")
92 return 92 return
93 } 93 }
94 logging.WithError(err).Errorf(c, "got non-transient error in Sch eduleExecution") 94 logging.WithError(err).Errorf(c, "got non-transient error in Sch eduleExecution")
95 origErr := err 95 origErr := err
96 96
97 // put a and e to the transaction buffer, so that 97 // put a and e to the transaction buffer, so that
98 // FinishExecution.RollForward can see them. 98 // FinishExecution.RollForward can see them.
99 if err = ds.Put(c, a, e); err != nil { 99 if err = ds.Put(c, a, e); err != nil {
(...skipping 14 matching lines...) Expand all
114 if err = ds.Put(c, a, e); err != nil { 114 if err = ds.Put(c, a, e); err != nil {
115 logging.WithError(err).Errorf(c, "putting attempt+execution") 115 logging.WithError(err).Errorf(c, "putting attempt+execution")
116 } 116 }
117 117
118 return 118 return
119 } 119 }
120 120
121 func init() { 121 func init() {
122 tumble.Register((*ScheduleExecution)(nil)) 122 tumble.Register((*ScheduleExecution)(nil))
123 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698