Forward non-200 status in proxy. Start with event stats reader
This commit is contained in:
@@ -104,8 +104,18 @@ pub async fn get_level_1(lev0: Vec<PathBuf>) -> Result<Vec<PathBuf>, Error> {
|
||||
|
||||
pub async fn database_connect(db_config: &Database) -> Result<PgClient, Error> {
|
||||
let d = db_config;
|
||||
let uri = format!("postgresql://{}:{}@{}:{}/{}", d.user, d.pass, d.host, 5432, d.name);
|
||||
let (cl, conn) = tokio_postgres::connect(&uri, tokio_postgres::NoTls).await.errstr()?;
|
||||
let dbport = 5432;
|
||||
let uri = format!("postgresql://{}:{}@{}:{}/{}", d.user, d.pass, d.host, dbport, d.name);
|
||||
let (cl, conn) = tokio_postgres::connect(&uri, tokio_postgres::NoTls)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Can not connect to database postgresql://{}:...@{}:{}/{}",
|
||||
d.user, d.host, dbport, d.name
|
||||
);
|
||||
e
|
||||
})
|
||||
.errstr()?;
|
||||
// TODO monitor connection drop.
|
||||
let _cjh = tokio::spawn(async move {
|
||||
if let Err(e) = conn.await {
|
||||
@@ -542,7 +552,10 @@ fn categorize_index_files(list: &Vec<String>) -> Result<Vec<IndexFile>, Error> {
|
||||
}
|
||||
|
||||
pub async fn index_file_path_list(channel: Channel, dbconf: Database) -> Result<Vec<PathBuf>, Error> {
|
||||
let dbc = database_connect(&dbconf).await?;
|
||||
let dbc = database_connect(&dbconf).await.map_err(|e| {
|
||||
error!("CAN NOT CONNECT TO DATABASE [{e:?}]");
|
||||
e
|
||||
})?;
|
||||
let sql = "select i.path from indexfiles i, channels c, channel_index_map m where c.name = $1 and m.channel = c.rowid and i.rowid = m.index";
|
||||
let rows = dbc.query(sql, &[&channel.name()]).await.errstr()?;
|
||||
let mut index_paths = vec![];
|
||||
|
||||
@@ -86,6 +86,7 @@ pub async fn make_event_pipe(
|
||||
}
|
||||
AggKind::DimXBinsN(_) => err::todoval(),
|
||||
AggKind::EventBlobs => err::todoval(),
|
||||
AggKind::Stats1 => err::todoval(),
|
||||
},
|
||||
Shape::Wave(_n1) => match evq.agg_kind {
|
||||
AggKind::Plain => Box::pin(filtered) as Pin<Box<dyn Stream<Item = _> + Send>>,
|
||||
@@ -286,6 +287,7 @@ pub async fn make_event_pipe(
|
||||
Box::pin(tr) as _
|
||||
}
|
||||
AggKind::EventBlobs => err::todoval(),
|
||||
AggKind::Stats1 => err::todoval(),
|
||||
},
|
||||
_ => {
|
||||
error!("TODO shape {:?}", channel_config.shape);
|
||||
|
||||
@@ -182,10 +182,23 @@ macro_rules! arm2 {
|
||||
|
||||
macro_rules! arm1 {
|
||||
($item:expr, $sty1:ident, $sty2:ident, $shape:expr, $ak:expr) => {{
|
||||
if let AggKind::Stats1 = $ak {
|
||||
err::todo();
|
||||
return arm2!(
|
||||
$item,
|
||||
ScalarEvents,
|
||||
Plain,
|
||||
PlainEvents,
|
||||
Scalar,
|
||||
ScalarPlainEvents,
|
||||
$sty1,
|
||||
$sty2
|
||||
);
|
||||
}
|
||||
match $shape {
|
||||
Shape::Scalar => match $ak {
|
||||
AggKind::EventBlobs => {
|
||||
warn!("arm1 unhandled EventBlobs");
|
||||
warn!("arm1 unhandled AggKind::EventBlobs");
|
||||
panic!()
|
||||
}
|
||||
AggKind::Plain => arm2!(
|
||||
@@ -228,6 +241,8 @@ macro_rules! arm1 {
|
||||
$sty1,
|
||||
$sty2
|
||||
),
|
||||
// Handled above..
|
||||
AggKind::Stats1 => panic!(),
|
||||
},
|
||||
Shape::Wave(_) => match $ak {
|
||||
AggKind::EventBlobs => {
|
||||
@@ -274,6 +289,8 @@ macro_rules! arm1 {
|
||||
$sty1,
|
||||
$sty2
|
||||
),
|
||||
// Handled above..
|
||||
AggKind::Stats1 => panic!(),
|
||||
},
|
||||
Shape::Image(..) => {
|
||||
// There should be no images on archiver.
|
||||
|
||||
@@ -15,6 +15,7 @@ fn read_pb_00() -> Result<(), Error> {
|
||||
let block1 = async move {
|
||||
let homedir = std::env::var("HOME").unwrap();
|
||||
let path = PathBuf::from(homedir)
|
||||
.join("daqbuffer-testdata")
|
||||
.join("archappdata")
|
||||
.join("lts")
|
||||
.join("ArchiverStore")
|
||||
|
||||
Reference in New Issue
Block a user