mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Redis: Check for connection on NewRDBWrapper()
This commit is contained in:
parent
cb018cea9d
commit
dce9c0fa4f
1 changed files with 7 additions and 2 deletions
9
redis.go
9
redis.go
|
|
@ -82,10 +82,15 @@ func (rdbw *RDBWrapper) CompareAndSetConnected(connected bool) (swapped bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func NewRDBWrapper(rdb *redis.Client) *RDBWrapper {
|
||||
func NewRDBWrapper(rdb *redis.Client) (*RDBWrapper, error) {
|
||||
rdbw := RDBWrapper{Rdb: rdb, ConnectedAtomic: new(uint32)}
|
||||
rdbw.ConnectionUpCondition = sync.NewCond(&sync.Mutex{})
|
||||
|
||||
res := rdbw.Rdb.Ping()
|
||||
if res.Err() != nil {
|
||||
return nil, res.Err()
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
rdbw.CheckConnection(true)
|
||||
|
|
@ -93,7 +98,7 @@ func NewRDBWrapper(rdb *redis.Client) *RDBWrapper {
|
|||
}
|
||||
}()
|
||||
|
||||
return &rdbw
|
||||
return &rdbw, nil
|
||||
}
|
||||
|
||||
func (rdbw *RDBWrapper) getConnectionCheckInterval() time.Duration {
|
||||
|
|
|
|||
Loading…
Reference in a new issue