From d17ea720c10284a036e5977b6800345736078617 Mon Sep 17 00:00:00 2001 From: John Ku Date: Thu, 10 Dec 2015 10:14:03 -0800 Subject: [PATCH] custom selection and error handler for NewPool --- client/pool.go | 5 +++-- client/pool_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/pool.go b/client/pool.go index 23efb74..08933bf 100644 --- a/client/pool.go +++ b/client/pool.go @@ -60,10 +60,11 @@ type Pool struct { } // Return a new pool. -func NewPool() (pool *Pool) { +func NewPool(selectionFn SelectionHandler, errorFn ErrorHandler) (pool *Pool) { return &Pool{ clients: make(map[string]*poolClient, poolSize), - SelectionHandler: SelectWithRate, + SelectionHandler: selectionFn, + ErrorHandler: errorFn, } } diff --git a/client/pool_test.go b/client/pool_test.go index 5324db9..bb85aa8 100644 --- a/client/pool_test.go +++ b/client/pool_test.go @@ -5,7 +5,7 @@ import ( ) var ( - pool = NewPool() + pool = NewPool(selectWithRate, func(error) {}) ) func TestPoolAdd(t *testing.T) {