Browse Source

Fix dialyzer.

Roberto Ostinelli 3 years ago
parent
commit
2103171fb2
6 changed files with 120 additions and 123 deletions
  1. 1 1
      src/syn.hrl
  2. 1 1
      src/syn_backbone.erl
  3. 64 62
      src/syn_gen_scope.erl
  4. 16 19
      src/syn_groups.erl
  5. 37 38
      src/syn_registry.erl
  6. 1 2
      test/syn_test_suite_helper.erl

+ 1 - 1
src/syn.hrl

@@ -69,7 +69,7 @@
     handler_state = undefined :: any(),
     scope = default :: atom(),
     process_name :: atom(),
-    nodes = #{} :: #{node() => pid()},
+    nodes_map = #{} :: #{node() => pid()},
     multicast_pid :: pid(),
     table_by_name :: atom(),
     table_by_pid :: atom()

+ 1 - 1
src/syn_backbone.erl

@@ -150,7 +150,7 @@ code_change(_OldVsn, State, _Extra) ->
 %% ===================================================================
 %% Internal
 %% ===================================================================
--spec ensure_table_exists(Type :: set | ordered_set, TableId :: atom(), Scope :: atom()) -> ok.
+-spec ensure_table_exists(Type :: ets:type(), TableId :: atom(), Scope :: atom()) -> ok.
 ensure_table_exists(Type, TableId, Scope) ->
     %% build name
     TableIdBin = atom_to_binary(TableId),

+ 64 - 62
src/syn_gen_scope.erl

@@ -52,33 +52,33 @@
 %% internal
 -export([multicast_loop/0]).
 
+%% includes
+-include("syn.hrl").
+
 %% callbacks
