Struct lapin_futures::client::Client [−][src]
pub struct Client<T> { pub configuration: ConnectionConfiguration, // some fields omitted }
the Client structures connects to a server and creates channels
Fields
configuration: ConnectionConfiguration
Methods
impl<T: AsyncRead + AsyncWrite + Send + Sync + 'static> Client<T>
[src]
impl<T: AsyncRead + AsyncWrite + Send + Sync + 'static> Client<T>
pub fn connect(
stream: T,
options: ConnectionOptions
) -> impl Future<Item = (Self, Heartbeat<impl Future<Item = (), Error = Error> + Send + 'static>), Error = Error> + Send + 'static
[src]
pub fn connect(
stream: T,
options: ConnectionOptions
) -> impl Future<Item = (Self, Heartbeat<impl Future<Item = (), Error = Error> + Send + 'static>), Error = Error> + Send + 'static
Takes a stream (TCP, TLS, unix socket, etc) and uses it to connect to an AMQP server.
This function returns a future that resolves once the connection handshake is done.
The result is a tuple containing a Client
that can be used to create Channel
s and a
Heartbeat
instance. The heartbeat is a task (it implements Future
) that should be
spawned independently of the other futures.
To stop the heartbeat task, see HeartbeatHandle
.
Example
use tokio::net::TcpStream; use tokio::runtime::Runtime; use lapin_futures::client::{Client, ConnectionOptions}; let addr = "127.0.0.1:5672".parse().unwrap(); let f = TcpStream::connect(&addr) .and_then(|stream| { Client::connect(stream, ConnectionOptions::default()) }) .and_then(|(client, mut heartbeat)| { let handle = heartbeat.handle().unwrap(); tokio::spawn( heartbeat.map_err(|e| eprintln!("The heartbeat task errored: {}", e)) ); /// ... handle.stop(); Ok(()) }); Runtime::new().unwrap().block_on_all( f.map_err(|e| eprintln!("An error occured: {}", e)) ).expect("runtime exited with failure");
pub fn create_channel(
&self
) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static
[src]
pub fn create_channel(
&self
) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static
creates a new channel
returns a future that resolves to a Channel
once the method succeeds
pub fn create_confirm_channel(
&self,
options: ConfirmSelectOptions
) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static
[src]
pub fn create_confirm_channel(
&self,
options: ConfirmSelectOptions
) -> impl Future<Item = Channel<T>, Error = Error> + Send + 'static
returns a future that resolves to a Channel
once the method succeeds
the channel will support RabbitMQ's confirm extension