diff --git a/workers.go b/workers.go index dc36433..c017407 100644 --- a/workers.go +++ b/workers.go @@ -32,6 +32,7 @@ type Runner interface { Start() Runner Stop() chan error Wait() error + AvailableWorkers() int64 } type runner struct { @@ -199,6 +200,11 @@ func (r *runner) waitForDrain() { } } +// AvailableWorkers . +func (r *runner) AvailableWorkers() int64 { + return r.numWorkers - int64(len(r.limiter)) +} + // startWork Runs the before function and starts processing until one of three things happen. // 1. A term signal is received or cancellation of context. // 2. Stop function is called.