Skip to content

Commit

Permalink
Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Lemire committed Oct 27, 2023
1 parent b58cdda commit fa555d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions protocol/daemons/pricefeed/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ type Client struct {
stopDaemon sync.Once

// isHealthy indicates whether the daemon is healthy - i.e., it is actively running and calculating prices.
// The daemon is considered healthy after startup is complete and while it is producing non-empty price updates.
// The daemon is considered healthy when it is producing non-empty price updates. It will be considered unhealthy
// until it produces its first non-empty price update.
isHealthy atomic.Bool
}

// Ensure Client implements the DaemonClient interface.
var _ daemontypes.DaemonClient = (*Client)(nil)

// HealthCheck returns an error if the daemon is unhealthy.
// The daemon is considered unhealthy if it either failed to initialize or is producing empty price updates.
// The daemon is considered unhealthy if it is not producing non-empty price updates. We expect a short period of time
// to pass on daemon startup where the daemon is unhealthy as the price cache warms up.
// This method is synchronized by isHealthy, which is an atomic.Bool.
func (c *Client) HealthCheck(_ context.Context) error {
if !c.isHealthy.Load() {
Expand Down

0 comments on commit fa555d8

Please sign in to comment.