Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
f949c6de
Commit
f949c6de
authored
a year ago
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
not retry when hook result code is int and !=0
parent
5eee86ad
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
11 行删除
+21
-11
server/WebHook.cpp
+21
-11
没有找到文件。
server/WebHook.cpp
查看文件 @
f949c6de
...
...
@@ -94,15 +94,16 @@ static onceToken token([]() {
}
//namespace Cluster
static
void
parse_http_response
(
const
SockException
&
ex
,
const
Parser
&
res
,
const
function
<
void
(
const
Value
&
,
const
string
&
)
>
&
fun
){
const
function
<
void
(
const
Value
&
,
const
string
&
,
const
bool
&
)
>
&
fun
){
bool
should_retry
=
true
;
if
(
ex
)
{
auto
errStr
=
StrPrinter
<<
"[network err]:"
<<
ex
.
what
()
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
);
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
return
;
}
if
(
res
.
Url
()
!=
"200"
)
{
auto
errStr
=
StrPrinter
<<
"[bad http status code]:"
<<
res
.
Url
()
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
);
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
return
;
}
Value
result
;
...
...
@@ -111,20 +112,29 @@ static void parse_http_response(const SockException &ex, const Parser &res,
ss
>>
result
;
}
catch
(
std
::
exception
&
ex
)
{
auto
errStr
=
StrPrinter
<<
"[parse json failed]:"
<<
ex
.
what
()
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
);
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
return
;
}
if
(
result
[
"code"
].
asInt
()
!=
0
)
{
auto
errStr
=
StrPrinter
<<
"[json code]:"
<<
"code="
<<
result
[
"code"
]
<<
",msg="
<<
result
[
"msg"
]
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
);
auto
code
=
result
[
"code"
];
if
(
!
code
.
isInt64
())
{
auto
errStr
=
StrPrinter
<<
"[json code]:"
<<
"code not int :"
<<
code
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
return
;
}
should_retry
=
false
;
if
(
code
.
asInt64
()
!=
0
){
auto
errStr
=
StrPrinter
<<
"[auth failed]: code:"
<<
code
<<
" msg:"
<<
result
[
"msg"
]
<<
endl
;
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
return
;
}
try
{
fun
(
result
,
""
);
fun
(
result
,
""
,
should_retry
);
}
catch
(
std
::
exception
&
ex
)
{
auto
errStr
=
StrPrinter
<<
"[do hook invoker failed]:"
<<
ex
.
what
()
<<
endl
;
//如果还是抛异常,那么再上抛异常
fun
(
Json
::
nullValue
,
errStr
);
fun
(
Json
::
nullValue
,
errStr
,
should_retry
);
}
}
...
...
@@ -173,12 +183,12 @@ void do_http_hook(const string &url, const ArgsType &body, const function<void(c
Ticker
ticker
;
requester
->
startRequester
(
url
,
[
url
,
func
,
bodyStr
,
body
,
requester
,
ticker
,
retry
](
const
SockException
&
ex
,
const
Parser
&
res
)
mutable
{
onceToken
token
(
nullptr
,
[
&
]()
mutable
{
requester
.
reset
();
});
parse_http_response
(
ex
,
res
,
[
&
](
const
Value
&
obj
,
const
string
&
err
)
{
parse_http_response
(
ex
,
res
,
[
&
](
const
Value
&
obj
,
const
string
&
err
,
const
bool
&
should_retry
)
{
if
(
!
err
.
empty
())
{
// hook失败
WarnL
<<
"hook "
<<
url
<<
" "
<<
ticker
.
elapsedTime
()
<<
"ms,failed"
<<
err
<<
":"
<<
bodyStr
;
if
(
retry
--
>
0
)
{
if
(
retry
--
>
0
&&
should_retry
)
{
requester
->
getPoller
()
->
doDelayTask
(
MAX
(
retry_delay
,
0.0
)
*
1000
,
[
url
,
body
,
func
,
retry
]
{
do_http_hook
(
url
,
body
,
func
,
retry
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论