nomad: Adding Size to EvaluatePool

This commit is contained in:
Armon Dadgar
2016-02-20 13:25:49 -08:00
parent 8f32e65227
commit 9dc72fee95
2 changed files with 14 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ func NewEvaluatePool(workers, bufSize int) *EvaluatePool {
return p
}
// Size returns the current size
func (p *EvaluatePool) Size() int {
return p.workers
}
// SetSize is used to resize the worker pool
func (p *EvaluatePool) SetSize(size int) {
// Handle an upwards resize

View File

@@ -42,10 +42,19 @@ func TestEvaluatePool(t *testing.T) {
func TestEvaluatePool_Resize(t *testing.T) {
pool := NewEvaluatePool(1, 4)
defer pool.Shutdown()
if n := pool.Size(); n != 1 {
t.Fatalf("bad: %d", n)
}
// Scale up
pool.SetSize(4)
if n := pool.Size(); n != 4 {
t.Fatalf("bad: %d", n)
}
// Scale down
pool.SetSize(2)
if n := pool.Size(); n != 2 {
t.Fatalf("bad: %d", n)
}
}