fix(emqx_retainer): remove disc_only option

This commit is contained in:
lafirest 2022-01-04 14:40:11 +08:00
parent 126924bc54
commit aacdc5c2f7
4 changed files with 13 additions and 17 deletions

View File

@ -13,10 +13,9 @@ etc/emqx_retainer.conf:
## Where to store the retained messages. ## Where to store the retained messages.
## Notice that all nodes in a cluster are to have the same storage_type. ## Notice that all nodes in a cluster are to have the same storage_type.
## ##
## Value: ram | disc | disc_only ## Value: ram | disc
## - ram: memory only ## - ram: memory only
## - disc: both memory and disc ## - disc: both memory and disc
## - disc_only: disc only
## ##
## Default: ram ## Default: ram
retainer.storage_type = ram retainer.storage_type = ram
@ -56,4 +55,3 @@ Author
------ ------
EMQ X Team EMQ X Team

View File

@ -74,7 +74,7 @@ emqx_retainer {
type = built_in_database type = built_in_database
## storage_type: ram | disc | disc_only ## storage_type: ram | disc
storage_type = ram storage_type = ram
## Maximum number of retained messages. 0 means no limit. ## Maximum number of retained messages. 0 means no limit.

View File

@ -45,24 +45,22 @@
create_resource(#{storage_type := StorageType}) -> create_resource(#{storage_type := StorageType}) ->
Copies = case StorageType of Copies = case StorageType of
ram -> ram_copies; ram -> ram_copies;
disc -> disc_copies; disc -> disc_copies
disc_only -> disc_only_copies
end, end,
TableType = case StorageType of
disc_only -> set;
_ -> ordered_set
end,
StoreProps = [{ets, [compressed, StoreProps = [{ets, [compressed,
{read_concurrency, true}, {read_concurrency, true},
{write_concurrency, true}]}, {write_concurrency, true}]},
{dets, [{auto_save, 1000}]}], {dets, [{auto_save, 1000}]}],
ok = mria:create_table(?TAB, [ ok = mria:create_table(?TAB, [
{type, TableType}, {type, ordered_set},
{rlog_shard, ?RETAINER_SHARD}, {rlog_shard, ?RETAINER_SHARD},
{storage, Copies}, {storage, Copies},
{record_name, retained}, {record_name, retained},
{attributes, record_info(fields, retained)}, {attributes, record_info(fields, retained)},
{storage_properties, StoreProps}]), {storage_properties, StoreProps}
]),
ok = mria_rlog:wait_for_shards([?RETAINER_SHARD], infinity), ok = mria_rlog:wait_for_shards([?RETAINER_SHARD], infinity),
case mnesia:table_info(?TAB, storage_type) of case mnesia:table_info(?TAB, storage_type) of
Copies -> ok; Copies -> ok;

View File

@ -20,7 +20,7 @@ fields("emqx_retainer") ->
fields(mnesia_config) -> fields(mnesia_config) ->
[ {type, ?TYPE(hoconsc:union([built_in_database]))} [ {type, ?TYPE(hoconsc:union([built_in_database]))}
, {storage_type, sc(hoconsc:union([ram, disc, disc_only]), ram)} , {storage_type, sc(hoconsc:union([ram, disc]), ram)}
, {max_retained_messages, sc(integer(), 0, fun is_pos_integer/1)} , {max_retained_messages, sc(integer(), 0, fun is_pos_integer/1)}
]; ];