summaryrefslogtreecommitdiff
path: root/pkg/worker_watcher
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-02-11 13:57:41 +0300
committerValery Piashchynski <[email protected]>2021-02-11 13:57:41 +0300
commit509abc76a0f7b88678de67843ca79d9052ad8dd6 (patch)
tree92727c3ff8087597bac65eee2c26c9484c98be7f /pkg/worker_watcher
parentf007fcd5f352d1f83bfdfd2dd47d063d55f9db50 (diff)
Doc comments
Diffstat (limited to 'pkg/worker_watcher')
-rw-r--r--pkg/worker_watcher/container/interface.go4
-rwxr-xr-xpkg/worker_watcher/worker_watcher.go8
2 files changed, 10 insertions, 2 deletions
diff --git a/pkg/worker_watcher/container/interface.go b/pkg/worker_watcher/container/interface.go
index bb66897f..532bace9 100644
--- a/pkg/worker_watcher/container/interface.go
+++ b/pkg/worker_watcher/container/interface.go
@@ -2,8 +2,12 @@ package container
import "github.com/spiral/roadrunner/v2/pkg/worker"
+// Vector interface represents vector container
type Vector interface {
+ // Enqueue used to put worker to the vector
Enqueue(worker.BaseProcess)
+ // Dequeue used to get worker from the vector
Dequeue() (worker.BaseProcess, bool)
+ // Destroy used to stop releasing the workers
Destroy()
}
diff --git a/pkg/worker_watcher/worker_watcher.go b/pkg/worker_watcher/worker_watcher.go
index 3e0633a3..804e4658 100755
--- a/pkg/worker_watcher/worker_watcher.go
+++ b/pkg/worker_watcher/worker_watcher.go
@@ -103,7 +103,7 @@ func (ww *workerWatcher) Get(ctx context.Context) (worker.BaseProcess, error) {
}
return
case worker.StateWorking: // how??
- ww.container.Enqueue(w)
+ ww.container.Enqueue(w) // put it back, let worker finish the work
continue
case
// all the possible wrong states
@@ -143,11 +143,15 @@ func (ww *workerWatcher) Allocate() error {
return errors.E(op, errors.WorkerAllocate, err)
}
+ // add worker to Wait
ww.addToWatch(sw)
+ // add new worker to the workers slice (to get information about workers in parallel)
ww.workers = append(ww.workers, sw)
+ // unlock Allocate mutex
ww.Unlock()
+ // push the worker to the container
ww.Push(sw)
return nil
}
@@ -184,7 +188,7 @@ func (ww *workerWatcher) Destroy(ctx context.Context) {
ww.container.Destroy()
ww.Unlock()
- tt := time.NewTicker(time.Millisecond * 500)
+ tt := time.NewTicker(time.Millisecond * 100)
defer tt.Stop()
for {
select {