chore(hooks): delete is_function()
This commit is contained in:
parent
b21959b0c3
commit
0dd068135d
|
@ -197,7 +197,7 @@ hook(HookPoint, Action) ->
|
||||||
-> ok | {error, already_exists}).
|
-> ok | {error, already_exists}).
|
||||||
hook(HookPoint, Action, Priority) when is_integer(Priority) ->
|
hook(HookPoint, Action, Priority) when is_integer(Priority) ->
|
||||||
emqx_hooks:add(HookPoint, Action, Priority);
|
emqx_hooks:add(HookPoint, Action, Priority);
|
||||||
hook(HookPoint, Action, Filter) when is_function(Filter); is_tuple(Filter) ->
|
hook(HookPoint, Action, {_M, _F, _A} = Filter ) ->
|
||||||
emqx_hooks:add(HookPoint, Action, Filter).
|
emqx_hooks:add(HookPoint, Action, Filter).
|
||||||
|
|
||||||
-spec(hook(emqx_hooks:hookpoint(), emqx_hooks:action(), emqx_hooks:filter(), integer())
|
-spec(hook(emqx_hooks:hookpoint(), emqx_hooks:action(), emqx_hooks:filter(), integer())
|
||||||
|
|
|
@ -118,7 +118,7 @@ add(HookPoint, Action) when is_function(Action); is_tuple(Action) ->
|
||||||
|
|
||||||
-spec(add(hookpoint(), action(), filter() | integer() | list())
|
-spec(add(hookpoint(), action(), filter() | integer() | list())
|
||||||
-> ok_or_error(already_exists)).
|
-> ok_or_error(already_exists)).
|
||||||
add(HookPoint, Action, Filter) when is_function(Filter); is_tuple(Filter) ->
|
add(HookPoint, Action, {_M, _F, _A} = Filter) ->
|
||||||
add(HookPoint, #callback{action = Action, filter = Filter, priority = 0});
|
add(HookPoint, #callback{action = Action, filter = Filter, priority = 0});
|
||||||
add(HookPoint, Action, Priority) when is_integer(Priority) ->
|
add(HookPoint, Action, Priority) when is_integer(Priority) ->
|
||||||
add(HookPoint, #callback{action = Action, priority = Priority}).
|
add(HookPoint, #callback{action = Action, priority = Priority}).
|
||||||
|
@ -185,12 +185,12 @@ filter_passed(undefined, _Args) -> true;
|
||||||
filter_passed(Filter, Args) ->
|
filter_passed(Filter, Args) ->
|
||||||
execute(Filter, Args).
|
execute(Filter, Args).
|
||||||
|
|
||||||
safe_execute(Fun, Args) ->
|
safe_execute({M, F, A}, Args) ->
|
||||||
try execute(Fun, Args) of
|
try execute({M, F, A}, Args) of
|
||||||
Result -> Result
|
Result -> Result
|
||||||
catch
|
catch
|
||||||
Error:Reason:Stacktrace ->
|
Error:Reason:Stacktrace ->
|
||||||
?LOG(error, "Failed to execute ~0p: ~0p", [Fun, {Error, Reason, Stacktrace}]),
|
?LOG(error, "Failed to execute ~0p: ~0p", [{M, F, A}, {Error, Reason, Stacktrace}]),
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue