4.7 Module classy_node

Management of the local site and node.

4.7.1 Types

run_level_atom()
-type run_level_atom() :: stopped |
                          single |
                          cluster |
                          quorum.

4.7.2 Functions

n_restarts()
-spec n_restarts() -> {ok, non_neg_integer()} |
                      {error, nodedown}.

Return number of node restarts since creation of the site.

This value is monotonically increasing.

peer_info()
-spec peer_info() -> #{classy:site() =>
                           classy:peer_info()}.
parent_site()
-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.

the_site()
-spec the_site() -> {ok, classy:site()} | undefined.

Return ID of the local site.

the_cluster()
-spec the_cluster() -> {ok, classy:cluster_id()} |
                       undefined.

Return ID of the cluster that the local site currently belongs to.

maybe_init_the_site(MaybeSite)
-spec maybe_init_the_site(classy:site() |
                          undefined) -> ok.

Initialize local site and cluster.

Initialization of the site ID is done as following:

  1. If the site ID is already stored in the DB, then it is kept as is and nothing is done.
  2. If the value not stored, and is provided as a binary argument, then the argument is used as the new site ID.
  3. If the value is not stored, and the argument is 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.


JavaScript license information