#[cfg(feature = "constellation")]
use constellation::*;
use std::{env, time::SystemTime};
use amadeus::prelude::*;
fn main() {
#[cfg(feature = "constellation")]
init(Resources::default());
let processes = env::args()
.nth(1)
.and_then(|arg| arg.parse::<usize>().ok())
.unwrap_or(10);
let start = SystemTime::now();
let pool = ProcessPool::new(processes, 1, Resources::default()).unwrap();
#[derive(Data, Clone, PartialEq, PartialOrd, Debug)]
struct Weather {
city: Option<String>,
temp_lo: Option<i32>,
temp_hi: Option<i32>,
prcp: Option<f32>,
date: Option<Date>,
invent: Option<InventoryItem>,
}
#[derive(Data, Clone, PartialEq, PartialOrd, Debug)]
struct InventoryItem {
name: Option<String>,
supplier_id: Option<i32>,
price: Option<f64>,
}
let rows = Postgres::<Weather>::new(vec![(
"postgres://postgres:a@localhost/alec".parse().unwrap(),
vec![amadeus::source::postgres::Source::Table(
"weather".parse().unwrap(),
)],
)]);
assert_eq!(
rows.unwrap()
.map(FnMut!(|row: Result<_, _>| row.unwrap()))
.count(&pool),
4
);
println!("in {:?}", start.elapsed().unwrap());
}