summaryrefslogtreecommitdiff
path: root/pool.go
blob: 22e8c9701d25b352170d20ec3ea05a0ac4d95bd1 (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
package roadrunner

const (
	// EventCreated thrown when new worker is spawned.
	EventCreated = iota

	// EventDestruct thrown before worker destruction.
	EventDestruct

	// EventError thrown any worker related even happen (error passed as context)
	EventError
)

// Pool managed set of inner worker processes.
type Pool 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)

	// Replace replaces dead or expired worker with new instance.
	Replace(w *Worker, caused interface{})

	// Destroy all underlying workers (but let them to complete the task).
	Destroy()
}