Fix api 1 status request

This commit is contained in:
Dominik Werder
2024-10-07 23:40:56 +02:00
parent 8bddb73579
commit 365cdcf2d6
11 changed files with 167 additions and 68 deletions

View File

@@ -5,7 +5,7 @@ use netpod::DtNano;
use serde::Deserialize;
use serde::Serialize;
pub trait AggTimeWeightOutputAvg: fmt::Debug + Clone + Serialize + for<'a> Deserialize<'a> {}
pub trait AggTimeWeightOutputAvg: fmt::Debug + Clone + Send + Serialize + for<'a> Deserialize<'a> {}
impl AggTimeWeightOutputAvg for u64 {}
@@ -13,7 +13,7 @@ impl AggTimeWeightOutputAvg for f32 {}
impl AggTimeWeightOutputAvg for f64 {}
pub trait AggregatorTimeWeight<EVT>
pub trait AggregatorTimeWeight<EVT>: fmt::Debug + Send
where
EVT: EventValueType,
{
@@ -23,6 +23,7 @@ where
fn result_and_reset_for_new_bin(&mut self, filled_width_fraction: f32) -> EVT::AggTimeWeightOutputAvg;
}
#[derive(Debug)]
pub struct AggregatorNumeric {
sum: f64,
}

View File

@@ -27,7 +27,7 @@ pub trait Container<EVT>: fmt::Debug + Clone + PreviewRange + Serialize + for<'a
fn pop_front(&mut self) -> Option<EVT>;
}
pub trait EventValueType: fmt::Debug + Clone + PartialOrd {
pub trait EventValueType: fmt::Debug + Clone + PartialOrd + Send {
type Container: Container<Self>;
type AggregatorTimeWeight: AggregatorTimeWeight<Self>;
type AggTimeWeightOutputAvg: AggTimeWeightOutputAvg;

View File

@@ -6,6 +6,7 @@ use crate::binning::container_events::ContainerEvents;
use crate::binning::container_events::ContainerEventsTakeUpTo;
use crate::binning::container_events::EventSingle;
use crate::channelevents::ChannelEvents;
use core::fmt;
use err::thiserror;
use err::ThisError;
use futures_util::Stream;
@@ -81,6 +82,7 @@ struct LstRef<'a, EVT>(&'a EventSingle<EVT>);
struct LstMut<'a, EVT>(&'a mut EventSingle<EVT>);
#[derive(Debug)]
struct InnerB<EVT>
where
EVT: EventValueType,
@@ -243,6 +245,7 @@ where
}
}
#[derive(Debug)]
struct InnerA<EVT>
where
EVT: EventValueType,
@@ -381,6 +384,20 @@ where
out: ContainerBins<EVT>,
}
impl<EVT> fmt::Debug for BinnedEventsTimeweight<EVT>
where
EVT: EventValueType,
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("BinnedEventsTimeweight")
.field("lst", &self.lst)
.field("range", &self.range)
.field("inner_a", &self.inner_a)
.field("out", &self.out)
.finish()
}
}
impl<EVT> BinnedEventsTimeweight<EVT>
where
EVT: EventValueType,

View File

@@ -1,9 +1,14 @@
use super::timeweight_events::BinnedEventsTimeweight;
use crate::binning::container_events::EventValueType;
use crate::channelevents::ChannelEvents;
use err::thiserror;
use err::ThisError;
use futures_util::Stream;
use items_0::streamitem::Sitemty;
use items_0::timebin::BinnedEventsTimeweightTrait;
use items_0::timebin::BinningggBinnerDyn;
use items_0::timebin::BinningggContainerBinsDyn;
use items_0::timebin::BinningggContainerEventsDyn;
use items_0::timebin::BinningggError;
use netpod::BinnedRange;
use netpod::TsNano;
@@ -17,37 +22,48 @@ pub enum Error {
InnerDynMissing,
}
pub struct BinnedEventsTimeweightDyn {
#[derive(Debug)]
pub struct BinnedEventsTimeweightDynbox<EVT>
where
EVT: EventValueType,
{
range: BinnedRange<TsNano>,
binner: Option<Box<dyn BinningggBinnerDyn>>,
binner: BinnedEventsTimeweight<EVT>,
}
impl BinnedEventsTimeweightDyn {
pub fn new(range: BinnedRange<TsNano>) -> Self {
Self { range, binner: None }
impl<EVT> BinnedEventsTimeweightDynbox<EVT>
where
EVT: EventValueType + 'static,
{
pub fn new(range: BinnedRange<TsNano>) -> Box<dyn BinnedEventsTimeweightTrait> {
let ret = Self {
binner: BinnedEventsTimeweight::new(range.clone()),
range,
};
Box::new(ret)
}
}
pub fn ingest(&mut self, mut evs_all: ContainerEventsDyn) -> Result<(), BinningggError> {
TODO;
impl<EVT> BinnedEventsTimeweightTrait for BinnedEventsTimeweightDynbox<EVT>
where
EVT: EventValueType,
{
fn ingest(&mut self, evs_all: Box<dyn BinningggContainerEventsDyn>) -> Result<(), BinningggError> {
todo!()
}
pub fn input_done_range_final(&mut self) -> Result<(), BinningggError> {
self.binner
.as_mut()
.ok_or(Error::InnerDynMissing)?
.input_done_range_final()
fn input_done_range_final(&mut self) -> Result<(), BinningggError> {
// self.binner.input_done_range_final()
todo!()
}
pub fn input_done_range_open(&mut self) -> Result<(), BinningggError> {
self.binner
.as_mut()
.ok_or(Error::InnerDynMissing)?
.input_done_range_open()
fn input_done_range_open(&mut self) -> Result<(), BinningggError> {
// self.binner.input_done_range_open()
todo!()
}
pub fn output(&mut self) -> ContainerBinsDyn {
TODO;
fn output(&mut self) -> Result<Box<dyn BinningggContainerBinsDyn>, BinningggError> {
// self.binner.output()
todo!()
}
}
@@ -63,3 +79,38 @@ impl Stream for BinnedEventsTimeweightStream {
todo!()
}
}
#[derive(Debug)]
pub struct BinnedEventsTimeweightLazy {
range: BinnedRange<TsNano>,
binned_events: Option<Box<dyn BinnedEventsTimeweightTrait>>,
}
impl BinnedEventsTimeweightLazy {
pub fn new(range: BinnedRange<TsNano>) -> Self {
Self {
range,
binned_events: None,
}
}
}
impl BinnedEventsTimeweightTrait for BinnedEventsTimeweightLazy {
fn ingest(&mut self, evs_all: Box<dyn BinningggContainerEventsDyn>) -> Result<(), BinningggError> {
// TODO the container must provide a method to create the dyn binner.
let binned_events = self.binned_events.get_or_insert_with(|| todo!());
todo!()
}
fn input_done_range_final(&mut self) -> Result<(), BinningggError> {
todo!()
}
fn input_done_range_open(&mut self) -> Result<(), BinningggError> {
todo!()
}
fn output(&mut self) -> Result<Box<dyn BinningggContainerBinsDyn>, BinningggError> {
todo!()
}
}

View File

@@ -49,6 +49,7 @@ impl Container<EnumVariant> for EnumVariantContainer {
}
}
#[derive(Debug)]
pub struct EnumVariantAggregatorTimeWeight {
sum: f32,
}