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

Side by Side Diff: common/api/dm/service/v1/execution_data.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
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 dm
6
7 import "errors"
8
9 // NewExecutionScheduling creates an Execution in the SCHEDULING state.
10 func NewExecutionScheduling() *Execution {
11 return &Execution{
12 Data: &Execution_Data{
13 ExecutionType: &Execution_Data_Scheduling_{
14 &Execution_Data_Scheduling{}}}}
15 }
16
17 // NewExecutionRunning creates an Execution in the RUNNING state.
18 func NewExecutionRunning() *Execution {
19 return &Execution{
20 Data: &Execution_Data{
21 ExecutionType: &Execution_Data_Running_{
22 &Execution_Data_Running{}}}}
23 }
24
25 // NewExecutionStopping creates an Execution in the STOPPING state.
26 func NewExecutionStopping() *Execution {
27 return &Execution{
28 Data: &Execution_Data{
29 ExecutionType: &Execution_Data_Stopping_{
30 &Execution_Data_Stopping{}}}}
31 }
32
33 // NewExecutionFinished creates an Execution in the FINISHED state.
34 func NewExecutionFinished(state string) *Execution {
35 return &Execution{
36 Data: &Execution_Data{
37 ExecutionType: &Execution_Data_Finished_{
38 &Execution_Data_Finished{state}}}}
39 }
40
41 // NewExecutionAbnormalFinish creates an Execution in the ABNORMAL_FINISH state.
42 func NewExecutionAbnormalFinish(af *AbnormalFinish) *Execution {
43 return &Execution{
44 Data: &Execution_Data{
45 ExecutionType: &Execution_Data_AbnormalFinish{af}}}
46 }
47
48 // State computes the Execution_State for the current Execution_Data
49 func (d *Execution_Data) State() Execution_State {
50 if d != nil {
51 switch d.ExecutionType.(type) {
52 case *Execution_Data_Scheduling_:
53 return Execution_SCHEDULING
54 case *Execution_Data_Running_:
55 return Execution_RUNNING
56 case *Execution_Data_Stopping_:
57 return Execution_STOPPING
58 case *Execution_Data_Finished_:
59 return Execution_FINISHED
60 case *Execution_Data_AbnormalFinish:
61 return Execution_ABNORMAL_FINISHED
62 }
63 }
64 return Execution_SCHEDULING
65 }
66
67 // Normalize returns an error iff the Execution_Auth has invalid form (e.g.
68 // contains nils).
69 func (a *Execution_Auth) Normalize() error {
70 if a == nil {
71 return errors.New("Execution_Auth is nil")
72 }
73 if a.Id == nil {
74 return errors.New("Execution_Auth.Id is nil")
75 }
76 return nil
77 }
OLDNEW
« no previous file with comments | « common/api/dm/service/v1/ensure_graph_data_normalize.go ('k') | common/api/dm/service/v1/execution_state_evolve.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698