Files
cloud-services/pkg/health/redis.go

54 lines
981 B
Go

package health
import (
"context"
"fiskerinc.com/modules/redis"
"fiskerinc.com/modules/redisv2"
)
type RedisHealth struct {
pool redis.ClientPoolInterface
}
func NewRedisHealth(pool redis.ClientPoolInterface) *RedisHealth {
return &RedisHealth{
pool: pool,
}
}
func (h *RedisHealth) Check(ctx context.Context) error {
client := h.pool.GetFromPool()
defer client.Close()
return client.Ping()
}
func (h *RedisHealth) RedisStatus(system *System) {
stats := h.pool.GetPool().Stats()
system.RedisStats = &stats
}
type RedisHealthV2 struct {
redisClient redisv2.ClientInterface
}
func NewRedisHealthV2(redisClient redisv2.ClientInterface) *RedisHealthV2 {
return &RedisHealthV2{
redisClient: redisClient,
}
}
func (h *RedisHealthV2) Check(ctx context.Context) error {
return h.redisClient.Ping()
}
func (h *RedisHealthV2) RedisStatus(system *System) {
// Im not so sure what
// stats := h.redisClient.GetClient().PoolStats()
system.RedisStats = nil
}