Browse Source

Rename groups to pg.

Roberto Ostinelli 3 years ago
parent
commit
0383d029ec
8 changed files with 36 additions and 36 deletions
  1. 1 1
      src/syn.app.src
  2. 14 14
      src/syn.erl
  3. 2 2
      src/syn.hrl
  4. 2 2
      src/syn_backbone.erl
  5. 10 10
      src/syn_pg.erl
  6. 1 1
      src/syn_scope_sup.erl
  7. 5 5
      test/syn_pg_SUITE.erl
  8. 1 1
      test/syn_test_suite_helper.erl

+ 1 - 1
src/syn.app.src

@@ -4,7 +4,7 @@
         {vsn, "3.0.0"},
         {registered, [
             syn_backbone,
-            syn_groups,
+            syn_pg,
             syn_registry,
             syn_sup
         ]},

+ 14 - 14
src/syn.erl

@@ -422,22 +422,22 @@ send({Scope, Name}, Message) ->
 %% '''
 -spec members(Scope :: atom(), GroupName :: term()) -> [{Pid :: pid(), Meta :: term()}].
 members(Scope, GroupName) ->
-    syn_groups:members(Scope, GroupName).
+    syn_pg:members(Scope, GroupName).
 
 %% @doc Returns whether a `pid()' is a member of GroupName in the specified `Scope'.
 -spec is_member(Scope :: atom(), GroupName :: any(), Pid :: pid()) -> boolean().
 is_member(Scope, GroupName, Pid) ->
-    syn_groups:is_member(Scope, GroupName, Pid).
+    syn_pg:is_member(Scope, GroupName, Pid).
 
 %% @doc Returns the list of all members for GroupName in the specified `Scope' running on the local node.
 -spec local_members(Scope :: atom(), GroupName :: term()) -> [{Pid :: pid(), Meta :: term()}].
 local_members(Scope, GroupName) ->
-    syn_groups:local_members(Scope, GroupName).
+    syn_pg:local_members(Scope, GroupName).
 
 %% @doc Returns whether a `pid()' is a member of GroupName in the specified `Scope' running on the local node.
 -spec is_local_member(Scope :: atom(), GroupName :: any(), Pid :: pid()) -> boolean().
 is_local_member(Scope, GroupName, Pid) ->
-    syn_groups:is_local_member(Scope, GroupName, Pid).
+    syn_pg:is_local_member(Scope, GroupName, Pid).
 
 %% @equiv join(Scope, GroupName, Pid, undefined)
 %% @end
@@ -469,7 +469,7 @@ join(Scope, GroupName, Pid) ->
 %% '''
 -spec join(Scope :: atom(), GroupName :: any(), Pid :: pid(), Meta :: any()) -> ok | {error, Reason :: any()}.
 join(Scope, GroupName, Pid, Meta) ->
-    syn_groups:join(Scope, GroupName, Pid, Meta).
+    syn_pg:join(Scope, GroupName, Pid, Meta).
 
 %% @doc Removes a `pid()' from GroupName in the specified `Scope'.
 %%
@@ -482,7 +482,7 @@ join(Scope, GroupName, Pid, Meta) ->
 %% automatically from their groups.
 -spec leave(Scope :: atom(), GroupName :: any(), Pid :: pid()) -> ok | {error, Reason :: any()}.
 leave(Scope, GroupName, Pid) ->
-    syn_groups:leave(Scope, GroupName, Pid).
+    syn_pg:leave(Scope, GroupName, Pid).
 
 %% @doc Returns the count of all the groups for the specified `Scope'.
 %%
@@ -499,12 +499,12 @@ leave(Scope, GroupName, Pid) ->
 %% '''
 -spec group_count(Scope :: atom()) -> non_neg_integer().
 group_count(Scope) ->
-    syn_groups:count(Scope).
+    syn_pg:count(Scope).
 
 %% @doc Returns the count of all the groups for the specified `Scope' which have at least 1 process running on `Node'.
 -spec group_count(Scope :: atom(), Node :: node()) -> non_neg_integer().
 group_count(Scope, Node) ->
