Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
53
pkg/health/redis.go
Normal file
53
pkg/health/redis.go
Normal file
@@ -0,0 +1,53 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user