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

Unified Diff: dm/appengine/distributor/jobsim/distributor.go

Issue 2347973003: Refactor distributor API so that methods always get the Quest_Desc too. (Closed)
Patch Set: Created 4 years, 3 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: dm/appengine/distributor/jobsim/distributor.go
diff --git a/dm/appengine/distributor/jobsim/distributor.go b/dm/appengine/distributor/jobsim/distributor.go
index 0ad5629411683ee7b1402c042e43570db3831a1a..1cfbe448bb47a5054161c4343292b07b59e9b11b 100644
--- a/dm/appengine/distributor/jobsim/distributor.go
+++ b/dm/appengine/distributor/jobsim/distributor.go
@@ -41,22 +41,24 @@ func (j *jobsimDist) parsePayload(payload string) (*jobsimExecution, error) {
return ret, err
}
-func (j *jobsimDist) Run(tsk *distributor.TaskDescription) (tok distributor.Token, _ time.Duration, err error) {
+func (j *jobsimDist) Run(desc *dm.Quest_Desc, exAuth *dm.Execution_Auth, prev *dm.JsonResult) (tok distributor.Token, _ time.Duration, err error) {
// TODO(riannucci): Fix luci-gae so we can truly escape the transaction when
// we build the jobsimDist instance. See luci/gae#23.
ds := txnBuf.GetNoTxn(j.c)
logging.Fields{
- "eid": tsk.ExecutionAuth().Id,
+ "eid": exAuth.Id,
}.Infof(j.c, "jobsim: running new task")
- jtsk, err := j.parsePayload(tsk.Payload().Parameters)
+ jtsk, err := j.parsePayload(desc.Parameters)
if err != nil {
return
}
- jtsk.ExAuth = *tsk.ExecutionAuth()
+ jtsk.ExAuth = *exAuth
jtsk.Status = jobsimRunnable
- jtsk.StateOrReason = tsk.PreviousResult().Object
+ if prev != nil {
+ jtsk.StateOrReason = prev.Object
+ }
jtsk.CfgName = j.cfg.Name
key := []*datastore.Key{
@@ -95,7 +97,7 @@ func (j *jobsimDist) Run(tsk *distributor.TaskDescription) (tok distributor.Toke
return
}
-func (j *jobsimDist) Cancel(tok distributor.Token) error {
+func (j *jobsimDist) Cancel(_ *dm.Quest_Desc, tok distributor.Token) error {
jtsk := &jobsimExecution{ID: string(tok)}
cancelBody := func(ds datastore.Interface) (needWrite bool, err error) {
@@ -124,7 +126,7 @@ func (j *jobsimDist) Cancel(tok distributor.Token) error {
}, nil)
}
-func (j *jobsimDist) GetStatus(tok distributor.Token) (*dm.Result, error) {
+func (j *jobsimDist) GetStatus(_ *dm.Quest_Desc, tok distributor.Token) (*dm.Result, error) {
jtsk, err := loadTask(j.c, string(tok))
if err != nil {
return nil, err
@@ -137,7 +139,7 @@ func (j *jobsimDist) InfoURL(tok distributor.Token) string {
return fmt.Sprintf("jobsim://%s/ver/%s/tok/%s", j.cfg.Name, j.cfg.Version, tok)
}
-func (j *jobsimDist) HandleNotification(note *distributor.Notification) (*dm.Result, error) {
+func (j *jobsimDist) HandleNotification(_ *dm.Quest_Desc, note *distributor.Notification) (*dm.Result, error) {
n := &notification{}
err := json.Unmarshal(note.Data, n)
if err != nil {

Powered by Google App Engine
This is Rietveld 408576698