Malachi.CLI.Rpc (malachi v0.8.13)

View Source

Shared Erlang-distribution/RPC plumbing for the operator mix tasks (mix malachi.user, mix malachi.acl): resolve the target node, bring this task's VM up as a distributed node and connect, and build the RPC seam the task's testable core calls through. Kept free of Mix.* (it returns {:error, message} rather than raising) so the tasks own their own output/exit behavior.

Summary

Functions

Brings this task's VM up as a distributed node (if not already) and connects to node, applying cookie (or $RELEASE_COOKIE). Returns :ok, or {:error, message} when the node cannot be reached.

The RPC seam: a (module, fun, args -> {:ok, value} | {:error, reason}) function that calls node over Erlang distribution. The task's execute/3 core calls through this, and tests substitute a fake.

Formats an RPC transport failure for display.

The target node: --node, else $MALACHI_NODE, else malachi@127.0.0.1.

Functions

connect(node, cookie)

@spec connect(node(), String.t() | nil) :: :ok | {:error, String.t()}

Brings this task's VM up as a distributed node (if not already) and connects to node, applying cookie (or $RELEASE_COOKIE). Returns :ok, or {:error, message} when the node cannot be reached.

rpc(node)

@spec rpc(node()) :: (module(), atom(), list() -> {:ok, term()} | {:error, term()})

The RPC seam: a (module, fun, args -> {:ok, value} | {:error, reason}) function that calls node over Erlang distribution. The task's execute/3 core calls through this, and tests substitute a fake.

rpc_error(reason)

@spec rpc_error(term()) :: String.t()

Formats an RPC transport failure for display.

target_node(opts)

@spec target_node(keyword()) :: node()

The target node: --node, else $MALACHI_NODE, else malachi@127.0.0.1.