Move binned type, add tests
This commit is contained in:
@@ -16,7 +16,7 @@ use url::Url;
|
||||
|
||||
async fn binned_json(url: Url, req: Request<Body>, node_config: &NodeConfigCached) -> Result<Response<Body>, Error> {
|
||||
info!("httpret plain_events_json req: {:?}", req);
|
||||
let (head, _body) = req.into_parts();
|
||||
let (_head, _body) = req.into_parts();
|
||||
let query = BinnedQuery::from_url(&url).map_err(|e| {
|
||||
let msg = format!("can not parse query: {}", e.msg());
|
||||
e.add_public_msg(msg)
|
||||
@@ -27,7 +27,6 @@ async fn binned_json(url: Url, req: Request<Body>, node_config: &NodeConfigCache
|
||||
query.set_series_id(chconf.series);
|
||||
let query = query;
|
||||
// ---
|
||||
|
||||
let span1 = span!(
|
||||
Level::INFO,
|
||||
"httpret::binned",
|
||||
@@ -38,15 +37,7 @@ async fn binned_json(url: Url, req: Request<Body>, node_config: &NodeConfigCache
|
||||
span1.in_scope(|| {
|
||||
debug!("begin");
|
||||
});
|
||||
let _: Result<_, Error> = match head.headers.get(http::header::ACCEPT) {
|
||||
//Some(v) if v == APP_OCTET => binned_binary(query, chconf, &ctx, node_config).await,
|
||||
//Some(v) if v == APP_JSON || v == ACCEPT_ALL => binned_json(query, chconf, &ctx, node_config).await,
|
||||
_ => Ok(response(StatusCode::NOT_ACCEPTABLE).body(Body::empty())?),
|
||||
};
|
||||
|
||||
// TODO analogue to `streams::plaineventsjson::plain_events_json` create a function for binned json.
|
||||
|
||||
let item = streams::plaineventsjson::plain_events_json("", &node_config.node_config.cluster)
|
||||
let item = streams::timebinnedjson::timebinned_json(&query, &node_config.node_config.cluster)
|
||||
.instrument(span1)
|
||||
.await?;
|
||||
let buf = serde_json::to_vec(&item)?;
|
||||
|
||||
@@ -43,24 +43,49 @@ pub async fn chconf_from_database(channel: &Channel, ncc: &NodeConfigCached) ->
|
||||
);
|
||||
}
|
||||
if channel.backend() == "test-inmem" {
|
||||
if channel.name() == "inmem-d0-i32" {
|
||||
let ret = if channel.name() == "inmem-d0-i32" {
|
||||
let ret = ChConf {
|
||||
series: 1,
|
||||
scalar_type: ScalarType::I32,
|
||||
shape: Shape::Scalar,
|
||||
};
|
||||
return Ok(ret);
|
||||
}
|
||||
Ok(ret)
|
||||
} else {
|
||||
error!("no test information");
|
||||
Err(Error::with_msg_no_trace(format!("no test information"))
|
||||
.add_public_msg("No channel config for test channel {:?}"))
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
if channel.backend() == "test-disk-databuffer" {
|
||||
if channel.name() == "scalar-i32-be" {
|
||||
// TODO the series-ids here are just random. Need to integrate with better test setup.
|
||||
let ret = if channel.name() == "scalar-i32-be" {
|
||||
let ret = ChConf {
|
||||
series: 1,
|
||||
scalar_type: ScalarType::I32,
|
||||
shape: Shape::Scalar,
|
||||
};
|
||||
return Ok(ret);
|
||||
}
|
||||
Ok(ret)
|
||||
} else if channel.name() == "wave-f64-be-n21" {
|
||||
let ret = ChConf {
|
||||
series: 2,
|
||||
scalar_type: ScalarType::F64,
|
||||
shape: Shape::Wave(21),
|
||||
};
|
||||
Ok(ret)
|
||||
} else if channel.name() == "const-regular-scalar-i32-be" {
|
||||
let ret = ChConf {
|
||||
series: 3,
|
||||
scalar_type: ScalarType::I32,
|
||||
shape: Shape::Scalar,
|
||||
};
|
||||
Ok(ret)
|
||||
} else {
|
||||
error!("no test information");
|
||||
Err(Error::with_msg_no_trace(format!("no test information"))
|
||||
.add_public_msg("No channel config for test channel {:?}"))
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
// TODO use a common already running worker pool for these queries:
|
||||
let dbconf = &ncc.node_config.cluster.database;
|
||||
|
||||
Reference in New Issue
Block a user