54 lines
1017 B
Go
54 lines
1017 B
Go
package health
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/fiskerinc/cloud-services/pkg/redis"
|
|
"github.com/fiskerinc/cloud-services/pkg/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
|
|
}
|