diff options
author | Valery Piashchynski <[email protected]> | 2020-12-22 23:27:51 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-22 23:27:51 +0300 |
commit | 1f6749ed4cf3cfd2beade4949945a382abd66b15 (patch) | |
tree | 7dff57a0223376746fd6cd49dc439f8766fe9f1b /pkg/pool/static_pool.go | |
parent | 95a72fe8003c66ac2d9a52b964aba4ee1d88363f (diff) |
Redisighn factory interface (add event listeners as variadic)v2.0.0-alpha28
Diffstat (limited to 'pkg/pool/static_pool.go')
-rwxr-xr-x | pkg/pool/static_pool.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index b181a805..23bb2d5f 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -39,6 +39,9 @@ type StaticPool struct { // distributes the events events events.Handler + // saved list of event listeners + listeners []events.EventListener + // manages worker states and TTLs ww worker.Watcher @@ -103,6 +106,7 @@ func Initialize(ctx context.Context, cmd Command, factory worker.Factory, cfg Co func AddListeners(listeners ...events.EventListener) Options { return func(p *StaticPool) { + p.listeners = listeners for i := 0; i < len(listeners); i++ { p.addListener(listeners[i]) } @@ -265,7 +269,7 @@ func (sp *StaticPool) newPoolAllocator(ctx context.Context, timeout time.Duratio return func() (worker.BaseProcess, error) { ctx, cancel := context.WithTimeout(ctx, timeout) defer cancel() - w, err := factory.SpawnWorkerWithTimeout(ctx, cmd()) + w, err := factory.SpawnWorkerWithTimeout(ctx, cmd(), sp.listeners...) if err != nil { return nil, err } |