Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve the IP address of the AMQP service #8

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AMQP_ADDRESS=127.0.0.1:5672
AMQP_ADDRESS=127.0.0.1
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AMQP_ADDRESS=127.0.0.1:5672
AMQP_ADDRESS=127.0.0.1
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ amq-protocol = "^0.16"
dotenv = "0.8.0"
futures = "^0.1"
lapin-futures = "^0.8"
resolve = "0.1.2"
rocket = "0.2.8"
rocket_codegen = "0.2.8"
schani = { git = "https://github.com/schani-rs/schani.git" }
Expand Down
14 changes: 10 additions & 4 deletions src/bin/processor.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
extern crate amq_protocol;
extern crate dotenv;
extern crate futures;
extern crate tokio_core;
extern crate lapin_futures as lapin;
extern crate resolve;
extern crate tokio_core;

use std::env;
use std::net;
use amq_protocol::types::FieldTable;
use dotenv::dotenv;
use futures::Stream;
use futures::future::Future;
use tokio_core::reactor::Core;
use tokio_core::net::TcpStream;
use lapin::client::ConnectionOptions;
use lapin::channel::{BasicConsumeOptions, QueueDeclareOptions};
use tokio_core::reactor::Core;
use tokio_core::net::TcpStream;
use resolve::resolve_host;

fn main() {
dotenv().ok();

// create the reactor
let mut core = Core::new().unwrap();
let handle = core.handle();
let addr = env::var("AMQP_ADDRESS").expect("AMQP_ADDRESS must be set").parse().unwrap();
let host = env::var("AMQP_ADDRESS").expect("AMQP_ADDRESS must be set");
let host_addr = resolve_host(&host).expect("could not lookup host").last().unwrap();
let addr = net::SocketAddr::new(host_addr, 5672);

println!("connecting to AMQP service at {}", host_addr);
core.run(TcpStream::connect(&addr, &handle)
.and_then(|stream| {

Expand Down