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

Unified Diff: common/api/dm/service/v1/attempt_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/attempt_data.go
diff --git a/common/api/dm/service/v1/attempt_data.go b/common/api/dm/service/v1/attempt_data.go
index 7c7658e804a3f1d32b895ac5c0da5196503dbea6..9d7220be5100b9dea5cfd6babee09494e24c9da6 100644
--- a/common/api/dm/service/v1/attempt_data.go
+++ b/common/api/dm/service/v1/attempt_data.go
@@ -10,65 +10,64 @@ import (
google_pb "github.com/luci/luci-go/common/proto/google"
)
-// NewAttemptNeedsExecution creates an Attempt in the NeedsExecution state.
-func NewAttemptNeedsExecution(pending time.Time) *Attempt {
+// NewAttemptScheduling creates an Attempt in the SCHEDULING state.
+func NewAttemptScheduling() *Attempt {
return &Attempt{
Data: &Attempt_Data{
- AttemptType: &Attempt_Data_NeedsExecution_{
- NeedsExecution: &Attempt_Data_NeedsExecution{
- google_pb.NewTimestamp(pending)}}}}
+ AttemptType: &Attempt_Data_Scheduling_{
+ &Attempt_Data_Scheduling{}}}}
}
-// NewAttemptExecuting creates an Attempt in the Executing state.
+// NewAttemptExecuting creates an Attempt in the EXECUTING state.
func NewAttemptExecuting(curExID uint32) *Attempt {
return &Attempt{
Data: &Attempt_Data{
+ NumExecutions: curExID,
AttemptType: &Attempt_Data_Executing_{
- Executing: &Attempt_Data_Executing{
- curExID}}}}
+ &Attempt_Data_Executing{curExID}}}}
}
-// NewAttemptAddingDeps creates an Attempt in the AddingDeps state.
-func NewAttemptAddingDeps(numAdding, numWaiting uint32) *Attempt {
+// NewAttemptWaiting creates an Attempt in the WAITING state.
+func NewAttemptWaiting(numWaiting uint32) *Attempt {
return &Attempt{
Data: &Attempt_Data{
- AttemptType: &Attempt_Data_AddingDeps_{
- AddingDeps: &Attempt_Data_AddingDeps{
- numAdding, numWaiting}}}}
+ AttemptType: &Attempt_Data_Waiting_{
+ &Attempt_Data_Waiting{numWaiting}}}}
}
-// NewAttemptBlocked creates an Attempt in the Blocked state.
-func NewAttemptBlocked(numWaiting uint32) *Attempt {
+// NewAttemptFinished creates an Attempt in the FINISHED state.
+func NewAttemptFinished(expiration time.Time, jsonResultSize uint32, jsonResult string, finalPersistentState []byte) *Attempt {
return &Attempt{
Data: &Attempt_Data{
- AttemptType: &Attempt_Data_Blocked_{
- Blocked: &Attempt_Data_Blocked{
- numWaiting}}}}
+ AttemptType: &Attempt_Data_Finished_{
+ &Attempt_Data_Finished{
+ google_pb.NewTimestamp(expiration), jsonResultSize, jsonResult, finalPersistentState}}}}
}
-// NewAttemptFinished creates an Attempt in the Finished state.
-func NewAttemptFinished(expiration time.Time, jsonResultSize uint32, jsonResult string) *Attempt {
+// NewAttemptAbnormalFinish creates an Attempt in the ABNORMAL_FINISH state.
+func NewAttemptAbnormalFinish(af *AbnormalFinish) *Attempt {
return &Attempt{
Data: &Attempt_Data{
- AttemptType: &Attempt_Data_Finished_{
- Finished: &Attempt_Data_Finished{
- google_pb.NewTimestamp(expiration), jsonResultSize, jsonResult}}}}
+ AttemptType: &Attempt_Data_AbnormalFinish{af}}}
}
// State computes the Attempt_State for the current Attempt_Data
func (d *Attempt_Data) State() Attempt_State {
- switch d.AttemptType.(type) {
- case *Attempt_Data_Executing_:
- return Attempt_EXECUTING
- case *Attempt_Data_AddingDeps_:
- return Attempt_ADDING_DEPS
- case *Attempt_Data_Blocked_:
- return Attempt_BLOCKED
- case *Attempt_Data_Finished_:
- return Attempt_FINISHED
+ if d != nil {
+ switch d.AttemptType.(type) {
+ case *Attempt_Data_Scheduling_:
+ return Attempt_SCHEDULING
+ case *Attempt_Data_Executing_:
+ return Attempt_EXECUTING
+ case *Attempt_Data_Waiting_:
+ return Attempt_WAITING
+ case *Attempt_Data_Finished_:
+ return Attempt_FINISHED
+ case *Attempt_Data_AbnormalFinish:
+ return Attempt_ABNORMAL_FINISHED
+ }
}
- // NEEDS_EXECUTION is the default
- return Attempt_NEEDS_EXECUTION
+ return Attempt_SCHEDULING
}
// NormalizePartial will nil out the Partial field for this Attempt if all
@@ -83,3 +82,10 @@ func (d *Attempt) NormalizePartial() {
d.Partial = nil
}
}
+
+// Any returns true iff any of the Partial fields are true such that they could
+// be successfully loaded on a subsequent query.
+func (p *Attempt_Partial) Any() bool {
+ return (p.BackDeps || p.Data || p.Executions || p.FwdDeps ||
+ p.Result == Attempt_Partial_NOT_LOADED)
+}
« no previous file with comments | « common/api/dm/service/v1/activate_execution_normalize.go ('k') | common/api/dm/service/v1/attempt_state_evolve.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698