Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

AvailableWorkers #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Runner interface {
Start() Runner
Stop() chan error
Wait() error
AvailableWorkers() int64
}

type runner struct {
Expand Down Expand Up @@ -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.
Expand Down