chore(gw): rename cm-registry shard name
This commit is contained in:
parent
c05ecdbcb8
commit
cf17a55079
|
@ -19,12 +19,8 @@
|
||||||
|
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
|
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
|
|
||||||
%% XXX: needless
|
|
||||||
%-export([is_enabled/0]).
|
|
||||||
|
|
||||||
-export([ register_channel/2
|
-export([ register_channel/2
|
||||||
, unregister_channel/2
|
, unregister_channel/2
|
||||||
]).
|
]).
|
||||||
|
@ -40,8 +36,7 @@
|
||||||
, code_change/3
|
, code_change/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
-define(CM_SHARD, emqx_gateway_cm_shard).
|
||||||
|
|
||||||
-define(LOCK, {?MODULE, cleanup_down}).
|
-define(LOCK, {?MODULE, cleanup_down}).
|
||||||
|
|
||||||
-record(channel, {chid, pid}).
|
-record(channel, {chid, pid}).
|
||||||
|
@ -113,8 +108,7 @@ handle_info({membership, {mnesia, down, Node}}, State = #{type := Type}) ->
|
||||||
Tab = tabname(Type),
|
Tab = tabname(Type),
|
||||||
global:trans({?LOCK, self()},
|
global:trans({?LOCK, self()},
|
||||||
fun() ->
|
fun() ->
|
||||||
%% FIXME: The shard name should be fixed later
|
mria:transaction(?CM_SHARD, fun cleanup_channels/2, [Node, Tab])
|
||||||
mria:transaction(?MODULE, fun cleanup_channels/2, [Node, Tab])
|
|
||||||
end),
|
end),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
|
|
|
@ -52,21 +52,6 @@
|
||||||
|
|
||||||
-record(emqx_sn_registry, {key, value}).
|
-record(emqx_sn_registry, {key, value}).
|
||||||
|
|
||||||
%% Mnesia bootstrap
|
|
||||||
%-export([mnesia/1]).
|
|
||||||
|
|
||||||
%-boot_mnesia({mnesia, [boot]}).
|
|
||||||
|
|
||||||
%%% @doc Create or replicate tables.
|
|
||||||
%-spec(mnesia(boot | copy) -> ok).
|
|
||||||
%mnesia(boot) ->
|
|
||||||
% %% Optimize storage
|
|
||||||
% StoreProps = [{ets, [{read_concurrency, true}]}],
|
|
||||||
% ok = mria:create_table(?MODULE, [
|
|
||||||
% {attributes, record_info(fields, emqx_sn_registry)},
|
|
||||||
% {ram_copies, [node()]},
|
|
||||||
% {storage_properties, StoreProps}]).
|
|
||||||
|
|
||||||
-type registry() :: {Tab :: atom(),
|
-type registry() :: {Tab :: atom(),
|
||||||
RegistryPid :: pid()}.
|
RegistryPid :: pid()}.
|
||||||
|
|
||||||
|
@ -145,8 +130,6 @@ init([InstaId, PredefTopics]) ->
|
||||||
{rlog_shard, ?SN_SHARD}
|
{rlog_shard, ?SN_SHARD}
|
||||||
]),
|
]),
|
||||||
ok = mria:wait_for_tables([Tab]),
|
ok = mria:wait_for_tables([Tab]),
|
||||||
% FIXME:
|
|
||||||
%ok = mria_rlog:wait_for_shards([?CM_SHARD], infinity),
|
|
||||||
MaxPredefId = lists:foldl(
|
MaxPredefId = lists:foldl(
|
||||||
fun(#{id := TopicId, topic := TopicName0}, AccId) ->
|
fun(#{id := TopicId, topic := TopicName0}, AccId) ->
|
||||||
TopicName = iolist_to_binary(TopicName0),
|
TopicName = iolist_to_binary(TopicName0),
|
||||||
|
|
Loading…
Reference in New Issue