diff options
author | Valery Piashchynski <[email protected]> | 2020-11-27 00:35:15 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-11-27 00:35:15 +0300 |
commit | fa9a7e319b5ac6d98fd18d1e4986de35fde254e5 (patch) | |
tree | 559908f3a491a15bb4926f79dbfde350ec7d4c40 /supervisor_pool.go | |
parent | 46ae5dcc22d971b0f909bce23ec8fdef26811ed6 (diff) |
Add new pool event: EventNoFreeWorkers which indicates than RR can't get
worker from the stack during the allowed allocate timeout.
Diffstat (limited to 'supervisor_pool.go')
-rwxr-xr-x | supervisor_pool.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/supervisor_pool.go b/supervisor_pool.go index 6fcb71e6..dfec5559 100755 --- a/supervisor_pool.go +++ b/supervisor_pool.go @@ -102,8 +102,8 @@ func (sp *supervisedPool) Workers() (workers []WorkerBase) { return sp.pool.Workers() } -func (sp *supervisedPool) RemoveWorker(ctx context.Context, worker WorkerBase) error { - return sp.pool.RemoveWorker(ctx, worker) +func (sp *supervisedPool) RemoveWorker(worker WorkerBase) error { + return sp.pool.RemoveWorker(worker) } func (sp *supervisedPool) Destroy(ctx context.Context) { @@ -134,7 +134,6 @@ func (sp *supervisedPool) Stop() { func (sp *supervisedPool) control() { now := time.Now() - ctx := context.TODO() const op = errors.Op("supervised pool control tick") // THIS IS A COPY OF WORKERS @@ -152,7 +151,7 @@ func (sp *supervisedPool) control() { } if sp.cfg.TTL != 0 && now.Sub(workers[i].Created()).Seconds() >= float64(sp.cfg.TTL) { - err = sp.pool.RemoveWorker(ctx, workers[i]) + err = sp.pool.RemoveWorker(workers[i]) if err != nil { sp.events.Push(PoolEvent{Event: EventSupervisorError, Payload: errors.E(op, err)}) return @@ -162,13 +161,12 @@ func (sp *supervisedPool) control() { } if sp.cfg.MaxWorkerMemory != 0 && s.MemoryUsage >= sp.cfg.MaxWorkerMemory*MB { - err = sp.pool.RemoveWorker(ctx, workers[i]) + err = sp.pool.RemoveWorker(workers[i]) if err != nil { sp.events.Push(PoolEvent{Event: EventSupervisorError, Payload: errors.E(op, err)}) return } sp.events.Push(PoolEvent{Event: EventMaxMemory, Payload: workers[i]}) - continue } @@ -194,7 +192,7 @@ func (sp *supervisedPool) control() { // maxWorkerIdle more than diff between now and last used if sp.cfg.IdleTTL-uint64(res) <= 0 { - err = sp.pool.RemoveWorker(ctx, workers[i]) + err = sp.pool.RemoveWorker(workers[i]) if err != nil { sp.events.Push(PoolEvent{Event: EventSupervisorError, Payload: errors.E(op, err)}) return |