liuhaijun 3f5f28d785 add sheduling agent
Change-Id: I89f35fb3984044c57f10727432755012542f9fd8
2023-11-16 10:55:57 +00:00

24 lines
489 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package data
import (
"context"
c "git.inspur.com/sbg-jszt/cfn/cfn-schedule-agent/config"
"github.com/go-redis/redis/v8"
)
var Rdb *redis.Client
func initRedis() {
Rdb = redis.NewClient(&redis.Options{
Addr: c.Config.Redis.Host + ":" + c.Config.Redis.Port,
Password: c.Config.Redis.Password,
DB: c.Config.Redis.Database,
})
var ctx = context.Background()
_, err := Rdb.Ping(ctx).Result()
if err != nil {
panic("Redis connection failed" + err.Error())
}
}