Skip to content

Commit

Permalink
Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Lemire committed Dec 11, 2023
1 parent 9c0fccf commit 933627f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion protocol/daemons/server/types/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ func (u *healthCheckerMutableState) SchedulePoll(nextPollDelay time.Duration) {
u.timer.Reset(nextPollDelay)
}

// InitializePolling schedules the first poll for the health-checkable service. This method is synchronized.
// InitializePolling schedules the first poll for the health-checkable service. This method is meant to be called
// immediately after initializing the health checker mutable state. This method is synchronized.
func (u *healthCheckerMutableState) InitializePolling(firstPollDelay time.Duration, pollFunc func()) {
u.lock.Lock()
defer u.lock.Unlock()
Expand Down Expand Up @@ -218,6 +219,8 @@ func StartNewHealthChecker(
}

// The first poll is scheduled after the startup grace period to allow the service to initialize.
// We initialize the timer and schedule a poll outside of object creation in order to avoid data races for
// extremely short startup grace periods.
checker.mutableState.InitializePolling(startupGracePeriod, checker.Poll)

return checker
Expand Down

0 comments on commit 933627f

Please sign in to comment.