--callback init(State :: term()) ->
+-callback init(#state{}) ->
     {ok, HandlerState :: term()}.
 -callback handle_call(Request :: term(), From :: {pid(), Tag :: term()},
-    State :: term()) ->
-    {reply, Reply :: term(), NewState :: term()} |
-    {reply, Reply :: term(), NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), Reply :: term(), NewState :: term()} |
-    {stop, Reason :: term(), NewState :: term()}.
--callback handle_info(Info :: timeout | term(), State :: term()) ->
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), NewState :: term()}.
--callback save_remote_data(RemoteData :: any(), State :: term()) -> any().
--callback get_local_data(State :: term()) -> {ok, Data :: any()} | undefined.
--callback purge_local_data_for_node(Node :: node(), State :: term()) -> any().
-
-%% includes
--include("syn.hrl").
+    #state{}) ->
+    {reply, Reply :: term(), #state{}} |
+    {reply, Reply :: term(), #state{}, timeout() | hibernate | {continue, term()}} |
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), Reply :: term(), #state{}} |
+    {stop, Reason :: term(), #state{}}.
+-callback handle_info(Info :: timeout | term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
+-callback save_remote_data(RemoteData :: term(), #state{}) -> any().
+-callback get_local_data(#state{}) -> {ok, Data :: term()} | undefined.
+-callback purge_local_data_for_node(Node :: node(), #state{}) -> any().
 
 %% ===================================================================
 %% API
 %% ===================================================================
 -spec start_link(Handler :: module(), Scope :: atom()) ->
-    {ok, Pid :: pid()} | {error, {already_started, Pid :: pid()}} | {error, Reason :: any()}.
+    {ok, Pid :: pid()} | {error, {already_started, Pid :: pid()}} | {error, Reason :: term()}.
 start_link(Handler, Scope) when is_atom(Scope) ->
     %% build name
     HandlerBin = atom_to_binary(Handler),
@@ -96,11 +96,11 @@ get_subcluster_nodes(Handler, Scope) ->
         ProcessName -> gen_server:call(ProcessName, get_subcluster_nodes)
     end.
 
--spec call(Handler :: module(), Scope :: atom(), Message :: any()) -> Response :: any().
+-spec call(Handler :: module(), Scope :: atom(), Message :: term()) -> Response :: term().
 call(Handler, Scope, Message) ->
     call(Handler, node(), Scope, Message).
 
--spec call(Handler :: module(), Node :: atom(), Scope :: atom(), Message :: any()) -> Response :: any().
+-spec call(Handler :: module(), Node :: atom(), Scope :: atom(), Message :: term()) -> Response :: term().
 call(Handler, Node, Scope, Message) ->
     case get_process_name_for_scope(Handler, Scope) of
         undefined -> error({invalid_scope, Scope});
@@ -110,19 +110,19 @@ call(Handler, Node, Scope, Message) ->
 %% ===================================================================
 %% In-Process API
 %% ===================================================================
--spec broadcast(Message :: any(), #state{}) -> any().
+-spec broadcast(Message :: term(), #state{}) -> any().
 broadcast(Message, State) ->
     broadcast(Message, [], State).
 
--spec broadcast(Message :: any(), ExcludedNodes :: [node()], #state{}) -> any().
+-spec broadcast(Message :: term(), ExcludedNodes :: [node()], #state{}) -> any().
 broadcast(Message, ExcludedNodes, #state{multicast_pid = MulticastPid} = State) ->
     MulticastPid ! {broadcast, Message, ExcludedNodes, State}.
 
--spec broadcast_all_cluster(Message :: any(), #state{}) -> any().
+-spec broadcast_all_cluster(Message :: term(), #state{}) -> any().
 broadcast_all_cluster(Message, #state{multicast_pid = MulticastPid} = State) ->
     MulticastPid ! {broadcast_all_cluster, Message, State}.
 
--spec send_to_node(RemoteNode :: node(), Message :: any(), #state{}) -> any().
+-spec send_to_node(RemoteNode :: node(), Message :: term(), #state{}) -> any().
 send_to_node(RemoteNode, Message, #state{process_name = ProcessName}) ->
     erlang:send({ProcessName, RemoteNode}, Message, [noconnect]).
 
@@ -135,10 +135,8 @@ send_to_node(RemoteNode, Message, #state{process_name = ProcessName}) ->
 %% ----------------------------------------------------------------------------------------------------------
 -spec init([term()]) ->
     {ok, #state{}} |
-    {ok, #state{}, Timeout :: non_neg_integer()} |
-    ignore |
-    {stop, Reason :: any()} |
-    {continue, any()}.
+    {ok, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term()} | ignore.
 init([Handler, Scope, ProcessName]) ->
     %% monitor nodes
     ok = net_kernel:monitor_nodes(true),
@@ -165,17 +163,17 @@ init([Handler, Scope, ProcessName]) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Call messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_call(Request :: term(), From :: {pid(), Tag :: term()},
-    State :: term()) ->
-    {reply, Reply :: term(), NewState :: term()} |
-    {reply, Reply :: term(), NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), Reply :: term(), NewState :: term()} |
-    {stop, Reason :: term(), NewState :: term()}.
+-spec handle_call(Request :: term(), From :: {pid(), Tag :: term()}, #state{}) ->
+    {reply, Reply :: term(), #state{}} |
+    {reply, Reply :: term(), #state{}, timeout() | hibernate | {continue, term()}} |
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), Reply :: term(), #state{}} |
+    {stop, Reason :: term(), #state{}}.
 handle_call(get_subcluster_nodes, _From, #state{
-    nodes = Nodes
+    nodes_map = NodesMap
 } = State) ->
+    Nodes = maps:keys(NodesMap),
     {reply, Nodes, State};
 
 handle_call(Request, From, #state{handler = Handler} = State) ->
@@ -184,24 +182,24 @@ handle_call(Request, From, #state{handler = Handler} = State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Cast messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_cast(Request :: term(), State :: term()) ->
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), NewState :: term()}.
+-spec handle_cast(Request :: term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
 handle_cast(Msg, #state{handler = Handler} = State) ->
     Handler:handle_cast(Msg, State).
 
 %% ----------------------------------------------------------------------------------------------------------
 %% Info messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_info(Info :: timeout | term(), State :: term()) ->
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), NewState :: term()}.
+-spec handle_info(Info :: timeout | term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
 handle_info({'3.0', discover, RemoteScopePid}, #state{
     handler = Handler,
     scope = Scope,
-    nodes = Nodes
+    nodes_map = NodesMap
 } = State) ->
     RemoteScopeNode = node(RemoteScopePid),
     error_logger:info_msg("SYN[~s] Received DISCOVER request from node '~s'for ~s and scope '~s'",
@@ -211,7 +209,7 @@ handle_info({'3.0', discover, RemoteScopePid}, #state{
     {ok, LocalData} = Handler:get_local_data(State),
     send_to_node(RemoteScopeNode, {'3.0', ack_sync, self(), LocalData}, State),
     %% is this a new node?
-    case maps:is_key(RemoteScopeNode, Nodes) of
+    case maps:is_key(RemoteScopeNode, NodesMap) of
         true ->
             %% already known, ignore
             {noreply, State};
@@ -219,12 +217,12 @@ handle_info({'3.0', discover, RemoteScopePid}, #state{
         false ->
             %% monitor
             _MRef = monitor(process, RemoteScopePid),
-            {noreply, State#state{nodes = Nodes#{RemoteScopeNode => RemoteScopePid}}}
+            {noreply, State#state{nodes_map = NodesMap#{RemoteScopeNode => RemoteScopePid}}}
     end;
 
 handle_info({'3.0', ack_sync, RemoteScopePid, Data}, #state{
     handler = Handler,
-    nodes = Nodes,
+    nodes_map = NodesMap,
     scope = Scope
 } = State) ->
     RemoteScopeNode = node(RemoteScopePid),
@@ -234,7 +232,7 @@ handle_info({'3.0', ack_sync, RemoteScopePid, Data}, #state{
     %% save remote data
     Handler:save_remote_data(Data, State),
     %% is this a new node?
-    case maps:is_key(RemoteScopeNode, Nodes) of
+    case maps:is_key(RemoteScopeNode, NodesMap) of
         true ->
             %% already known
             {noreply, State};
@@ -246,23 +244,23 @@ handle_info({'3.0', ack_sync, RemoteScopePid, Data}, #state{
             {ok, LocalData} = Handler:get_local_data(State),
             send_to_node(RemoteScopeNode, {'3.0', ack_sync, self(), LocalData}, State),
             %% return
-            {noreply, State#state{nodes = Nodes#{RemoteScopeNode => RemoteScopePid}}}
+            {noreply, State#state{nodes_map = NodesMap#{RemoteScopeNode => RemoteScopePid}}}
     end;
 
 handle_info({'DOWN', MRef, process, Pid, Reason}, #state{
     handler = Handler,
     scope = Scope,
-    nodes = Nodes
+    nodes_map = NodesMap
 } = State) when node(Pid) =/= node() ->
     %% scope process down
     RemoteNode = node(Pid),
-    case maps:take(RemoteNode, Nodes) of
-        {Pid, Nodes1} ->
+    case maps:take(RemoteNode, NodesMap) of
+        {Pid, NodesMap1} ->
             error_logger:info_msg("SYN[~s] Scope Process '~s' for ~s is DOWN on node '~s': ~p",
                 [node(), Scope, Handler, RemoteNode, Reason]
             ),
             Handler:purge_local_data_for_node(RemoteNode, State),
-            {noreply, State#state{nodes = Nodes1}};
+            {noreply, State#state{nodes_map = NodesMap1}};
 
         error ->
             %% relay to handler
@@ -289,6 +287,10 @@ handle_info(Info, #state{handler = Handler} = State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Continue messages
 %% ----------------------------------------------------------------------------------------------------------
+-spec handle_continue(Info :: term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
 handle_continue(after_init, #state{
     handler = Handler,
     scope = Scope
@@ -300,15 +302,15 @@ handle_continue(after_init, #state{
 %% ----------------------------------------------------------------------------------------------------------
 %% Terminate
 %% ----------------------------------------------------------------------------------------------------------
--spec terminate(Reason :: any(), #state{}) -> terminated.
+-spec terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()), #state{}) -> any().
 terminate(Reason, #state{handler = Handler}) ->
-    error_logger:info_msg("SYN[~s] ~s terminating with reason: ~p", [node(), Handler, Reason]),
-    terminated.
+    error_logger:info_msg("SYN[~s] ~s terminating with reason: ~p", [node(), Handler, Reason]).
 
 %% ----------------------------------------------------------------------------------------------------------
 %% Convert process state when code is changed.
 %% ----------------------------------------------------------------------------------------------------------
--spec code_change(OldVsn :: any(), #state{}, Extra :: any()) -> {ok, #state{}}.
+-spec code_change(OldVsn :: (term() | {down, term()}), #state{}, Extra :: term()) ->
+    {ok, NewState :: term()} | {error, Reason :: term()}.
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
@@ -322,10 +324,10 @@ get_process_name_for_scope(Handler, Scope) ->
 -spec multicast_loop() -> terminated.
 multicast_loop() ->
     receive
-        {broadcast, Message, ExcludedNodes, #state{process_name = ProcessName, nodes = Nodes}} ->
+        {broadcast, Message, ExcludedNodes, #state{process_name = ProcessName, nodes_map = NodesMap}} ->
             lists:foreach(fun(RemoteNode) ->
                 erlang:send({ProcessName, RemoteNode}, Message, [noconnect])
-            end, maps:keys(Nodes) -- ExcludedNodes),
+            end, maps:keys(NodesMap) -- ExcludedNodes),
             multicast_loop();
 
         {broadcast_all_cluster, Message, #state{process_name = ProcessName}} ->

+ 16 - 19
src/syn_groups.erl

@@ -51,9 +51,9 @@
 start_link(Scope) when is_atom(Scope) ->
     syn_gen_scope:start_link(?MODULE, Scope).
 
--spec get_subcluster_nodes(#state{}) -> [node()].
-get_subcluster_nodes(State) ->
-    syn_gen_scope:get_subcluster_nodes(?MODULE, State).
+-spec get_subcluster_nodes(Scope :: atom()) -> [node()].
+get_subcluster_nodes(Scope) ->
+    syn_gen_scope:get_subcluster_nodes(?MODULE, Scope).
 
 %% ===================================================================
 %% Callbacks
@@ -62,8 +62,8 @@ get_subcluster_nodes(State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Init
 %% ----------------------------------------------------------------------------------------------------------
--spec init(State :: term()) -> {ok, State :: term()}.
-init(State) ->
+-spec init(#state{}) -> {ok, HandlerState :: term()}.
+init(_State) ->
     HandlerState = #{},
     %% init
     {ok, HandlerState}.
@@ -71,15 +71,13 @@ init(State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Call messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_call(Request :: term(), From :: {pid(), Tag :: term()},
-    State :: term()) ->
-    {reply, Reply :: term(), NewState :: term()} |
-    {reply, Reply :: term(), NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), Reply :: term(), NewState :: term()} |
-    {stop, Reason :: term(), NewState :: term()}.
-
+-spec handle_call(Request :: term(), From :: {pid(), Tag :: term()}, #state{}) ->
+    {reply, Reply :: term(), #state{}} |
+    {reply, Reply :: term(), #state{}, timeout() | hibernate | {continue, term()}} |
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), Reply :: term(), #state{}} |
+    {stop, Reason :: term(), #state{}}.
 handle_call(Request, From, State) ->
     error_logger:warning_msg("SYN[~s] Received from ~p an unknown call message: ~p", [node(), From, Request]),
     {reply, undefined, State}.
@@ -87,11 +85,10 @@ handle_call(Request, From, State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Info messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_info(Info :: timeout | term(), State :: term()) ->
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), NewState :: term()}.
-
+-spec handle_info(Info :: timeout | term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
 handle_info(Info, State) ->
     error_logger:warning_msg("SYN[~s] Received an unknown info message: ~p", [node(), Info]),
     {noreply, State}.

+ 37 - 38
src/syn_registry.erl

@@ -56,19 +56,19 @@
 %% API
 %% ===================================================================
 -spec start_link(Scope :: atom()) ->
-    {ok, Pid :: pid()} | {error, {already_started, Pid :: pid()}} | {error, Reason :: any()}.
+    {ok, Pid :: pid()} | {error, {already_started, Pid :: pid()}} | {error, Reason :: term()}.
 start_link(Scope) when is_atom(Scope) ->
     syn_gen_scope:start_link(?MODULE, Scope).
 
--spec get_subcluster_nodes(#state{}) -> [node()].
-get_subcluster_nodes(State) ->
-    syn_gen_scope:get_subcluster_nodes(?MODULE, State).
+-spec get_subcluster_nodes(Scope :: atom()) -> [node()].
+get_subcluster_nodes(Scope) ->
+    syn_gen_scope:get_subcluster_nodes(?MODULE, Scope).
 
--spec lookup(Name :: any()) -> {pid(), Meta :: any()} | undefined.
+-spec lookup(Name :: term()) -> {pid(), Meta :: term()} | undefined.
 lookup(Name) ->
     lookup(default, Name).
 
--spec lookup(Scope :: atom(), Name :: any()) -> {pid(), Meta :: any()} | undefined.
+-spec lookup(Scope :: atom(), Name :: term()) -> {pid(), Meta :: term()} | undefined.
 lookup(Scope, Name) ->
     case syn_backbone:get_table_name(syn_registry_by_name, Scope) of
         undefined ->
@@ -81,18 +81,18 @@ lookup(Scope, Name) ->
             end
     end.
 
--spec register(Name :: any(), Pid :: pid()) -> ok | {error, Reason :: any()}.
+-spec register(Name :: term(), Pid :: pid()) -> ok | {error, Reason :: term()}.
 register(Name, Pid) ->
     register(default, Name, Pid, undefined).
 
--spec register(NameOrScope :: any(), PidOrName :: any(), MetaOrPid :: any()) -> ok | {error, Reason :: any()}.
+-spec register(NameOrScope :: term(), PidOrName :: term(), MetaOrPid :: term()) -> ok | {error, Reason :: term()}.
 register(Name, Pid, Meta) when is_pid(Pid) ->
     register(default, Name, Pid, Meta);
 
 register(Scope, Name, Pid) when is_pid(Pid) ->
     register(Scope, Name, Pid, undefined).
 
--spec register(Scope :: atom(), Name :: any(), Pid :: pid(), Meta :: any()) -> ok | {error, Reason :: any()}.
+-spec register(Scope :: atom(), Name :: term(), Pid :: pid(), Meta :: term()) -> ok | {error, Reason :: term()}.
 register(Scope, Name, Pid, Meta) ->
     Node = node(Pid),
     case syn_gen_scope:call(?MODULE, Node, Scope, {register_on_owner, node(), Name, Pid, Meta}) of
@@ -108,11 +108,11 @@ register(Scope, Name, Pid, Meta) ->
             Response
     end.
 
--spec unregister(Name :: any()) -> ok | {error, Reason :: any()}.
+-spec unregister(Name :: term()) -> ok | {error, Reason :: term()}.
 unregister(Name) ->
     unregister(default, Name).
 
--spec unregister(Scope :: atom(), Name :: any()) -> ok | {error, Reason :: any()}.
+-spec unregister(Scope :: atom(), Name :: term()) -> ok | {error, Reason :: term()}.
 unregister(Scope, Name) ->
     case syn_backbone:get_table_name(syn_registry_by_name, Scope) of
         undefined ->
@@ -170,7 +170,7 @@ count(Scope, Node) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Init
 %% ----------------------------------------------------------------------------------------------------------
--spec init(State :: term()) -> {ok, State :: term()}.
+-spec init(#state{}) -> {ok, HandlerState :: term()}.
 init(State) ->
     HandlerState = #{},
     %% rebuild
@@ -181,14 +181,13 @@ init(State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Call messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_call(Request :: term(), From :: {pid(), Tag :: term()},
-    State :: term()) ->
-    {reply, Reply :: term(), NewState :: term()} |
-    {reply, Reply :: term(), NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), Reply :: term(), NewState :: term()} |
-    {stop, Reason :: term(), NewState :: term()}.
+-spec handle_call(Request :: term(), From :: {pid(), Tag :: term()}, #state{}) ->
+    {reply, Reply :: term(), #state{}} |
+    {reply, Reply :: term(), #state{}, timeout() | hibernate | {continue, term()}} |
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), Reply :: term(), #state{}} |
+    {stop, Reason :: term(), #state{}}.
 handle_call({register_on_owner, RequesterNode, Name, Pid, Meta}, _From, #state{
     scope = Scope,
     table_by_name = TableByName,
@@ -265,10 +264,10 @@ handle_call(Request, From, State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Info messages
 %% ----------------------------------------------------------------------------------------------------------
--spec handle_info(Info :: timeout | term(), State :: term()) ->
-    {noreply, NewState :: term()} |
-    {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
-    {stop, Reason :: term(), NewState :: term()}.
+-spec handle_info(Info :: timeout | term(), #state{}) ->
+    {noreply, #state{}} |
+    {noreply, #state{}, timeout() | hibernate | {continue, term()}} |
+    {stop, Reason :: term(), #state{}}.
 handle_info({'3.0', sync_register, Scope, Name, Pid, Meta, Time}, State) ->
     handle_registry_sync(Scope, Name, Pid, Meta, Time, State),
     {noreply, State};
@@ -315,18 +314,18 @@ handle_info(Info, State) ->
 %% ----------------------------------------------------------------------------------------------------------
 %% Data
 %% ----------------------------------------------------------------------------------------------------------
--spec get_local_data(State :: term()) -> {ok, Data :: any()} | undefined.
+-spec get_local_data(#state{}) -> {ok, Data :: term()} | undefined.
 get_local_data(#state{table_by_name = TableByName}) ->
     {ok, get_registry_tuples_for_node(node(), TableByName)}.
 
--spec save_remote_data(RemoteData :: any(), State :: term()) -> any().
+-spec save_remote_data(RemoteData :: term(), #state{}) -> any().
 save_remote_data(RegistryTuplesOfRemoteNode, #state{scope = Scope} = State) ->
     %% insert tuples
     lists:foreach(fun({Name, Pid, Meta, Time}) ->
         handle_registry_sync(Scope, Name, Pid, Meta, Time, State)
     end, RegistryTuplesOfRemoteNode).
 
--spec purge_local_data_for_node(Node :: node(), State :: term()) -> any().
+-spec purge_local_data_for_node(Node :: node(), #state{}) -> any().
 purge_local_data_for_node(Node, #state{
     scope = Scope,
     table_by_name = TableByName,
@@ -363,7 +362,7 @@ get_registry_tuples_for_node(Node, TableByName) ->
         [{{'$1', '$2', '$3', '$4'}}]
     }]).
 
--spec find_registry_entry_by_name(Name :: any(), TableByName :: atom()) ->
+-spec find_registry_entry_by_name(Name :: term(), TableByName :: atom()) ->
     Entry :: syn_registry_entry() | undefined.
 find_registry_entry_by_name(Name, TableByName) ->
     case ets:lookup(TableByName, Name) of
@@ -408,9 +407,9 @@ maybe_demonitor(Pid, TableByPid) ->
     end.
 
 -spec add_to_local_table(
-    Name :: any(),
+    Name :: term(),
     Pid :: pid(),
-    Meta :: any(),
+    Meta :: term(),
     Time :: integer(),
     MRef :: undefined | reference(),
     TableByName :: atom(),
@@ -424,7 +423,7 @@ add_to_local_table(Name, Pid, Meta, Time, MRef, TableByName, TableByPid) ->
     true = ets:insert(TableByPid, {Pid, Name, Meta, Time, MRef, node(Pid)}).
 
 -spec remove_from_local_table(
-    Name :: any(),
+    Name :: term(),
     Pid :: pid(),
     TableByName :: atom(),
     TableByPid :: atom()
@@ -434,11 +433,11 @@ remove_from_local_table(Name, Pid, TableByName, TableByPid) ->
     true = ets:match_delete(TableByPid, {Pid, Name, '_', '_', '_', '_'}).
 
 -spec update_local_table(
-    Name :: any(),
+    Name :: term(),
     PreviousPid :: pid(),
     {
         Pid :: pid(),
-        Meta :: any(),
+        Meta :: term(),
         Time :: integer(),
         MRef :: undefined | reference()
     },
@@ -465,9 +464,9 @@ purge_registry_for_remote_node(Scope, Node, TableByName, TableByPid) when Node =
 
 -spec handle_registry_sync(
     Scope :: atom(),
-    Name :: any(),
+    Name :: term(),
     Pid :: pid(),
-    Meta :: any(),
+    Meta :: term(),
     Time :: non_neg_integer(),
     #state{}
 ) -> any().
@@ -510,9 +509,9 @@ handle_registry_sync(Scope, Name, Pid, Meta, Time, #state{
 
 -spec resolve_conflict(
     Scope :: atom(),
-    Name :: any(),
-    {Pid :: pid(), Meta :: any(), Time :: non_neg_integer()},
-    {TablePid :: pid(), TableMeta :: any(), TableTime :: non_neg_integer(), TableMRef :: reference()},
+    Name :: term(),
+    {Pid :: pid(), Meta :: term(), Time :: non_neg_integer()},
+    {TablePid :: pid(), TableMeta :: term(), TableTime :: non_neg_integer(), TableMRef :: reference()},
     #state{}
 ) -> any().
 resolve_conflict(Scope, Name, {Pid, Meta, Time}, {TablePid, TableMeta, TableTime, TableMRef}, #state{

+ 1 - 2
test/syn_test_suite_helper.erl

@@ -249,8 +249,7 @@ process_main() ->
 do_assert_scope_subcluster(Module, Node, Scope, ExpectedNodes) ->
     do_assert_scope_subcluster(Module, Node, Scope, ExpectedNodes, os:system_time(millisecond)).
 do_assert_scope_subcluster(Module, Node, Scope, ExpectedNodes, StartAt) ->
-    NodesMap = rpc:call(Node, Module, get_subcluster_nodes, [Scope]),
-    Nodes = maps:keys(NodesMap),
+    Nodes = rpc:call(Node, Module, get_subcluster_nodes, [Scope]),
     case do_assert_cluster(Nodes, ExpectedNodes, StartAt) of
         continue -> do_assert_scope_subcluster(Module, Node, Scope, ExpectedNodes, StartAt);
         _ -> ok