Compare commits
4 Commits
bootstrap/
...
registry/v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3d17b9d34 | ||
|
|
62ee65a36b | ||
|
|
a28f55cb99 | ||
|
|
9a4861eff2 |
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Service = config.NewServiceInfo(
|
||||
Service = utils.NewServiceInfo(
|
||||
"",
|
||||
"1.0.0",
|
||||
"",
|
||||
|
||||
@@ -22,9 +22,9 @@ require (
|
||||
github.com/google/subcommands v1.2.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.7
|
||||
github.com/tx7do/kratos-bootstrap/config v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/logger v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/logger v0.0.6
|
||||
github.com/tx7do/kratos-bootstrap/registry v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/tracer v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0
|
||||
@@ -173,6 +173,6 @@ require (
|
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
|
||||
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1059,7 +1059,7 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
|
||||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 h1:sCP7Vv3xx/CWIuTPVN38lUPx0uw0lcLfzaiDa8Ja01A=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.3/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4=
|
||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
|
||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
|
||||
|
||||
@@ -9,6 +9,7 @@ replace (
|
||||
github.com/imdario/mergo => dario.cat/mergo v0.3.16
|
||||
|
||||
github.com/tx7do/kratos-bootstrap/api => ../api
|
||||
github.com/tx7do/kratos-bootstrap/utils => ../utils
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -19,7 +20,8 @@ require (
|
||||
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20241105072421-f8b97f675b32
|
||||
github.com/go-kratos/kratos/v2 v2.8.2
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.7
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0
|
||||
go.uber.org/zap v1.27.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/tx7do/kratos-bootstrap/logger/zap"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
"github.com/tx7do/kratos-bootstrap/utils"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package consul
|
||||
|
||||
import (
|
||||
consulKratos "github.com/go-kratos/kratos/contrib/registry/consul/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
consulKratos "github.com/go-kratos/kratos/contrib/registry/consul/v2"
|
||||
consulClient "github.com/hashicorp/consul/api"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
@@ -11,6 +11,10 @@ import (
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Consul
|
||||
func NewRegistry(c *conf.Registry) *consulKratos.Registry {
|
||||
if c == nil || c.Consul == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := consulClient.DefaultConfig()
|
||||
cfg.Address = c.Consul.GetAddress()
|
||||
cfg.Scheme = c.Consul.GetScheme()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package etcd
|
||||
|
||||
import (
|
||||
etcdKratos "github.com/go-kratos/kratos/contrib/registry/etcd/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
etcdKratos "github.com/go-kratos/kratos/contrib/registry/etcd/v2"
|
||||
etcdClient "go.etcd.io/etcd/client/v3"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
@@ -11,6 +11,10 @@ import (
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Etcd
|
||||
func NewRegistry(c *conf.Registry) *etcdKratos.Registry {
|
||||
if c == nil || c.Etcd == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := etcdClient.Config{
|
||||
Endpoints: c.Etcd.Endpoints,
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package eureka
|
||||
|
||||
import (
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
eurekaKratos "github.com/go-kratos/kratos/contrib/registry/eureka/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Eureka
|
||||
func NewRegistry(c *conf.Registry) *eurekaKratos.Registry {
|
||||
if c == nil || c.Eureka == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var opts []eurekaKratos.Option
|
||||
opts = append(opts, eurekaKratos.WithHeartbeat(c.Eureka.HeartbeatInterval.AsDuration()))
|
||||
opts = append(opts, eurekaKratos.WithRefresh(c.Eureka.RefreshInterval.AsDuration()))
|
||||
|
||||
@@ -3,9 +3,9 @@ package kubernetes
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
k8sRegistry "github.com/go-kratos/kratos/contrib/registry/kubernetes/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
k8sRegistry "github.com/go-kratos/kratos/contrib/registry/kubernetes/v2"
|
||||
k8s "k8s.io/client-go/kubernetes"
|
||||
k8sRest "k8s.io/client-go/rest"
|
||||
k8sTools "k8s.io/client-go/tools/clientcmd"
|
||||
@@ -15,7 +15,11 @@ import (
|
||||
)
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Kubernetes
|
||||
func NewRegistry(_ *conf.Registry) *k8sRegistry.Registry {
|
||||
func NewRegistry(cfg *conf.Registry) *k8sRegistry.Registry {
|
||||
if cfg == nil || cfg.Kubernetes == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
restConfig, err := k8sRest.InClusterConfig()
|
||||
if err != nil {
|
||||
home := k8sUtil.HomeDir()
|
||||
@@ -33,7 +37,8 @@ func NewRegistry(_ *conf.Registry) *k8sRegistry.Registry {
|
||||
return nil
|
||||
}
|
||||
|
||||
reg := k8sRegistry.NewRegistry(clientSet)
|
||||
var namespace string
|
||||
reg := k8sRegistry.NewRegistry(clientSet, namespace)
|
||||
|
||||
return reg
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package nacos
|
||||
|
||||
import (
|
||||
nacosKratos "github.com/go-kratos/kratos/contrib/registry/nacos/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
nacosKratos "github.com/go-kratos/kratos/contrib/registry/nacos/v2"
|
||||
nacosClients "github.com/nacos-group/nacos-sdk-go/clients"
|
||||
nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"
|
||||
nacosVo "github.com/nacos-group/nacos-sdk-go/vo"
|
||||
@@ -13,6 +13,10 @@ import (
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Nacos
|
||||
func NewRegistry(c *conf.Registry) *nacosKratos.Registry {
|
||||
if c == nil || c.Nacos == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
srvConf := []nacosConstant.ServerConfig{
|
||||
*nacosConstant.NewServerConfig(c.Nacos.Address, c.Nacos.Port),
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package polaris
|
||||
|
||||
import (
|
||||
polarisKratos "github.com/go-kratos/kratos/contrib/registry/polaris/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
polarisKratos "github.com/go-kratos/kratos/contrib/registry/polaris/v2"
|
||||
|
||||
polarisApi "github.com/polarismesh/polaris-go"
|
||||
polarisApi "github.com/polarismesh/polaris-go/api"
|
||||
polarisModel "github.com/polarismesh/polaris-go/pkg/model"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
@@ -13,6 +12,10 @@ import (
|
||||
|
||||
// NewPolarisRegistry 创建一个注册发现客户端 - Polaris
|
||||
func NewPolarisRegistry(c *conf.Registry) *polarisKratos.Registry {
|
||||
if c == nil || c.Polaris == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
var consumer polarisApi.ConsumerAPI
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package servicecomb
|
||||
|
||||
import (
|
||||
servicecombKratos "github.com/go-kratos/kratos/contrib/registry/servicecomb/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
servicecombClient "github.com/go-chassis/sc-client"
|
||||
servicecombKratos "github.com/go-kratos/kratos/contrib/registry/servicecomb/v2"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - Servicecomb
|
||||
func NewRegistry(c *conf.Registry) *servicecombKratos.Registry {
|
||||
if c == nil || c.Servicecomb == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := servicecombClient.Options{
|
||||
Endpoints: c.Servicecomb.Endpoints,
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package zookeeper
|
||||
|
||||
import (
|
||||
zookeeperKratos "github.com/go-kratos/kratos/contrib/registry/zookeeper/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
zookeeperKratos "github.com/go-kratos/kratos/contrib/registry/zookeeper/v2"
|
||||
"github.com/go-zookeeper/zk"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
@@ -11,6 +11,10 @@ import (
|
||||
|
||||
// NewRegistry 创建一个注册发现客户端 - ZooKeeper
|
||||
func NewRegistry(c *conf.Registry) *zookeeperKratos.Registry {
|
||||
if c == nil || c.Zookeeper == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
conn, _, err := zk.Connect(c.Zookeeper.Endpoints, c.Zookeeper.Timeout.AsDuration())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
6
tag.bat
6
tag.bat
@@ -4,9 +4,9 @@ git tag utils/v0.1.0 --force
|
||||
|
||||
git tag cache/redis/v0.0.5 --force
|
||||
git tag oss/minio/v0.0.5 --force
|
||||
git tag registry/v0.0.5 --force
|
||||
git tag registry/v0.0.6 --force
|
||||
git tag config/v0.0.5 --force
|
||||
git tag logger/v0.0.5 --force
|
||||
git tag logger/v0.0.6 --force
|
||||
git tag rpc/v0.0.5 --force
|
||||
git tag tracer/v0.0.5 --force
|
||||
|
||||
@@ -17,7 +17,7 @@ git tag database/influxdb/v0.0.1 --force
|
||||
git tag database/cassandra/v0.0.1 --force
|
||||
git tag database/clickhouse/v0.0.2 --force
|
||||
|
||||
git tag bootstrap/v0.0.5 --force
|
||||
git tag bootstrap/v0.0.8 --force
|
||||
|
||||
git tag v0.5.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user