Skip to content

Commit

Permalink
Send only changes of health
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaniwaki committed Oct 29, 2018
1 parent 259338d commit 1462fe7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,16 @@ func (m *HostDevicePlugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePl
func (m *HostDevicePlugin) healthCheck() {
log.Printf("Starting health check every %d seconds", m.healthCheckIntervalSeconds)
ticker := time.NewTicker(m.healthCheckIntervalSeconds * time.Second)
lastHealth := ""
for {
select {
case <-ticker.C:
m.health <- getHostDevicesHealth(m.hostDevices)
health := getHostDevicesHealth(m.hostDevices)
if lastHealth != health {
log.Printf("Health is changed: %s -> %s", lastHealth, health)
m.health <- health
}
lastHealth = health
case <-m.stop:
ticker.Stop()
return
Expand Down

0 comments on commit 1462fe7

Please sign in to comment.