Deliver events from LTS

This commit is contained in:
Dominik Werder
2021-07-10 14:05:42 +02:00
parent 09724fd540
commit 35f3f9249e
8 changed files with 118 additions and 185 deletions

View File

@@ -1,4 +1,6 @@
use bytes::{BufMut, Bytes, BytesMut};
use err::Error;
use items::frame::make_frame;
use items::{Appendable, RangeOverlapInfo, SitemtyFrameType};
use netpod::log::*;
use netpod::NanoRange;

View File

@@ -18,8 +18,9 @@ use items::{
};
use netpod::log::*;
use netpod::query::RawEventsQuery;
use netpod::{AggKind, ByteOrder, Channel, NanoRange, NodeConfigCached, PerfOpts, ScalarType, Shape};
use parse::channelconfig::{extract_matching_config_entry, read_local_config, MatchingConfigEntry};
use netpod::{
AggKind, ByteOrder, Channel, ChannelConfigQuery, NanoRange, NodeConfigCached, PerfOpts, ScalarType, Shape,
};
use serde::de::DeserializeOwned;
use serde_json::Value as JsonValue;
use std::fmt::Debug;
@@ -177,34 +178,21 @@ pub async fn channel_exec<F>(
where
F: ChannelExecFunction,
{
let channel_config = match read_local_config(channel, &node_config.node).await {
Ok(k) => k,
Err(e) => {
if e.msg().contains("ErrorKind::NotFound") {
return Ok(F::empty());
} else {
return Err(e);
}
}
let q = ChannelConfigQuery {
channel: channel.clone(),
range: range.clone(),
};
match extract_matching_config_entry(range, &channel_config)? {
MatchingConfigEntry::Multiple => Err(Error::with_msg("multiple config entries found"))?,
MatchingConfigEntry::None => {
// TODO function needs to provide some default.
err::todoval()
}
MatchingConfigEntry::Entry(entry) => {
let ret = channel_exec_config(
f,
entry.scalar_type.clone(),
entry.byte_order.clone(),
entry.to_shape()?,
agg_kind,
node_config,
)?;
Ok(ret)
}
}
let conf = httpclient::get_channel_config(&q, node_config).await?;
let ret = channel_exec_config(
f,
conf.scalar_type.clone(),
// TODO is the byte order ever important here?
conf.byte_order.unwrap_or(ByteOrder::LE).clone(),
conf.shape.clone(),
agg_kind,
node_config,
)?;
Ok(ret)
}
pub struct PlainEvents {

View File

@@ -27,6 +27,7 @@ where
<ENP as EventsNodeProcessor>::Output: Unpin + 'static,
Result<StreamItem<RangeCompletableItem<<ENP as EventsNodeProcessor>::Output>>, err::Error>: FrameType,
{
netpod::log::info!("x_processed_stream_from_node to: {}:{}", node.host, node.port_raw);
let net = TcpStream::connect(format!("{}:{}", node.host, node.port_raw)).await?;
let qjs = serde_json::to_string(&query)?;
let (netin, mut netout) = net.into_split();