Deliver plain dim-0 and dim-1 events as json

This commit is contained in:
Dominik Werder
2021-06-11 13:35:48 +02:00
parent 20d5fe9573
commit b736905448
23 changed files with 1177 additions and 164 deletions

View File

@@ -1,7 +1,8 @@
use crate::gather::gather_get_json;
use bytes::Bytes;
use disk::binned::prebinned::pre_binned_bytes_for_http;
use disk::binned::query::{BinnedQuery, PlainEventsQuery, PreBinnedQuery};
use disk::binned::query::{BinnedQuery, PreBinnedQuery};
use disk::events::PlainEventsQuery;
use disk::raw::conn::events_service;
use err::Error;
use future::Future;
@@ -175,7 +176,7 @@ async fn http_service_try(req: Request<Body>, node_config: &NodeConfigCached) ->
} else {
Ok(response(StatusCode::METHOD_NOT_ALLOWED).body(Body::empty())?)
}
} else if path == "/api/4/plain_events_json" {
} else if path == "/api/4/alpha_plain_events_json" {
if req.method() == Method::GET {
Ok(plain_events_json(req, &node_config).await?)
} else {
@@ -411,8 +412,12 @@ async fn plain_events(req: Request<Body>, node_config: &NodeConfigCached) -> Res
async fn plain_events_json(req: Request<Body>, node_config: &NodeConfigCached) -> Result<Response<Body>, Error> {
let (head, _body) = req.into_parts();
let query = PlainEventsQuery::from_request(&head)?;
let op =
disk::channelexec::PlainEventsJson::new(query.channel().clone(), query.range().clone(), node_config.clone());
let op = disk::channelexec::PlainEventsJson::new(
query.channel().clone(),
query.range().clone(),
query.timeout(),
node_config.clone(),
);
let s = disk::channelexec::channel_exec(op, query.channel(), query.range(), node_config).await?;
let ret = response(StatusCode::OK).body(BodyStream::wrapped(s, format!("plain_events")))?;
Ok(ret)