Skip to content

Commit

Permalink
PR feedback: clearer struct naming as knapsackSleepStateUpdater
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Jun 27, 2024
1 parent 1c514f4 commit ba831ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func runLauncher(ctx context.Context, cancel func(), multiSlogger, systemMultiSl
// For now, remediation is not performed -- we only log the hardware change.
agent.DetectAndRemediateHardwareChange(ctx, k)

powerEventSubscriber := powereventwatcher.NewKnapsackSubscriber(slogger, k)
powerEventSubscriber := powereventwatcher.NewKnapsackSleepStateUpdater(slogger, k)
powerEventWatcher, err := powereventwatcher.New(ctx, slogger, powerEventSubscriber)
if err != nil {
slogger.Log(ctx, slog.LevelDebug,
Expand Down
8 changes: 4 additions & 4 deletions ee/powereventwatcher/power_event_watcher_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type noOpPowerEventWatcher struct {
interrupted bool
}

type noOpKnapsackSubscriber struct{}
type noOpKnapsackSleepStateUpdater struct{}

func NewKnapsackSubscriber(_ *slog.Logger, _ types.Knapsack) *noOpKnapsackSubscriber {
return &noOpKnapsackSubscriber{}
func NewKnapsackSleepStateUpdater(_ *slog.Logger, _ types.Knapsack) *noOpKnapsackSleepStateUpdater {
return &noOpKnapsackSleepStateUpdater{}
}

func New(ctx context.Context, _ *slog.Logger, _ *noOpKnapsackSubscriber) (*noOpPowerEventWatcher, error) {
func New(ctx context.Context, _ *slog.Logger, _ *noOpKnapsackSleepStateUpdater) (*noOpPowerEventWatcher, error) {
_, span := traces.StartSpan(ctx)
defer span.End()

Expand Down
12 changes: 6 additions & 6 deletions ee/powereventwatcher/power_event_watcher_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ type (
OnStartup() error
}

// knapsackSubscriber implements the powerEventSubscriber interface and
// knapsackSleepStateUpdater implements the powerEventSubscriber interface and
// updates the knapsack.InModernStandby state based on the power events observed
knapsackSubscriber struct {
knapsackSleepStateUpdater struct {
knapsack types.Knapsack
slogger *slog.Logger
}
Expand All @@ -63,14 +63,14 @@ const (
operationSuccessfulMsg = "The operation completed successfully."
)

func NewKnapsackSubscriber(slogger *slog.Logger, k types.Knapsack) *knapsackSubscriber {
return &knapsackSubscriber{
func NewKnapsackSleepStateUpdater(slogger *slog.Logger, k types.Knapsack) *knapsackSleepStateUpdater {
return &knapsackSleepStateUpdater{
knapsack: k,
slogger: slogger,
}
}

func (ks *knapsackSubscriber) OnPowerEvent(eventID int) error {
func (ks *knapsackSleepStateUpdater) OnPowerEvent(eventID int) error {
switch eventID {
case eventIdEnteringModernStandby, eventIdEnteringSleep:
ks.slogger.Log(context.TODO(), slog.LevelDebug,
Expand Down Expand Up @@ -106,7 +106,7 @@ func (ks *knapsackSubscriber) OnPowerEvent(eventID int) error {
return nil
}

func (ks *knapsackSubscriber) OnStartup() error {
func (ks *knapsackSleepStateUpdater) OnStartup() error {
// Clear InModernStandby flag, in case it's cached. We may have missed wake/sleep events
// while launcher was not running, and we want to err on the side of assuming the device
// is awake.
Expand Down

0 comments on commit ba831ce

Please sign in to comment.