fix(limiter): add `limiter` back to the configs API

This commit is contained in:
firest 2022-10-11 18:05:14 +08:00
parent 1e43fc3004
commit 88a0c77707
2 changed files with 13 additions and 45 deletions

View File

@ -107,14 +107,12 @@ insert_bucket(Id, Type, Bucket) ->
delete_bucket(Type, Id) ->
ets:delete(?TAB, ?UID(Id, Type)).
post_config_update([limiter], _Config, NewConf, _OldConf, _AppEnvs) ->
Types = lists:delete(client, maps:keys(NewConf)),
_ = [on_post_config_update(Type, NewConf) || Type <- Types],
ok;
post_config_update([limiter, Type], _Config, NewConf, _OldConf, _AppEnvs) ->
Config = maps:get(Type, NewConf),
case emqx_limiter_server:whereis(Type) of
undefined ->
start_server(Type, Config);
_ ->
emqx_limiter_server:update_config(Type, Config)
end.
on_post_config_update(Type, NewConf).
%%--------------------------------------------------------------------
%% @doc
@ -258,3 +256,11 @@ format_status(_Opt, Status) ->
%%--------------------------------------------------------------------
%% Internal functions
%%--------------------------------------------------------------------
on_post_config_update(Type, NewConf) ->
Config = maps:get(Type, NewConf),
case emqx_limiter_server:whereis(Type) of
undefined ->
start_server(Type, Config);
_ ->
emqx_limiter_server:update_config(Type, Config)
end.

View File

@ -63,7 +63,6 @@
<<"prometheus">>,
<<"telemetry">>,
<<"sys_topics">>,
<<"limiter">>,
<<"listeners">>
] ++ global_zone_roots()
).
@ -78,7 +77,6 @@ paths() ->
"/configs",
"/configs_reset/:rootname",
"/configs/global_zone"
%% "/configs/limiter/:limiter_type"
] ++
lists:map(fun({Name, _Type}) -> ?PREFIX ++ binary_to_list(Name) end, config_list()).
@ -168,42 +166,6 @@ schema("/configs/global_zone") ->
}
}
};
%% schema("/configs/limiter/:limiter_type") ->
%% Schema = hoconsc:ref(emqx_limiter_schema, limiter_opts),
%% Parameters = [
%% {limiter_type,
%% hoconsc:mk(
%% hoconsc:enum(emqx_limiter_schema:types()),
%% #{
%% in => path,
%% required => true,
%% example => <<"bytes_in">>,
%% desc => <<"The limiter type">>
%% }
%% )}
%% ],
%% #{
%% 'operationId' => config,
%% get => #{
%% tags => ?TAGS,
%% description => <<"Get config of this limiter">>,
%% parameters => Parameters,
%% responses => #{
%% 200 => Schema,
%% 404 => emqx_dashboard_swagger:error_codes(['NOT_FOUND'], <<"config not found">>)
%% }
%% },
%% put => #{
%% tags => ?TAGS,
%% description => <<"Update config of this limiter">>,
%% parameters => Parameters,
%% 'requestBody' => Schema,
%% responses => #{
%% 200 => Schema,
%% 400 => emqx_dashboard_swagger:error_codes(['UPDATE_FAILED'])
%% }
%% }
%% };
schema(Path) ->
{RootKey, {_Root, Schema}} = find_schema(Path),
#{