refactor: make dialyzer happy

This commit is contained in:
zmstone 2024-06-19 10:03:28 +02:00
parent 54fc605cc5
commit f0e5721959
1 changed files with 15 additions and 6 deletions

View File

@ -24,11 +24,18 @@
version/0, version/0,
version_with_prefix/0, version_with_prefix/0,
vsn_compare/1, vsn_compare/1,
vsn_compare/2 vsn_compare/2,
on_load/0
]). ]).
-on_load(on_load/0).
-include("emqx_release.hrl"). -include("emqx_release.hrl").
-ifndef(EMQX_RELEASE_EDITION).
-define(EMQX_RELEASE_EDITION, ce).
-endif.
-define(EMQX_DESCS, #{ -define(EMQX_DESCS, #{
ee => "EMQX Enterprise", ee => "EMQX Enterprise",
ce => "EMQX" ce => "EMQX"
@ -49,6 +56,11 @@
ce => "v" ce => "v"
}). }).
%% @hidden Initialize edition. Almost static. use persistent_term to trick compiler.
-spec on_load() -> ok.
on_load() ->
persistent_term:put('EMQX_RELEASE_EDITION', ?EMQX_RELEASE_EDITION).
%% @doc Return EMQX description. %% @doc Return EMQX description.
description() -> description() ->
maps:get(edition(), ?EMQX_DESCS). maps:get(edition(), ?EMQX_DESCS).
@ -57,11 +69,8 @@ description() ->
%% Read info from persistent_term at runtime. %% Read info from persistent_term at runtime.
%% Or meck this function to run tests for another edition. %% Or meck this function to run tests for another edition.
-spec edition() -> ce | ee. -spec edition() -> ce | ee.
-ifdef(EMQX_RELEASE_EDITION). edition() ->
edition() -> ?EMQX_RELEASE_EDITION. persistent_term:get('EMQX_RELEASE_EDITION').
-else.
edition() -> ce.
-endif.
%% @doc Return EMQX version prefix string. %% @doc Return EMQX version prefix string.
edition_vsn_prefix() -> edition_vsn_prefix() ->