Skip to content

Instantly share code, notes, and snippets.

@Geal
Created March 13, 2017 09:21
Show Gist options
  • Save Geal/73f88fc3cd94a4cfd836729920e57263 to your computer and use it in GitHub Desktop.
Save Geal/73f88fc3cd94a4cfd836729920e57263 to your computer and use it in GitHub Desktop.
Client.new(<some TCP or TLS stream>)
.connect() //will start the handshake of 7 or so messages, returns a future that resolves once the handshake is done
.and_then(|client| {
client.create_channel() // returns a future that resolves once the channel is created
.map(|channel| {
channel
.queue("queue_name") // returns a future that resolves once the queue is declared
.and_then(|queue| {
queue.publish(|queue| {
queue.send(message)
})
})
})
});
client.create_channel() // returns a future that resolves once the channel is created
.map(|channel| {
channel
.queue("queue_name") // returns a future that resolves once the queue is declared
.and_then(|queue| {
queue.consume(|message| {
//handle messages here
})
})
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment