diff options
author | Valery Piashchynski <[email protected]> | 2021-01-11 13:00:52 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-11 13:00:52 +0300 |
commit | c4112cd214a9c7cbed82c82eefc75904fb42d1af (patch) | |
tree | 680cc5f0d3f9a0d78a944e026568af61c12bd87e /worker.go | |
parent | 5dc83ef5eee77f4d1ef557e5f8b566e75892680d (diff) |
Update CI
Format imports and code
Distinct internal and app errors
Diffstat (limited to 'worker.go')
-rw-r--r-- | worker.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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) |