summaryrefslogtreecommitdiff
path: root/pkg/worker_watcher
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-24 01:24:50 +0300
committerValery Piashchynski <[email protected]>2021-01-24 01:24:50 +0300
commit00f94201218079cf2ba3ebbddc9095c0ac4804ae (patch)
tree91fb62dd0c3a78dff2eaf1d0586397a0031682d5 /pkg/worker_watcher
parente5a93ee2a305c87ab128dfd166e735c6eeb77e43 (diff)
Update Pool and WorkerWatcher interfaces
Diffstat (limited to 'pkg/worker_watcher')
-rw-r--r--pkg/worker_watcher/interface.go4
-rw-r--r--pkg/worker_watcher/stack.go4
-rwxr-xr-xpkg/worker_watcher/worker_watcher.go6
3 files changed, 7 insertions, 7 deletions
diff --git a/pkg/worker_watcher/interface.go b/pkg/worker_watcher/interface.go
index 13991541..927aa270 100644
--- a/pkg/worker_watcher/interface.go
+++ b/pkg/worker_watcher/interface.go
@@ -11,7 +11,7 @@ type Watcher interface {
AddToWatch(workers []worker.SyncWorker) error
// GetFreeWorker provide first free worker
- GetFreeWorker(ctx context.Context) (*worker.SyncWorkerImpl, error)
+ GetFreeWorker(ctx context.Context) (worker.SyncWorker, error)
// PutWorker enqueues worker back
PushWorker(w worker.SyncWorker)
@@ -23,7 +23,7 @@ type Watcher interface {
Destroy(ctx context.Context)
// WorkersList return all stack w/o removing it from internal storage
- WorkersList() []*worker.SyncWorkerImpl
+ WorkersList() []worker.SyncWorker
// RemoveWorker remove worker from the stack
RemoveWorker(wb worker.SyncWorker) error
diff --git a/pkg/worker_watcher/stack.go b/pkg/worker_watcher/stack.go
index 2d23d0e9..d76f4d8f 100644
--- a/pkg/worker_watcher/stack.go
+++ b/pkg/worker_watcher/stack.go
@@ -85,10 +85,10 @@ func (stack *Stack) FindAndRemoveByPid(pid int64) bool {
}
// Workers return copy of the workers in the stack
-func (stack *Stack) Workers() []*worker.SyncWorkerImpl {
+func (stack *Stack) Workers() []worker.SyncWorker {
stack.mutex.Lock()
defer stack.mutex.Unlock()
- workersCopy := make([]*worker.SyncWorkerImpl, 0, 1)
+ workersCopy := make([]worker.SyncWorker, 0, 1)
// copy
for _, v := range stack.workers {
if v != nil {
diff --git a/pkg/worker_watcher/worker_watcher.go b/pkg/worker_watcher/worker_watcher.go
index f87bd021..2c3d512d 100755
--- a/pkg/worker_watcher/worker_watcher.go
+++ b/pkg/worker_watcher/worker_watcher.go
@@ -39,7 +39,7 @@ func (ww *workerWatcher) AddToWatch(workers []worker.SyncWorker) error {
return nil
}
-func (ww *workerWatcher) GetFreeWorker(ctx context.Context) (*worker.SyncWorkerImpl, error) {
+func (ww *workerWatcher) GetFreeWorker(ctx context.Context) (worker.SyncWorker, error) {
const op = errors.Op("worker_watcher_get_free_worker")
// thread safe operation
w, stop := ww.stack.Pop()
@@ -127,11 +127,11 @@ func (ww *workerWatcher) Destroy(ctx context.Context) {
}
// Warning, this is O(n) operation, and it will return copy of the actual workers
-func (ww *workerWatcher) WorkersList() []*worker.SyncWorkerImpl {
+func (ww *workerWatcher) WorkersList() []worker.SyncWorker {
return ww.stack.Workers()
}
-func (ww *workerWatcher) wait(w worker.SyncWorker) {
+func (ww *workerWatcher) wait(w worker.BaseProcess) {
const op = errors.Op("worker_watcher_wait")
err := w.Wait()
if err != nil {