pub struct Notifier<S: NotifySink> { /* private fields */ }Expand description
Keeps one notification per held app in step with what the effector did.
Call record for every applied action, then
end_tick once per loop iteration; notifications are
only sent from end_tick, so a thaw and a cap of the same app in one tick
replace the notification instead of closing and reopening it. A release
by thaw also waits one more tick before closing, since the policy caps a
still-hot app on the tick after its thaw.
Implementations§
Source§impl<S: NotifySink> Notifier<S>
impl<S: NotifySink> Notifier<S>
pub fn new(sink: S, cfg: &GuardConfig) -> Self
pub fn sink(&self) -> &S
pub fn flags(&self) -> NotifyFlags
Sourcepub fn set_flags(&mut self, flags: NotifyFlags)
pub fn set_flags(&mut self, flags: NotifyFlags)
Apply new notification settings. Turning notify off closes what is
shown; turning the early warning off closes it.
Sourcepub fn record(&mut self, action: &Action, applied: Option<Applied>)
pub fn record(&mut self, action: &Action, applied: Option<Applied>)
Note one action the effector applied. applied is None when it
failed. Cheap: nothing is sent or looked up until
end_tick.
Sourcepub fn end_tick(
&mut self,
now_ms: u64,
memory: Memory,
name: &mut dyn FnMut(&str, &str) -> String,
)
pub fn end_tick( &mut self, now_ms: u64, memory: Memory, name: &mut dyn FnMut(&str, &str) -> String, )
Send what changed this tick. memory is how the memory looked on this
tick (see memory_state). name maps an app key
and one of its cgroups to a display name; it is called once per newly
held app, after every action of the tick was applied.