summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/worker.go b/worker.go
index 04b58e49..7221c2de 100644
--- a/worker.go
+++ b/worker.go
@@ -164,38 +164,35 @@ func (w *Worker) Kill() error {
// errors. Method might return JobError indicating issue with payload.
func (w *Worker) Exec(rqs *Payload) (rsp *Payload, err error) {
w.mu.Lock()
- defer w.mu.Unlock()
if rqs == nil {
+ w.mu.Unlock()
return nil, fmt.Errorf("payload can not be empty")
}
if w.state.Value() != StateReady {
+ w.mu.Unlock()
return nil, fmt.Errorf("worker is not ready (%s)", w.state.String())
}
w.state.set(StateWorking)
- defer w.state.registerExec()
rsp, err = w.execPayload(rqs)
if err != nil {
if _, ok := err.(JobError); !ok {
w.state.set(StateErrored)
+ w.state.registerExec()
+ w.mu.Unlock()
return nil, err
}
}
- // todo: attach when payload is complete
- // todo: new status
-
w.state.set(StateReady)
+ w.state.registerExec()
+ w.mu.Unlock()
return rsp, err
}
-func (w *Worker) markDestroying() {
- w.state.set(StateDestroying)
-}
-
func (w *Worker) start() error {
if err := w.cmd.Start(); err != nil {
close(w.waitDone)