summaryrefslogtreecommitdiff
path: root/interfaces/worker/watcher.go
blob: ce2c1c5a5934ae54ddb043442c0b60e115e666ee (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
package worker

import "context"

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

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

	// PutWorker enqueues worker back
	PushWorker(w BaseProcess)

	// 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() []BaseProcess

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