worker/server: drop the JobResult method
Let's speak why I merged JobResult and JobStatus together: Both methods actually called jobqueue.JobStatus(), so performance-wise there's no real difference and it feels to me that it makes the code simpler: You don't have to decide which method to call, you just get all the data about a job in one call. We could split those again when we see some perf issues with retrieving logs on each status check but I don't think we should optimize prematurely. Let's leave some work for the future us.
This commit is contained in:
parent
070929b622
commit
e4d32f9e2f
1 changed files with 0 additions and 25 deletions
|
|
@ -116,31 +116,6 @@ func (s *Server) JobStatus(id uuid.UUID) (*JobStatus, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) JobResult(id uuid.UUID) (common.ComposeState, *common.ComposeResult, error) {
|
||||
var canceled bool
|
||||
var result OSBuildJobResult
|
||||
|
||||
_, started, finished, canceled, err := s.jobs.JobStatus(id, &result)
|
||||
if err != nil {
|
||||
return common.CWaiting, nil, err
|
||||
}
|
||||
|
||||
state := common.CWaiting
|
||||
if canceled {
|
||||
state = common.CFailed
|
||||
} else if !finished.IsZero() {
|
||||
if result.OSBuildOutput.Success {
|
||||
state = common.CFinished
|
||||
} else {
|
||||
state = common.CFailed
|
||||
}
|
||||
} else if !started.IsZero() {
|
||||
state = common.CRunning
|
||||
}
|
||||
|
||||
return state, result.OSBuildOutput, nil
|
||||
}
|
||||
|
||||
// jsonErrorf() is similar to http.Error(), but returns the message in a json
|
||||
// object with a "message" field.
|
||||
func jsonErrorf(writer http.ResponseWriter, code int, message string, args ...interface{}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue