mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
nomad: Adding Size to EvaluatePool
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user