This repository has been archived on 2026-01-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Game/Server/common/db/etcd/etcd.go
2025-06-25 00:01:48 +08:00

30 lines
498 B
Go

package etcd
import (
commonConfig "common/config"
"fmt"
clientv3 "go.etcd.io/etcd/client/v3"
)
var etcdClient *clientv3.Client
func Init(cfg *commonConfig.EtcdConfig) error {
client, err := clientv3.New(clientv3.Config{
Endpoints: []string{fmt.Sprintf("%v:%v", cfg.Host, cfg.Port)},
DialTimeout: 0,
})
etcdClient = client
return err
}
func Close() error {
if etcdClient != nil {
return etcdClient.Close()
}
return nil
}
func Client() *clientv3.Client {
return etcdClient
}