diff --git a/Cargo.toml b/Cargo.toml index 7055459..708e5b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,5 @@ no-thrash = [] trace = [] debug = [] test = [] +localhost = [] +harrison = [] diff --git a/src/influx.rs b/src/influx.rs index 456371e..7fe0d4c 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -27,15 +27,26 @@ use super::{nanos, file_logger, LOG_LEVEL}; use warnings::Warning; const WRITER_ADDR: &'static str = "ipc:///tmp/mm/influx"; -//const WRITER_ADDR: &'static str = "tcp://127.0.0.1:17853"; -const DB_NAME: &'static str = "mm"; -const DB_HOST: &'static str = "http://washington.0ptimus.internal:8086/write"; -//const DB_HOST: &'static str = "http://harrison.0ptimus.internal:8086/write"; const ZMQ_RCV_HWM: i32 = 0; const ZMQ_SND_HWM: i32 = 0; const BUFFER_SIZE: u16 = 80; +#[cfg(not(any(test, feature = "test")))] +const DB_NAME: &'static str = "mm2"; + +#[cfg(any(test, feature = "test"))] +const DB_NAME: &'static str = "mm2_test"; + +#[cfg(all(not(feature = "harrison"), any(test, feature = "test", feature = "localhost")))] +const DB_HOST: &'static str = "http://127.0.0.1:8086/write"; + +#[cfg(feature = "harrison")] +const DB_HOST: &'static str = "http://harrison.0ptimus.internal:8086/write"; + +#[cfg(not(any(feature = "harrison", feature = "localhost", test, feature = "test")))] +const DB_HOST: &'static str = "http://washington.0ptimus.internal:8086/write"; + pub use super::{dur_nanos, dt_nanos}; pub type Map = OrderMap>; @@ -303,7 +314,7 @@ impl InfluxWriter { _ => { #[cfg(feature = "no-thrash")] - thread::sleep(Duration::new(0, 0)) + thread::sleep(Duration::new(0, 1)) } } } @@ -495,9 +506,9 @@ pub fn serialize_owned(measurement: &OwnedMeasurement, line: &mut String) { } } - +#[deprecated(since="0.4", note="Replace with InfluxWriter")] pub fn writer(warnings: Sender) -> thread::JoinHandle<()> { - thread::spawn(move || { + thread::Builder::new().name("mm:inflx-wtr".into()).spawn(move || { let _ = fs::create_dir("/tmp/mm"); let ctx = zmq::Context::new(); let socket = pull(&ctx).expect("influx::writer failed to create pull socket"); @@ -549,7 +560,7 @@ pub fn writer(warnings: Sender) -> thread::JoinHandle<()> { } } } - }) + }).unwrap() } #[derive(Debug, Clone, PartialEq)]