-    syn_groups:count(Scope, Node).
+    syn_pg:count(Scope, Node).
 
 %% @equiv group_count(Scope, node())
 %% @end
@@ -529,14 +529,14 @@ local_group_count(Scope) ->
 %% '''
 -spec group_names(Scope :: atom()) -> [GroupName :: term()].
 group_names(Scope) ->
-    syn_groups:group_names(Scope).
+    syn_pg:group_names(Scope).
 
 %% @doc Returns the group names for the specified `Scope' which have at least 1 process running on `Node'.
 %%
 %% The order of the group names is not guaranteed to be the same on all calls.
 -spec group_names(Scope :: atom(), Node :: node()) -> [GroupName :: term()].
 group_names(Scope, Node) ->
-    syn_groups:group_names(Scope, Node).
+    syn_pg:group_names(Scope, Node).
 
 %% @equiv group_names(Scope, node())
 %% @end
@@ -571,14 +571,14 @@ local_group_names(Scope) ->
 %% '''
 -spec publish(Scope :: atom(), GroupName :: any(), Message :: any()) -> {ok, RecipientCount :: non_neg_integer()}.
 publish(Scope, GroupName, Message) ->
-    syn_groups:publish(Scope, GroupName, Message).
+    syn_pg:publish(Scope, GroupName, Message).
 
 %% @doc Publish a message to all group members running on the local node in the specified `Scope'.
 %%
 %% Works similarly to {@link publish/3} for local processes.
 -spec local_publish(Scope :: atom(), GroupName :: any(), Message :: any()) -> {ok, RecipientCount :: non_neg_integer()}.
 local_publish(Scope, GroupName, Message) ->
-    syn_groups:local_publish(Scope, GroupName, Message).
+    syn_pg:local_publish(Scope, GroupName, Message).
 
 %% @equiv multi_call(Scope, GroupName, Message, 5000)
 %% @end
@@ -607,11 +607,11 @@ multi_call(Scope, GroupName, Message) ->
         BadReplies :: [{pid(), Meta :: term()}]
     }.
 multi_call(Scope, GroupName, Message, Timeout) ->
-    syn_groups:multi_call(Scope, GroupName, Message, Timeout).
+    syn_pg:multi_call(Scope, GroupName, Message, Timeout).
 
 %% @doc Allows a group member to reply to a multi call.
 %%
 %% See {@link multi_call/4} for info.
 -spec multi_call_reply(Caller :: term(), Reply :: any()) -> {syn_multi_call_reply, pid(), Reply :: any()}.
 multi_call_reply(Caller, Reply) ->
-    syn_groups:multi_call_reply(Caller, Reply).
+    syn_pg:multi_call_reply(Caller, Reply).

+ 2 - 2
src/syn.hrl

@@ -50,7 +50,7 @@
     Meta :: any(),
     Time :: integer()
 }.
--type syn_groups_entry() :: {
+-type syn_pg_entry() :: {
     {
         GroupName :: any(),
         Pid :: pid()
@@ -60,7 +60,7 @@
     MRef :: undefined | reference(),
     Node :: node()
 }.
--type syn_groups_tuple() :: {
+-type syn_pg_tuple() :: {
     GroupName :: any(),
     Pid :: pid(),
     Meta :: any(),

+ 2 - 2
src/syn_backbone.erl

@@ -101,8 +101,8 @@ handle_call({create_tables_for_scope, Scope}, _From, State) ->
     error_logger:info_msg("SYN[~s] Creating tables for scope '~s'", [?MODULE, Scope]),
     ensure_table_existence(set, syn_registry_by_name, Scope),
     ensure_table_existence(bag, syn_registry_by_pid, Scope),
-    ensure_table_existence(ordered_set, syn_groups_by_name, Scope),
-    ensure_table_existence(ordered_set, syn_groups_by_pid, Scope),
+    ensure_table_existence(ordered_set, syn_pg_by_name, Scope),
+    ensure_table_existence(ordered_set, syn_pg_by_pid, Scope),
     {reply, ok, State};
 
 handle_call(Request, From, State) ->

+ 10 - 10
src/syn_groups.erl → src/syn_pg.erl

@@ -23,7 +23,7 @@
 %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 %% THE SOFTWARE.
 %% ==========================================================================================================
--module(syn_groups).
+-module(syn_pg).
 -behaviour(syn_gen_scope).
 
 %% API
@@ -75,7 +75,7 @@ members(Scope, GroupName) ->
 
 -spec is_member(Scope :: atom(), GroupName :: term(), Pid :: pid()) -> boolean().
 is_member(Scope, GroupName, Pid) ->
-    case syn_backbone:get_table_name(syn_groups_by_name, Scope) of
+    case syn_backbone:get_table_name(syn_pg_by_name, Scope) of
         undefined ->
             error({invalid_scope, Scope});
 
@@ -92,7 +92,7 @@ local_members(Scope, GroupName) ->
 
 -spec do_get_members(Scope :: atom(), GroupName :: term(), NodeParam :: atom()) -> [{Pid :: pid(), Meta :: term()}].
 do_get_members(Scope, GroupName, NodeParam) ->
-    case syn_backbone:get_table_name(syn_groups_by_name, Scope) of
+    case syn_backbone:get_table_name(syn_pg_by_name, Scope) of
         undefined ->
             error({invalid_scope, Scope});
 
@@ -106,7 +106,7 @@ do_get_members(Scope, GroupName, NodeParam) ->
 
 -spec is_local_member(Scope :: atom(), GroupName :: term(), Pid :: pid()) -> boolean().
 is_local_member(Scope, GroupName, Pid) ->
-    case syn_backbone:get_table_name(syn_groups_by_name, Scope) of
+    case syn_backbone:get_table_name(syn_pg_by_name, Scope) of
         undefined ->
             error({invalid_scope, Scope});
 
@@ -135,7 +135,7 @@ join(Scope, GroupName, Pid, Meta) ->
 
 -spec leave(Scope :: atom(), GroupName :: term(), Pid :: pid()) -> ok | {error, Reason :: term()}.
 leave(Scope, GroupName, Pid) ->
-    case syn_backbone:get_table_name(syn_groups_by_name, Scope) of
+    case syn_backbone:get_table_name(syn_pg_by_name, Scope) of
         undefined ->
             error({invalid_scope, Scope});
 
@@ -177,7 +177,7 @@ group_names(Scope, Node) ->
 
 -spec group_names_ordset(Scope :: atom(), Node :: node()) -> ordsets:ordset(GroupName :: term()).
 group_names_ordset(Scope, NodeParam) ->
-    case syn_backbone:get_table_name(syn_groups_by_name, Scope) of
+    case syn_backbone:get_table_name(syn_pg_by_name, Scope) of
         undefined ->
             error({invalid_scope, Scope});
 
@@ -395,7 +395,7 @@ rebuild_monitors(#state{
     GroupsTuples = get_groups_tuples_for_node(node(), TableByName),
     do_rebuild_monitors(GroupsTuples, #{}, State).
 
--spec do_rebuild_monitors([syn_groups_tuple()], #{pid() => reference()}, #state{}) -> ok.
+-spec do_rebuild_monitors([syn_pg_tuple()], #{pid() => reference()}, #state{}) -> ok.
 do_rebuild_monitors([], _, _) -> ok;
 do_rebuild_monitors([{GroupName, Pid, Meta, Time} | T], NewMRefs, #state{
     table_by_name = TableByName,
@@ -454,7 +454,7 @@ do_join_on_node(GroupName, Pid, Meta, MRef, Reason, RequesterNode, CallbackMetho
     %% return
     {reply, {ok, {CallbackMethod, Time, TableByName, TableByPid}}, State}.
 
--spec get_groups_tuples_for_node(Node :: node(), TableByName :: atom()) -> [syn_groups_tuple()].
+-spec get_groups_tuples_for_node(Node :: node(), TableByName :: atom()) -> [syn_pg_tuple()].
 get_groups_tuples_for_node(Node, TableByName) ->
     ets:select(TableByName, [{
         {{'$1', '$2'}, '$3', '$4', '_', Node},
@@ -476,14 +476,14 @@ find_monitor_for_pid(Pid, TableByPid) when is_pid(Pid) ->
     end.
 
 -spec find_groups_entry_by_name_and_pid(GroupName :: term(), Pid :: pid(), TableByName :: atom()) ->
-    Entry :: syn_groups_entry() | undefined.
+    Entry :: syn_pg_entry() | undefined.
 find_groups_entry_by_name_and_pid(GroupName, Pid, TableByName) ->
     case ets:lookup(TableByName, {GroupName, Pid}) of
         [] -> undefined;
         [Entry] -> Entry
     end.
 
--spec find_groups_entries_by_pid(Pid :: pid(), TableByPid :: atom()) -> GroupEntries :: [syn_groups_entry()].
+-spec find_groups_entries_by_pid(Pid :: pid(), TableByPid :: atom()) -> GroupEntries :: [syn_pg_entry()].
 find_groups_entries_by_pid(Pid, TableByPid) when is_pid(Pid) ->
     ets:select(TableByPid, [{
         {{Pid, '_'}, '_', '_', '_', '_'},

+ 1 - 1
src/syn_scope_sup.erl

@@ -50,7 +50,7 @@ init([Scope]) ->
     %% set children
     Children = [
         scope_child_spec(syn_registry, Scope),
-        scope_child_spec(syn_groups, Scope)
+        scope_child_spec(syn_pg, Scope)
     ],
     {ok, {{one_for_one, 10, 10}, Children}}.
 

+ 5 - 5
test/syn_groups_SUITE.erl → test/syn_pg_SUITE.erl

@@ -23,7 +23,7 @@
 %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 %% THE SOFTWARE.
 %% ==========================================================================================================
--module(syn_groups_SUITE).
+-module(syn_pg_SUITE).
 
 %% callbacks
 -export([all/0]).
@@ -565,8 +565,8 @@ three_nodes_join_leave_and_monitor(Config) ->
     0 = rpc:call(SlaveNode2, syn, group_count, [scope_bc, SlaveNode2]),
 
     %% crash scope process to ensure that monitors get recreated
-    exit(whereis(syn_groups_scope_ab), kill),
-    syn_test_suite_helper:wait_process_name_ready(syn_groups_scope_ab),
+    exit(whereis(syn_pg_scope_ab), kill),
+    syn_test_suite_helper:wait_process_name_ready(syn_pg_scope_ab),
 
     %% kill process
     syn_test_suite_helper:kill_process(Pid),
@@ -727,7 +727,7 @@ three_nodes_cluster_changes(Config) ->
     syn_test_suite_helper:assert_cluster(node(), [SlaveNode1, SlaveNode2]),
     syn_test_suite_helper:assert_cluster(SlaveNode1, [node(), SlaveNode2]),
     syn_test_suite_helper:assert_cluster(SlaveNode2, [node(), SlaveNode1]),
-    syn_test_suite_helper:wait_process_name_ready(syn_groups_scope_all),
+    syn_test_suite_helper:wait_process_name_ready(syn_pg_scope_all),
 
     %% retrieve
     syn_test_suite_helper:assert_wait(
@@ -1186,7 +1186,7 @@ three_nodes_custom_event_handler_joined_left(Config) ->
 
     %% ---> don't call on monitor rebuild
     %% crash the scope process on local
-    syn_test_suite_helper:kill_process(syn_groups_scope_all),
+    syn_test_suite_helper:kill_process(syn_pg_scope_all),
 
     %% no messages
     syn_test_suite_helper:assert_wait(

+ 1 - 1
test/syn_test_suite_helper.erl

@@ -190,7 +190,7 @@ assert_registry_scope_subcluster(Node, Scope, ExpectedNodes) ->
     do_assert_scope_subcluster(syn_registry, Node, Scope, ExpectedNodes).
 
 assert_groups_scope_subcluster(Node, Scope, ExpectedNodes) ->
-    do_assert_scope_subcluster(syn_groups, Node, Scope, ExpectedNodes).
+    do_assert_scope_subcluster(syn_pg, Node, Scope, ExpectedNodes).
 
 assert_received_messages(Messages) ->
     assert_received_messages(Messages, []).