chore(exhook): add a comment to bool type

This commit is contained in:
JianBo He 2021-04-14 19:31:38 +08:00 committed by turtleDeng
parent 446a69c814
commit b7a8884d4a
2 changed files with 16 additions and 9 deletions

View File

@ -96,7 +96,8 @@ call_fold(Hookpoint, Req, AccFun, [ServiceName|More]) ->
{ok, Resp} -> {ok, Resp} ->
case AccFun(Req, Resp) of case AccFun(Req, Resp) of
{stop, NReq} -> {stop, NReq}; {stop, NReq} -> {stop, NReq};
{ok, NReq} -> call_fold(Hookpoint, NReq, AccFun, More) {ok, NReq} -> call_fold(Hookpoint, NReq, AccFun, More);
_ -> call_fold(Hookpoint, Req, AccFun, More)
end; end;
_ -> _ ->
call_fold(Hookpoint, Req, AccFun, More) call_fold(Hookpoint, Req, AccFun, More)

View File

@ -89,6 +89,12 @@ on_client_disconnected(ClientInfo, Reason, _ConnInfo) ->
cast('client.disconnected', Req). cast('client.disconnected', Req).
on_client_authenticate(ClientInfo, AuthResult) -> on_client_authenticate(ClientInfo, AuthResult) ->
%% XXX: Bool is missing more information about the atom of the result
%% So, the `Req` has missed detailed info too.
%%
%% The return value of `call_fold` just a bool, that has missed
%% detailed info too.
%%
Bool = maps:get(auth_result, AuthResult, undefined) == success, Bool = maps:get(auth_result, AuthResult, undefined) == success,
Req = #{clientinfo => clientinfo(ClientInfo), Req = #{clientinfo => clientinfo(ClientInfo),
result => Bool result => Bool
@ -287,8 +293,6 @@ stringfy(Term) ->
%% Acc funcs %% Acc funcs
%% see exhook.proto %% see exhook.proto
merge_responsed_bool(Req, #{type := 'IGNORE'}) ->
{ok, Req};
merge_responsed_bool(Req, #{type := Type, value := {bool_result, NewBool}}) merge_responsed_bool(Req, #{type := Type, value := {bool_result, NewBool}})
when is_boolean(NewBool) -> when is_boolean(NewBool) ->
NReq = Req#{result => NewBool}, NReq = Req#{result => NewBool},
@ -296,18 +300,20 @@ merge_responsed_bool(Req, #{type := Type, value := {bool_result, NewBool}})
'CONTINUE' -> {ok, NReq}; 'CONTINUE' -> {ok, NReq};
'STOP_AND_RETURN' -> {stop, NReq} 'STOP_AND_RETURN' -> {stop, NReq}
end; end;
merge_responsed_bool(Req, Resp) -> merge_responsed_bool(_Req, #{type := 'IGNORE'}) ->
ignore;
merge_responsed_bool(_Req, Resp) ->
?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]), ?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]),
{ok, Req}. ignore.
merge_responsed_message(Req, #{type := 'IGNORE'}) ->
{ok, Req};
merge_responsed_message(Req, #{type := Type, value := {message, NMessage}}) -> merge_responsed_message(Req, #{type := Type, value := {message, NMessage}}) ->
NReq = Req#{message => NMessage}, NReq = Req#{message => NMessage},
case Type of case Type of
'CONTINUE' -> {ok, NReq}; 'CONTINUE' -> {ok, NReq};
'STOP_AND_RETURN' -> {stop, NReq} 'STOP_AND_RETURN' -> {stop, NReq}
end; end;
merge_responsed_message(Req, Resp) -> merge_responsed_message(_Req, #{type := 'IGNORE'}) ->
ignore;
merge_responsed_message(_Req, Resp) ->
?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]), ?LOG(warning, "Unknown responsed value ~0p to merge to callback chain", [Resp]),
{ok, Req}. ignore.