Skip to content

Commit

Permalink
Fix swoft-service-governance requirement, add random balancer select …
Browse files Browse the repository at this point in the history
…method as defaults
  • Loading branch information
huangzhhui committed Mar 9, 2018
1 parent 39b2f62 commit f6357e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Pool/ConnectPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public function getConnect()
if ($this->currentCount > $this->poolConfig->getMaxActive()) {
return null;
}
if (! $this->queue->isEmpty()) {
if (!$this->queue->isEmpty()) {
$connect = $this->queue->shift();

return $connect;
}

Expand Down Expand Up @@ -82,8 +83,10 @@ public function getConnectAddress()
{
$serviceList = $this->getServiceList();
$balancerType = $this->poolConfig->getBalancer();
if (! \function_exists('balancer')) {
return $serviceList[array_rand($serviceList)];
}
$balancer = balancer()->select($balancerType);

return $balancer->select($serviceList);
}

Expand Down

0 comments on commit f6357e6

Please sign in to comment.