classy_node ¶Management of the local site and node.
-spec n_restarts() -> {ok, non_neg_integer()} |
{error, nodedown}.
Return number of node restarts since creation of the site.
This value is monotonically increasing.
-spec peer_info() -> #{classy:site() =>
classy:peer_info()}.
-spec parent_site() -> {ok, classy:site()} | undefined.
Return ID of the site that invited us to the_cluster.
The return value could be equal to {ok, the_site()} for the site that originally created the cluster.
undefined return value means the local site is not initialized.
-spec the_site() -> {ok, classy:site()} | undefined.
Return ID of the local site.
-spec the_cluster() -> {ok, classy:cluster_id()} |
undefined.
Return ID of the cluster that the local site currently belongs to.
-spec maybe_init_the_site(classy:site() |
undefined) -> ok.
Initialize local site and cluster.
Initialization of the site ID is done as following:
undefined,
then site ID is initialized to a random value.
When site ID changes, classy:on_create_site/2 callback runs.
Cluster ID initialization logic is similar,
but there’s no way to customize the initial value.
That has to do with the classy’s requirement
that cluster IDs change to an entirely new value when site is kicked.
classy:on_create_cluster/2 hook is called for the new clusters.