View Source Cluster-Bot
Introduction • Installation • Getting Started
Introduction
ClusterBot
is a small elixir library to manage nodes and automatically reconnect if a node disconnects thus trying to maintain a constant pool of nodes.
Nodes are cached using Cachex and stored to the file system.
If a node is not reachable in 24 hours, it will permamently be removed from the cache.
Installation
Add cluster_bot
to your list of dependencies in mix.exs
:
def deps do
[
{:cluster_bot, "~> 0.2.0"}
]
end
Getting Started
The ClusterMonitor implements the GenServer behavior and is thus usable with a standard OTP supervision tree.
children = [
ClusterMonitor,
...
]
Supervisor.start_link(children, [
strategy: :one_for_one,
name: Your.Supervisor
])
You are also able to change some parameters in you config. This is purly optional and mainly involves interval times:
config :cluster_bot,
fetch_interval: 5_000,
reconnect_interval: 5_000,
refresh_interval: 60_000,
output: "cache.bin"
Get oldest Node
In some cases it might be necessary to get the oldest node as it often holds the most amount of data. ClusterMonitor provides a function to get the oldest node.
node = ClusterMonitor.oldest_node() # or nil if current node is oldest node