src/Biz/CloudPlatform/Client/FailoverCloudAPI.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\CloudPlatform\Client;
class FailoverCloudAPI extends AbstractCloudAPI
{
const FAILOVER_COUNT = 3;
protected $servers = array();
protected $serverConfigPath = null;
protected $apiType = null;
protected $rootApiUrl = null;
public function __construct(array $options)
{
parent::__construct($options);
$this->rootApiUrl = $this->apiUrl;
}
protected function _request($method, $uri, $params, $headers)
{
try {
$result = parent::_request($method, $uri, $params, $headers);
if ($this->servers['next_refresh_time'] < time()) {
$self = $this;
$this->servers = $this->refreshServerConfigFile(function () use ($self) {
return $self->getServerList(0);
}, 'noneblocking');
}
return $result;
} catch (CloudAPIIOException $e) {
if ($this->apiType !== 'leaf') {
throw $e;
}
$that = $this;
$this->refreshServerConfigFile(function ($fp, $data, $maxFailoverCount) use ($that) {
if (($data['failed_expired'] > 0) && ($data['failed_expired'] > time())) {
++$data['failed_count'];
} else {
$data['failed_count'] = 1;
$data['failed_expired'] = time() + 120;
}
if ($data['failed_count'] == $maxFailoverCount) {
$data = $that->voteLeafServer($data);
}
return $data;
}, 'nonblocking');
throw $e;
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。