Reduce log
This commit is contained in:
@@ -204,7 +204,7 @@ async fn proxy_http_service_inner(
|
||||
Ok(proxy_backend_query::<MapPulseQuery>(req, ctx, proxy_config).await?)
|
||||
} else if path == "/api/4/binned" {
|
||||
Ok(proxy_backend_query::<BinnedQuery>(req, ctx, proxy_config).await?)
|
||||
} else if let Some(h) = crate::api4::accounting::AccountingIngestedBytes::handler(&req) {
|
||||
} else if let Some(_) = crate::api4::accounting::AccountingIngestedBytes::handler(&req) {
|
||||
Ok(proxy_backend_query::<query::api4::AccountingIngestedBytesQuery>(req, ctx, proxy_config).await?)
|
||||
} else if path == "/api/4/channel/config" {
|
||||
Ok(proxy_backend_query::<ChannelConfigQuery>(req, ctx, proxy_config).await?)
|
||||
@@ -510,7 +510,7 @@ where
|
||||
return Ok(response_err_msg(StatusCode::BAD_REQUEST, msg)?);
|
||||
}
|
||||
};
|
||||
info!("proxy_backend_query {query:?} {head:?}");
|
||||
debug!("proxy_backend_query {query:?} {head:?}");
|
||||
let query_host = get_query_host_for_backend(&query.backend(), proxy_config)?;
|
||||
// TODO remove this special case
|
||||
// SPECIAL CASE:
|
||||
@@ -522,7 +522,7 @@ where
|
||||
let uri_path: String = if url.as_str().contains("/map/pulse/") {
|
||||
match MapPulseQuery::from_url(&url) {
|
||||
Ok(qu) => {
|
||||
info!("qu {qu:?}");
|
||||
debug!("qu {qu:?}");
|
||||
format!("/api/4/map/pulse/{}/{}", qu.backend, qu.pulse)
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -533,7 +533,7 @@ where
|
||||
} else {
|
||||
head.uri.path().into()
|
||||
};
|
||||
info!("uri_path {uri_path}");
|
||||
debug!("uri_path {uri_path}");
|
||||
let mut url = Url::parse(&format!("{}{}", query_host, uri_path))?;
|
||||
query.append_to_url(&mut url);
|
||||
|
||||
@@ -558,9 +558,11 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
debug!("send request {req:?}");
|
||||
let req = req.body(body_empty())?;
|
||||
|
||||
let fut = async move {
|
||||
debug!("requesting {:?} {:?} {:?}", req.method(), req.uri(), req.headers());
|
||||
let mut send_req = httpclient::httpclient::connect_client(req.uri()).await?;
|
||||
let res = send_req.send_request(req).await?;
|
||||
Ok::<_, Error>(res)
|
||||
@@ -596,15 +598,3 @@ fn get_query_host_for_backend(backend: &str, proxy_config: &ProxyConfig) -> Resu
|
||||
}
|
||||
return Err(Error::with_msg(format!("host not found for backend {:?}", backend)));
|
||||
}
|
||||
|
||||
fn get_random_query_host_for_backend(backend: &str, proxy_config: &ProxyConfig) -> Result<String, Error> {
|
||||
let url = get_query_host_for_backend(backend, proxy_config)?;
|
||||
// TODO remove special code, make it part of configuration
|
||||
if url.contains("sf-daqbuf-23.psi.ch") {
|
||||
let id = 21 + rand::random::<u32>() % 13;
|
||||
let url = url.replace("-23.", &format!("-{id}."));
|
||||
Ok(url)
|
||||
} else {
|
||||
Ok(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
use crate::bodystream::response;
|
||||
use crate::err::Error;
|
||||
use crate::proxy::get_query_host_for_backend;
|
||||
use crate::requests::accepts_cbor_frames;
|
||||
use crate::requests::accepts_json_or_all;
|
||||
use crate::ReqCtx;
|
||||
use http::header;
|
||||
use http::HeaderValue;
|
||||
use http::Method;
|
||||
use http::Request;
|
||||
use http::StatusCode;
|
||||
use http::Uri;
|
||||
use httpclient::body_bytes;
|
||||
use httpclient::body_empty;
|
||||
use httpclient::body_stream;
|
||||
use httpclient::connect_client;
|
||||
use httpclient::read_body_bytes;
|
||||
use httpclient::Requ;
|
||||
use httpclient::StreamIncoming;
|
||||
use httpclient::StreamResponse;
|
||||
use netpod::get_url_query_pairs;
|
||||
use netpod::log::*;
|
||||
use netpod::query::api1::Api1Query;
|
||||
use netpod::req_uri_to_url;
|
||||
use netpod::FromUrl;
|
||||
use netpod::HasBackend;
|
||||
use netpod::ProxyConfig;
|
||||
use netpod::ACCEPT_ALL;
|
||||
use netpod::APP_CBOR;
|
||||
use netpod::APP_JSON;
|
||||
use netpod::X_DAQBUF_REQID;
|
||||
use query::api4::events::PlainEventsQuery;
|
||||
|
||||
pub struct EventsHandler {}
|
||||
@@ -46,21 +41,16 @@ impl EventsHandler {
|
||||
|
||||
pub async fn handle(&self, req: Requ, ctx: &ReqCtx, proxy_config: &ProxyConfig) -> Result<StreamResponse, Error> {
|
||||
if req.method() != Method::GET {
|
||||
return Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?);
|
||||
}
|
||||
|
||||
let def = HeaderValue::from_static("*/*");
|
||||
let accept = req.headers().get(header::ACCEPT).unwrap_or(&def);
|
||||
let accept = accept.to_str()?;
|
||||
|
||||
if accept.contains(APP_CBOR) {
|
||||
self.handle_cbor(req, ctx, proxy_config).await
|
||||
} else if accept.contains(APP_JSON) {
|
||||
return Ok(crate::proxy::proxy_backend_query::<PlainEventsQuery>(req, ctx, proxy_config).await?);
|
||||
} else if accept.contains(ACCEPT_ALL) {
|
||||
todo!()
|
||||
Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(body_empty())?)
|
||||
} else {
|
||||
return Err(Error::with_msg_no_trace(format!("bad accept {:?}", req.headers())));
|
||||
if accepts_cbor_frames(req.headers()) {
|
||||
// self.handle_cbor(req, ctx, proxy_config).await
|
||||
Ok(crate::proxy::proxy_backend_query::<PlainEventsQuery>(req, ctx, proxy_config).await?)
|
||||
} else if accepts_json_or_all(req.headers()) {
|
||||
Ok(crate::proxy::proxy_backend_query::<PlainEventsQuery>(req, ctx, proxy_config).await?)
|
||||
} else {
|
||||
Err(Error::with_msg_no_trace(format!("bad accept {:?}", req.headers())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ use err::Error;
|
||||
use netpod::get_url_query_pairs;
|
||||
use netpod::log::*;
|
||||
use netpod::query::CacheUsage;
|
||||
use netpod::query::PulseRangeQuery;
|
||||
use netpod::query::TimeRangeQuery;
|
||||
use netpod::range::evrange::SeriesRange;
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::ByteSize;
|
||||
|
||||
Reference in New Issue
Block a user