rx_write_stream: something,
}*/
-#[throws(AE)]
+#[allow(unused_variables)] // xxx
+async fn run_client<C>(ic: InstanceConfig, hclient: Arc<hyper::Client<C>>)
+ -> Result<Void, AE>
+{
+ throw!(anyhow!("arrgh"));
+}
+
#[tokio::main]
-async fn main() {
+async fn main() -> Result<(), AE> {
let ics = config::read(LinkEnd::Client)?;
+ if ics.is_empty() { throw!(anyhow!("no associations with server(s)")); }
+
+ env_logger::init();
let https = HttpsConnector::new();
- let hclient = Client::builder().build::<_, hyper::Body>(https);
+ let hclient = hyper::Client::builder().build::<_, hyper::Body>(https);
+ let hclient = Arc::new(hclient);
- let clients = ics.into_iter().map(|| run_client(ic));
-
+ info!("starting");
+ let () = future::select_all(
+ ics.into_iter().map(|ic| Box::pin(async {
+ let assocname = ic.to_string();
+ info!("{} starting", &assocname);
+ let hclient = hclient.clone();
+ let join = task::spawn(async {
+ run_client(ic, hclient).await.void_unwrap_err()
+ });
+ match join.await {
+ Ok(e) => {
+ error!("{} failed: {:?}", &assocname, e);
+ },
+ Err(je) => {
+ error!("{} panicked!", &assocname);
+ panic::resume_unwind(je.into_panic());
+ },
+ }
+ }))
+ ).await.0;
- eprintln!("{:#?}", &instances);
+ error!("quitting because one of your client connections crashed");
+ process::exit(16);
}
SN::Link(LinkName { server, client })
}
}
+impl Display for InstanceConfig {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ write!(f, "[{} {}]", &self.server, &self.vaddr)?;
+ }
+}
+
impl Display for SectionName {
#[throws(fmt::Error)]
fn fmt(&self, f: &mut fmt::Formatter) {
agg.read_extra(extra).context("extra config")?;
}
- eprintln!("GOT {:#?}", agg);
+ //eprintln!("GOT {:#?}", agg);
Ok::<_,AE>(agg)
})().context("read configuration")?;
pub use std::mem;
pub use std::net::{IpAddr, Ipv4Addr};
pub use std::path::{Path, PathBuf};
+pub use std::panic;
+pub use std::process;
pub use std::str::FromStr;
pub use std::sync::Arc;
pub use anyhow::{anyhow, Context};
pub use extend::ext;
pub use fehler::{throw, throws};
+pub use futures::future;
pub use hyper::Uri;
+pub use hyper_tls::HttpsConnector;
pub use ipnet::IpNet;
pub use itertools::{iproduct, Itertools};
pub use lazy_regex::regex_is_match;
+pub use log::{info, error};
pub use structopt::StructOpt;
+pub use tokio::task;
pub use tokio::time::Duration;
-pub use void::{self, Void};
+pub use void::{self, Void, ResultVoidExt, ResultVoidErrExt};
-pub use crate::config;
+pub use crate::config::{self, InstanceConfig};
pub use crate::utils::*;
pub use crate::types::*;