feat: registry.

This commit is contained in:
Bobo
2025-06-02 14:09:11 +08:00
parent 0759f2d752
commit 54e887034f
37 changed files with 285 additions and 55 deletions

View File

@@ -2,14 +2,21 @@ package consul
import (
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
consulClient "github.com/hashicorp/consul/api"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
r "github.com/tx7do/kratos-bootstrap/registry"
)
func init() {
// 注册 Consul 注册发现客户端
//registry.RegisterDiscoveryCreator(registry.Consul, NewRegistry)
r.RegisterRegistrarCreator(string(r.Consul), func(c *conf.Registry) registry.Registrar {
return NewRegistry(c)
})
r.RegisterDiscoveryCreator(string(r.Consul), func(c *conf.Registry) registry.Discovery {
return NewRegistry(c)
})
}
// NewRegistry 创建一个注册发现客户端 - Consul

View File

@@ -8,14 +8,15 @@ replace (
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.4.1
github.com/tx7do/kratos-bootstrap/api => ../../api
github.com/tx7do/kratos-bootstrap/registry => ../registry
github.com/tx7do/kratos-bootstrap/registry => ../
)
require (
github.com/go-kratos/kratos/v2 v2.8.4
github.com/hashicorp/consul/api v1.32.1
github.com/stretchr/testify v1.10.0
github.com/tx7do/kratos-bootstrap/api v0.0.20
github.com/tx7do/kratos-bootstrap/api v0.0.21
github.com/tx7do/kratos-bootstrap/registry v0.1.0
)
require (