Refactor status package to use portbase/runtime.
Refactor the status package to use portbase/runtime and make system status readonly. Also adapts the code base to the new portbase/notifications package.
This commit is contained in:
36
status/autopilot.go
Normal file
36
status/autopilot.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package status
|
||||
|
||||
import "context"
|
||||
|
||||
var runAutoPilot = make(chan struct{})
|
||||
|
||||
func triggerAutopilot() {
|
||||
select {
|
||||
case runAutoPilot <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func autoPilot(ctx context.Context) error {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-runAutoPilot:
|
||||
}
|
||||
|
||||
selected := SelectedSecurityLevel()
|
||||
mitigation := getHighestMitigationLevel()
|
||||
|
||||
active := SecurityLevelNormal
|
||||
if selected != SecurityLevelOff {
|
||||
active = selected
|
||||
} else if mitigation != SecurityLevelOff {
|
||||
active = mitigation
|
||||
}
|
||||
|
||||
setActiveLevel(active)
|
||||
|
||||
pushSystemStatus()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user