Struct erl_dist::epmd::EpmdClient
[−]
[src]
pub struct EpmdClient { /* fields omitted */ }
EPMD client.
This implements the client side of the EPMD protocol.
Examples
Queries the information of the "foo" node:
use fibers::{Executor, InPlaceExecutor, Spawn}; use fibers::net::TcpStream; use futures::Future; use erl_dist::epmd::{DEFAULT_EPMD_PORT, EpmdClient}; let epmd_addr = format!("127.0.0.1:{}", DEFAULT_EPMD_PORT).parse().unwrap(); let target_node = "foo"; let mut executor = InPlaceExecutor::new().unwrap(); // Queries the node information asynchronously. let monitor = executor.spawn_monitor(TcpStream::connect(epmd_addr) .and_then(move |socket| EpmdClient::new().get_node_info(socket, target_node))); let result = executor.run_fiber(monitor).unwrap(); match result { Err(e) => println!("Failed: {}", e), Ok(None) => println!("Not found:"), Ok(Some(info)) => println!("Found: {:?}", info), }
See epmd_cli.rs file for more comprehensive examples.
Methods
impl EpmdClient
[src]
fn new() -> Self
Makes a new EpmdClient
instance.
fn register<S>(
&self,
stream: S,
node: NodeInfo
) -> BoxFuture<(S, Creation), Error> where
S: Read + Write + Send + 'static,
&self,
stream: S,
node: NodeInfo
) -> BoxFuture<(S, Creation), Error> where
S: Read + Write + Send + 'static,
Registers a node in the EPMD connected by stream
.
The connection created to the EPMD must be kept as long as the node is a distributed node. When the connection is closed, the node is automatically unregistered from the EPMD.
Note
For executing asynchronously, we assume that stream
returns
the std::io::ErrorKind::WouldBlock
error if an I/O operation would be about to block.
fn get_node_info<S>(
&self,
stream: S,
node_name: &str
) -> BoxFuture<Option<NodeInfo>, Error> where
S: Read + Write + Send + 'static,
&self,
stream: S,
node_name: &str
) -> BoxFuture<Option<NodeInfo>, Error> where
S: Read + Write + Send + 'static,
Queries the distribution port (and other information) of
the node_name
node to the EPMD connected by stream
.
If the node has not been registered in the EPMD, this will return None
.
Note
For executing asynchronously, we assume that stream
returns
the std::io::ErrorKind::WouldBlock
error if an I/O operation would be about to block.
fn kill<S>(&self, stream: S) -> BoxFuture<String, Error> where
S: Read + Write + Send + 'static,
S: Read + Write + Send + 'static,
Kills the EPMD connected by stream
.
This request kills the running EPMD. It is almost never used.
If the EPMD is killed, it will returns "OK"
.
Note
For executing asynchronously, we assume that stream
returns
the std::io::ErrorKind::WouldBlock
error if an I/O operation would be about to block.
fn get_names<S>(&self, stream: S) -> BoxFuture<String, Error> where
S: Read + Write + Send + 'static,
S: Read + Write + Send + 'static,
Gets all registered names from the EPMD connected by stream
.
The result value is a string written for each active node.
The format of each entry is "name ${NODE_NAME} at port ${PORT}\n"
.
Note
For executing asynchronously, we assume that stream
returns
the std::io::ErrorKind::WouldBlock
error if an I/O operation would be about to block.
fn dump<S>(&self, stream: S) -> BoxFuture<String, Error> where
S: Read + Write + Send + 'static,
S: Read + Write + Send + 'static,
Dumps all data from the EPMD connected by stream
.
This request is not really used, it is to be regarded as a debug feature.
The result value is a string written for each node kept in the EPMD.
The format of each entry is
"active name ${NODE_NAME} at port ${PORT}, fd = ${FD}\n"
or
"old/unused name ${NODE_NAME} at port ${PORT}, fd = ${FD}\n"
Note
For executing asynchronously, we assume that stream
returns
the std::io::ErrorKind::WouldBlock
error if an I/O operation would be about to block.