feat: initialize
This commit is contained in:
32
internal/managed_job/status.go
Normal file
32
internal/managed_job/status.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package managed_job
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"gitea.com/logicamp/lc"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (job *ManagedJob) checkStatus() error {
|
||||
if job.state.JobId == nil {
|
||||
lc.Logger.Debug("[managed-job] [status] no job id")
|
||||
return ErrNoJobId
|
||||
}
|
||||
statusResp, err := job.client.Job(*job.state.JobId)
|
||||
if err != nil {
|
||||
lc.Logger.Debug("[managed-job] [status] cannot fetch status", zap.Error(err))
|
||||
if strings.IndexAny(err.Error(), "http status not 2xx: 404") == 0 {
|
||||
job.updateState(jobState{
|
||||
JobId: job.state.JobId,
|
||||
Status: JobStatusNotFound,
|
||||
})
|
||||
}
|
||||
return err
|
||||
}
|
||||
lc.Logger.Debug("[managed-job] [status]", zap.Any("status-resp", statusResp))
|
||||
job.updateState(jobState{
|
||||
JobId: job.state.JobId,
|
||||
Status: JobStatus(statusResp.State),
|
||||
})
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user