diff options
author | Valery Piashchynski <[email protected]> | 2021-11-06 09:58:53 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-11-07 16:11:37 +0300 |
commit | c27daeeb9e70cd99cdc8355c08455d1e4d453815 (patch) | |
tree | 0cbe568d760ab47456432c2ffd6c231ba0d5f378 | |
parent | 160055c16d4c1ca1e0e19853cbb89ef3509c7556 (diff) |
update worker's vector
Signed-off-by: Valery Piashchynski <[email protected]>
-rw-r--r-- | worker_watcher/container/channel/vec.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/worker_watcher/container/channel/vec.go b/worker_watcher/container/channel/vec.go index fd50c8d1..63df052f 100644 --- a/worker_watcher/container/channel/vec.go +++ b/worker_watcher/container/channel/vec.go @@ -69,8 +69,16 @@ func (v *Vec) Push(w worker.BaseProcess) { // replace with the new one and return from the loop // new worker can be ttl-ed at this moment, it's possible to replace TTL-ed worker with new TTL-ed worker // But this case will be handled in the worker_watcher::Get - v.workers <- w - return + select { + case v.workers <- w: + return + // the place for the new worker was occupied before + default: + // kill the new worker and reallocate it + w.State().Set(worker.StateInvalid) + _ = w.Kill() + return + } } } } |