diff options
author | Valery Piashchynski <[email protected]> | 2021-01-15 14:22:02 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-15 14:22:02 +0300 |
commit | e68c8e2eb9ea705e9d846023d545410c7613de64 (patch) | |
tree | 4fe8eadc1e7af49f1f282782ac1b7f2283fb63ea /pkg/worker_watcher/stack.go | |
parent | f7d5f8fb3d14519dc89e346d6b2fc67c1837da5f (diff) |
Use uniform snake case in the configs, fix critical issue with wrong
calculation of workers in stack at the Destroy stage
Diffstat (limited to 'pkg/worker_watcher/stack.go')
-rw-r--r-- | pkg/worker_watcher/stack.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/worker_watcher/stack.go b/pkg/worker_watcher/stack.go index 55f1f52a..788750dc 100644 --- a/pkg/worker_watcher/stack.go +++ b/pkg/worker_watcher/stack.go @@ -10,17 +10,19 @@ import ( ) type Stack struct { - workers []worker.BaseProcess - mutex sync.RWMutex - destroy bool - actualNumOfWorkers int64 + workers []worker.BaseProcess + mutex sync.RWMutex + destroy bool + actualNumOfWorkers uint64 + initialNumOfWorkers uint64 } -func NewWorkersStack() *Stack { +func NewWorkersStack(initialNumOfWorkers uint64) *Stack { w := runtime.NumCPU() return &Stack{ - workers: make([]worker.BaseProcess, 0, w), - actualNumOfWorkers: 0, + workers: make([]worker.BaseProcess, 0, w), + actualNumOfWorkers: 0, + initialNumOfWorkers: initialNumOfWorkers, } } @@ -113,7 +115,7 @@ func (stack *Stack) Destroy(ctx context.Context) { case <-tt.C: stack.mutex.Lock() // that might be one of the workers is working - if len(stack.workers) != int(stack.actualNumOfWorkers) { + if stack.initialNumOfWorkers != stack.actualNumOfWorkers { stack.mutex.Unlock() continue } |