summaryrefslogtreecommitdiff
path: root/pkg/worker_watcher/interface.go
blob: 13991541f1dfd4a11b6044256ea08424047784a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package worker_watcher //nolint:golint,stylecheck

import (
	"context"

	"github.com/spiral/roadrunner/v2/pkg/worker"
)

type Watcher interface {
	// AddToWatch used to add stack to wait its state
	AddToWatch(workers []worker.SyncWorker) error

	// GetFreeWorker provide first free worker
	GetFreeWorker(ctx context.Context) (*worker.SyncWorkerImpl, error)

	// PutWorker enqueues worker back
	PushWorker(w worker.SyncWorker)

	// AllocateNew used to allocate new worker and put in into the WorkerWatcher
	AllocateNew() error

	// Destroy destroys the underlying stack
	Destroy(ctx context.Context)

	// WorkersList return all stack w/o removing it from internal storage
	WorkersList() []*worker.SyncWorkerImpl

	// RemoveWorker remove worker from the stack
	RemoveWorker(wb worker.SyncWorker) error
}