diff --git a/src/classy_hook.erl b/src/classy_hook.erl index 5d5a84b..c46a251 100644 --- a/src/classy_hook.erl +++ b/src/classy_hook.erl @@ -28,7 +28,6 @@ Module responsible for managing the hooks. %%================================================================================ %% Type declarations %%================================================================================ - -define(tab, ?MODULE). -doc """ @@ -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(), diff --git a/src/classy_internal.hrl b/src/classy_internal.hrl index eecce67..a349f6d 100644 --- a/src/classy_internal.hrl +++ b/src/classy_internal.hrl @@ -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). diff --git a/src/classy_membership.erl b/src/classy_membership.erl index d147efd..0b1dffa 100644 --- a/src/classy_membership.erl +++ b/src/classy_membership.erl @@ -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 @@ -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 @@ -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), diff --git a/src/classy_node.erl b/src/classy_node.erl index 64eb616..ab055b7 100644 --- a/src/classy_node.erl +++ b/src/classy_node.erl @@ -605,7 +605,7 @@ ensure_the_id(Key, OnCreateHook, HookArgs, Default) -> [] -> 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,