Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
00f791ad83
  1. 3
      workers/config.go
  2. 24
      workers/worker.go

3
workers/config.go

@ -9,12 +9,13 @@ package workers
import (
"forge.chapril.org/dune/sdk"
"forge.chapril.org/losyme/errors"
"forge.chapril.org/losyme/zombie"
)
const _maxPoolSize = 20
type Logger interface {
Trace(msg string, kv ...interface{})
zombie.Logger
Info(msg string, kv ...interface{})
Warning(msg string, kv ...interface{})
Error(msg string, kv ...interface{})

24
workers/worker.go

@ -55,7 +55,12 @@ func (w *worker) updateJob(job *jw.Job) {
job, err := w.model.UpdateJob(job)
if logger := w.logger; logger != nil {
if err != nil {
logger.Error("END", "job", jobID, nil, err) //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"END",
"job", jobID,
"workflow", job.Workflow,
nil, err,
)
return
}
@ -63,6 +68,7 @@ func (w *worker) updateJob(job *jw.Job) {
logger.Info( //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"END",
"job", job.ID,
"workflow", job.Workflow,
"status", job.Status,
"run_after", job.RunAfter.String(),
"attempt", fmt.Sprintf("%d/%d", job.Attempt, job.MaxAttempts),
@ -71,7 +77,12 @@ func (w *worker) updateJob(job *jw.Job) {
return
}
logger.Info("END", "job", job.ID, "status", job.Status) //::::::::::::::::::::::::::::::::::::::::::::::::::::::
logger.Info( //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"END",
"job", job.ID,
"workflow", job.Workflow,
"status", job.Status,
)
}
}
@ -82,6 +93,7 @@ func (w *worker) runJob(job *jw.Job) {
w.logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"PANIC ERROR RECOVERED",
"job", job.ID,
"workflow", job.Workflow,
"data", data,
"stack", string(debug.Stack()),
)
@ -93,7 +105,12 @@ func (w *worker) runJob(job *jw.Job) {
if err := w.runner.Run(job); err != nil {
if w.logger != nil {
w.logger.Error("RUN", "job", job.ID, nil, err) //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
w.logger.Error( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"RUN",
"job", job.ID,
"workflow", job.Workflow,
nil, err,
)
}
job.Failed().SetError(err.Error())
@ -119,6 +136,7 @@ func (w *worker) maybeRunJob() time.Duration {
"Worker",
"id", w.id,
"job", job.ID,
"workflow", job.Workflow,
"count", count,
)
}

Loading…
Cancel
Save