Simple implementation of gossip protocol. Infect state information around the cluster via gossipping.
ok = simple_gossip:set({<<"hello world">>, 0}).Or
ok = simple_gossip:set(fun({Text, Counter}) ->
case Counter rem 10 of
0 ->
no_change;
Rem ->
{change, {Text, Counter+(10-Rem)}}
end
end).{<<"hello world">>, 0} = simple_gossip:get().simple_gossip:status().Result can be
{ok, GossipVsn, LeaderNode, NodesInTheCluster}{error, gossip_vsn_mismatch, LeaderNode, NodesInTheCluster}: Nodes do not agree on cluster state (different GossipVsn). Try again later{error, {timeout, NodesDoNotResponseInTime}, LeaderNode, NodesInTheCluster}: Cannot retrieve information from cluster nodes in time
simple_gossip:subscribe(self()).It will send a message {data_changed, {<<"hello world">>,0}} to the given
process's inbox when the data has been changed.
simple_gossip:unsubscribe(self()).simple_gossip:join('test@cluster').simple_gossip:leave('test@cluster').$ rebar3 compile
$ rebar3 test