blob: 6a1501885995a73db60da14e3c287e2e55af334f (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package pool
import (
"context"
"github.com/spiral/roadrunner/v2/payload"
"github.com/spiral/roadrunner/v2/worker"
)
// Pool managed set of inner worker processes.
type Pool interface {
// GetConfig returns pool configuration.
GetConfig() interface{}
// Exec executes task with payload
Exec(rqs *payload.Payload) (*payload.Payload, error)
// Workers returns worker list associated with the pool.
Workers() (workers []worker.BaseProcess)
// RemoveWorker removes worker from the pool.
RemoveWorker(worker worker.BaseProcess) error
// Reset kill all workers inside the watcher and replaces with new
Reset(ctx context.Context) error
// Destroy all underlying stack (but let them to complete the task).
Destroy(ctx context.Context)
// ExecWithContext executes task with context which is used with timeout
execWithTTL(ctx context.Context, rqs *payload.Payload) (*payload.Payload, error)
}
// Watcher is an interface for the Sync workers lifecycle
type Watcher interface {
// Watch used to add workers to the container
Watch(workers []worker.BaseProcess) error
// Take takes the first free worker
Take(ctx context.Context) (worker.BaseProcess, error)
// Release releases the worker putting it back to the queue
Release(w worker.BaseProcess)
// Allocate - allocates new worker and put it into the WorkerWatcher
Allocate() error
// Destroy destroys the underlying container
Destroy(ctx context.Context)
// Reset will replace container and workers array, kill all workers
Reset(ctx context.Context)
// List return all container w/o removing it from internal storage
List() []worker.BaseProcess
// Remove will remove worker from the container
Remove(wb worker.BaseProcess)
}
|