From 7827731423dac9c1372fa55347bc6f752fef7d69 Mon Sep 17 00:00:00 2001 From: "dc.To" Date: Sun, 27 Apr 2025 14:16:23 +0800 Subject: [PATCH] rename to registry --- config/etcd.go | 7 ------- registry/etcd.go | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) delete mode 100644 config/etcd.go create mode 100644 registry/etcd.go diff --git a/config/etcd.go b/config/etcd.go deleted file mode 100644 index 6cc830d..0000000 --- a/config/etcd.go +++ /dev/null @@ -1,7 +0,0 @@ -package config - -import "os" - -func Endpoint() string { - return os.Getenv("ETCD_ENDPOINTS") -} diff --git a/registry/etcd.go b/registry/etcd.go new file mode 100644 index 0000000..a2e40c5 --- /dev/null +++ b/registry/etcd.go @@ -0,0 +1,18 @@ +package config + +import ( + "os" + + "github.com/gogf/gf/contrib/registry/etcd/v2" + "github.com/gogf/gf/contrib/rpc/grpcx/v2" +) + +func Endpoint() string { + return os.Getenv("ETCD_ENDPOINTS") +} + +func Etcd() { + if Endpoint() != "" { + grpcx.Resolver.Register(etcd.New(Endpoint())) + } +}