package config

import (
	"github.com/sirupsen/logrus"
	"go.etcd.io/etcd/client/v3"
	"os"
	"time"
)

var (
	Etcd *clientv3.Client
)

func InitEtcd() {
	config := clientv3.Config{
		Endpoints:   []string{os.Getenv("ETCD_URL")},
		DialTimeout: time.Second * 3,
	}

	//连接
	client, err := clientv3.New(config)
	if err != nil {
		logrus.Panic("连接Etcd不成功, err:", err)
		return
	}
	Etcd = client
}
