blob: 8372b4a6c20d5b094c2c66f5bc6d1676da5388c7 (
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
|
package roadrunner
const (
// EventWorkerConstruct thrown when new worker is spawned.
EventWorkerConstruct = iota + 100
// EventWorkerDestruct thrown after worker destruction.
EventWorkerDestruct
// EventWorkerKill thrown after worker is being forcefully killed.
EventWorkerKill
// EventWorkerError thrown any worker related even happen (passed with WorkerError)
EventWorkerError
// EventWorkerDead thrown when worker stops worker for any reason.
EventWorkerDead
// EventPoolError caused on pool wide errors
EventPoolError
)
// Pool managed set of inner worker processes.
type Pool interface {
// Watch enables worker watching (to destroy expired workers or workers which experience
// memory leaks).
Watch(w Watcher)
// Listen all caused events to attached watcher.
Listen(l func(event int, ctx interface{}))
// Exec one task with given payload and context, returns result or error.
Exec(rqs *Payload) (rsp *Payload, err error)
// Workers returns worker list associated with the pool.
Workers() (workers []*Worker)
// Destroy all underlying workers (but let them to complete the task).
Destroy()
}
|