Refactor one-before retrieve
This commit is contained in:
@@ -3,6 +3,7 @@ pub mod histo;
|
||||
pub mod query;
|
||||
pub mod range;
|
||||
pub mod status;
|
||||
pub mod stream_impl_tracer;
|
||||
pub mod streamext;
|
||||
pub mod ttl;
|
||||
|
||||
@@ -116,6 +117,12 @@ pub const DATETIME_FMT_9MS: &str = "%Y-%m-%dT%H:%M:%S.%9fZ";
|
||||
|
||||
const TEST_BACKEND: &str = "testbackend-00";
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const trigger: [&'static str; 1] = [
|
||||
//
|
||||
"S30CB05-VMCP-A010:PRESSURE",
|
||||
];
|
||||
|
||||
pub struct OnDrop<F>
|
||||
where
|
||||
F: FnOnce() -> (),
|
||||
|
||||
43
crates/netpod/src/stream_impl_tracer.rs
Normal file
43
crates/netpod/src/stream_impl_tracer.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use crate::log::*;
|
||||
|
||||
pub struct StreamImplTracer {
|
||||
name: String,
|
||||
npoll_cnt: usize,
|
||||
npoll_max: usize,
|
||||
loop_cnt: usize,
|
||||
loop_max: usize,
|
||||
}
|
||||
|
||||
impl StreamImplTracer {
|
||||
pub fn new(name: String, npoll_max: usize, loop_max: usize) -> Self {
|
||||
Self {
|
||||
name,
|
||||
npoll_cnt: 0,
|
||||
npoll_max,
|
||||
loop_cnt: 0,
|
||||
loop_max,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn poll_enter(&mut self) -> bool {
|
||||
self.npoll_cnt += 1;
|
||||
if self.npoll_cnt >= self.npoll_max {
|
||||
trace!("{} poll {} reached limit", self.name, self.npoll_cnt);
|
||||
true
|
||||
} else {
|
||||
trace!("{} poll {}", self.name, self.npoll_cnt);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn loop_enter(&mut self) -> bool {
|
||||
self.loop_cnt += 1;
|
||||
if self.loop_cnt >= self.loop_max {
|
||||
trace!("{} loop {} reached limit", self.name, self.loop_cnt);
|
||||
true
|
||||
} else {
|
||||
trace!("{} loop {}", self.name, self.loop_cnt);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user