libcluster v3.1.1 Cluster.Supervisor

This module handles supervising the configured topologies, and is designed to support being started within your own supervision tree, as shown below:

defmodule MyApp.App do
  use Application

  def start(_type, _args) do
    topologies = [
      example: [
        strategy: Cluster.Strategy.Epmd,
        config: [hosts: [:"a@127.0.0.1", :"b@127.0.0.1"]],
      ]
    ]
    children = [
      {Cluster.Supervisor, [topologies, [name: MyApp.ClusterSupervisor]]},
      ..other children..
    ]
    Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
  end
end

The topologies configuration structure shown above can be built manually, like shown, so that you can load config at runtime in a way that best suits your application; or if you don't need to do any special config handling, you can use the Mix config file, and just use Application.get_env(:libcluster, :topologies). That config would look like so:

config :libcluster,
  topologies: [
    example: [...]
  ]

Use the method most convenient for you.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Start a new instance of this supervisor. This is the callback indicated in the child specification returned by child_spec/1. It expects a list of the form [config, supervisor_opts], or [config]. The former allows you to provide options for the supervisor like with Supervisor.start_link/3.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

start_link(args)

Start a new instance of this supervisor. This is the callback indicated in the child specification returned by child_spec/1. It expects a list of the form [config, supervisor_opts], or [config]. The former allows you to provide options for the supervisor like with Supervisor.start_link/3.