March Docs

Cluster

Cluster: peer address discovery for distributed March applications.

Parse MARCH_CLUSTER_NODES=host:port,host:port,... from the environment into a List(NodeAddr), then dial each node with NodeRpc.connect.

  let addrs = Cluster.from_env()
  let conns  = List.map(fn a -> NodeRpc.connect(a.host, a.port), addrs)

Malformed entries (missing colon, non-numeric port) are silently skipped. For testing or hardcoded configs use Cluster.from_list.

Types

typeNodeAddrNodeAddr = {#

Functions

fnfrom_envfrom_env() : List(NodeAddr)#

Parse MARCH_CLUSTER_NODES into a list of peer addresses. Returns [] if the variable is unset or empty.

    march> Cluster.from_env()
    []
fnfrom_listfrom_list(pairs : List((String, Int))) : List(NodeAddr)#

Build a peer list from a literal list of (host, port) pairs. Useful in tests or when addresses are known at compile time.

    march> Cluster.from_list([("127.0.0.1", 29852), ("10.0.0.2", 29853)])
    [{ host: "127.0.0.1", port: 29852 }, { host: "10.0.0.2", port: 29853 }]