Commit 2dfec35e by 王召彬

上传腾讯云日志支持错误重试

parent 6a1ffe99
......@@ -50,21 +50,24 @@ class ClsLog
private static function uploadToCls($topicId, $pbData) {
$authorization = ClsSignature::create();
$uri = 'http://ap-beijing.cls.myqcloud.com/structuredlog?topic_id='.$topicId;
$res = (new Client)->post($uri, [
'headers' => [
'Host' => 'ap-beijing.cls.myqcloud.com',
'Authorization' => $authorization,
'Content-Type' => 'application/x-protobuf',
],
'body'=>$pbData,
'timeout' => 20,
]);
if($res->getResponse()->getStatusCode() != 200) {
$msg = '上传腾讯云日志服务失败:'.$res->getResult();
self::writeClsErrors($msg);
return false;
for($n = 0;$n < 3;$n++){
$res = (new Client)->post($uri, [
'headers' => [
'Host' => 'ap-beijing.cls.myqcloud.com',
'Authorization' => $authorization,
'Content-Type' => 'application/x-protobuf',
],
'body'=>$pbData,
'timeout' => 30,
]);
if($res->getResponse()->getStatusCode() == 200) {
return true;
}
Coroutine::sleep(1);
}
return true;
$msg = '上传腾讯云日志服务失败:'.$res->getResult();
self::writeClsErrors($msg);
return false;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment