refactor: move shared macros to header file
This commit is contained in:
parent
674f837f36
commit
b1dfbf7984
|
@ -0,0 +1,22 @@
|
|||
%%--------------------------------------------------------------------
|
||||
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||
%%
|
||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||
%% you may not use this file except in compliance with the License.
|
||||
%% You may obtain a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing, software
|
||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
%% See the License for the specific language governing permissions and
|
||||
%% limitations under the License.
|
||||
%%--------------------------------------------------------------------
|
||||
-ifndef(EMQX_SCHEMA_HRL).
|
||||
-define(EMQX_SCHEMA_HRL, true).
|
||||
|
||||
-define(TOMBSTONE, marked_for_deletion).
|
||||
-define(TOMBSTONE_BIN, <<"marked_for_deletion">>).
|
||||
|
||||
-endif.
|
|
@ -20,11 +20,10 @@
|
|||
-elvis([{elvis_style, dont_repeat_yourself, #{min_complexity => 10000}}]).
|
||||
|
||||
-include("emqx_mqtt.hrl").
|
||||
-include("emqx_schema.hrl").
|
||||
-include("logger.hrl").
|
||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||
-ifdef(TEST).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-endif.
|
||||
|
||||
%% APIs
|
||||
-export([
|
||||
list_raw/0,
|
||||
|
@ -68,8 +67,8 @@
|
|||
|
||||
-define(CONF_KEY_PATH, [listeners, '?', '?']).
|
||||
-define(TYPES_STRING, ["tcp", "ssl", "ws", "wss", "quic"]).
|
||||
-define(MARK_DEL, marked_for_deletion).
|
||||
-define(MARK_DEL_BIN, <<"marked_for_deletion">>).
|
||||
-define(MARK_DEL, ?TOMBSTONE).
|
||||
-define(MARK_DEL_BIN, ?TOMBSTONE_BIN).
|
||||
|
||||
-spec id_example() -> atom().
|
||||
id_example() -> 'tcp:default'.
|
||||
|
@ -857,9 +856,3 @@ unregister_ocsp_stapling_refresh(Type, Name) ->
|
|||
default_max_conn() ->
|
||||
%% TODO: <<"infinity">>
|
||||
5_000_000.
|
||||
|
||||
-ifdef(TEST).
|
||||
%% since it's a copy-paste. we need to ensure it's the same atom.
|
||||
ensure_same_atom_test() ->
|
||||
?assertEqual(?MARK_DEL, emqx_schema:tombstone()).
|
||||
-endif.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
-dialyzer(no_fail_call).
|
||||
-elvis([{elvis_style, invalid_dynamic_call, disable}]).
|
||||
|
||||
-include("emqx_schema.hrl").
|
||||
-include("emqx_authentication.hrl").
|
||||
-include("emqx_access_control.hrl").
|
||||
-include_lib("typerefl/include/types.hrl").
|
||||
|
@ -3193,7 +3194,7 @@ special_env(_Name) -> error.
|
|||
|
||||
%% The tombstone atom.
|
||||
tombstone() ->
|
||||
marked_for_deletion.
|
||||
?TOMBSTONE.
|
||||
|
||||
%% Make a map type, the value of which is allowed to be 'marked_for_deletion'
|
||||
%% 'marked_for_delition' is a special value which means the key is deleted.
|
||||
|
@ -3219,7 +3220,7 @@ get_tombstone_map_value_type(Schema) ->
|
|||
keep_default_tombstone(Map, _Opts) when is_map(Map) ->
|
||||
maps:filter(
|
||||
fun(Key, Value) ->
|
||||
Key =:= <<"default">> orelse Value =/= atom_to_binary(tombstone())
|
||||
Key =:= <<"default">> orelse Value =/= ?TOMBSTONE_BIN
|
||||
end,
|
||||
Map
|
||||
);
|
||||
|
|
|
@ -644,7 +644,7 @@ create(Path, Conf) ->
|
|||
wrap(emqx_conf:update(Path, {create, Conf}, ?OPTS(cluster))).
|
||||
|
||||
ensure_remove(Path) ->
|
||||
wrap(emqx_conf:update(Path, emqx_schema:tombstone(), ?OPTS(cluster))).
|
||||
wrap(emqx_conf:tombstone(Path, ?OPTS(cluster))).
|
||||
|
||||
wrap({error, {post_config_update, emqx_listeners, Reason}}) -> {error, Reason};
|
||||
wrap({error, {pre_config_update, emqx_listeners, Reason}}) -> {error, Reason};
|
||||
|
|
Loading…
Reference in New Issue