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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: common/api/dm/service/v1/execution_data.go
diff --git a/common/api/dm/service/v1/execution_data.go b/common/api/dm/service/v1/execution_data.go
new file mode 100644
index 0000000000000000000000000000000000000000..effb4467652636213737265e562d1c229855e481
--- /dev/null
+++ b/common/api/dm/service/v1/execution_data.go
@@ -0,0 +1,77 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package dm
+
+import "errors"
+
+// NewExecutionScheduling creates an Execution in the SCHEDULING state.
+func NewExecutionScheduling() *Execution {
+ return &Execution{
+ Data: &Execution_Data{
+ ExecutionType: &Execution_Data_Scheduling_{
+ &Execution_Data_Scheduling{}}}}
+}
+
+// NewExecutionRunning creates an Execution in the RUNNING state.
+func NewExecutionRunning() *Execution {
+ return &Execution{
+ Data: &Execution_Data{
+ ExecutionType: &Execution_Data_Running_{
+ &Execution_Data_Running{}}}}
+}
+
+// NewExecutionStopping creates an Execution in the STOPPING state.
+func NewExecutionStopping() *Execution {
+ return &Execution{
+ Data: &Execution_Data{
+ ExecutionType: &Execution_Data_Stopping_{
+ &Execution_Data_Stopping{}}}}
+}
+
+// NewExecutionFinished creates an Execution in the FINISHED state.
+func NewExecutionFinished(state string) *Execution {
+ return &Execution{
+ Data: &Execution_Data{
+ ExecutionType: &Execution_Data_Finished_{
+ &Execution_Data_Finished{state}}}}
+}
+
+// NewExecutionAbnormalFinish creates an Execution in the ABNORMAL_FINISH state.
+func NewExecutionAbnormalFinish(af *AbnormalFinish) *Execution {
+ return &Execution{
+ Data: &Execution_Data{
+ ExecutionType: &Execution_Data_AbnormalFinish{af}}}
+}
+
+// State computes the Execution_State for the current Execution_Data
+func (d *Execution_Data) State() Execution_State {
+ if d != nil {
+ switch d.ExecutionType.(type) {
+ case *Execution_Data_Scheduling_:
+ return Execution_SCHEDULING
+ case *Execution_Data_Running_:
+ return Execution_RUNNING
+ case *Execution_Data_Stopping_:
+ return Execution_STOPPING
+ case *Execution_Data_Finished_:
+ return Execution_FINISHED
+ case *Execution_Data_AbnormalFinish:
+ return Execution_ABNORMAL_FINISHED
+ }
+ }
+ return Execution_SCHEDULING
+}
+
+// Normalize returns an error iff the Execution_Auth has invalid form (e.g.
+// contains nils).
+func (a *Execution_Auth) Normalize() error {
+ if a == nil {
+ return errors.New("Execution_Auth is nil")
+ }
+ if a.Id == nil {
+ return errors.New("Execution_Auth.Id is nil")
+ }
+ return nil
+}
« 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