Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor power_event_watcher for configurable subscriber behavior #1764

Merged
merged 5 commits into from
Jun 27, 2024

Conversation

zackattack01
Copy link
Contributor

To support the windows watchdog efforts, we will be re-using the power_event_watcher code from the watchdog service. Currently the power_event_watcher component takes a knapsack reference and directly manipulates the InModernStandby value as a result of the observed events. These are also persisted to bbolt, making this a little tricky for sharing with a separate service as is.

We can't simply read the values from bbolt within watchdog because if launcher proper stops functioning (and requires watchdog intervention) we shouldn't trust the latest stored value.

We also likely won't want two versions of the same logs always being added from both watchdog and launcher, and I didn't want to just duplicate all of this code. This was the cleanest approach I could come up with, and should allow watchdog to simply define a new powerEventSubscriber (and avoid knapsack/stores setup). happy to hear any alternative suggestions!

@zackattack01 zackattack01 marked this pull request as draft June 27, 2024 16:02
@zackattack01 zackattack01 marked this pull request as ready for review June 27, 2024 16:21
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach! Just had a nit about naming


// knapsackSubscriber implements the powerEventSubscriber interface and
// updates the knapsack.InModernStandby state based on the power events observed
knapsackSubscriber struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might just be me, but I was confused because knapsackSubscriber sounds like something subscribing to the knapsack and not (effectively) the knapsack subscribing to something else. What about something like knapsackUpdater (or something along those lines but more specific, like knapsackSleepStateUpdater)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, that makes more sense thank you. will do knapsackSleepStateUpdater

@zackattack01 zackattack01 force-pushed the zack/power_event_watcher_updates branch from 57d1252 to ba831ce Compare June 27, 2024 19:33
@zackattack01 zackattack01 added this pull request to the merge queue Jun 27, 2024
Merged via the queue into main with commit 096376b Jun 27, 2024
29 checks passed
@zackattack01 zackattack01 deleted the zack/power_event_watcher_updates branch June 27, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants