qqq
This commit is contained in:
@@ -64,7 +64,11 @@ class Pool implements PoolInterface
|
||||
if (!isset($this->_connections[$name])) {
|
||||
throw new Exception('Channel is not exists.');
|
||||
}
|
||||
return $this->_connections[$name];
|
||||
$channel = $this->_connections[$name];
|
||||
if ($channel->isClose()) {
|
||||
$channel->reconnect();
|
||||
}
|
||||
return $channel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,29 @@ class PoolItem
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isClose(): bool
|
||||
{
|
||||
if ($this->_items instanceof Channel) {
|
||||
return $this->_items->errCode == SWOOLE_CHANNEL_CLOSED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reconnect(): void
|
||||
{
|
||||
if ($this->_items instanceof Channel && $this->_items->errCode == SWOOLE_CHANNEL_CLOSED) {
|
||||
$this->_items = new Channel($this->maxCreated);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Channel|SplQueue $items
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user