diff options
author | Valery Piashchynski <[email protected]> | 2020-11-09 15:11:10 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-09 15:11:10 +0300 |
commit | 0874bcb2f6b284a940ba4f3507eb8c4619c27868 (patch) | |
tree | c99d15624cd080cad22b7c8fb7d4714b2dc124fb /worker_watcher.go | |
parent | 9fbe7726dd55cfedda724b7644e1b6bf7c1a6cb4 (diff) | |
parent | f218dcbd7e55d9ad1df8336e2331cdaa62d9ded3 (diff) |
Merge pull request #390 from spiral/feature/switch_to_spiral_errorsv2.0.0-alpha17
Feature/switch to spiral errors
Diffstat (limited to 'worker_watcher.go')
-rwxr-xr-x | worker_watcher.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/worker_watcher.go b/worker_watcher.go index 36b3e029..3a89554d 100755 --- a/worker_watcher.go +++ b/worker_watcher.go @@ -158,7 +158,7 @@ func (ww *workerWatcher) GetFreeWorker(ctx context.Context) (WorkerBase, error) ww.ReduceWorkersCount() return w, nil case <-tout.C: - return nil, errors.Str("no free stack") + return nil, errors.E(op, errors.Str("no free workers in the stack")) } } } @@ -169,9 +169,10 @@ func (ww *workerWatcher) GetFreeWorker(ctx context.Context) (WorkerBase, error) func (ww *workerWatcher) AllocateNew(ctx context.Context) error { ww.stack.mutex.Lock() + const op = errors.Op("allocate new worker") sw, err := ww.allocator() if err != nil { - return err + return errors.E(op, err) } ww.addToWatch(sw) @@ -188,6 +189,7 @@ func (ww *workerWatcher) AllocateNew(ctx context.Context) error { func (ww *workerWatcher) RemoveWorker(ctx context.Context, wb WorkerBase) error { ww.stack.mutex.Lock() + const op = errors.Op("remove worker") defer ww.stack.mutex.Unlock() pid := wb.Pid() for i := 0; i < len(ww.stack.workers); i++ { @@ -200,7 +202,7 @@ func (ww *workerWatcher) RemoveWorker(ctx context.Context, wb WorkerBase) error wb.State().Set(StateInvalid) err := wb.Kill() if err != nil { - return err + return errors.E(op, err) } break } @@ -274,12 +276,13 @@ func (ww *workerWatcher) WorkersList() []WorkerBase { } func (ww *workerWatcher) wait(ctx context.Context, w WorkerBase) { + const op = errors.Op("process wait") err := w.Wait(ctx) if err != nil { ww.events.Push(WorkerEvent{ Event: EventWorkerError, Worker: w, - Payload: err, + Payload: errors.E(op, err), }) } @@ -301,7 +304,7 @@ func (ww *workerWatcher) wait(ctx context.Context, w WorkerBase) { if err != nil { ww.events.Push(PoolEvent{ Event: EventPoolError, - Payload: err, + Payload: errors.E(op, err), }) } @@ -316,7 +319,7 @@ func (ww *workerWatcher) wait(ctx context.Context, w WorkerBase) { if err != nil { ww.events.Push(PoolEvent{ Event: EventPoolError, - Payload: err, + Payload: errors.E(op, err), }) return } |