func (rd *RedisClusterDriver) RegisterServiceNode(serviceName string) (nodeID string, err error) {
	nodeID = uuid.New().String()
	key := rd.getKeyPre(serviceName) + nodeID
	if err := rd.redisClient.Set(rd.ctx, key, nodeID, rd.timeout).Err(); err != nil {
		return "", err
	}
	return key, nil
}
RegisterServiceNode  register a service node
package redis_cluster
import (
	"context"
	"crypto/tls"
	"fmt"
	"github.com/go-redis/redis/v8"
	"github.com/google/uuid"
	"sync"
	"time"
)
const GlobalKeyPrefix = "distributed-cron:"
type Conf struct {
	Proto string
	Addrs    []string
	Password string
	MaxRedirects int
	ReadOnly     bool
	TLSConfig *tls.Config
}
type RedisClusterDriver struct {
	conf        *Conf
	redisClient *redis.ClusterClient
	timeout     time.Duration
	Key         string
	ctx         context.Context
}
func NewDriver(conf *Conf) (*RedisClusterDriver, error) {
	opts := &redis.ClusterOptions{
		Addrs:    conf.Addrs,
		Password: conf.Password,
		ReadOnly: conf.ReadOnly,
	}
	if conf.MaxRedirects > 0 {
		opts.MaxRedirects = conf.MaxRedirects
	}
	if conf.TLSConfig != nil {
		opts.TLSConfig = conf.TLSConfig
	}
	redisClient := redis.NewClusterClient(opts)
	return &RedisClusterDriver{
		conf:        conf,
		redisClient: redisClient,
		ctx:         context.TODO(),
	}, nil
}
func (rd *RedisClusterDriver) Ping() error {
	if err := rd.redisClient.Set(rd.ctx, "ping", "pong", 0).Err(); err != nil {
		return err
	}
	return nil
}
func (rd *RedisClusterDriver) getKeyPre(serviceName string) string {
	return GlobalKeyPrefix + serviceName + ":"
}
func (rd *RedisClusterDriver) SetTimeout(timeout time.Duration) {
	rd.timeout = timeout
}
func (rd *RedisClusterDriver) SetHeartBeat(nodeID string) {
	go rd.heartBear(nodeID)
}
func (rd *RedisClusterDriver) heartBear(nodeID string) {
	key := nodeID
	tickers := time.NewTicker(rd.timeout / 2)
	for range tickers.C {
		if err := rd.redisClient.Expire(rd.ctx, key, rd.timeout).Err(); err != nil {
			panic(err)
		}
	}
}
func (rd *RedisClusterDriver) GetServiceNodeList(serviceName string) ([]string, error) {
	mathStr := fmt.Sprintf("%s*", rd.getKeyPre(serviceName))
	return rd.scan(mathStr)
}