Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cets_status module #32

Merged
merged 9 commits into from
Sep 14, 2023
Merged

Add cets_status module #32

merged 9 commits into from
Sep 14, 2023

Conversation

arcusfelis
Copy link
Contributor

@arcusfelis arcusfelis commented Sep 11, 2023

Add cets_status module

The code gets a list of nodes, gets a list of servers and compares them.
After that it produces a map like:

-type info() :: #{
    %% Nodes that are connected to us and have the CETS disco process started.
    available_nodes := [node()],
    %% Nodes that do not respond to our pings.
    unavailable_nodes := [node()],
    %% Nodes with stopped disco
    remote_nodes_without_disco := [node()],
    %% Nodes that has our local tables running (but could also have some unknown tables).
    %% All joined nodes replicate data between each other.
    joined_nodes := [node()],
    %% Nodes that have more tables registered than the local node.
    remote_nodes_with_unknown_tables := [node()],
    remote_unknown_tables := [table_name()],
    %% Nodes that are available, but do not host one of our local tables.
    remote_nodes_with_missing_tables => [node()],
    remote_missing_tables := [table_name()],
    %% Nodes that replicate at least one of our local tables to a different list of nodes
    %% (could temporary happen during a netsplit)
    conflict_nodes := [node()],
    conflict_tables := [table_name()],
    %% Nodes that are extracted from the discovery backend.
    discovered_nodes := [node()],
    %% True, if discovery backend returned the list of nodes the last time we've tried
    %% to call it.
    discovery_works := boolean()
}.

The map could be used for getting the status of the cluster.

This functionality is used in MongooseIM like that esl/MongooseIM#4116

@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.77% 🎉

Comparison is base (ada5e7e) 96.61% compared to head (7281810) 97.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
+ Coverage   96.61%   97.38%   +0.77%     
==========================================
  Files           8        9       +1     
  Lines         531      612      +81     
==========================================
+ Hits          513      596      +83     
+ Misses         18       16       -2     
Files Changed Coverage Δ
src/cets.erl 100.00% <100.00%> (ø)
src/cets_call.erl 87.09% <100.00%> (+2.48%) ⬆️
src/cets_discovery.erl 93.57% <100.00%> (+1.71%) ⬆️
src/cets_status.erl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arcusfelis arcusfelis marked this pull request as ready for review September 12, 2023 08:34
Copy link
Contributor

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set operations happening here over maps and lists and proplists and maps of proplists and lists of maps and maps of maps of lists and just about every combination possible, is actually quite entertaining :D

Just a few minor comments.

src/cets_status.erl Outdated Show resolved Hide resolved
src/cets_status.erl Outdated Show resolved Hide resolved
src/cets_status.erl Outdated Show resolved Hide resolved
src/cets_status.erl Outdated Show resolved Hide resolved
Copy link
Contributor

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NelsonVides NelsonVides merged commit def7da2 into main Sep 14, 2023
8 checks passed
@NelsonVides NelsonVides deleted the cets_status branch September 14, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants