Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update triple and some relies version, add consumer registry timeout configuration item #1516

Merged
merged 9 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func initZapLoggerWithSyncer(conf *Config) *zap.Logger {
core := zapcore.NewCore(
conf.getEncoder(),
conf.getLogWriter(),
zap.NewAtomicLevelAt(zap.DebugLevel),
zap.NewAtomicLevelAt(conf.ZapConfig.Level.Level()),
)

return zap.New(core, zap.AddCallerSkip(1))
Expand Down
1 change: 0 additions & 1 deletion config/config_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (

var (
rootConfig = NewRootConfigBuilder().Build()
maxWait = 3
)

func Load(opts ...LoaderConfOption) error {
Expand Down
20 changes: 16 additions & 4 deletions config/consumer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const (
// ConsumerConfig is Consumer default configuration
type ConsumerConfig struct {
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
// ConnectTimeout will be remove in 3.0 config-enhance
ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"`
// support string
RegistryIDs []string `yaml:"registryIDs" json:"registryIDs,omitempty" property:"registryIDs"`

Expand All @@ -50,7 +48,8 @@ type ConsumerConfig struct {

References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"`

FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"`
FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.下划线是不是要改横线
2.为什么要添加这个key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 我改成横线吧
  2. 用来配置客户端的 registry 超时时间

MaxWaitTimeForServiceDiscovery string `default:"3s" yaml:"max-wait-time-for-service-discovery" json:"max-wait-time-for-service-discovery,omitempty" property:"max-wait-time-for-service-discovery"`

rootConfig *RootConfig
}
Expand Down Expand Up @@ -99,6 +98,15 @@ func (cc *ConsumerConfig) Load() {
ref.Implement(rpcService)
}

var maxWait int

if maxWaitDuration, err := time.ParseDuration(cc.MaxWaitTimeForServiceDiscovery); err != nil {
logger.Warnf("Invalid consumer max wait time for service discovery: %s, fallback to 3s", cc.MaxWaitTimeForServiceDiscovery)
maxWait = 3
} else {
maxWait = int(maxWaitDuration.Seconds())
}

// wait for invoker is available, if wait over default 3s, then panic
var count int
for {
Expand Down Expand Up @@ -138,7 +146,6 @@ func SetConsumerConfig(c ConsumerConfig) {
func newEmptyConsumerConfig() *ConsumerConfig {
newConsumerConfig := &ConsumerConfig{
References: make(map[string]*ReferenceConfig, 8),
ConnectTimeout: "3s",
RequestTimeout: "3s",
Check: true,
}
Expand Down Expand Up @@ -168,6 +175,11 @@ func (ccb *ConsumerConfigBuilder) SetRequestTimeout(requestTimeout string) *Cons
return ccb
}

func (ccb *ConsumerConfigBuilder) SetMaxWaitTimeForServiceDiscovery(maxWaitTimeForServiceDiscovery string) *ConsumerConfigBuilder {
ccb.consumerConfig.MaxWaitTimeForServiceDiscovery = maxWaitTimeForServiceDiscovery
return ccb
}

func (ccb *ConsumerConfigBuilder) SetProxyFactory(proxyFactory string) *ConsumerConfigBuilder {
ccb.consumerConfig.ProxyFactory = proxyFactory
return ccb
Expand Down
7 changes: 6 additions & 1 deletion config/root_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ func registerPOJO() {

func (rc *RootConfig) Init() error {
registerPOJO()
if err := rc.Logger.Init(); err != nil {
if err := rc.Logger.Init(); err != nil { // init default logger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is useless code.

If you init logger after configcenter , and print success info. Then if not success info of config center then init fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency logic is: config-center's Init procedure relies on default logger, because it would print some logs using default logger. And the user-configed logger relies on config-center's init procedure, to get the logger config from config-center and set the default logger to target logger. So the init logic is

  1. [Init default Logger to avoid NPE if user not configure logger] or [Init user configured logger]
  2. Try to load configuration from config center, to overwrite local configuration
  3. Reload Logger with latest configuration file. The result is also default logger or user configured logger.
    And It's not useless codes. @zouyx

return err
}
if err := rc.ConfigCenter.Init(rc); err != nil {
logger.Infof("config center doesn't start, because %s", err)
} else {
if err := rc.Logger.Init(); err != nil { // init logger using config from config center again
return err
}
}

if err := rc.Application.Init(); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ require (
github.com/apache/dubbo-go-hessian2 v1.9.3
github.com/creasty/defaults v1.5.2
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.17
github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c
github.com/dubbogo/gost v1.11.18
github.com/dubbogo/triple v1.0.7
github.com/emicklei/go-restful/v3 v3.7.1
github.com/fsnotify/fsnotify v1.5.1
github.com/ghodss/yaml v1.0.0
github.com/go-co-op/gocron v0.1.1
github.com/go-co-op/gocron v1.9.0
github.com/go-playground/validator/v10 v10.9.0
github.com/go-resty/resty/v2 v2.3.0
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down
17 changes: 9 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl8
github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8=
github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/gost v1.11.17 h1:Dwaoqv/G21nYsGkeQoLbCAOryRPl6B7pEsZSJcr55nE=
github.com/dubbogo/gost v1.11.17/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/gost v1.11.18 h1:e9WRvDQut6cePYcQEOUC15vGSfftO7q9G2+Vw2s4CHE=
github.com/dubbogo/gost v1.11.18/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8=
github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc=
github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c h1:/Qrdqo2JVrywDANk04DHrvdfREdIApAWZ6stbYZfNaM=
github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog=
github.com/dubbogo/triple v1.0.7 h1:rPRtf5QNQO2FqXckMugn8KmQyhXQPZyImrEJ/OKAB7o=
github.com/dubbogo/triple v1.0.7/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
Expand Down Expand Up @@ -231,8 +230,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-co-op/gocron v0.1.1 h1:OfDmkqkCguFtFMsm6Eaayci3DADLa8pXvdmOlPU/JcU=
github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M=
github.com/go-co-op/gocron v1.9.0 h1:+V+DDenw3ryB7B+tK1bAIC5p0ruw4oX9IqAsdRnGIf0=
github.com/go-co-op/gocron v1.9.0/go.mod h1:DbJm9kdgr1sEvWpHCA7dFFs/PGHPMil9/97EXCRPr4k=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
Expand Down Expand Up @@ -263,7 +262,6 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A=
github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
Expand Down Expand Up @@ -671,6 +669,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -933,6 +933,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
6 changes: 3 additions & 3 deletions metadata/report/delegate/delegate_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func(
retryTimesIfNonFail: 600,
}

newJob, err := mrr.scheduler.Every(uint64(mrr.retryPeriod)).Seconds().Do(
newJob, err := mrr.scheduler.Every(int(mrr.retryPeriod)).Seconds().Do(
func() {
mrr.retryCounter.Inc()
logger.Infof("start to retry task for metadata report. retry times: %v", mrr.retryCounter.Load())
Expand All @@ -91,7 +91,7 @@ func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func(
// startRetryTask will make scheduler with retry task run
func (mrr *metadataReportRetry) startRetryTask() {
mrr.scheduler.StartAt(time.Now().Add(500 * time.Millisecond))
mrr.scheduler.Start()
mrr.scheduler.StartAsync()
}

// MetadataReport is a absolute delegate for MetadataReport
Expand Down Expand Up @@ -145,7 +145,7 @@ func NewMetadataReport() (*MetadataReport, error) {
return nil, err
}
scheduler.StartAt(time.Now().Add(500 * time.Millisecond))
scheduler.Start()
scheduler.StartAsync()
}
return bmr, nil
}
Expand Down
1 change: 0 additions & 1 deletion protocol/jsonrpc/jsonrpc_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func TestJsonrpcProtocolRefer(t *testing.T) {
"side=provider&timeout=3000&timestamp=1556509797245")
assert.NoError(t, err)
con := config.ConsumerConfig{
ConnectTimeout: "5s",
RequestTimeout: "5s",
}
config.SetConsumerConfig(con)
Expand Down