Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
fix: do not add/remove workers in debug mode
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Sep 24, 2023
1 parent 736fe1f commit 0e54ba9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 8 additions & 0 deletions pool/static_pool/workers_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func (sp *Pool) Workers() (workers []*worker.Process) {
}

func (sp *Pool) RemoveWorker(ctx context.Context) error {
if sp.cfg.Debug {
sp.log.Warn("remove worker operation is not allowed in debug mode")
return nil
}
var cancel context.CancelFunc
_, ok := ctx.Deadline()
if !ok {
Expand All @@ -130,6 +134,10 @@ func (sp *Pool) RemoveWorker(ctx context.Context) error {
}

func (sp *Pool) AddWorker() error {
if sp.cfg.Debug {
sp.log.Warn("add worker operation is not allowed in debug mode")
return nil
}
return sp.ww.AddWorker()
}

Expand Down
5 changes: 0 additions & 5 deletions worker_watcher/worker_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ func (ww *WorkerWatcher) AddWorker() error {
}

func (ww *WorkerWatcher) RemoveWorker(ctx context.Context) error {
// we can't remove worker if there are no workers :)
if ww.container.Len() == 0 {
return nil
}

w, err := ww.Take(ctx)
if err != nil {
return err
Expand Down

0 comments on commit 0e54ba9

Please sign in to comment.