LibclusterMesh.Config (libcluster_mesh v0.1.0)

Copy Markdown View Source

Validated configuration shared by all mesh strategies.

Built once at strategy startup from the libcluster topology config. Invalid configuration — a missing key, a value of the wrong shape, or a key the strategy does not support — raises ArgumentError immediately with a descriptive message instead of failing silently at poll time.

Cluster members are selected either by hostname prefixes (hostnames, used by the named meshes: Tailscale, ZTL, NetBird) or by an IPv4 CIDR (cidr, used by plain WireGuard, which has no hostnames). The strategy decides which selector it requires.

iex> LibclusterMesh.Config.new!([node_basename: "myapp", hostnames: ["myapp-"]], "tailscale")
%LibclusterMesh.Config{
  node_basename: "myapp",
  hostnames: ["myapp-"],
  cli: "tailscale",
  socket: nil,
  interface: nil,
  cidr: nil,
  handshake_max_age: 180,
  runner: LibclusterMesh.Runner.SystemCmd,
  polling_interval: 5000,
  cmd_timeout: 10000
}

Summary

Types

How a strategy picks cluster members out of the mesh: by hostname prefix, or by IPv4 CIDR on meshes that have no hostnames.

t()

Functions

Builds a Config from a libcluster topology config keyword list.

Types

opts()

@type opts() :: [selector: selector(), socket: boolean()]
  • selector — member selection mode (default :hostnames)
  • socket — whether the strategy's daemon takes a socket path

selector()

@type selector() :: :hostnames | :cidr

How a strategy picks cluster members out of the mesh: by hostname prefix, or by IPv4 CIDR on meshes that have no hostnames.

t()

@type t() :: %LibclusterMesh.Config{
  cidr: LibclusterMesh.CIDR.t() | nil,
  cli: String.t(),
  cmd_timeout: pos_integer(),
  handshake_max_age: pos_integer(),
  hostnames: [String.t()],
  interface: String.t() | nil,
  node_basename: String.t(),
  polling_interval: pos_integer(),
  runner: module(),
  socket: String.t() | nil
}
  • node_basename — the part before @ shared by every node in the cluster
  • hostnames — mesh hostname prefixes that identify cluster members
  • cidr — parsed IPv4 CIDR selecting cluster members by mesh IP
  • cli — path to the mesh CLI binary (strategy provides its default)
  • socket — daemon socket path passed to the CLI (LOLIPOP ZTL only)
  • interface — network interface name (WireGuard only)
  • handshake_max_age — seconds since the last WireGuard handshake for a peer to still count as online (WireGuard only)
  • runner — module implementing LibclusterMesh.Runner
  • polling_interval — milliseconds between polls
  • cmd_timeout — milliseconds to wait for the CLI before giving up

Functions

new!(config, default_cli, opts \\ [])

@spec new!(Keyword.t(), String.t(), opts()) :: t()

Builds a Config from a libcluster topology config keyword list.

default_cli is the strategy's CLI default (e.g. "tailscale"). The selector decides which member-selection keys are required and which are refused: :hostnames requires a non-empty hostnames list, :cidr requires a valid cidr string and an interface name.

Raises ArgumentError when a required key is missing or any value has the wrong shape.