feat: initialize

This commit is contained in:
2024-11-30 01:22:51 +03:30
commit 3b0aff5688
16 changed files with 761 additions and 0 deletions

View 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
}