WIP
This commit is contained in:
@@ -18,6 +18,7 @@ use items_2::frame::make_term_frame;
|
||||
use netpod::log::*;
|
||||
use netpod::Cluster;
|
||||
use netpod::Node;
|
||||
use netpod::APP_OCTET;
|
||||
use query::api4::events::EventsSubQuery;
|
||||
use query::api4::events::Frame1Parts;
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -63,32 +64,29 @@ pub async fn x_processed_event_blobs_stream_from_node_http(
|
||||
use http::Request;
|
||||
use httpclient::http;
|
||||
use httpclient::hyper;
|
||||
use hyper::Body;
|
||||
use hyper::StatusCode;
|
||||
|
||||
let frame1 = make_node_command_frame(subq.clone())?;
|
||||
let item = sitem_data(frame1.clone());
|
||||
let buf = item.make_frame()?;
|
||||
let buf = item.make_frame()?.freeze();
|
||||
|
||||
let url = node.baseurl().join("/api/4/private/eventdata/frames").unwrap();
|
||||
debug!("open_event_data_streams_http post {url}");
|
||||
let req = Request::builder()
|
||||
.method(Method::POST)
|
||||
.uri(url.to_string())
|
||||
.header(header::ACCEPT, "application/octet-stream")
|
||||
.body(Body::from(buf.to_vec()))
|
||||
.header(header::ACCEPT, APP_OCTET)
|
||||
.body(httpclient::Full::new(buf))
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
let client = hyper::Client::new();
|
||||
let mut client = httpclient::connect_client(req.uri()).await?;
|
||||
let res = client
|
||||
.request(req)
|
||||
.send_request(req)
|
||||
.await
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
if res.status() != StatusCode::OK {
|
||||
error!("Server error {:?}", res);
|
||||
let (head, body) = res.into_parts();
|
||||
let buf = hyper::body::to_bytes(body)
|
||||
.await
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
let buf = httpclient::read_body_bytes(body).await?;
|
||||
let s = String::from_utf8_lossy(&buf);
|
||||
return Err(Error::with_msg(format!(
|
||||
concat!(
|
||||
@@ -101,7 +99,7 @@ pub async fn x_processed_event_blobs_stream_from_node_http(
|
||||
)));
|
||||
}
|
||||
let (_head, body) = res.into_parts();
|
||||
let frames = InMemoryFrameStream::new(body, subq.inmem_bufcap());
|
||||
let frames = InMemoryFrameStream::new(httpclient::IncomingStream::new(body), subq.inmem_bufcap());
|
||||
let frames = Box::pin(frames);
|
||||
let stream = EventsFromFrames::new(frames, url.to_string());
|
||||
debug!("open_event_data_streams_http done {url}");
|
||||
@@ -165,31 +163,28 @@ where
|
||||
use http::Request;
|
||||
use httpclient::http;
|
||||
use httpclient::hyper;
|
||||
use hyper::Body;
|
||||
use hyper::StatusCode;
|
||||
|
||||
let item = sitem_data(frame1.clone());
|
||||
let buf = item.make_frame()?;
|
||||
let buf = item.make_frame()?.freeze();
|
||||
|
||||
let url = node.baseurl().join("/api/4/private/eventdata/frames").unwrap();
|
||||
debug!("open_event_data_streams_http post {url}");
|
||||
let req = Request::builder()
|
||||
.method(Method::POST)
|
||||
.uri(url.to_string())
|
||||
.header(header::ACCEPT, "application/octet-stream")
|
||||
.body(Body::from(buf.to_vec()))
|
||||
.header(header::ACCEPT, APP_OCTET)
|
||||
.body(httpclient::Full::new(buf))
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
let client = hyper::Client::new();
|
||||
let mut client = httpclient::connect_client(req.uri()).await?;
|
||||
let res = client
|
||||
.request(req)
|
||||
.send_request(req)
|
||||
.await
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
if res.status() != StatusCode::OK {
|
||||
error!("Server error {:?}", res);
|
||||
let (head, body) = res.into_parts();
|
||||
let buf = hyper::body::to_bytes(body)
|
||||
.await
|
||||
.map_err(|e| Error::with_msg_no_trace(e.to_string()))?;
|
||||
let buf = httpclient::read_body_bytes(body).await?;
|
||||
let s = String::from_utf8_lossy(&buf);
|
||||
return Err(Error::with_msg(format!(
|
||||
concat!(
|
||||
@@ -202,7 +197,7 @@ where
|
||||
)));
|
||||
}
|
||||
let (_head, body) = res.into_parts();
|
||||
let frames = InMemoryFrameStream::new(body, subq.inmem_bufcap());
|
||||
let frames = InMemoryFrameStream::new(httpclient::IncomingStream::new(body), subq.inmem_bufcap());
|
||||
let frames = Box::pin(frames);
|
||||
let stream = EventsFromFrames::<T>::new(frames, url.to_string());
|
||||
debug!("open_event_data_streams_http done {url}");
|
||||
|
||||
Reference in New Issue
Block a user