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())) + } +}