pub struct WindowAggregator { /* private fields */ }Expand description
窗口聚合器
按时间窗口收集 SanitizedEvent, 在窗口关闭时构建 StructuredContext。
Implementations§
Source§impl WindowAggregator
impl WindowAggregator
Sourcepub fn new(window_secs: u64, now_ms: i64) -> Self
pub fn new(window_secs: u64, now_ms: i64) -> Self
创建新的窗口聚合器
window_secs 为窗口长度, 默认 10 秒。
now_ms 为当前 epoch 毫秒时间戳。
Sourcepub fn push(&mut self, event: SanitizedEvent)
pub fn push(&mut self, event: SanitizedEvent)
向当前窗口追加一个脱敏事件
Sourcepub fn is_expired(&self, now_ms: i64) -> bool
pub fn is_expired(&self, now_ms: i64) -> bool
窗口是否已到期
Sourcepub fn close(&mut self, now_ms: i64) -> Option<StructuredContext>
pub fn close(&mut self, now_ms: i64) -> Option<StructuredContext>
关闭当前窗口, 构建 StructuredContext, 并重置缓冲区。
now_ms 为窗口结束时间 (epoch ms)。
返回 Some(StructuredContext) 如果窗口非空, 否则返回 None。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WindowAggregator
impl RefUnwindSafe for WindowAggregator
impl Send for WindowAggregator
impl Sync for WindowAggregator
impl Unpin for WindowAggregator
impl UnsafeUnpin for WindowAggregator
impl UnwindSafe for WindowAggregator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more