nodex v0.1.2 Nodex.Cnode

A module to help calling into and maintaining C-nodes.

Link to this section Summary

Functions

Call into the C-Node managed by Cnode referenced by pid or name. Returns the response or an error after a configurable timeout.

Returns a specification to start this module under a supervisor.

Returns the :"sname@host" identifier for the C-Node. With this you can leverage Node.monitor/2 or Kernel.send/2 for your own purposes.

Callback implementation for GenServer.init/1.

Starts a GenServer that will start and monitor a C-Node.

Link to this section Types

Specs

init_args() :: %{
  exec_path: binary(),
  ready_line: binary(),
  spawn_inactive_timeout: integer(),
  sname: binary(),
  hostname: binary(),
  os_pid: integer()
}
Link to this type

pid_or_name()

Specs

pid_or_name() :: pid() | atom()

Link to this section Functions

Link to this function

call(pid_or_name, msg, timeout \\ 5000)

Specs

call(pid_or_name(), any(), integer()) :: {:ok, any()} | {:error, :timeout}

Call into the C-Node managed by Cnode referenced by pid or name. Returns the response or an error after a configurable timeout.

Parameters

  • pid_or_name: The pid or name of the Cnode GenServer
  • msg: The message for the C-Node
  • timeoout: (optional, default: 5000) the time in milliseconds that is waited for a response.
Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

cnode(pid_or_name)

Specs

cnode(pid_or_name()) :: node()

Returns the :"sname@host" identifier for the C-Node. With this you can leverage Node.monitor/2 or Kernel.send/2 for your own purposes.

Parameters

  • pid_or_name: The pid or name of the Cnode GenServer

Callback implementation for GenServer.init/1.

Link to this function

spawn_cnode(state)

Link to this function

start_link(init_args, opts \\ [])

Starts a GenServer that will start and monitor a C-Node.

Parameters

  • init_args: A map providing configuration on how to start a C-Node.
    • :exec_path required provide a path to the C-Node executable.
    • :ready_line a custom message that is awaited on the STDOUT of the C-Node.
    • :spawn_inactive_timeout set a timeout in milliseconds after the C-Node is considered unresponsive before receiving the ready_line.