summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-11 13:00:52 +0300
committerValery Piashchynski <[email protected]>2021-01-11 13:00:52 +0300
commitc4112cd214a9c7cbed82c82eefc75904fb42d1af (patch)
tree680cc5f0d3f9a0d78a944e026568af61c12bd87e /worker.go
parent5dc83ef5eee77f4d1ef557e5f8b566e75892680d (diff)
Update CI
Format imports and code Distinct internal and app errors
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/worker.go b/worker.go
index 4fbf4369..7d9e79b0 100644
--- a/worker.go
+++ b/worker.go
@@ -153,6 +153,9 @@ func (w *Worker) Kill() error {
}
}
+var ErrEmptyPayload = errors.New("payload can not be empty")
+var ErrWorkerNotReady = errors.New("worker is not ready")
+
// Exec sends payload to worker, executes it and returns result or
// error. Make sure to handle worker.Wait() to gather worker level
// errors. Method might return JobError indicating issue with payload.
@@ -161,12 +164,12 @@ func (w *Worker) Exec(rqs *Payload) (rsp *Payload, err error) {
if rqs == nil {
w.mu.Unlock()
- return nil, fmt.Errorf("payload can not be empty")
+ return nil, ErrEmptyPayload
}
if w.state.Value() != StateReady {
w.mu.Unlock()
- return nil, fmt.Errorf("worker is not ready (%s)", w.state.String())
+ return nil, ErrWorkerNotReady
}
w.state.set(StateWorking)