#[cfg(feature = "constellation")] use constellation::*; use std::time::{Duration, SystemTime}; use amadeus::dist::prelude::*; fn main() { if cfg!(miri) { return; } #[cfg(feature = "constellation")] init(Resources::default()); tokio::runtime::Builder::new() .threaded_scheduler() .enable_all() .build() .unwrap() .block_on(async { let thread_pool_time = { let thread_pool = ThreadPool::new(None, None).unwrap(); run(&thread_pool).await }; #[cfg(feature = "constellation")] let process_pool_time = { let process_pool = ProcessPool::new(None, None, None, Resources::default()).unwrap(); run(&process_pool).await }; #[cfg(not(feature = "constellation"))] let process_pool_time = "-"; println!("in {:?} {:?}", thread_pool_time, process_pool_time); }) } async fn run(pool: &P) -> Duration { let start = SystemTime::now(); #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct Weather { city: Option, temp_lo: Option, temp_hi: Option, prcp: Option, date: Option, invent: Option, } #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct InventoryItem { name: Option, supplier_id: Option, price: Option, } // https://datahub.io/cryptocurrency/bitcoin let rows = Postgres::::new(vec![( "postgres://postgres:a@localhost/alec".parse().unwrap(), vec![PostgresSelect::Table("weather".parse().unwrap())], )]); assert_eq!( rows.dist_stream() .map(FnMut!(|row: Result<_, _>| row.unwrap())) .count(&pool) .await, 4 ); // TODO // let rows = Postgres::::new(vec![( // "postgres://postgres:a@localhost/alec".parse().unwrap(), // vec![amadeus::source::postgres::Source::Table( // "weather".parse().unwrap(), // )], // )]); // assert_eq!( // rows.dist_stream() // .map(FnMut!(|row: Result| -> Value { // let value = row.unwrap(); // // println!("{:?}", value); // // let _: GameDerived = value.clone().downcast().unwrap(); // value // })) // .count(&pool).await, // 4 // ); start.elapsed().unwrap() }