summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-03-31 18:31:09 +0300
committerWolfy-J <[email protected]>2018-03-31 18:31:09 +0300
commitf8ff7aeedc893969d02115d23b62503a75228446 (patch)
treeabe67a449cba8e00f23ad25b43d481d4b6fa1dee
parent73240266eb12fbc763d9780ba66ffa8bc0f2c38b (diff)
worker destruction made public
-rw-r--r--pool.go3
-rw-r--r--static_pool.go4
-rw-r--r--static_pool_test.go2
3 files changed, 6 insertions, 3 deletions
diff --git a/pool.go b/pool.go
index f491dfa5..e432ec25 100644
--- a/pool.go
+++ b/pool.go
@@ -13,6 +13,9 @@ const (
// Pool managed set of inner worker processes.
type Pool interface {
+ // Watch attaches pool event watcher.
+ Watch(o func(event int, w *Worker, ctx interface{}))
+
// Exec one task with given payload and context, returns result or error.
Exec(rqs *Payload) (rsp *Payload, err error)
diff --git a/static_pool.go b/static_pool.go
index 04f08d24..c119a270 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -70,8 +70,8 @@ func NewPool(cmd func() *exec.Cmd, factory Factory, cfg Config) (*StaticPool, er
return p, nil
}
-// Observe attaches pool event watcher.
-func (p *StaticPool) Observe(o func(event int, w *Worker, ctx interface{})) {
+// Watch attaches pool event watcher.
+func (p *StaticPool) Watch(o func(event int, w *Worker, ctx interface{})) {
p.observer = o
}
diff --git a/static_pool_test.go b/static_pool_test.go
index 6e6aa4be..ada6c3d2 100644
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -150,7 +150,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
assert.NotNil(t, p)
assert.NoError(t, err)
- p.Observe(func(e int, w *Worker, ctx interface{}) {
+ p.Watch(func(e int, w *Worker, ctx interface{}) {
if err, ok := ctx.(error); ok {
assert.Contains(t, err.Error(), "undefined_function()")
}