Sovite.Core.Cluster.SharedConfig (sovite v0.6.0)

Copy Markdown View Source

The configuration the nodes of a cluster share: a TOML file, the same on every node, under each node's own config file.

[cluster]
shared_config = "/var/lib/sovite/cluster.toml"

sovitectl cluster config push FILE (or POST /api/cluster/config) sends a new version to every node. Each node checks it together with its own file (Sovite.Core.Config.load_with_shared/2), stores it, and reloads; a node whose own settings do not work with it keeps the version it has, and logs why. The settings of a node's own file win over the shared ones (see Sovite.Core.Config.load/1), so each node keeps its own [server] hostname, listeners, [cluster] table, and so on, and the shared file holds the rest: domains, routing, restrictions, limits, tenants, and IP pools.

Each version has a number, one more than the newest the pushing node knew, and the name of that node. A newer version replaces an older one; of two with the same number, the one from the node whose name sorts last wins. A node that comes back, or joins, gets the newest version from the nodes it meets.

The file starts with a comment that holds the version:

# sovite shared config: version 3, from mx1@10.0.0.1, 2026-10-18T20:00:00Z

Summary

Functions

Whether the server running with config file config_path can take content as its shared configuration. Returns :ok or the reasons.

Whether a is newer than b (or b is nil).

The version stored at path, or nil when there is none.

Stores shared at path, replacing the file at once.

Types

t()

@type t() :: %{version: non_neg_integer(), origin: String.t(), content: String.t()}

Functions

check(config_path, content)

@spec check(Path.t() | nil, String.t()) :: :ok | {:error, [String.t()]}

Whether the server running with config file config_path can take content as its shared configuration. Returns :ok or the reasons.

newer?(a, b)

@spec newer?(t() | map(), t() | map() | nil) :: boolean()

Whether a is newer than b (or b is nil).

read(path)

@spec read(Path.t() | nil) :: t() | nil

The version stored at path, or nil when there is none.

write(path, shared)

@spec write(Path.t(), t()) :: :ok | {:error, File.posix()}

Stores shared at path, replacing the file at once.