OLD | NEW |
(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 mutate |
| 6 |
| 7 import ( |
| 8 "golang.org/x/net/context" |
| 9 |
| 10 "github.com/luci/gae/service/datastore" |
| 11 "github.com/luci/luci-go/appengine/cmd/dm/model" |
| 12 "github.com/luci/luci-go/appengine/tumble" |
| 13 "github.com/luci/luci-go/common/api/dm/service/v1" |
| 14 ) |
| 15 |
| 16 // ActivateExecution executes an execution, moving it from the |
| 17 // SCHEDULING->RUNNING state, and resetting the execution timeout (if any). |
| 18 type ActivateExecution struct { |
| 19 Auth *dm.Execution_Auth |
| 20 NewTok []byte |
| 21 } |
| 22 |
| 23 // Root implements tumble.Mutation. |
| 24 func (a *ActivateExecution) Root(c context.Context) *datastore.Key { |
| 25 return model.AttemptKeyFromID(c, a.Auth.Id.AttemptID()) |
| 26 } |
| 27 |
| 28 // RollForward implements tumble.Mutation |
| 29 func (a *ActivateExecution) RollForward(c context.Context) (muts []tumble.Mutati
on, err error) { |
| 30 _, e, err := model.ActivateExecution(c, a.Auth, a.NewTok) |
| 31 if err == nil { |
| 32 err = ResetExecutionTimeout(c, e) |
| 33 } |
| 34 return |
| 35 } |
| 36 |
| 37 func init() { |
| 38 tumble.Register((*ActivateExecution)(nil)) |
| 39 } |
OLD | NEW |