Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/classy_hook.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Module responsible for managing the hooks.
%%================================================================================
%% Type declarations
%%================================================================================

-define(tab, ?MODULE).

-doc """
Expand All @@ -55,16 +54,16 @@ It can be used to unregister the hook.
init() ->
ets:new(?tab, [named_table, ordered_set, public, {keypos, 1}]),
%% Default initialization:
classy:on_node_init(fun classy_builtin_hooks:gen_random_site_id/0, -100),
classy:post_kick(fun classy_builtin_hooks:maybe_reinitialize_after_kick/3, -100),
classy:on_node_init(fun classy_builtin_hooks:gen_random_site_id/0, ?min_hook_prio),
classy:post_kick(fun classy_builtin_hooks:maybe_reinitialize_after_kick/3, ?min_hook_prio),
%% Info logging:
classy:on_create_site(fun classy_builtin_hooks:log_create_site/1, 100),
classy:on_create_cluster(fun classy_builtin_hooks:log_create_cluster/2, 100),
classy:pre_join(fun classy_builtin_hooks:log_pre_join/4, 100),
classy:post_join(fun classy_builtin_hooks:log_post_join/3, -100),
classy:on_membership_change(fun classy_builtin_hooks:log_membership_change/4, 100),
classy:run_level(fun classy_builtin_hooks:log_run_level/2, -100),
classy:on_peer_connection_change(fun classy_builtin_hooks:log_peer_connection_change/5, 100),
classy:on_create_site(fun classy_builtin_hooks:log_create_site/1, ?max_hook_prio),
classy:on_create_cluster(fun classy_builtin_hooks:log_create_cluster/2, ?max_hook_prio),
classy:pre_join(fun classy_builtin_hooks:log_pre_join/4, ?max_hook_prio),
classy:post_join(fun classy_builtin_hooks:log_post_join/3, ?min_hook_prio),
classy:on_membership_change(fun classy_builtin_hooks:log_membership_change/4, ?max_hook_prio),
classy:run_level(fun classy_builtin_hooks:log_run_level/2, ?min_hook_prio),
classy:on_peer_connection_change(fun classy_builtin_hooks:log_peer_connection_change/5, ?max_hook_prio),
%% Discovery strategies:
classy_discovery_static:hook(),
classy_discovery_dns:hook(),
Expand Down
3 changes: 3 additions & 0 deletions src/classy_internal.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
-include_lib("snabbkaffe/include/trace.hrl").
-include("classy.hrl").

-define(max_hook_prio, 100000).
-define(min_hook_prio, -?max_hook_prio).

-define(on_node_init, on_node_init).
-define(on_create_cluster, on_create_cluster).
-define(on_create_site, on_create_site).
Expand Down
8 changes: 3 additions & 5 deletions src/classy_membership.erl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ cast_sync(Cluster, Site, SyncData) ->
%% @doc Send membership data to the process
-spec call_sync(classy:cluster_id(), classy:site(), sync_data()) -> ok.
call_sync(Cluster, Site, SyncData) ->
?tp(debug, classy_membership_call_sync,
?tp(classy_membership_call_sync,
#{ clus => Cluster
, local => Site
, clock => #cast_sync.c
Expand Down Expand Up @@ -536,7 +536,7 @@ handle_sync_in(Req, S0) ->
, acked = AckedOut
, data = Data
} = Req,
?tp(debug, classy_membership_sync_in,
?tp(classy_membership_sync_in,
#{ from => From
, since => Since
, clock => Cf
Expand Down Expand Up @@ -570,9 +570,7 @@ handle_sync_in(Req, S0) ->
-spec handle_sync_out(#s{}) -> #s{}.
handle_sync_out(S = #s{cluster = Cluster}) ->
SyncTargets = sync_targets(S),
?tp(debug, classy_membership_sync_out,
#{ targets => SyncTargets
}),
?tp(classy_membership_sync_out, #{targets => SyncTargets}),
maps:foreach(
fun(Site, Node) ->
Since = get_acked_out(Site, S),
Expand Down
2 changes: 1 addition & 1 deletion src/classy_node.erl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
IsConn = false
end,
case classy_table:lookup(?site_info, Site) of
[#site_info{isconn = IsConn, node = Node}] ->

Check warning on line 528 in src/classy_node.erl

View workflow job for this annotation

GitHub Actions / build (27, ubuntu-latest, 3.24.0)

variable 'Node' exported from 'case' (line 520, column 14)

Check warning on line 528 in src/classy_node.erl

View workflow job for this annotation

GitHub Actions / build (27, ubuntu-latest, 3.24.0)

variable 'IsConn' exported from 'case' (line 520, column 14)
%% No changes:
ok;
_ ->
Expand Down Expand Up @@ -605,7 +605,7 @@
[] ->
case Default of
undefined ->
Val = base64:encode(crypto:strong_rand_bytes(32));
Val = binary:encode_hex(crypto:strong_rand_bytes(32), uppercase);
Val when is_binary(Val) ->
ok
end,
Expand Down
Loading