Skip to content

Commit

Permalink
return err before creating multi pools if lbs is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaynanavare committed Mar 26, 2024
1 parent 10d9975 commit 9ede250
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions multipool.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type MultiPool struct {
// NewMultiPool instantiates a MultiPool with a size of the pool list and a size
// per pool, and the load-balancing strategy.
func NewMultiPool(size, sizePerPool int, lbs LoadBalancingStrategy, options ...Option) (*MultiPool, error) {
if lbs != RoundRobin && lbs != LeastTasks {
return nil, ErrInvalidLoadBalancingStrategy
}
pools := make([]*Pool, size)
for i := 0; i < size; i++ {
pool, err := NewPool(sizePerPool, options...)
Expand All @@ -64,9 +67,6 @@ func NewMultiPool(size, sizePerPool int, lbs LoadBalancingStrategy, options ...O
}
pools[i] = pool
}
if lbs != RoundRobin && lbs != LeastTasks {
return nil, ErrInvalidLoadBalancingStrategy
}
return &MultiPool{pools: pools, lbs: lbs}, nil
}

Expand Down

0 comments on commit 9ede250

Please sign in to comment.