feat(modules): manage mria tables explicitly during startup

This commit is contained in:
Andrew Mayorov 2024-01-30 20:56:33 +01:00
parent b6d77c164e
commit b07df487f0
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 6 additions and 7 deletions

View File

@ -25,12 +25,8 @@
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
-include_lib("emqx/include/emqx_hooks.hrl").
%% Mnesia bootstrap
-export([mnesia/1]).
-boot_mnesia({mnesia, [boot]}).
-export([
create_tables/0,
start_link/0,
on_message_publish/1
]).
@ -118,14 +114,16 @@
%%------------------------------------------------------------------------------
%% Mnesia bootstrap
%%------------------------------------------------------------------------------
mnesia(boot) ->
create_tables() ->
ok = mria:create_table(?TAB, [
{type, ordered_set},
{storage, disc_copies},
{local_content, true},
{record_name, delayed_message},
{attributes, record_info(fields, delayed_message)}
]).
]),
[?TAB].
%%------------------------------------------------------------------------------
%% Hooks

View File

@ -24,6 +24,7 @@
]).
start(_Type, _Args) ->
ok = mria:wait_for_tables(emqx_delayed:create_tables()),
{ok, Sup} = emqx_modules_sup:start_link(),
maybe_enable_modules(),
{ok, Sup}.