Behaviours: gen_server.
Controller for additional Erlang node running on the same host, or in a different container/host (e.g. Docker).
Origin node - Erlang VM instance that spawns additional nodes. Peer node - a node spawned by the origin. Control process - a process running on origin node, if it terminates, peer node terminates too. Control connection - a connection between origin and peer, can be ether Erlang Distribution connection, or alternative one.
I/O is forwarded from peer node to origin via control connection.
When standard_io is used as alternative connection, peer node uses standard out to multiplex console output and control sequences. Characters in range of 192-255 are reserved for control sequences, see encode_port_data for details. If peer node attempts to print characters in this range, an controlling process on the origin node may terminate with an error (because CRC check will fail).
Alternative connection via TCP does not have that limitation, but it also does not redirect console I/O from the peer node.connection() = 0..65535 | {inet:ip_address(), 0..65535} | standard_io
disconnect_timeout() = 1000..4294967295 | infinity
exec() = file:name() | {file:name(), [string()]}
SSH support: {"/usr/bin/ssh", ["account@host_b", "/usr/bin/erl"]}
peer_state() = booting | running | {down, Reason::term()}
server_ref() = pid()
start_options() = #{name => atom() | string(), longnames => boolean(), host => string(), peer_down => stop | continue | crash, connection => connection(), exec => exec(), detached => boolean(), args => [string()], post_process_args => fun(([string()]) -> [string()]), env => [{string(), string()}], wait_boot => wait_boot(), shutdown => close | halt | {halt, disconnect_timeout()} | disconnect_timeout()}
state() = #peer_state{options = start_options(), node = atom(), exec = file:name(), args = [string()], connection = undefined | port() | gen_tcp:socket(), listen_socket = undefined | gen_tcp:socket(), stdio = binary(), peer_state = peer_state(), notify = false | {pid(), reference()}, seq = non_neg_integer(), outstanding = #{non_neg_integer() => {reference(), pid()}}}
wait_boot() = timeout() | {pid(), Tag::term()} | false
| call/4 | Calls M:F(A) remotely, via alternative connection, with default 5 seconds timeout. |
| call/5 | Call M:F(A) remotely, timeout is explicitly specified. |
| cast/4 | Cast M:F(A) remotely, don't care about the result. |
| code_change/3 | |
| get_state/1 | returns peer node state. |
| handle_call/3 | |
| handle_cast/2 | |
| handle_info/2 | |
| init/1 | |
| init_supervision/2 | |
| random_name/0 | Creates random node name, using "peer" as prefix. |
| random_name/1 | Creates sufficiently random node name, using OS process ID for origin VM, resulting name looks like prefix-3-7161. |
| send/3 | Sends a message to pid or named process on the peer node using alternative connection. |
| start/0 | |
| start/1 | Starts peer node, not linked to the calling process. |
| start_link/0 | Starts a distributed node with random name, on this host, and waits for that node to boot. |
| start_link/1 | Starts peer node, linked to the calling process. |
| start_supervision/0 | |
| stop/1 | Stops controlling process, shutting down peer node synchronously. |
| supervision_child_spec/0 | |
| system_code_change/4 | |
| system_continue/3 | |
| system_get_state/1 | |
| system_replace_state/2 | |
| system_terminate/4 | |
| terminate/2 |
call(Dest::server_ref(), Module::module(), Function::atom(), Args::[term()]) -> Result::term()
Calls M:F(A) remotely, via alternative connection, with default 5 seconds timeout
call(Dest::server_ref(), Module::module(), Function::atom(), Args::[term()], Timeout::timeout()) -> Result::term()
Call M:F(A) remotely, timeout is explicitly specified
cast(Dest::server_ref(), Module::module(), Function::atom(), Args::[term()]) -> ok
Cast M:F(A) remotely, don't care about the result
code_change(OldVsn, State, Extra) -> any()
get_state(Dest::server_ref()) -> peer_state()
returns peer node state.
handle_call(X1, From, Peer_state) -> any()
handle_cast(X1, Peer_state) -> any()
handle_info(X1, Peer_state) -> any()
init(X1::[Name::atom(), ...]) -> {ok, state()}
init_supervision(Parent::term(), InSupTree::term()) -> no_return()
random_name() -> string()
Creates random node name, using "peer" as prefix.
random_name(Prefix::string() | atom()) -> string()
Creates sufficiently random node name, using OS process ID for origin VM, resulting name looks like prefix-3-7161
send(Dest::server_ref(), To::pid() | atom(), Message::term()) -> ok
Sends a message to pid or named process on the peer node using alternative connection. No delivery guarantee.
start() -> pid()
start(Options::start_options()) -> {ok, pid()} | {ok, pid(), node()} | {error, Reason}
Reason = term()
Starts peer node, not linked to the calling process.
start_link() -> {ok, pid(), node()} | {error, Reason::term()}
Starts a distributed node with random name, on this host, and waits for that node to boot. Returns full node name, registers local process with the same name as peer node.
start_link(Options::start_options()) -> {ok, pid()} | {ok, pid(), node()} | {error, Reason}
Reason = term()
Starts peer node, linked to the calling process. Accepts additional command line arguments and other important options.
start_supervision() -> any()
stop(Dest::server_ref()) -> ok
Stops controlling process, shutting down peer node synchronously
supervision_child_spec() -> any()
system_code_change(State, Module, OldVsn, Extra) -> any()
system_continue(Parent, X2, Peer_sup_state) -> any()
system_get_state(State) -> any()
system_replace_state(StateFun, State) -> any()
system_terminate(Reason, Parent, Debug, State) -> any()
terminate(Reason::term(), Peer_state::state()) -> ok
Generated by EDoc