From 730c76737a64c798b37adefb15ea0f223361631b Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sun, 28 Jan 2018 18:58:06 +0300 Subject: Context --- pool.go | 8 ++++---- pool_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pool.go b/pool.go index deb24fd7..dfa7ab1b 100644 --- a/pool.go +++ b/pool.go @@ -26,8 +26,8 @@ const ( // Pool controls worker creation, destruction and task routing. type Pool struct { - // EventHandler is optional callback to handle worker create/destruct/error events. - EventHandler func(event int, w *Worker, ctx interface{}) + // Observer is optional callback to handle worker create/destruct/error events. + Observer func(event int, w *Worker, ctx interface{}) // pool behaviour cfg Config @@ -236,7 +236,7 @@ func (p *Pool) createWorker() (*Worker, error) { // throw invokes event handler if any. func (p *Pool) throw(event int, w *Worker, ctx interface{}) { - if p.EventHandler != nil { - p.EventHandler(event, w, ctx) + if p.Observer != nil { + p.Observer(event, w, ctx) } } diff --git a/pool_test.go b/pool_test.go index db38cbc4..bada2fe8 100644 --- a/pool_test.go +++ b/pool_test.go @@ -149,8 +149,8 @@ func Test_Pool_Broken_Replace(t *testing.T) { assert.NotNil(t, p) assert.NoError(t, err) - - p.EventHandler = func(e int, w *Worker, ctx interface{}) { + + p.Observer = func(e int, w *Worker, ctx interface{}) { if err, ok := ctx.(error); ok { assert.Contains(t, err.Error(), "undefined_function()") } -- cgit v1.2.3