DalaDev.Remote (dala_dev v0.1.2)

Copy Markdown View Source

Easy remote debugging and tracing interface for dala Elixir cluster nodes.

Provides a simple interface to debug and trace remote nodes without needing to manually handle RPC calls or node selection.

Usage

Select a node

iex> DalaDev.Remote.select_node(:"dala_demo@127.0.0.1")
:ok

List available nodes

iex> DalaDev.Remote.nodes()
[node1@host, node2@host]

Call remote functions

iex> DalaDev.Remote.Observer.observe()
{:ok, %{system: %{...}, processes: [...], ...}}

iex> DalaDev.Remote.Debugger.memory_report()
{:ok, %{total: "1.2 GB", processes: "45 MB", ...}}

iex> DalaDev.Remote.Debugger.inspect_process(MyApp.Worker)
{:ok, %{pid: "#PID<0.123.0>", state: "...", ...}}

iex> DalaDev.Remote.Debugger.eval("1 + 1")
{:ok, 2}

iex> DalaDev.Remote.Tracer.trace_messages(MyApp.Worker, duration: 5000)
{:ok, [%{type: :send, message: "..."}, ...]}

Set custom timeout

iex> DalaDev.Remote.set_timeout(10_000)
:ok

Get current selection

iex> DalaDev.Remote.selected_node()
{:ok, node()}

Automatic Node Selection

If only one remote node is available, it will be automatically selected. If multiple nodes are available, you must explicitly select one.

Default Timeout

The default timeout for all remote operations is 5000ms (5 seconds). This can be changed using set_timeout/1.

Summary

Functions

Automatically selects a node if only one is available.

Returns a specification to start this module under a supervisor.

Clears the currently selected node.

Gets the current timeout setting.

Lists all connected remote nodes (excluding the current node).

Selects a node for subsequent remote operations.

Gets the currently selected node.

Sets the default timeout for remote operations.

Starts the Remote helper.

Functions

auto_select()

@spec auto_select() :: {:ok, node()} | {:error, term()}

Automatically selects a node if only one is available.

Returns {:ok, node} if auto-selected, {:error, reason} otherwise.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_selection()

@spec clear_selection() :: :ok

Clears the currently selected node.

Returns :ok.

get_timeout()

@spec get_timeout() :: non_neg_integer()

Gets the current timeout setting.

Returns the timeout in milliseconds.

nodes()

@spec nodes() :: [node()]

Lists all connected remote nodes (excluding the current node).

select_node(node)

@spec select_node(node() | String.t()) :: :ok | {:error, term()}

Selects a node for subsequent remote operations.

Returns :ok on success, {:error, reason} on failure.

selected_node()

@spec selected_node() :: {:ok, node()} | {:error, :no_node_selected}

Gets the currently selected node.

Returns {:ok, node} if a node is selected, {:error, :no_node_selected} otherwise.

set_timeout(timeout)

@spec set_timeout(non_neg_integer()) :: :ok

Sets the default timeout for remote operations.

Returns :ok.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the Remote helper.

This is automatically started by the application supervisor.