diff --git a/src/Pool/ConnectPool.php b/src/Pool/ConnectPool.php index a8067bd5..eb44b941 100644 --- a/src/Pool/ConnectPool.php +++ b/src/Pool/ConnectPool.php @@ -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; } @@ -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); }