mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-12-20 18:27:11 +00:00
Add logging for unhydrated values
This commit is contained in:
parent
4fba2f317d
commit
f48d404a15
1 changed files with 16 additions and 6 deletions
22
src/db.rs
22
src/db.rs
|
@ -1,7 +1,7 @@
|
||||||
use activitystreams::primitives::XsdAnyUri;
|
use activitystreams::primitives::XsdAnyUri;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use bb8_postgres::tokio_postgres::{row::Row, Client};
|
use bb8_postgres::tokio_postgres::{row::Row, Client};
|
||||||
use log::info;
|
use log::{info, warn};
|
||||||
use rsa::RSAPrivateKey;
|
use rsa::RSAPrivateKey;
|
||||||
use rsa_pem::KeyExt;
|
use rsa_pem::KeyExt;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -148,15 +148,25 @@ pub async fn hydrate_listeners(client: &Client) -> Result<HashSet<XsdAnyUri>, Er
|
||||||
parse_rows(rows)
|
parse_rows(rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_rows<T>(rows: Vec<Row>) -> Result<HashSet<T>, Error>
|
fn parse_rows<T, E>(rows: Vec<Row>) -> Result<HashSet<T>, Error>
|
||||||
where
|
where
|
||||||
T: std::str::FromStr + Eq + std::hash::Hash,
|
T: std::str::FromStr<Err = E> + Eq + std::hash::Hash,
|
||||||
|
E: std::fmt::Display,
|
||||||
{
|
{
|
||||||
let hs = rows
|
let hs = rows
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(move |row| {
|
.filter_map(move |row| match row.try_get::<_, String>(0) {
|
||||||
let s: String = row.try_get(0).ok()?;
|
Ok(s) => match s.parse() {
|
||||||
s.parse().ok()
|
Ok(t) => Some(t),
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Couln't parse row, '{}', {}", s, e);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Couldn't get column, {}", e);
|
||||||
|
None
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue