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.
## 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
## - disc: both memory and disc
## - disc_only: disc only
##
## Default: ram
retainer.storage_type = ram
@ -56,4 +55,3 @@ Author
------
EMQ X Team

View File

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

View File

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

View File

@ -20,7 +20,7 @@ fields("emqx_retainer") ->
fields(mnesia_config) ->
[ {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)}
];