/**
* @param string $host RPC名称,
* @param string $module 模块名称
* @param string $rpcConfigFile RPC服务器的配置文件路径
* @throws Exception 如果模块名称为空,将抛出异常
*/
public function __construct($host, $module, $rpcConfigFile = '')
{
if (empty($module)) {
throw new InvalidConfigException("Error module is empty", 1);
}
if (empty($host)) {
throw new InvalidConfigException("Error host is empty", 1);
}
if (empty($rpcConfigFile) && !defined('RPC_CONFIG_FILE')) {
throw new InvalidConfigException("Error rpcConfigFile is empty or RPC_CONFIG_FILE constant undefined", 1);
}
if (empty($rpcConfigFile)) {
$rpcConfigFile = RPC_CONFIG_FILE;
}
$this->module = $module;
$configs = (require $rpcConfigFile);
if (isset($configs[$host]['timeout'])) {
$this->timeout = $configs[$host]['timeout'];
}
if (isset($configs[$host]['pool_timeout'])) {
$this->pool_timeout = $configs[$host]['pool_timeout'];
}
parent::__construct(self::getNodeByWeight($configs[$host]));
$this->__set('timeout', $this->timeout);
$this->__set('pool_timeout', $this->pool_timeout);
}