This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 0aac960  Update triple and some relies version, add consumer registry 
timeout configuration item (#1516)
0aac960 is described below

commit 0aac960e6219d4138ac2f72ea19ad0d45857784d
Author: Laurence <[email protected]>
AuthorDate: Sun Oct 17 12:31:58 2021 +0800

    Update triple and some relies version, add consumer registry timeout 
configuration item (#1516)
    
    * fix: update triple and consumer wait for regitry logic
    
    * fix: linter
    
    * fix: add config api for max wait time
    
    * fix: ut
    
    * fix: logger config can't read from config center
    
    * fix: logger level
    
    * fix: level param
    
    * update relies version
---
 common/logger/logger.go                     |  2 +-
 config/config_loader.go                     |  1 -
 config/consumer_config.go                   | 20 ++++++++++++++++----
 config/root_config.go                       |  7 ++++++-
 go.mod                                      |  6 +++---
 go.sum                                      | 17 +++++++++--------
 metadata/report/delegate/delegate_report.go |  6 +++---
 protocol/jsonrpc/jsonrpc_protocol_test.go   |  1 -
 8 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/common/logger/logger.go b/common/logger/logger.go
index 6d4f207..bc19e46 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -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))
diff --git a/config/config_loader.go b/config/config_loader.go
index 1379b93..a4ca685 100644
--- a/config/config_loader.go
+++ b/config/config_loader.go
@@ -38,7 +38,6 @@ import (
 
 var (
        rootConfig = NewRootConfigBuilder().Build()
-       maxWait    = 3
 )
 
 func Load(opts ...LoaderConfOption) error {
diff --git a/config/consumer_config.go b/config/consumer_config.go
index db34f45..749ea78 100644
--- a/config/consumer_config.go
+++ b/config/consumer_config.go
@@ -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"`
 
@@ -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"`
+       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
 }
@@ -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 {
@@ -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,
        }
@@ -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
diff --git a/config/root_config.go b/config/root_config.go
index 0b88999..7db0a34 100644
--- a/config/root_config.go
+++ b/config/root_config.go
@@ -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
                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
        }
diff --git a/go.mod b/go.mod
index 371523d..31add86 100644
--- a/go.mod
+++ b/go.mod
@@ -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
diff --git a/go.sum b/go.sum
index 7f88042..13f8523 100644
--- a/go.sum
+++ b/go.sum
@@ -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=
@@ -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=
@@ -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=
@@ -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=
@@ -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=
diff --git a/metadata/report/delegate/delegate_report.go 
b/metadata/report/delegate/delegate_report.go
index 23765d7..536da6b 100644
--- a/metadata/report/delegate/delegate_report.go
+++ b/metadata/report/delegate/delegate_report.go
@@ -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())
@@ -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
@@ -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
 }
diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go 
b/protocol/jsonrpc/jsonrpc_protocol_test.go
index b714678..feb070a 100644
--- a/protocol/jsonrpc/jsonrpc_protocol_test.go
+++ b/protocol/jsonrpc/jsonrpc_protocol_test.go
@@ -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)

Reply via email to