mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Add type config.Redis
Redis defines Redis client configuration.
This commit is contained in:
parent
03f26b5b18
commit
140f46af0e
1 changed files with 27 additions and 0 deletions
27
pkg/config/redis.go
Normal file
27
pkg/config/redis.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/icinga/icingadb/pkg/icingaredis"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Redis defines Redis client configuration.
|
||||
type Redis struct {
|
||||
Address string `yaml:"address"`
|
||||
Password string `yaml:"password"`
|
||||
}
|
||||
|
||||
// NewClient prepares Redis client configuration,
|
||||
// calls redis.NewClient, but returns *icingaredis.Client.
|
||||
func (r *Redis) NewClient(logger *zap.SugaredLogger) (*icingaredis.Client, error) {
|
||||
c := redis.NewClient(&redis.Options{
|
||||
Addr: r.Address,
|
||||
Password: r.Password,
|
||||
DB: 0, // Use default DB,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
})
|
||||
|
||||
return icingaredis.NewClient(c, logger), nil
|
||||
}
|
||||
Loading…
Reference in a new issue