fix(bpapi): Add exceptions for experimental features

This commit is contained in:
ieQu1 2024-03-28 12:03:41 +01:00
parent 02b72d79fc
commit 8c6d8bdd12
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
1 changed files with 42 additions and 23 deletions

View File

@ -81,6 +81,12 @@
"emqx_mgmt_api:do_query/2, emqx_mgmt_api:collect_total_from_tail_nodes/2" "emqx_mgmt_api:do_query/2, emqx_mgmt_api:collect_total_from_tail_nodes/2"
). ).
%% Only the APIs for the features that haven't reached General
%% Availability can be added here:
-define(EXPERIMENTAL_APIS, [
{emqx_ds, 4}
]).
-define(XREF, myxref). -define(XREF, myxref).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -132,7 +138,19 @@ check_compat(_, _) ->
check_api_immutability(#{release := Rel1, api := APIs1}, #{release := Rel2, api := APIs2}) -> check_api_immutability(#{release := Rel1, api := APIs1}, #{release := Rel2, api := APIs2}) ->
%% TODO: Handle API deprecation %% TODO: Handle API deprecation
_ = maps:map( _ = maps:map(
fun(Key = {API, Version}, Val) -> fun(Key, Val) ->
case lists:member(Key, ?EXPERIMENTAL_APIS) of
true ->
ok;
false ->
do_check_api_immutability(Rel1, Rel2, APIs2, Key, Val)
end
end,
APIs1
),
ok.
do_check_api_immutability(Rel1, Rel2, APIs2, Key = {API, Version}, Val) ->
case maps:get(Key, APIs2, undefined) of case maps:get(Key, APIs2, undefined) of
Val -> Val ->
ok; ok;
@ -148,17 +166,18 @@ check_api_immutability(#{release := Rel1, api := APIs1}, #{release := Rel2, api
[API, Version, Rel2, Rel1] [API, Version, Rel2, Rel1]
) )
end; end;
_Val -> OldVal ->
setnok(), setnok(),
logger:error( logger:error(
"API ~p v~p was changed between ~p and ~p. Backplane API should be immutable.", "API ~p v~p was changed between ~p and ~p. Backplane API should be immutable.",
[API, Version, Rel1, Rel2] [API, Version, Rel1, Rel2]
)
end
end,
APIs1
), ),
ok. D21 = maps:get(calls, Val) -- maps:get(calls, OldVal),
D12 = maps:get(calls, OldVal) -- maps:get(calls, Val),
logger:error("Added calls:~n ~p", [D21]),
logger:error("Removed calls:~n ~p", [D12])
end.
filter_calls(Calls) -> filter_calls(Calls) ->
F = fun({{Mf, _, _}, {Mt, _, _}}) -> F = fun({{Mf, _, _}, {Mt, _, _}}) ->