Compare commits
6 Commits
bootstrap/
...
bootstrap/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e9d634935 | ||
|
|
f65e647380 | ||
|
|
be232fe811 | ||
|
|
52fc752502 | ||
|
|
120029bb01 | ||
|
|
f3d17b9d34 |
@@ -23,9 +23,9 @@ require (
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/spf13/cobra v1.8.1
|
||||
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.6
|
||||
github.com/tx7do/kratos-bootstrap/registry v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/config v0.0.7
|
||||
github.com/tx7do/kratos-bootstrap/logger v0.0.7
|
||||
github.com/tx7do/kratos-bootstrap/registry v0.0.7
|
||||
github.com/tx7do/kratos-bootstrap/tracer v0.0.5
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0
|
||||
golang.org/x/tools v0.27.0
|
||||
@@ -77,6 +77,7 @@ require (
|
||||
github.com/go-zookeeper/zk v1.0.4 // indirect
|
||||
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
|
||||
@@ -224,8 +224,9 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
|
||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -882,6 +883,7 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
|
||||
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
package apollo
|
||||
|
||||
import (
|
||||
"github.com/go-kratos/kratos/v2/config"
|
||||
|
||||
// apollo
|
||||
apolloKratos "github.com/go-kratos/kratos/contrib/config/apollo/v2"
|
||||
"github.com/go-kratos/kratos/v2/config"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Apollo
|
||||
func NewConfigSource(c *conf.RemoteConfig) config.Source {
|
||||
func NewConfigSource(cfg *conf.RemoteConfig) config.Source {
|
||||
if cfg == nil || cfg.Apollo == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
source := apolloKratos.NewSource(
|
||||
apolloKratos.WithAppID(c.Apollo.AppId),
|
||||
apolloKratos.WithCluster(c.Apollo.Cluster),
|
||||
apolloKratos.WithEndpoint(c.Apollo.Endpoint),
|
||||
apolloKratos.WithNamespace(c.Apollo.Namespace),
|
||||
apolloKratos.WithSecret(c.Apollo.Secret),
|
||||
apolloKratos.WithAppID(cfg.Apollo.AppId),
|
||||
apolloKratos.WithCluster(cfg.Apollo.Cluster),
|
||||
apolloKratos.WithEndpoint(cfg.Apollo.Endpoint),
|
||||
apolloKratos.WithNamespace(cfg.Apollo.Namespace),
|
||||
apolloKratos.WithSecret(cfg.Apollo.Secret),
|
||||
apolloKratos.WithEnableBackup(),
|
||||
)
|
||||
return source
|
||||
|
||||
@@ -22,6 +22,10 @@ func getConfigKey(configKey string, useBackslash bool) string {
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Consul
|
||||
func NewConfigSource(c *conf.RemoteConfig) config.Source {
|
||||
if c == nil || c.Consul == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := consulApi.DefaultConfig()
|
||||
cfg.Address = c.Consul.Address
|
||||
cfg.Scheme = c.Consul.Scheme
|
||||
|
||||
@@ -25,6 +25,10 @@ func getConfigKey(configKey string, useBackslash bool) string {
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Etcd
|
||||
func NewConfigSource(c *conf.RemoteConfig) config.Source {
|
||||
if c == nil || c.Etcd == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg := etcdClient.Config{
|
||||
Endpoints: c.Etcd.Endpoints,
|
||||
DialTimeout: c.Etcd.Timeout.AsDuration(),
|
||||
|
||||
108
config/go.mod
108
config/go.mod
@@ -17,33 +17,53 @@ require (
|
||||
github.com/go-kratos/kratos/contrib/config/etcd/v2 v2.0.0-20241105072421-f8b97f675b32
|
||||
github.com/go-kratos/kratos/contrib/config/kubernetes/v2 v2.0.0-20241105072421-f8b97f675b32
|
||||
github.com/go-kratos/kratos/contrib/config/nacos/v2 v2.0.0-20241105072421-f8b97f675b32
|
||||
github.com/go-kratos/kratos/contrib/config/polaris/v2 v2.0.0-20241105072421-f8b97f675b32
|
||||
github.com/go-kratos/kratos/v2 v2.8.2
|
||||
github.com/hashicorp/consul/api v1.30.0
|
||||
github.com/nacos-group/nacos-sdk-go v1.1.5
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.5
|
||||
github.com/polarismesh/polaris-go v1.5.8
|
||||
github.com/tx7do/kratos-bootstrap/api v0.0.7
|
||||
go.etcd.io/etcd/client/v3 v3.5.17
|
||||
google.golang.org/grpc v1.68.0
|
||||
k8s.io/client-go v0.31.2
|
||||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.0 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 // indirect
|
||||
github.com/apolloconfig/agollo/v4 v4.3.1 // indirect
|
||||
github.com/armon/go-metrics v0.4.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
|
||||
github.com/polarismesh/specification v1.5.3 // indirect
|
||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.60.1 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.6.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.1 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.63.51 // indirect
|
||||
github.com/apolloconfig/agollo/v4 v4.4.0 // indirect
|
||||
github.com/armon/go-metrics v0.5.3 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/go-errors/errors v1.0.1 // indirect
|
||||
github.com/go-errors/errors v1.5.1 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
||||
github.com/go-openapi/swag v0.23.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
|
||||
@@ -52,18 +72,18 @@ require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||
github.com/hashicorp/go-hclog v1.6.3 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/serf v0.10.1 // indirect
|
||||
github.com/imdario/mergo v0.3.6 // indirect
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
|
||||
github.com/imdario/mergo v1.0.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -72,44 +92,42 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/pelletier/go-toml v1.9.4 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/spf13/afero v1.8.2 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.7.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.11.0 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/spf13/viper v1.19.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/tx7do/kratos-bootstrap/utils v0.1.0
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.17 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.17.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
|
||||
golang.org/x/net v0.29.0 // indirect
|
||||
golang.org/x/oauth2 v0.23.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/term v0.24.0 // indirect
|
||||
golang.org/x/text v0.18.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
|
||||
golang.org/x/net v0.31.0 // indirect
|
||||
golang.org/x/oauth2 v0.24.0 // indirect
|
||||
golang.org/x/sync v0.9.0 // indirect
|
||||
golang.org/x/sys v0.27.0 // indirect
|
||||
golang.org/x/term v0.26.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/time v0.8.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
|
||||
google.golang.org/protobuf v1.35.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/ini.v1 v1.66.4 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.31.2 // indirect
|
||||
k8s.io/apimachinery v0.31.2 // indirect
|
||||
k8s.io/klog/v2 v2.130.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
|
||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||
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.3 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
626
config/go.sum
626
config/go.sum
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,10 @@ import (
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Kubernetes
|
||||
func NewConfigSource(c *conf.RemoteConfig) config.Source {
|
||||
if c == nil || c.Kubernetes == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
source := k8sKratos.NewSource(
|
||||
k8sKratos.Namespace(c.Kubernetes.Namespace),
|
||||
k8sKratos.LabelSelector(""),
|
||||
|
||||
@@ -25,6 +25,10 @@ func getConfigKey(configKey string, useBackslash bool) string {
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Nacos
|
||||
func NewConfigSource(c *conf.RemoteConfig) config.Source {
|
||||
if c == nil || c.Nacos == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
srvConf := []nacosConstant.ServerConfig{
|
||||
*nacosConstant.NewServerConfig(c.Nacos.Address, c.Nacos.Port),
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package polaris
|
||||
|
||||
import (
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
|
||||
//polarisKratos "github.com/go-kratos/kratos/contrib/config/polaris/v2"
|
||||
"github.com/go-kratos/kratos/v2/config"
|
||||
//"github.com/go-kratos/kratos/v2/log"
|
||||
//
|
||||
//polarisApi "github.com/polarismesh/polaris-go"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewConfigSource 创建一个远程配置源 - Polaris
|
||||
|
||||
@@ -3,11 +3,16 @@ package aliyun
|
||||
import (
|
||||
aliyunLogger "github.com/go-kratos/kratos/contrib/log/aliyun/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器 - Aliyun
|
||||
func NewLogger(cfg *conf.Logger) log.Logger {
|
||||
if cfg == nil || cfg.Aliyun == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
wrapped := aliyunLogger.NewAliyunLog(
|
||||
aliyunLogger.WithProject(cfg.Aliyun.Project),
|
||||
aliyunLogger.WithEndpoint(cfg.Aliyun.Endpoint),
|
||||
|
||||
@@ -3,11 +3,16 @@ package fluent
|
||||
import (
|
||||
fluentLogger "github.com/go-kratos/kratos/contrib/log/fluent/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器 - Fluent
|
||||
func NewLogger(cfg *conf.Logger) log.Logger {
|
||||
if cfg == nil || cfg.Fluent == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
wrapped, err := fluentLogger.NewLogger(cfg.Fluent.Endpoint)
|
||||
if err != nil {
|
||||
panic("create fluent logger failed")
|
||||
|
||||
@@ -3,12 +3,18 @@ package logrus
|
||||
import (
|
||||
logrusLogger "github.com/go-kratos/kratos/contrib/log/logrus/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器 - Logrus
|
||||
func NewLogger(cfg *conf.Logger) log.Logger {
|
||||
if cfg == nil || cfg.Logrus == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
loggerLevel, err := logrus.ParseLevel(cfg.Logrus.Level)
|
||||
if err != nil {
|
||||
loggerLevel = logrus.InfoLevel
|
||||
|
||||
@@ -3,11 +3,16 @@ package tencent
|
||||
import (
|
||||
tencentLogger "github.com/go-kratos/kratos/contrib/log/tencent/v2"
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器 - Tencent
|
||||
func NewLogger(cfg *conf.Logger) log.Logger {
|
||||
if cfg == nil || cfg.Tencent == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
wrapped, err := tencentLogger.NewLogger(
|
||||
tencentLogger.WithTopicID(cfg.Tencent.TopicId),
|
||||
tencentLogger.WithEndpoint(cfg.Tencent.Endpoint),
|
||||
|
||||
@@ -2,18 +2,22 @@ package zap
|
||||
|
||||
import (
|
||||
zapLogger "github.com/go-kratos/kratos/contrib/log/zap/v2"
|
||||
|
||||
"github.com/go-kratos/kratos/v2/log"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
|
||||
)
|
||||
|
||||
// NewLogger 创建一个新的日志记录器 - Zap
|
||||
func NewLogger(cfg *conf.Logger) log.Logger {
|
||||
if cfg == nil || cfg.Zap == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
encoderConfig := zap.NewProductionEncoderConfig()
|
||||
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
encoderConfig.TimeKey = "time"
|
||||
|
||||
@@ -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)
|
||||
|
||||
8
tag.bat
8
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 config/v0.0.5 --force
|
||||
git tag logger/v0.0.6 --force
|
||||
git tag registry/v0.0.7 --force
|
||||
git tag config/v0.0.7 --force
|
||||
git tag logger/v0.0.7 --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.7 --force
|
||||
git tag bootstrap/v0.0.10 --force
|
||||
|
||||
git tag v0.5.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user