Decide best-matching series to return, enable continue-at
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
use crate::bodystream::response;
|
||||
use crate::bodystream::ToPublicResponse;
|
||||
use crate::err::Error;
|
||||
use crate::requests::accepts_json_or_all;
|
||||
use crate::ReqCtx;
|
||||
use err::PublicError;
|
||||
use err::ToPublicError;
|
||||
use futures_util::StreamExt;
|
||||
use http::Method;
|
||||
@@ -75,8 +73,6 @@ impl AccountingIngestedBytes {
|
||||
.as_ref()
|
||||
.ok_or_else(|| Error::with_public_msg_no_trace(format!("no scylla configured")))?;
|
||||
let scy = scyllaconn::conn::create_scy_session(scyco).await?;
|
||||
// TODO so far, we sum over everything
|
||||
let series_id = 0;
|
||||
let mut stream = scyllaconn::accounting::AccountingStreamScylla::new(q.range().try_into()?, scy);
|
||||
let mut ret = AccountingEvents::empty();
|
||||
while let Some(item) = stream.next().await {
|
||||
|
||||
@@ -3,6 +3,8 @@ use crate::bodystream::response_err_msg;
|
||||
use crate::bodystream::ToPublicResponse;
|
||||
use crate::channelconfig::ch_conf_from_binned;
|
||||
use crate::err::Error;
|
||||
use crate::requests::accepts_json_or_all;
|
||||
use crate::requests::accepts_octets;
|
||||
use http::Method;
|
||||
use http::StatusCode;
|
||||
use httpclient::body_empty;
|
||||
@@ -65,9 +67,9 @@ async fn binned(req: Requ, ctx: &ReqCtx, node_config: &NodeConfigCached) -> Resu
|
||||
{
|
||||
Err(Error::with_msg_no_trace("hidden message").add_public_msg("PublicMessage"))?;
|
||||
}
|
||||
if crate::accepts_json(&req.headers()) {
|
||||
if accepts_json_or_all(&req.headers()) {
|
||||
Ok(binned_json(url, req, ctx, node_config).await?)
|
||||
} else if crate::accepts_octets(&req.headers()) {
|
||||
} else if accepts_octets(&req.headers()) {
|
||||
Ok(response_err_msg(
|
||||
StatusCode::NOT_ACCEPTABLE,
|
||||
format!("binary binned data not yet available"),
|
||||
|
||||
@@ -80,7 +80,7 @@ pub struct DocsHandler {}
|
||||
|
||||
impl DocsHandler {
|
||||
pub fn path_prefix() -> &'static str {
|
||||
"/api/4/docs/"
|
||||
"/api/4/docs"
|
||||
}
|
||||
|
||||
pub fn handler(req: &Requ) -> Option<Self> {
|
||||
@@ -93,6 +93,20 @@ impl DocsHandler {
|
||||
|
||||
pub async fn handle(&self, req: Requ, _ctx: &ReqCtx) -> Result<StreamResponse, Error> {
|
||||
let path = req.uri().path();
|
||||
if path == "/api/4/docs" {
|
||||
let ret = http::Response::builder()
|
||||
.status(StatusCode::TEMPORARY_REDIRECT)
|
||||
.header(http::header::LOCATION, "/api/4/docs/")
|
||||
.body(body_empty())?;
|
||||
return Ok(ret);
|
||||
}
|
||||
if path == "/api/4/docs/" {
|
||||
let ret = http::Response::builder()
|
||||
.status(StatusCode::TEMPORARY_REDIRECT)
|
||||
.header(http::header::LOCATION, "/api/4/docs/index.html")
|
||||
.body(body_empty())?;
|
||||
return Ok(ret);
|
||||
}
|
||||
let mut segs: VecDeque<_> = path.split("/").collect();
|
||||
for _ in 0..4 {
|
||||
segs.pop_front();
|
||||
|
||||
@@ -101,16 +101,17 @@ async fn plain_events_json(
|
||||
ctx: &ReqCtx,
|
||||
node_config: &NodeConfigCached,
|
||||
) -> Result<StreamResponse, Error> {
|
||||
info!("plain_events_json req: {:?}", req);
|
||||
let self_name = "plain_events_json";
|
||||
info!("{self_name} req: {:?}", req);
|
||||
let (_head, _body) = req.into_parts();
|
||||
let query = PlainEventsQuery::from_url(&url)?;
|
||||
info!("plain_events_json query {query:?}");
|
||||
info!("{self_name} query {query:?}");
|
||||
// TODO handle None case better and return 404
|
||||
let ch_conf = chconf_from_events_quorum(&query, ctx, node_config)
|
||||
.await
|
||||
.map_err(Error::from)?
|
||||
.ok_or_else(|| Error::with_msg_no_trace("channel not found"))?;
|
||||
info!("plain_events_json chconf_from_events_quorum: {ch_conf:?}");
|
||||
info!("{self_name} chconf_from_events_quorum: {ch_conf:?}");
|
||||
let open_bytes = OpenBoxedBytesViaHttp::new(node_config.node_config.cluster.clone());
|
||||
let item = streams::plaineventsjson::plain_events_json(
|
||||
&query,
|
||||
@@ -120,13 +121,15 @@ async fn plain_events_json(
|
||||
Box::pin(open_bytes),
|
||||
)
|
||||
.await;
|
||||
info!("{self_name} returned {}", item.is_ok());
|
||||
let item = match item {
|
||||
Ok(item) => item,
|
||||
Err(e) => {
|
||||
error!("got error from streams::plaineventsjson::plain_events_json {e:?}");
|
||||
error!("{self_name} got error from streams::plaineventsjson::plain_events_json {e}");
|
||||
return Err(e.into());
|
||||
}
|
||||
};
|
||||
let ret = response(StatusCode::OK).body(ToJsonBody::from(&item).into_body())?;
|
||||
info!("{self_name} response created");
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user