Commit 2dfec35e by 王召彬

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

parent 6a1ffe99
...@@ -50,21 +50,24 @@ class ClsLog ...@@ -50,21 +50,24 @@ class ClsLog
private static function uploadToCls($topicId, $pbData) { private static function uploadToCls($topicId, $pbData) {
$authorization = ClsSignature::create(); $authorization = ClsSignature::create();
$uri = 'http://ap-beijing.cls.myqcloud.com/structuredlog?topic_id='.$topicId; $uri = 'http://ap-beijing.cls.myqcloud.com/structuredlog?topic_id='.$topicId;
$res = (new Client)->post($uri, [ for($n = 0;$n < 3;$n++){
'headers' => [ $res = (new Client)->post($uri, [
'Host' => 'ap-beijing.cls.myqcloud.com', 'headers' => [
'Authorization' => $authorization, 'Host' => 'ap-beijing.cls.myqcloud.com',
'Content-Type' => 'application/x-protobuf', 'Authorization' => $authorization,
], 'Content-Type' => 'application/x-protobuf',
'body'=>$pbData, ],
'timeout' => 20, 'body'=>$pbData,
]); 'timeout' => 30,
if($res->getResponse()->getStatusCode() != 200) { ]);
$msg = '上传腾讯云日志服务失败:'.$res->getResult(); if($res->getResponse()->getStatusCode() == 200) {
self::writeClsErrors($msg); return true;
return false; }
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