HA: only read new hearbeats from Redis

Selecting any heartbeat from the last 15 seconds from Redis makes little
sense, just wait for new ones. If Icinga 2 just stopped, there is no
point in becoming active for just a few seconds, otherwise the next
heartbeat will arrive in a second anyways.
This commit is contained in:
Julian Brost 2021-02-12 09:01:55 +01:00
parent 4374eec849
commit 9d23bbec2e

View file

@ -5,12 +5,10 @@ package ha
import (
"crypto/sha1"
"encoding/json"
"fmt"
"github.com/Icinga/icingadb/connection"
"github.com/Icinga/icingadb/utils"
"github.com/go-redis/redis/v7"
log "github.com/sirupsen/logrus"
"time"
)
type Environment struct {
@ -43,7 +41,7 @@ func IcingaHeartbeatListener(rdb *connection.RDBWrapper, chEnv chan *Environment
log.Info("Starting heartbeat listener")
xReadArgs := redis.XReadArgs{
Streams: []string{"icinga:stats", fmt.Sprintf("%d-0", utils.TimeToMillisecs(time.Now().Add(-15*time.Second)))},
Streams: []string{"icinga:stats", "$"},
Count: 1,
Block: 0,
}