fix(message validation): don't call `emqx_conf:update` during boot

`load/0` and `unload/0` shouldn't call cluster operations.
This commit is contained in:
Thales Macedo Garitezi 2024-05-08 09:05:03 -03:00
parent 4403b4f5ce
commit d3bc32dc35
1 changed files with 14 additions and 2 deletions

View File

@ -69,10 +69,22 @@ remove_handler() ->
ok.
load() ->
lists:foreach(fun insert/1, emqx:get_config(?VALIDATIONS_CONF_PATH, [])).
Validations = emqx:get_config(?VALIDATIONS_CONF_PATH, []),
lists:foreach(
fun({Pos, Validation}) ->
ok = emqx_message_validation_registry:insert(Pos, Validation)
end,
lists:enumerate(Validations)
).
unload() ->
lists:foreach(fun delete/1, emqx:get_config(?VALIDATIONS_CONF_PATH, [])).
Validations = emqx:get_config(?VALIDATIONS_CONF_PATH, []),
lists:foreach(
fun(Validation) ->
ok = emqx_message_validation_registry:delete(Validation)
end,
Validations
).
-spec list() -> [validation()].
list() ->