Index: offload/src/main.rs ================================================================== --- offload/src/main.rs +++ offload/src/main.rs @@ -16,11 +16,11 @@ settings.merge(config::File::with_name("offload")).expect("Can't read configuration file"); let reddb = redis::Client::open("redis://127.0.0.1/").expect("Can't connect to the database"); let red = reddb.get_connection().expect("Can't initialize new connection"); - let re = Regex::new("^([0-9A-Z]+)_([a-z./0-9-]+)_([0-9.]+)$").expect("Can't parse regexp"); + let re = Regex::new("^([0-9A-Z]+)[|_]([a-zA-Z./0-9-_#]+)[|_]([0-9.]+)$").expect("Can't parse regexp"); let conn = Connection::connect(settings.get_str("pg").expect("Postgres connection absent in config"), TlsMode::None).expect("Can't connect to postgres"); let schemas = settings.get_array("schemas").expect("Schema list not found in config").into_iter().map(|value| config::Value::into_str(value).expect("We require string here")); for schema in schemas { let data_key = schema.to_owned() + "_counter_pending"; @@ -39,11 +39,11 @@ let trans = conn.transaction().expect("Can't start transaction"); let stmt = trans.prepare(&format!("select {}.merge_counter($1::text, $2::text, ($3::text)::inet, $4::smallint);", &schema)).expect("Can't prepare statement"); for (client, count) in stats { //println!("# {:?}: {:?}", &client, &count); - let cap = re.captures(&client).expect("Client match failed"); + let cap = re.captures(&client).expect(&format!("Client match failed: {}", &client)); //let addr = IpAddr::V4(cap[3].parse().expect("Can't parse IP")); //println!("insert into x values({:?}, {:?}, {:?}, {:?});", &cap[1], &cap[2], &cap[3], &count); stmt.execute(&[&cap[1].to_string(), &cap[2].to_string(), &cap[3].to_string(), &count]).expect("Can't execute prepared"); //trans.query(&format!("select {}.merge_counter($1::text, $2::text, $3::inet, $4::smallint);", &schema), &[&cap[1].to_string(), &cap[2].to_string(), &cap[3].to_string(), &count]).expect("Can't prepare statement"); }