Parses ztlctl status output (YAML) into LibclusterMesh.Peer structs.
ztlctl status prints a YAML-ish document whose peers: list is rendered
as aligned text, one peer per line:
- IP DNS_NAME OWNER OS STATEOnly the first two whitespace-delimited fields are consumed, so owner
display names containing spaces are safe. Without --all the CLI lists
online peers only, hence online?: true — the strategy never passes it.
Summary
Functions
Parses the status output. Never raises: unrecognized lines are skipped, and
a CLI error message is surfaced as {:error, message}.
The name this node answers to on the mesh, or nil.
Functions
@spec parse_peers(String.t()) :: {:ok, [LibclusterMesh.Peer.t()]} | {:error, String.t()}
Parses the status output. Never raises: unrecognized lines are skipped, and
a CLI error message is surfaced as {:error, message}.
iex> LibclusterMesh.ZTLStatus.parse_peers("""
...> state: Connected
...> ip: 100.64.0.6
...> peers:
...> - 100.64.0.7 myapp-2.example.internal Owner Name linux online
...> """)
{:ok, [%LibclusterMesh.Peer{ip: "100.64.0.7", hostname: "myapp-2", online?: true}]}
iex> LibclusterMesh.ZTLStatus.parse_peers("state: Connected\nip: 100.64.0.6\n")
{:ok, []}
The name this node answers to on the mesh, or nil.
Its own entry is not in the peer list — a node is not something to connect to — but it is the one entry a person is guaranteed to be looking at, so anything showing the mesh by name needs it separately.
iex> LibclusterMesh.ZTLStatus.parse_self("state: Connected\nhostname: myapp-1.example.internal\n")
"myapp-1"
iex> LibclusterMesh.ZTLStatus.parse_self("state: Connected\n")
nil