From 518be2b4c8cc996c0efa73141799fcce6ad48e30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Apr 2021 05:55:10 +0000 Subject: [PATCH 1/9] build(deps): bump actions/cache from v2.1.4 to v2.1.5 Bumps [actions/cache](https://github.com/actions/cache) from v2.1.4 to v2.1.5. - [Release notes](https://github.com/actions/cache/releases) - [Commits](https://github.com/actions/cache/compare/v2.1.4...1a9e2138d905efd099035b49d8b7a3888c653ca8) Signed-off-by: dependabot[bot] --- .github/workflows/github-actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 03472fb258..e1e216166e 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@v2 - name: Cache dependencies - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.5 with: # Cache path: ~/go/pkg/mod From 4cb6e4401b788d1088058cc7ca2d9bb205d2d261 Mon Sep 17 00:00:00 2001 From: randy Date: Sat, 15 May 2021 16:47:21 +0800 Subject: [PATCH 2/9] improve etcd version and change create to put (#1203) --- go.mod | 8 ++-- go.sum | 70 +++++++++++++++++++++++------ metadata/report/etcd/report.go | 8 ++-- metadata/report/etcd/report_test.go | 2 +- registry/etcdv3/listener_test.go | 2 +- registry/etcdv3/registry.go | 2 +- remoting/etcdv3/listener.go | 4 +- remoting/etcdv3/listener_test.go | 2 +- 8 files changed, 72 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 8927e4d365..2bffff5363 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/creasty/defaults v1.5.1 github.com/docker/go-connections v0.4.0 // indirect github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.8 + github.com/dubbogo/gost v1.11.9 github.com/dubbogo/triple v1.0.0 github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect github.com/emicklei/go-restful/v3 v3.4.0 @@ -51,10 +51,12 @@ require ( github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 - go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 + go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 + go.etcd.io/etcd/client/v3 v3.5.0-alpha.0 + go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 go.uber.org/atomic v1.7.0 go.uber.org/zap v1.16.0 - google.golang.org/grpc v1.33.1 + google.golang.org/grpc v1.36.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.16.9 k8s.io/apimachinery v0.16.9 diff --git a/go.sum b/go.sum index d06f2d0440..64bb4d5e97 100644 --- a/go.sum +++ b/go.sum @@ -119,6 +119,8 @@ github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 h1:D21IyuvjDCshj1 github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40 h1:xvUo53O5MRZhVMJAxWCJcS5HHrqAiAG9SJ1LpMu6aAI= +github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= @@ -132,6 +134,12 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5 h1:xD/lrqdvwsc+O2bjSSi3YqY73Ke3LAiSCx49aCesA0E= +github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= +github.com/cockroachdb/errors v1.2.4 h1:Lap807SXTH5tri2TivECb/4abUkMZC9zRoLarvcKDqs= +github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coredns/coredns v1.1.2 h1:bAFHrSsBeTeRG5W3Nf2su3lUGw7Npw2UKeCJm/3A638= github.com/coredns/coredns v1.1.2/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= @@ -147,14 +155,17 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28= -github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= +github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creasty/defaults v1.5.1 h1:j8WexcS3d/t4ZmllX4GEkl4wIB/trOr035ajcLHCISM= github.com/creasty/defaults v1.5.1/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -182,8 +193,8 @@ 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.10.1/go.mod h1:+mQGS51XQEUWZP2JeGZTxJwipjRKtJO7Tr+FOg+72rI= -github.com/dubbogo/gost v1.11.8 h1:OPTG4qIyNQ949GbdgHvpvYiVNno/X/YBozOVBLuNkS4= -github.com/dubbogo/gost v1.11.8/go.mod h1:2nB8jSrxVPwW5DBsRu3FZQH1+Ual3wnRHwFqjG9+4PY= +github.com/dubbogo/gost v1.11.9 h1:UWtqPL20bZuGu66GGwhN0dINnANIARlGv7v72tfgdE0= +github.com/dubbogo/gost v1.11.9/go.mod h1:HWgGZZQcNhkFpWEc9As671pXAsfoXH7Eyy2MYzoy+xo= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.2-0.20210326124702-e6a866993192 h1:CBEicrrVwR6u8ty+kL68ItxXVk1jaVYThrsx5ARhxUc= github.com/dubbogo/net v0.0.2-0.20210326124702-e6a866993192/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= @@ -217,6 +228,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg= @@ -224,6 +237,8 @@ github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs= +github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -268,6 +283,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= @@ -288,6 +304,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y 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= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -324,9 +341,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2 h1:AtvtonGEH/fZK0XPNNBdB6swgy7Iudfx88wzyIpwqJ8= github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2/go.mod h1:DavVbd41y+b7ukKDmlnPR4nGYmkWXR6vHUkjQNiHPBs= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -496,6 +512,7 @@ github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -519,6 +536,8 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -678,13 +697,13 @@ github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU= github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -694,6 +713,7 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= @@ -741,6 +761,8 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -750,6 +772,8 @@ github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d h1:bVQRCxQv github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/soheilhy/cmux v0.1.5-0.20210205191134-5ec6847320e5 h1:GJTW+uNMIV1RKwox+T4aN0/sQlYRg78uHZf2H0aBcDw= +github.com/soheilhy/cmux v0.1.5-0.20210205191134-5ec6847320e5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -760,6 +784,7 @@ github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -769,6 +794,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -797,6 +823,7 @@ github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 h1:kF/7m/ZU+0D4Jj5eZ41Zm3IH/J8OElK1Qtd7tVKAwLk= @@ -820,11 +847,22 @@ github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ github.com/zouyx/agollo/v3 v3.4.5/go.mod h1:LJr3kDmm23QSW+F1Ol4TMHDa7HvJvscMdVxJ2IpUTVc= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= -go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 h1:VcrIfasaLFkyjk6KNlXQSzO+B0fZcnECiDrKJsfxka0= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698 h1:jWtjCJX1qxhHISBMLRztWwR+EXkI7MJAF2HjHAE/x/I= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= +go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 h1:+e5nrluATIy3GP53znpkHMFzPTHGYyzvJGFCbuI6ZLc= +go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= +go.etcd.io/etcd/client/v2 v2.305.0-alpha.0 h1:jZepGpOeJATxsbMNBZczDS2jHdK/QVHM1iPe9jURJ8o= +go.etcd.io/etcd/client/v2 v2.305.0-alpha.0/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= +go.etcd.io/etcd/client/v3 v3.5.0-alpha.0 h1:dr1EOILak2pu4Nf5XbRIOCNIBjcz6UmkQd7hHRXwxaM= +go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= +go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0 h1:3yLUEC0nFCxw/RArImOyRUI4OAFbg4PFpBbAhSNzKNY= +go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= +go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0 h1:DvYJotxV9q1Lkn7pknzAbFO/CLtCVidCr2K9qRLJ8pA= +go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0/go.mod h1:FAwse6Zlm5v4tEWZaTjmNhe17Int4Oxbu7+2r0DiD3w= +go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 h1:fYv7CmmdyuIu27UmKQjS9K/1GtcCa+XnPKqiKBbQkrk= +go.etcd.io/etcd/server/v3 v3.5.0-alpha.0/go.mod h1:tsKetYpt980ZTpzl/gb+UOJj9RkIyCb1u4wjzMg90BQ= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -845,7 +883,6 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEa go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= @@ -860,12 +897,13 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -924,6 +962,7 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -977,6 +1016,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -985,6 +1025,7 @@ golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo= @@ -1001,6 +1042,7 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1034,6 +1076,7 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201014170642-d1624618ad65/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1071,6 +1114,7 @@ google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92 h1:jOTk2Z6KYaWoptUFqZ167cS8peoUPjFEXrsqfVkkCGc= google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go index 86b6bce463..159713029e 100644 --- a/metadata/report/etcd/report.go +++ b/metadata/report/etcd/report.go @@ -66,21 +66,21 @@ func (e *etcdMetadataReport) PublishAppMetadata(metadataIdentifier *identifier.S // metadata including the basic info of the server, provider info, and other user custom info func (e *etcdMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error { key := e.getNodeKey(providerIdentifier) - return e.client.Create(key, serviceDefinitions) + return e.client.Put(key, serviceDefinitions) } // StoreConsumerMetadata will store the metadata // metadata including the basic info of the server, consumer info, and other user custom info func (e *etcdMetadataReport) StoreConsumerMetadata(consumerMetadataIdentifier *identifier.MetadataIdentifier, serviceParameterString string) error { key := e.getNodeKey(consumerMetadataIdentifier) - return e.client.Create(key, serviceParameterString) + return e.client.Put(key, serviceParameterString) } // SaveServiceMetadata will store the metadata // metadata including the basic info of the server, service info, and other user custom info func (e *etcdMetadataReport) SaveServiceMetadata(metadataIdentifier *identifier.ServiceMetadataIdentifier, url *common.URL) error { key := e.getNodeKey(metadataIdentifier) - return e.client.Create(key, url.String()) + return e.client.Put(key, url.String()) } // RemoveServiceMetadata will remove the service metadata @@ -105,7 +105,7 @@ func (e *etcdMetadataReport) GetExportedURLs(metadataIdentifier *identifier.Serv // SaveSubscribedData will convert the urlList to json array and then store it func (e *etcdMetadataReport) SaveSubscribedData(subscriberMetadataIdentifier *identifier.SubscriberMetadataIdentifier, urls string) error { key := e.getNodeKey(subscriberMetadataIdentifier) - return e.client.Create(key, urls) + return e.client.Put(key, urls) } // GetSubscribedURLs will lookup the url diff --git a/metadata/report/etcd/report_test.go b/metadata/report/etcd/report_test.go index 88c5c82305..a459791dd6 100644 --- a/metadata/report/etcd/report_test.go +++ b/metadata/report/etcd/report_test.go @@ -26,7 +26,7 @@ import ( import ( "github.com/stretchr/testify/assert" - "go.etcd.io/etcd/embed" + "go.etcd.io/etcd/server/v3/embed" ) import ( diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index bc49991557..5dfc803951 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -26,7 +26,7 @@ import ( import ( "github.com/apache/dubbo-getty" "github.com/stretchr/testify/suite" - "go.etcd.io/etcd/embed" + "go.etcd.io/etcd/server/v3/embed" ) import ( diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index 5adfec7e77..6be5015b21 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -140,7 +140,7 @@ func (r *etcdV3Registry) CreatePath(k string) error { var tmpPath string for _, str := range strings.Split(k, "/")[1:] { tmpPath = path.Join(tmpPath, "/", str) - if err := r.client.Create(tmpPath, ""); err != nil { + if err := r.client.Put(tmpPath, ""); err != nil { return perrors.WithMessagef(err, "create path %s in etcd", tmpPath) } } diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go index b297427426..edfadab4d9 100644 --- a/remoting/etcdv3/listener.go +++ b/remoting/etcdv3/listener.go @@ -25,8 +25,8 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" perrors "github.com/pkg/errors" - "go.etcd.io/etcd/clientv3" - "go.etcd.io/etcd/mvcc/mvccpb" + "go.etcd.io/etcd/api/v3/mvccpb" + clientv3 "go.etcd.io/etcd/client/v3" ) import ( diff --git a/remoting/etcdv3/listener_test.go b/remoting/etcdv3/listener_test.go index b2856b1727..1795d0e22e 100644 --- a/remoting/etcdv3/listener_test.go +++ b/remoting/etcdv3/listener_test.go @@ -27,7 +27,7 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" "github.com/stretchr/testify/assert" - "go.etcd.io/etcd/embed" + "go.etcd.io/etcd/server/v3/embed" ) import ( From 0d0bd99182fd9ea10faceb98186e55788c1429fd Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Thu, 24 Jun 2021 11:18:27 +0800 Subject: [PATCH 3/9] make the package v3router/judger test coverage rate reach 80% (#1260) * make the package v3router/judger test coverage rate reach 80% * add router_chain unit test * refactor imports and some code * remove blank lines Co-authored-by: dongjianhui --- .../judger/attachment_match_judger.go | 55 +++++-------- .../judger/attachment_match_judger_test.go | 15 ++-- .../judger/list_string_match_judger_test.go | 40 ++++++++++ .../v3router/judger/method_match_judger.go | 1 + .../judger/method_match_judger_test.go | 77 +++++++++++++++++++ .../judger/url_label_match_judge_test.go | 41 ++++++++++ cluster/router/v3router/router_chain.go | 10 ++- cluster/router/v3router/router_chain_test.go | 53 +++++++++++++ config/uniform_router_config.go | 2 +- 9 files changed, 251 insertions(+), 43 deletions(-) create mode 100644 cluster/router/v3router/judger/list_string_match_judger_test.go create mode 100644 cluster/router/v3router/judger/method_match_judger_test.go create mode 100644 cluster/router/v3router/judger/url_label_match_judge_test.go diff --git a/cluster/router/v3router/judger/attachment_match_judger.go b/cluster/router/v3router/judger/attachment_match_judger.go index cb4d3eaa95..31f46e05cf 100644 --- a/cluster/router/v3router/judger/attachment_match_judger.go +++ b/cluster/router/v3router/judger/attachment_match_judger.go @@ -29,45 +29,30 @@ type AttachmentMatchJudger struct { // nolint func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool { invAttaMap := invocation.Attachments() - if amj.EagleeyeContext != nil { - for k, v := range amj.EagleeyeContext { - invAttaValue, ok := invAttaMap[k] - if !ok { - if v.Empty == "" { - return false - } - continue - } - // exist this key - str, ok := invAttaValue.(string) - if !ok { - return false - } - strJudger := NewStringMatchJudger(v) - if !strJudger.Judge(str) { - return false - } - } + if amj.EagleeyeContext != nil && !judge(amj.EagleeyeContext, invAttaMap) { + return false } - if amj.DubboContext != nil { - for k, v := range amj.DubboContext { - invAttaValue, ok := invAttaMap[k] - if !ok { - if v.Empty == "" { - return false - } - continue - } - // exist this key - str, ok := invAttaValue.(string) - if !ok { - return false - } - strJudger := NewStringMatchJudger(v) - if !strJudger.Judge(str) { + return amj.DubboContext == nil || judge(amj.DubboContext, invAttaMap) +} + +func judge(condition map[string]*config.StringMatch, invAttaMap map[string]interface{}) bool { + for k, v := range condition { + invAttaValue, ok := invAttaMap[k] + if !ok { + if v.Empty == "" { return false } + continue + } + // exist this key + str, ok := invAttaValue.(string) + if !ok { + return false + } + strJudger := NewStringMatchJudger(v) + if !strJudger.Judge(str) { + return false } } diff --git a/cluster/router/v3router/judger/attachment_match_judger_test.go b/cluster/router/v3router/judger/attachment_match_judger_test.go index 7e6b324947..26a8d5ed59 100644 --- a/cluster/router/v3router/judger/attachment_match_judger_test.go +++ b/cluster/router/v3router/judger/attachment_match_judger_test.go @@ -31,19 +31,24 @@ import ( ) func TestAttachmentMatchJudger(t *testing.T) { - dubboCtxMap := make(map[string]*config.StringMatch) + conditionMap := make(map[string]*config.StringMatch) dubboIvkMap := make(map[string]interface{}) - dubboCtxMap["test-key"] = &config.StringMatch{ + conditionMap["test-key"] = &config.StringMatch{ Exact: "abc", } dubboIvkMap["test-key"] = "abc" assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ - DubboContext: dubboCtxMap, + DubboContext: conditionMap, + }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) + assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) dubboIvkMap["test-key"] = "abd" assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ - DubboContext: dubboCtxMap, + DubboContext: conditionMap, + }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) + assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) - } diff --git a/cluster/router/v3router/judger/list_string_match_judger_test.go b/cluster/router/v3router/judger/list_string_match_judger_test.go new file mode 100644 index 0000000000..1816b9503f --- /dev/null +++ b/cluster/router/v3router/judger/list_string_match_judger_test.go @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package judger + +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + +func TestListStringMatchJudger(t *testing.T) { + assert.True(t, newListStringMatchJudger(&config.ListStringMatch{ + Oneof: []*config.StringMatch{{Exact: "abd"}}, + }).Judge("abd")) + + assert.False(t, newListStringMatchJudger(&config.ListStringMatch{ + Oneof: []*config.StringMatch{{Exact: "abc"}}, + }).Judge("abd")) +} diff --git a/cluster/router/v3router/judger/method_match_judger.go b/cluster/router/v3router/judger/method_match_judger.go index edf8fa0b4b..e069ef9cca 100644 --- a/cluster/router/v3router/judger/method_match_judger.go +++ b/cluster/router/v3router/judger/method_match_judger.go @@ -57,6 +57,7 @@ func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { if !newListStringMatchJudger(v.StrValue).Judge(value.String()) { return false } + // FIXME int invoke Float may cause panic case "float", "int": // todo now numbers Must not be zero, else it will ignore this match if !newListDoubleMatchJudger(v.NumValue).Judge(value.Float()) { diff --git a/cluster/router/v3router/judger/method_match_judger_test.go b/cluster/router/v3router/judger/method_match_judger_test.go new file mode 100644 index 0000000000..71e90aacb5 --- /dev/null +++ b/cluster/router/v3router/judger/method_match_judger_test.go @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package judger + +import ( + "reflect" + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +func TestMethodMatchJudger(t *testing.T) { + methodArgs := make([]*config.DubboMethodArg, 0) + methodArgs = append(methodArgs, &config.DubboMethodArg{ + Index: 1, + Type: "string", + StrValue: &config.ListStringMatch{Oneof: []*config.StringMatch{{Exact: "hello world"}}}, + NumValue: nil, + BoolValue: nil, + }) + methodArgs = append(methodArgs, &config.DubboMethodArg{ + Index: 2, + Type: "bool", + StrValue: nil, + NumValue: nil, + BoolValue: &config.BoolMatch{Exact: true}, + }) + methodArgs = append(methodArgs, &config.DubboMethodArg{ + Index: 3, + Type: "float64", + StrValue: nil, + NumValue: &config.ListDoubleMatch{Oneof: []*config.DoubleMatch{{Exact: 10}}}, + BoolValue: nil, + }) + + methodMatch := &config.DubboMethodMatch{ + NameMatch: &config.StringMatch{Exact: "Greet"}, + Argc: 3, + Args: methodArgs, + Argp: nil, + Headers: nil, + } + + stringValue := reflect.ValueOf("hello world") + boolValue := reflect.ValueOf(true) + numValue := reflect.ValueOf(10.0) + ivc := invocation.NewRPCInvocationWithOptions( + invocation.WithMethodName("Greet"), + invocation.WithParameterValues([]reflect.Value{stringValue, boolValue, numValue}), + ) + + assert.False(t, NewMethodMatchJudger(&config.DubboMethodMatch{NameMatch: &config.StringMatch{Exact: "Great"}}).Judge(ivc)) + assert.False(t, NewMethodMatchJudger(&config.DubboMethodMatch{NameMatch: &config.StringMatch{Exact: "Greet"}, Argc: 1}).Judge(ivc)) + assert.True(t, NewMethodMatchJudger(methodMatch).Judge(ivc)) +} diff --git a/cluster/router/v3router/judger/url_label_match_judge_test.go b/cluster/router/v3router/judger/url_label_match_judge_test.go new file mode 100644 index 0000000000..bb4b4679dd --- /dev/null +++ b/cluster/router/v3router/judger/url_label_match_judge_test.go @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package judger + +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common" +) + +func TestJudgeUrlLabel(t *testing.T) { + url := common.NewURLWithOptions(common.WithParamsValue("a", "A")) + + labels := make(map[string]string) + labels["a"] = "A" + assert.True(t, JudgeUrlLabel(url, labels)) + + labels["a"] = "B" + assert.False(t, JudgeUrlLabel(url, labels)) +} diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index 1ae21304ff..dc14c7325d 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -95,7 +95,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { logger.Error("newVSValue.ObjectMeta.Annotations has no key named kubectl.kubernetes.io/last-applied-configuration") return } - logger.Debugf("json file = %v\n", newVSJsonValue) + logger.Debugf("new virtual service json value = \n%v\n", newVSJsonValue) newVirtualServiceConfig := &config.VirtualServiceConfig{} if err := json.Unmarshal([]byte(newVSJsonValue), newVirtualServiceConfig); err != nil { logger.Error("on process json data unmarshal error = ", err) @@ -148,7 +148,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { return } default: - logger.Error("unknow unsupported event key:", event.Key) + logger.Error("unknown unsupported event key:", event.Key) } } @@ -180,6 +180,7 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte vsDecoder := yaml.NewDecoder(strings.NewReader(string(virtualServiceConfig))) drDecoder := yaml.NewDecoder(strings.NewReader(string(destinationRuleConfig))) + // parse virtual service for { virtualServiceCfg := &config.VirtualServiceConfig{} @@ -195,6 +196,7 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte virtualServiceConfigList = append(virtualServiceConfigList, virtualServiceCfg) } + // parse destination rule for { destRuleCfg := &config.DestinationRuleConfig{} err := drDecoder.Decode(destRuleCfg) @@ -205,10 +207,14 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte logger.Error("parseFromConfigTo destination rule err = ", err) return nil, err } + + // name -> labels destRuleCfgMap := make(map[string]map[string]string) for _, v := range destRuleCfg.Spec.SubSets { destRuleCfgMap[v.Name] = v.Labels } + + // host -> name -> labels destRuleConfigsMap[destRuleCfg.Spec.Host] = destRuleCfgMap } diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index 7293963d1c..4ce4eef3b0 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -22,6 +22,16 @@ import ( "testing" ) +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_api" + "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config_center" +) + import ( "github.com/stretchr/testify/assert" ) @@ -206,3 +216,46 @@ func TestRouterChain_Route(t *testing.T) { assert.Equal(t, 0, len(result)) //todo test find target invoker } + +func TestRouterChain_Process(t *testing.T) { + vsJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` + + rc := &RouterChain{} + mockVirtualServiceConfig := &config.VirtualServiceConfig{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + "kubectl.kubernetes.io/last-applied-configuration": vsJson, + }, + }, + } + + // test virtual service config chage event + mockVirtualServiceChangeEvent := &config_center.ConfigChangeEvent{ + Key: k8s_api.VirtualServiceEventKey, + Value: mockVirtualServiceConfig, + ConfigType: 0, + } + rc.Process(mockVirtualServiceChangeEvent) + + // test destination rule config chage event + destJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` + mockDestinationRuleConfig := &config.DestinationRuleConfig{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: map[string]string{ + "kubectl.kubernetes.io/last-applied-configuration": destJson, + }, + }, + } + mockDestinationRuleChangeEvent := &config_center.ConfigChangeEvent{ + Key: k8s_api.DestinationRuleEventKey, + Value: mockDestinationRuleConfig, + ConfigType: 0, + } + rc.Process(mockDestinationRuleChangeEvent) + + // test unknown event type + mockUnsupportedEvent := &config_center.ConfigChangeEvent{ + Key: "unknown", + } + rc.Process(mockUnsupportedEvent) +} diff --git a/config/uniform_router_config.go b/config/uniform_router_config.go index e18c07c082..fa5d02db19 100644 --- a/config/uniform_router_config.go +++ b/config/uniform_router_config.go @@ -25,7 +25,7 @@ import ( // nolint type MetaDataStruct struct { - Name string `yaml:"name"` + Name string `yaml:"name" json:"name"` } // VirtualService Config Definition From 912e12015a0542b1466bb7ac1232d4a6748f6a5c Mon Sep 17 00:00:00 2001 From: XavierNiu Date: Thu, 24 Jun 2021 11:18:54 +0800 Subject: [PATCH 4/9] Fix: Graceful shutdown bugs(supplement #1254) (#1257) * supplementary fix #1254 remove unused comments fix import cycle append apache license header fix gracefulShutdownFilter unittest bug go fmt fix gracefulShutdownConfig unittest bug fix gracefulShutdownConfig unittest bug go fmt * improve formatting based on code style * go fmt * set RequestsFinished explicitly * use mutex to protect variables of ShutdownConfig * ftr: add config (#1258) * recover gracefulShutdownFilter logic * remove unused mutex Co-authored-by: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> --- config/config_loader_test.go | 24 +++++++++++++++ config/config_setter.go | 26 ++++++++++++++++ config/graceful_shutdown.go | 8 +++++ config/graceful_shutdown_test.go | 9 ++++++ .../filter_impl/graceful_shutdown_filter.go | 30 +++++++++++-------- filter/filter_impl/tps_limit_filter_test.go | 5 ++-- go.sum | 1 - 7 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 config/config_setter.go diff --git a/config/config_loader_test.go b/config/config_loader_test.go index b0935a2885..59593ef20b 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,6 +18,7 @@ package config import ( + "context" "path/filepath" "sort" "sync" @@ -41,7 +42,9 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config_center" + "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/metadata/service" + "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -74,6 +77,13 @@ func TestConfigLoader(t *testing.T) { } func TestLoad(t *testing.T) { + extension.SetFilter(constant.CONSUMER_SHUTDOWN_FILTER, func() filter.Filter { + return &mockGracefulShutdownFilter{} + }) + extension.SetFilter(constant.PROVIDER_SHUTDOWN_FILTER, func() filter.Filter { + return &mockGracefulShutdownFilter{} + }) + doInitConsumer() doInitProvider() @@ -596,3 +606,17 @@ func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { } return res } + +type mockGracefulShutdownFilter struct{} + +func (f *mockGracefulShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + panic("implement me") +} + +func (f *mockGracefulShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + panic("implement me") +} + +func (f *mockGracefulShutdownFilter) Set(name string, config interface{}) { + return +} diff --git a/config/config_setter.go b/config/config_setter.go new file mode 100644 index 0000000000..9f114f26d0 --- /dev/null +++ b/config/config_setter.go @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package config + +const ( + GracefulShutdownFilterShutdownConfig = "GracefulShutdownFilterShutdownConfig" +) + +type Setter interface { + Set(name string, config interface{}) +} diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index fd34e200be..51443c9d5a 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -59,6 +59,14 @@ func GracefulShutdownInit() { signal.Notify(signals, ShutdownSignals...) + // retrieve ShutdownConfig for gracefulShutdownFilter + if filter, ok := extension.GetFilter(constant.CONSUMER_SHUTDOWN_FILTER).(Setter); ok && GetConsumerConfig().ShutdownConfig != nil { + filter.Set(GracefulShutdownFilterShutdownConfig, GetConsumerConfig().ShutdownConfig) + } + if filter, ok := extension.GetFilter(constant.PROVIDER_SHUTDOWN_FILTER).(Setter); ok && GetProviderConfig().ShutdownConfig != nil { + filter.Set(GracefulShutdownFilterShutdownConfig, GetProviderConfig().ShutdownConfig) + } + go func() { select { case sig := <-signals: diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go index 870302d288..920a268df2 100644 --- a/config/graceful_shutdown_test.go +++ b/config/graceful_shutdown_test.go @@ -24,10 +24,17 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/protocol" ) func TestGracefulShutdownInit(t *testing.T) { + extension.SetFilter(constant.CONSUMER_SHUTDOWN_FILTER, func() filter.Filter { + return &mockGracefulShutdownFilter{} + }) + extension.SetFilter(constant.PROVIDER_SHUTDOWN_FILTER, func() filter.Filter { + return &mockGracefulShutdownFilter{} + }) GracefulShutdownInit() } @@ -49,6 +56,8 @@ func TestBeforeShutdown(t *testing.T) { } // without configuration + consumerConfig = nil + providerConfig = nil BeforeShutdown() consumerConfig = &ConsumerConfig{ diff --git a/filter/filter_impl/graceful_shutdown_filter.go b/filter/filter_impl/graceful_shutdown_filter.go index 028ffd2e1e..9da238b9d5 100644 --- a/filter/filter_impl/graceful_shutdown_filter.go +++ b/filter/filter_impl/graceful_shutdown_filter.go @@ -32,19 +32,13 @@ import ( ) func init() { - consumerFiler := &gracefulShutdownFilter{ - shutdownConfig: config.GetConsumerConfig().ShutdownConfig, - } - providerFilter := &gracefulShutdownFilter{ - shutdownConfig: config.GetProviderConfig().ShutdownConfig, - } - + // `init()` is performed before config.Load(), so shutdownConfig will be retrieved after config was loaded. extension.SetFilter(constant.CONSUMER_SHUTDOWN_FILTER, func() filter.Filter { - return consumerFiler + return &gracefulShutdownFilter{} }) extension.SetFilter(constant.PROVIDER_SHUTDOWN_FILTER, func() filter.Filter { - return providerFilter + return &gracefulShutdownFilter{} }) } @@ -60,9 +54,6 @@ func (gf *gracefulShutdownFilter) Invoke(ctx context.Context, invoker protocol.I return gf.getRejectHandler().RejectedExecution(invoker.GetURL(), invocation) } atomic.AddInt32(&gf.activeCount, 1) - if gf.shutdownConfig != nil && gf.activeCount > 0 { - gf.shutdownConfig.RequestsFinished = false - } return invoker.Invoke(ctx, invocation) } @@ -70,12 +61,25 @@ func (gf *gracefulShutdownFilter) Invoke(ctx context.Context, invoker protocol.I func (gf *gracefulShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { atomic.AddInt32(&gf.activeCount, -1) // although this isn't thread safe, it won't be a problem if the gf.rejectNewRequest() is true. - if gf.shutdownConfig != nil && gf.activeCount <= 0 { + if gf.shutdownConfig != nil && gf.shutdownConfig.RejectRequest && gf.activeCount <= 0 { gf.shutdownConfig.RequestsFinished = true } return result } +func (gf *gracefulShutdownFilter) Set(name string, conf interface{}) { + switch name { + case config.GracefulShutdownFilterShutdownConfig: + if shutdownConfig, ok := conf.(*config.ShutdownConfig); !ok { + gf.shutdownConfig = shutdownConfig + return + } + logger.Warnf("the type of config for {%s} should be *config.ShutdownConfig", config.GracefulShutdownFilterShutdownConfig) + default: + // do nothing + } +} + func (gf *gracefulShutdownFilter) rejectNewRequest() bool { if gf.shutdownConfig == nil { return false diff --git a/filter/filter_impl/tps_limit_filter_test.go b/filter/filter_impl/tps_limit_filter_test.go index b70611dbc4..e9f8660890 100644 --- a/filter/filter_impl/tps_limit_filter_test.go +++ b/filter/filter_impl/tps_limit_filter_test.go @@ -101,9 +101,8 @@ func TestGenericFilterInvokeWithDefaultTpsLimiterNotAllow(t *testing.T) { attch := make(map[string]interface{}) result := tpsFilter.Invoke(context.Background(), - protocol.NewBaseInvoker( - - invokeUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) + protocol.NewBaseInvoker(invokeUrl), + invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) assert.Nil(t, result.Error()) assert.Nil(t, result.Result()) } diff --git a/go.sum b/go.sum index 3a278e00a6..3b01184d08 100644 --- a/go.sum +++ b/go.sum @@ -161,7 +161,6 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= From aa4f87edfc9757a94587e78d7599ca3c39c25e6d Mon Sep 17 00:00:00 2001 From: gaoxinge Date: Fri, 25 Jun 2021 13:19:58 +0800 Subject: [PATCH 5/9] refine grpc test code (#1266) * refine grpc test code * fix test * remove useless code * config test grpc server --- protocol/grpc/client_test.go | 24 +++--- protocol/grpc/common_test.go | 114 ---------------------------- protocol/grpc/grpc_invoker_test.go | 31 ++++---- protocol/grpc/grpc_protocol_test.go | 15 ++-- protocol/grpc/internal/server.go | 51 ++++++++----- 5 files changed, 75 insertions(+), 160 deletions(-) delete mode 100644 protocol/grpc/common_test.go diff --git a/protocol/grpc/client_test.go b/protocol/grpc/client_test.go index 2e2865576a..b53eac248a 100644 --- a/protocol/grpc/client_test.go +++ b/protocol/grpc/client_test.go @@ -18,6 +18,7 @@ package grpc import ( + "context" "reflect" "testing" ) @@ -29,7 +30,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal" ) @@ -44,14 +44,20 @@ func TestGetInvoker(t *testing.T) { } func TestNewClient(t *testing.T) { - go internal.InitGrpcServer() - defer internal.ShutdownGrpcServer() + server, err := internal.NewServer("127.0.0.1:30000") + assert.NoError(t, err) + go server.Start() + defer server.Stop() + + url, err := common.NewURL(mockGrpcCommonUrl) + assert.NoError(t, err) - url, err := common.NewURL("grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!") - assert.Nil(t, err) cli, err := NewClient(url) - if err != nil { - logger.Errorf("grpc new client error %v", err) - } - assert.NotNil(t, cli) + assert.NoError(t, err) + + impl := &internal.GreeterClientImpl{} + client := impl.GetDubboStub(cli.ClientConn) + result, err := client.SayHello(context.Background(), &internal.HelloRequest{Name: "request name"}) + assert.NoError(t, err) + assert.Equal(t, &internal.HelloReply{Message: "Hello request name"}, result) } diff --git a/protocol/grpc/common_test.go b/protocol/grpc/common_test.go deleted file mode 100644 index 5f44199c3e..0000000000 --- a/protocol/grpc/common_test.go +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package grpc - -import ( - "context" - "fmt" -) - -import ( - native_grpc "google.golang.org/grpc" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" -) - -// userd grpc-dubbo biz service -func addService() { - config.SetProviderService(newGreeterProvider()) -} - -type greeterProvider struct { - *greeterProviderBase -} - -func newGreeterProvider() *greeterProvider { - return &greeterProvider{ - greeterProviderBase: &greeterProviderBase{}, - } -} - -func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloRequest) (reply *internal.HelloReply, err error) { - fmt.Printf("req: %v", req) - return &internal.HelloReply{Message: "this is message from reply"}, nil -} - -func (g *greeterProvider) Reference() string { - return "GrpcGreeterImpl" -} - -// code generated by greeter.go -type greeterProviderBase struct { - proxyImpl protocol.Invoker -} - -func (g *greeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - g.proxyImpl = impl -} - -func (g *greeterProviderBase) GetProxyImpl() protocol.Invoker { - return g.proxyImpl -} - -func (g *greeterProviderBase) ServiceDesc() *native_grpc.ServiceDesc { - return &native_grpc.ServiceDesc{ - ServiceName: "helloworld.Greeter", - HandlerType: (*internal.GreeterServer)(nil), - Methods: []native_grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: dubboGreeterSayHelloHandler, - }, - }, - Streams: []native_grpc.StreamDesc{}, - Metadata: "helloworld.proto", - } -} - -func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context, - dec func(interface{}) error, interceptor native_grpc.UnaryServerInterceptor) (interface{}, error) { - - in := new(internal.HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - base := srv.(DubboGrpcService) - - args := []interface{}{} - args = append(args, in) - invo := invocation.NewRPCInvocation("SayHello", args, nil) - - if interceptor == nil { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() - } - info := &native_grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/helloworld.Greeter/SayHello", - } - handler := func(context.Context, interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() - } - return interceptor(ctx, in, info, handler) -} diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go index f657e6436c..70a7e5ddff 100644 --- a/protocol/grpc/grpc_invoker_test.go +++ b/protocol/grpc/grpc_invoker_test.go @@ -29,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) @@ -43,25 +42,29 @@ const ( ) func TestInvoke(t *testing.T) { - go internal.InitGrpcServer() - defer internal.ShutdownGrpcServer() + server, err := internal.NewServer("127.0.0.1:30000") + assert.NoError(t, err) + go server.Start() + defer server.Stop() url, err := common.NewURL(mockGrpcCommonUrl) - assert.Nil(t, err) + assert.NoError(t, err) cli, err := NewClient(url) - if err != nil { - logger.Errorf("grpc new client error %v", err) - } - invoker := NewGrpcInvoker(url, cli) + assert.NoError(t, err) - args := []reflect.Value{} + var args []reflect.Value args = append(args, reflect.ValueOf(&internal.HelloRequest{Name: "request name"})) bizReply := &internal.HelloReply{} - invo := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("SayHello"), - invocation.WithParameterValues(args), invocation.WithReply(bizReply)) + invo := invocation.NewRPCInvocationWithOptions( + invocation.WithMethodName("SayHello"), + invocation.WithParameterValues(args), + invocation.WithReply(bizReply), + ) + + invoker := NewGrpcInvoker(url, cli) res := invoker.Invoke(context.Background(), invo) - assert.Nil(t, res.Error()) - assert.NotNil(t, res.Result()) - assert.Equal(t, "Hello request name", bizReply.Message) + assert.NoError(t, res.Error()) + assert.Equal(t, &internal.HelloReply{Message: "Hello request name"}, res.Result().(reflect.Value).Interface()) + assert.Equal(t, &internal.HelloReply{Message: "Hello request name"}, bizReply) } diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 8163c51f22..c48ddb4d4c 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -69,12 +69,13 @@ func doInitProvider() { func TestGrpcProtocolExport(t *testing.T) { // Export - addService() + config.SetProviderService(internal.NewService()) doInitProvider() - proto := GetProtocol() url, err := common.NewURL(mockGrpcCommonUrl) assert.NoError(t, err) + + proto := GetProtocol() exporter := proto.Export(protocol.NewBaseInvoker(url)) time.Sleep(time.Second) @@ -98,13 +99,15 @@ func TestGrpcProtocolExport(t *testing.T) { } func TestGrpcProtocolRefer(t *testing.T) { - go internal.InitGrpcServer() - defer internal.ShutdownGrpcServer() - time.Sleep(time.Second) + server, err := internal.NewServer("127.0.0.1:30000") + assert.NoError(t, err) + go server.Start() + defer server.Stop() - proto := GetProtocol() url, err := common.NewURL(mockGrpcCommonUrl) assert.NoError(t, err) + + proto := GetProtocol() invoker := proto.Refer(url) // make sure url diff --git a/protocol/grpc/internal/server.go b/protocol/grpc/internal/server.go index 6e17a4f80d..ea0a48453b 100644 --- a/protocol/grpc/internal/server.go +++ b/protocol/grpc/internal/server.go @@ -27,11 +27,15 @@ import ( "google.golang.org/grpc" ) -var s *grpc.Server - // server is used to implement helloworld.GreeterServer. type server struct { - UnimplementedGreeterServer + *GreeterProviderBase +} + +func NewService() *server { + return &server{ + GreeterProviderBase: &GreeterProviderBase{}, + } } // SayHello implements helloworld.GreeterServer @@ -40,25 +44,38 @@ func (s *server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, e return &HelloReply{Message: "Hello " + in.GetName()}, nil } -// InitGrpcServer creates global gRPC server. -func InitGrpcServer() { - port := ":30000" +func (s *server) Reference() string { + return "GrpcGreeterImpl" +} + +type Server struct { + listener net.Listener + server *grpc.Server +} - lis, err := net.Listen("tcp", port) +func NewServer(address string) (*Server, error) { + listener, err := net.Listen("tcp", address) if err != nil { - log.Fatalf("failed to listen: %v", err) + return nil, err } - s = grpc.NewServer() - RegisterGreeterServer(s, &server{}) - if err := s.Serve(lis); err != nil { - log.Fatalf("failed to serve: %v", err) + + server := grpc.NewServer() + service := NewService() + RegisterGreeterServer(server, service) + + s := Server{ + listener: listener, + server: server, } + return &s, nil } -// ShutdownGrpcServer shuts down gRPC server gracefully -func ShutdownGrpcServer() { - if s == nil { - return +func (s *Server) Start() { + if err := s.server.Serve(s.listener); err != nil { + log.Fatalf("failed to serve: %v", err) } - s.GracefulStop() +} + +func (s *Server) Stop() { + s.server.GracefulStop() } From c642c08a1936a32d82bf3c31068b213ce8dc2c82 Mon Sep 17 00:00:00 2001 From: wangxw666 <2484713618@qq.com> Date: Fri, 25 Jun 2021 17:28:43 +0800 Subject: [PATCH 6/9] =?UTF-8?q?registry=20=E9=BB=98=E8=AE=A4=E5=80=BC?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: wangxiaowei14227 --- config/config_loader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 9fc7da4e1b..07ef3259e6 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -103,7 +103,7 @@ func setDefaultValue(target interface{}) { switch target.(type) { case *ProviderConfig: p := target.(*ProviderConfig) - if len(p.Registries) == 0 { + if len(p.Registries) == 0 && p.Registry == nil { p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig } if len(p.Protocols) == 0 { @@ -117,7 +117,7 @@ func setDefaultValue(target interface{}) { } default: c := target.(*ConsumerConfig) - if len(c.Registries) == 0 { + if len(c.Registries) == 0 && c.Registry == nil { c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig } if c.ApplicationConfig == nil { From be407bb2422d2de1eed69e9f8d2dc49aa786168c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BA=91=E5=85=B4?= <2385585770@qq.com> Date: Sun, 27 Jun 2021 12:24:05 +0800 Subject: [PATCH 7/9] config center for more parameters (#1277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * nacos config center optimize * up remote config * add protocol chick * up:代码优化 * go fmt --- common/constant/key.go | 23 +++++++--- config/config_center_config.go | 64 +++++++++++++++------------ config/config_center_config_test.go | 22 +--------- config/remote_config.go | 23 ++++++++-- config_center/apollo/impl_test.go | 2 +- config_center/nacos/client.go | 45 ++----------------- config_center/nacos/client_test.go | 6 +-- config_center/nacos/impl.go | 2 +- registry/nacos/service_discovery.go | 11 +++-- remoting/nacos/builder.go | 68 ++++++++++------------------- remoting/nacos/builder_test.go | 2 + 11 files changed, 114 insertions(+), 154 deletions(-) diff --git a/common/constant/key.go b/common/constant/key.go index a57a90c657..601a5dd342 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -136,13 +136,14 @@ const ( ) const ( - CONFIG_NAMESPACE_KEY = "config.namespace" - CONFIG_GROUP_KEY = "config.group" - CONFIG_APP_ID_KEY = "config.appId" - CONFIG_CLUSTER_KEY = "config.cluster" - CONFIG_CHECK_KEY = "config.check" - CONFIG_TIMEOUT_KET = "config.timeout" - CONFIG_LOG_DIR_KEY = "config.logDir" + CONFIG_NAMESPACE_KEY = "namespace" + CONFIG_GROUP_KEY = "group" + CONFIG_APP_ID_KEY = "appId" + CONFIG_CLUSTER_KEY = "cluster" + CONFIG_TIMEOUT_KEY = "timeout" + CONFIG_USERNAME_KEY = "username" + CONFIG_PASSWORD_KEY = "password" + CONFIG_LOG_DIR_KEY = "logDir" CONFIG_VERSION_KEY = "configVersion" COMPATIBLE_CONFIG_KEY = "compatible_config" ) @@ -172,6 +173,7 @@ const ( NACOS_DEFAULT_ROLETYPE = 3 NACOS_CACHE_DIR_KEY = "cacheDir" NACOS_LOG_DIR_KEY = "logDir" + NACOS_BEAT_INTERVAL_KEY = "beatInterval" NACOS_ENDPOINT = "endpoint" NACOS_SERVICE_NAME_SEPARATOR = ":" NACOS_CATEGORY_KEY = "category" @@ -181,6 +183,13 @@ const ( NACOS_PASSWORD = "password" NACOS_USERNAME = "username" NACOS_NOT_LOAD_LOCAL_CACHE = "nacos.not.load.cache" + NACOS_APP_NAME_KEY = "appName" + NACOS_REGION_ID_KEY = "regionId" + NACOS_ACCESS_KEY = "access" + NACOS_SECRET_KEY = "secret" + NACOS_OPEN_KMS_KEY = "kms" + NACOS_UPDATE_THREAD_NUM_KEY = "updateThreadNum" + NACOS_LOG_LEVEL_KEY = "logLevel" ) const ( diff --git a/config/config_center_config.go b/config/config_center_config.go index 415eadc549..360818c8d3 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -44,19 +44,20 @@ import ( // // ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type ConfigCenterConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` - Address string `yaml:"address" json:"address,omitempty"` - Cluster string `yaml:"cluster" json:"cluster,omitempty"` - Group string `default:"dubbo" yaml:"group" json:"group,omitempty"` - Username string `yaml:"username" json:"username,omitempty"` - Password string `yaml:"password" json:"password,omitempty"` - LogDir string `yaml:"log_dir" json:"log_dir,omitempty"` - ConfigFile string `default:"dubbo.properties" yaml:"config_file" json:"config_file,omitempty"` - Namespace string `default:"dubbo" yaml:"namespace" json:"namespace,omitempty"` - AppConfigFile string `default:"dubbo.properties" yaml:"app_config_file" json:"app_config_file,omitempty"` - AppId string `default:"dubbo" yaml:"app_id" json:"app_id,omitempty"` - TimeoutStr string `yaml:"timeout" json:"timeout,omitempty"` - RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"` + Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` + Address string `yaml:"address" json:"address,omitempty"` + Cluster string `yaml:"cluster" json:"cluster,omitempty"` + Group string `default:"dubbo" yaml:"group" json:"group,omitempty"` + Username string `yaml:"username" json:"username,omitempty"` + Password string `yaml:"password" json:"password,omitempty"` + LogDir string `yaml:"log_dir" json:"log_dir,omitempty"` + ConfigFile string `default:"dubbo.properties" yaml:"config_file" json:"config_file,omitempty"` + Namespace string `default:"dubbo" yaml:"namespace" json:"namespace,omitempty"` + AppConfigFile string `default:"dubbo.properties" yaml:"app_config_file" json:"app_config_file,omitempty"` + AppID string `default:"dubbo" yaml:"app_id" json:"app_id,omitempty"` + TimeoutStr string `yaml:"timeout" json:"timeout,omitempty"` + RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"` + Params map[string]string `yaml:"params" json:"parameters,omitempty"` } // UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function @@ -74,8 +75,15 @@ func (c *ConfigCenterConfig) GetUrlMap() url.Values { urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace) urlMap.Set(constant.CONFIG_GROUP_KEY, c.Group) urlMap.Set(constant.CONFIG_CLUSTER_KEY, c.Cluster) - urlMap.Set(constant.CONFIG_APP_ID_KEY, c.AppId) + urlMap.Set(constant.CONFIG_APP_ID_KEY, c.AppID) urlMap.Set(constant.CONFIG_LOG_DIR_KEY, c.LogDir) + urlMap.Set(constant.CONFIG_USERNAME_KEY, c.Username) + urlMap.Set(constant.CONFIG_PASSWORD_KEY, c.Password) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, c.TimeoutStr) + + for key, val := range c.Params { + urlMap.Set(key, val) + } return urlMap } @@ -84,22 +92,22 @@ type configCenter struct{} // toURL will compatible with baseConfig.ConfigCenterConfig.Address and baseConfig.ConfigCenterConfig.RemoteRef before 1.6.0 // After 1.6.0 will not compatible, only baseConfig.ConfigCenterConfig.RemoteRef func (b *configCenter) toURL(baseConfig BaseConfig) (*common.URL, error) { - if len(baseConfig.ConfigCenterConfig.Address) > 0 { + remoteRef := baseConfig.ConfigCenterConfig.RemoteRef + // if set remote ref use remote + if len(remoteRef) <= 0 { return common.NewURL(baseConfig.ConfigCenterConfig.Address, - common.WithProtocol(baseConfig.ConfigCenterConfig.Protocol), common.WithParams(baseConfig.ConfigCenterConfig.GetUrlMap())) + common.WithProtocol(baseConfig.ConfigCenterConfig.Protocol), + common.WithParams(baseConfig.ConfigCenterConfig.GetUrlMap())) } - - remoteRef := baseConfig.ConfigCenterConfig.RemoteRef rc, ok := baseConfig.GetRemoteConfig(remoteRef) - if !ok { return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) } - - newURL, err := rc.toURL() - if err == nil { - newURL.SetParams(baseConfig.ConfigCenterConfig.GetUrlMap()) + // set protocol if remote not set + if len(rc.Protocol) <= 0 { + rc.Protocol = baseConfig.ConfigCenterConfig.Protocol } + newURL, err := rc.ToURL() return newURL, err } @@ -124,8 +132,10 @@ func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl logger.Errorf("Get dynamic configuration error , error message is %v", err) return perrors.WithStack(err) } - config.GetEnvInstance().SetDynamicConfiguration(dynamicConfig) - content, err := dynamicConfig.GetProperties(baseConfig.ConfigCenterConfig.ConfigFile, config_center.WithGroup(baseConfig.ConfigCenterConfig.Group)) + envInstance := config.GetEnvInstance() + envInstance.SetDynamicConfiguration(dynamicConfig) + content, err := dynamicConfig.GetProperties(baseConfig.ConfigCenterConfig.ConfigFile, + config_center.WithGroup(baseConfig.ConfigCenterConfig.Group)) if err != nil { logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) return perrors.WithStack(err) @@ -155,7 +165,7 @@ func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl if err != nil { return perrors.WithStack(err) } - config.GetEnvInstance().UpdateExternalConfigMap(mapContent) + envInstance.UpdateExternalConfigMap(mapContent) // appGroup config file if len(appContent) != 0 { @@ -163,7 +173,7 @@ func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl if err != nil { return perrors.WithStack(err) } - config.GetEnvInstance().UpdateAppExternalConfigMap(appMapContent) + envInstance.UpdateAppExternalConfigMap(appMapContent) } return nil diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go index f0ff05e04b..ec11947e4d 100644 --- a/config/config_center_config_test.go +++ b/config/config_center_config_test.go @@ -59,6 +59,7 @@ func TestStartConfigCenterWithRemoteRef(t *testing.T) { baseConfig := &BaseConfig{ Remotes: m, ConfigCenterConfig: &ConfigCenterConfig{ + Protocol: "mock", Group: "dubbo", RemoteRef: "mock", ConfigFile: "mockDubbo.properties", @@ -72,24 +73,3 @@ func TestStartConfigCenterWithRemoteRef(t *testing.T) { assert.True(t, b) assert.Equal(t, "ikurento.com", v) } - -func TestStartConfigCenterWithRemoteRefError(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - m := make(map[string]*RemoteConfig) - m["mock"] = &RemoteConfig{Address: "172.0.0.1"} - baseConfig := &BaseConfig{ - Remotes: m, - ConfigCenterConfig: &ConfigCenterConfig{ - Protocol: "mock", - Group: "dubbo", - RemoteRef: "mock", - ConfigFile: "mockDubbo.properties", - }, - } - - c := &configCenter{} - err := c.startConfigCenter(*baseConfig) - assert.Error(t, err) -} diff --git a/config/remote_config.go b/config/remote_config.go index 25e17618e0..292a89e9d3 100644 --- a/config/remote_config.go +++ b/config/remote_config.go @@ -18,6 +18,7 @@ package config import ( + "net/url" "time" ) @@ -55,7 +56,8 @@ func (rc *RemoteConfig) Timeout() time.Duration { if res, err := time.ParseDuration(rc.TimeoutStr); err == nil { return res } - logger.Errorf("Could not parse the timeout string to Duration: %s, the default value will be returned", rc.TimeoutStr) + logger.Errorf("Could not parse the timeout string to Duration: %s, the default value will be returned", + rc.TimeoutStr) return 5 * time.Second } @@ -69,14 +71,29 @@ func (rc *RemoteConfig) GetParam(key string, def string) string { return param } -func (rc *RemoteConfig) toURL() (*common.URL, error) { +// ToURL config to url +func (rc *RemoteConfig) ToURL() (*common.URL, error) { if len(rc.Protocol) == 0 { return nil, perrors.Errorf("Must provide protocol in RemoteConfig.") } return common.NewURL(rc.Address, + common.WithProtocol(rc.Protocol), common.WithUsername(rc.Username), common.WithPassword(rc.Password), common.WithLocation(rc.Address), - common.WithProtocol(rc.Protocol), + common.WithParams(rc.getUrlMap()), ) } + +// getUrlMap get url map +func (rc *RemoteConfig) getUrlMap() url.Values { + urlMap := url.Values{} + urlMap.Set(constant.CONFIG_USERNAME_KEY, rc.Username) + urlMap.Set(constant.CONFIG_PASSWORD_KEY, rc.Password) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, rc.TimeoutStr) + + for key, val := range rc.Params { + urlMap.Set(key, val) + } + return urlMap +} diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index d0df630299..3392868223 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -187,7 +187,7 @@ func initMockApollo(t *testing.T) *apolloConfiguration { c := &config.BaseConfig{ConfigCenterConfig: &config.ConfigCenterConfig{ Protocol: "apollo", Address: "106.12.25.204:8080", - AppId: "testApplication_yang", + AppID: "testApplication_yang", Cluster: "dev", Namespace: "mockDubbog", }} diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go index f53c629f4e..908012b783 100644 --- a/config_center/nacos/client.go +++ b/config_center/nacos/client.go @@ -18,7 +18,6 @@ package nacos import ( - "strings" "sync" "time" ) @@ -29,7 +28,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/remoting/nacos" ) @@ -58,58 +56,21 @@ func (n *NacosClient) SetClient(configClient *nacosClient.NacosConfigClient) { n.Unlock() } -type option func(*options) - -type options struct { - nacosName string - // configClient *NacosClient -} - -// WithNacosName Set nacos name -func WithNacosName(name string) option { - return func(opt *options) { - opt.nacosName = name - } -} - // ValidateNacosClient Validate nacos configClient , if null then create it -func ValidateNacosClient(container nacosClientFacade, opts ...option) error { +func ValidateNacosClient(container nacosClientFacade) error { if container == nil { return perrors.Errorf("container can not be null") } - os := &options{} - for _, opt := range opts { - opt(os) - } - url := container.GetURL() - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - logger.Errorf("invalid timeout config %+v,got err %+v", - url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), err) - return perrors.WithMessagef(err, "newNacosClient(address:%+v)", url.Location) - } - nacosAddresses := strings.Split(url.Location, ",") - if container.NacosClient() == nil { + if container.NacosClient() == nil || container.NacosClient().Client() == nil { // in dubbo ,every registry only connect one node ,so this is []string{r.Address} newClient, err := nacos.NewNacosConfigClientByUrl(url) if err != nil { - logger.Errorf("newNacosClient(name{%s}, nacos address{%v}, timeout{%d}) = error{%v}", - os.nacosName, url.Location, timeout.String(), err) + logger.Errorf("ValidateNacosClient(name{%s}, nacos address{%v} = error{%v}", url.Location, err) return perrors.WithMessagef(err, "newNacosClient(address:%+v)", url.Location) } container.SetNacosClient(newClient) } - - if container.NacosClient().Client() == nil { - configClient, err := nacos.NewNacosConfigClientByUrl(url) - if err != nil { - logger.Errorf("initNacosConfigClient(addr:%+v,timeout:%v,url:%v) = err %+v", - nacosAddresses, timeout.String(), url, err) - return perrors.WithMessagef(err, "newNacosClient(address:%+v)", url.Location) - } - container.NacosClient().SetClient(configClient.Client()) - } return perrors.WithMessagef(nil, "newNacosClient(address:%+v)", url.PrimitiveURL) } diff --git a/config_center/nacos/client_test.go b/config_center/nacos/client_test.go index 458f2d9885..86305e7f58 100644 --- a/config_center/nacos/client_test.go +++ b/config_center/nacos/client_test.go @@ -39,7 +39,7 @@ func TestNewNacosClient(t *testing.T) { url: registryUrl, done: make(chan struct{}), } - err := ValidateNacosClient(c, WithNacosName(nacosClientName)) + err := ValidateNacosClient(c) assert.NoError(t, err) c.wg.Add(1) go HandleClientRestart(c) @@ -63,7 +63,7 @@ func TestSetNacosClient(t *testing.T) { done: make(chan struct{}), } - err := ValidateNacosClient(c, WithNacosName(nacosClientName)) + err := ValidateNacosClient(c) assert.NoError(t, err) c.wg.Add(1) go HandleClientRestart(c) @@ -85,7 +85,7 @@ func TestNewNacosClient_connectError(t *testing.T) { url: registryUrl, done: make(chan struct{}), } - err = ValidateNacosClient(c, WithNacosName(nacosClientName)) + err = ValidateNacosClient(c) assert.NoError(t, err) c.wg.Add(1) go HandleClientRestart(c) diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 50e10946fc..6d7326aaf0 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -65,7 +65,7 @@ func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, url: url, done: make(chan struct{}), } - err := ValidateNacosClient(c, WithNacosName(nacosClientName)) + err := ValidateNacosClient(c) if err != nil { logger.Errorf("nacos configClient start error ,error message is %v", err) return nil, err diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index def19967ae..174bf0bc82 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -326,7 +326,7 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { return nil, perrors.New("could not init the instance because the config is invalid") } - remoteConfig, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + rc, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } @@ -334,13 +334,16 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { if len(group) == 0 { group = defaultGroup } - - client, err := nacos.NewNacosClient(remoteConfig) + // set protocol if remote not set + if len(rc.Protocol) <= 0 { + rc.Protocol = sdc.Protocol + } + client, err := nacos.NewNacosClient(rc) if err != nil { return nil, perrors.WithMessage(err, "create nacos namingClient failed.") } - descriptor := fmt.Sprintf("nacos-service-discovery[%s]", remoteConfig.Address) + descriptor := fmt.Sprintf("nacos-service-discovery[%s]", rc.Address) newInstance := &nacosServiceDiscovery{ group: group, diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go index 462406185b..c42cc93e93 100644 --- a/remoting/nacos/builder.go +++ b/remoting/nacos/builder.go @@ -68,65 +68,43 @@ func GetNacosConfig(url *common.URL) ([]nacosConstant.ServerConfig, nacosConstan serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{IpAddr: ip, Port: uint64(port)}) } - var clientConfig nacosConstant.ClientConfig timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) if err != nil { return []nacosConstant.ServerConfig{}, nacosConstant.ClientConfig{}, err } - //enable local cache when nacos can not connect. - notLoadCache, err := strconv.ParseBool(url.GetParam(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")) - if err != nil { - notLoadCache = false - } - clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000) - // clientConfig.ListenInterval = 2 * clientConfig.TimeoutMs - clientConfig.CacheDir = url.GetParam(constant.NACOS_CACHE_DIR_KEY, "") - clientConfig.LogDir = url.GetParam(constant.NACOS_LOG_DIR_KEY, "") - clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "") - clientConfig.NamespaceId = url.GetParam(constant.NACOS_NAMESPACE_ID, "") - clientConfig.Username = url.GetParam(constant.NACOS_USERNAME, "") - clientConfig.Password = url.GetParam(constant.NACOS_PASSWORD, "") - clientConfig.NotLoadCacheAtStart = notLoadCache + clientConfig := nacosConstant.ClientConfig{ + TimeoutMs: uint64(int32(timeout / time.Millisecond)), + BeatInterval: url.GetParamInt(constant.NACOS_BEAT_INTERVAL_KEY, 5000), + NamespaceId: url.GetParam(constant.NACOS_NAMESPACE_ID, ""), + AppName: url.GetParam(constant.NACOS_APP_NAME_KEY, ""), + Endpoint: url.GetParam(constant.NACOS_ENDPOINT, ""), + RegionId: url.GetParam(constant.NACOS_REGION_ID_KEY, ""), + AccessKey: url.GetParam(constant.NACOS_ACCESS_KEY, ""), + SecretKey: url.GetParam(constant.NACOS_SECRET_KEY, ""), + OpenKMS: url.GetParamBool(constant.NACOS_OPEN_KMS_KEY, false), + CacheDir: url.GetParam(constant.NACOS_CACHE_DIR_KEY, ""), + UpdateThreadNum: url.GetParamByIntValue(constant.NACOS_UPDATE_THREAD_NUM_KEY, 20), + NotLoadCacheAtStart: url.GetParamBool(constant.NACOS_NOT_LOAD_LOCAL_CACHE, true), + Username: url.GetParam(constant.NACOS_USERNAME, ""), + Password: url.GetParam(constant.NACOS_PASSWORD, ""), + LogDir: url.GetParam(constant.NACOS_LOG_DIR_KEY, ""), + LogLevel: url.GetParam(constant.NACOS_LOG_LEVEL_KEY, "info"), + } return serverConfigs, clientConfig, nil } // NewNacosClient create an instance with the config func NewNacosClient(rc *config.RemoteConfig) (*nacosClient.NacosNamingClient, error) { - if len(rc.Address) == 0 { - return nil, perrors.New("nacos address is empty!") - } - addresses := strings.Split(rc.Address, ",") - scs := make([]nacosConstant.ServerConfig, 0, len(addresses)) - for _, addr := range addresses { - ip, portStr, err := net.SplitHostPort(addr) - if err != nil { - return nil, perrors.WithMessagef(err, "split [%s] ", addr) - } - port, _ := strconv.Atoi(portStr) - scs = append(scs, nacosConstant.ServerConfig{ - IpAddr: ip, - Port: uint64(port), - }) + url, err := rc.ToURL() + if err != nil { + return nil, err } + scs, cc, err := GetNacosConfig(url) - var cc nacosConstant.ClientConfig - timeout := rc.Timeout() - //enable local cache when nacos can not connect. - notLoadCache, err := strconv.ParseBool(rc.GetParam(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")) if err != nil { - notLoadCache = false + return nil, err } - cc.TimeoutMs = uint64(timeout.Nanoseconds() / constant.MsToNanoRate) - // cc.ListenInterval = 2 * cc.TimeoutMs - cc.CacheDir = rc.GetParam(constant.NACOS_CACHE_DIR_KEY, "") - cc.LogDir = rc.GetParam(constant.NACOS_LOG_DIR_KEY, "") - cc.Endpoint = rc.GetParam(constant.NACOS_ENDPOINT, "") - cc.NamespaceId = rc.GetParam(constant.NACOS_NAMESPACE_ID, "") - cc.Username = rc.Username - cc.Password = rc.Password - cc.NotLoadCacheAtStart = notLoadCache - return nacosClient.NewNacosNamingClient(getNacosClientName(), true, scs, cc) } diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go index 0d43ed09ae..959d27e2fe 100644 --- a/remoting/nacos/builder_test.go +++ b/remoting/nacos/builder_test.go @@ -35,6 +35,8 @@ import ( func TestNewNacosClient(t *testing.T) { rc := &config.RemoteConfig{} + rc.Protocol = "nacos" + rc.Username = "nacos" client, err := NewNacosClient(rc) // address is nil From b55682a021eff7791f8b14f1da9d36f2d12e627f Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sun, 27 Jun 2021 21:18:35 +0800 Subject: [PATCH 8/9] fix: add arch picture in readme and delete unused router field. (#1279) * fix * fix: delete notify --- README.md | 2 +- README_CN.md | 2 +- cluster/router/chain.go | 2 - cluster/router/chain/chain.go | 62 ++-------------- cluster/router/chain/invoker_cache.go | 78 -------------------- cluster/router/router.go | 2 +- cluster/router/rule.go | 31 -------- cluster/router/v3router/factory.go | 4 +- cluster/router/v3router/factory_test.go | 2 +- cluster/router/v3router/router_chain.go | 13 ++-- cluster/router/v3router/router_chain_test.go | 6 +- cluster/router/v3router/uniform_route.go | 4 +- 12 files changed, 21 insertions(+), 187 deletions(-) delete mode 100644 cluster/router/chain/invoker_cache.go delete mode 100644 cluster/router/rule.go diff --git a/README.md b/README.md index c3031e8fd8..7b35696dac 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Apache Dubbo-go, a Dubbo implementation written in Golang, is born to bridge the ## Architecture -![dubbo go extend](https://dubbogo.github.io/img/doc/dubbo-go-arch.png) +![dubbo go extend](https://dubbogo.github.io/img/doc/dubbo-go3.0-arch.jpg) Dubbo-go has been implemented most layers of Dubbo, like protocol layer, registry layer, etc. An extension module is applied to Dubbo-go in order to achieve a more flexible architecture. Developers are allowed to implement a customized layer conformed to the layer interface and use then in Dubbo-go via `extension.Set` method without modifying the source code. diff --git a/README_CN.md b/README_CN.md index 2f7963f203..d6b5dcb981 100644 --- a/README_CN.md +++ b/README_CN.md @@ -14,7 +14,7 @@ Apache Dubbo Go 语言实现,架起 Java 和 Golang 之间的桥梁,与 gRPC ## 架构 -![dubbo go extend](https://dubbogo.github.io/img/doc/dubbo-go-arch.png) +![dubbo go extend](https://dubbogo.github.io/img/doc/dubbo-go3.0-arch.jpg) Dubbo-go已经实现了Dubbo的大部分层级,包括协议层(protocol layer)、注册层(registry layer))等等。在Dubbo-go中使用了拓展模块(extension module)以实现更灵活的系统架构,开发者可以根据层接口实现一个自定义的层,并在不改动源代码的前提下通过`extension.Set`方法将它应用到Dubbo-go中。 diff --git a/cluster/router/chain.go b/cluster/router/chain.go index bde5aecd35..6c7c0347d8 100644 --- a/cluster/router/chain.go +++ b/cluster/router/chain.go @@ -29,6 +29,4 @@ type Chain interface { SetInvokers([]protocol.Invoker) // AddRouters Add routers AddRouters([]PriorityRouter) - // GetNotifyChan get notify channel of this chain - GetNotifyChan() chan struct{} } diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 9268bafcaa..616909ab1e 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -20,7 +20,6 @@ package chain import ( "sort" "sync" - "time" ) import ( @@ -31,7 +30,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/cluster/router" "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" @@ -53,21 +51,6 @@ type RouterChain struct { builtinRouters []router.PriorityRouter mutex sync.RWMutex - - url *common.URL - - // The times of address notification since last update for address cache - count int64 - // The timestamp of last update for address cache - last time.Time - // Channel for notify to update the address cache - notify chan struct{} - // Address cache - cache atomic.Value -} - -func (c *RouterChain) GetNotifyChan() chan struct{} { - return c.notify } // Route Loop routers in RouterChain and call Route method to determine the target invokers list. @@ -91,9 +74,6 @@ func (c *RouterChain) AddRouters(routers []router.PriorityRouter) { c.mutex.Lock() defer c.mutex.Unlock() c.routers = newRouters - go func() { - c.notify <- struct{}{} - }() } // SetInvokers receives updated invokers from registry center. If the times of notification exceeds countThreshold and @@ -102,10 +82,6 @@ func (c *RouterChain) SetInvokers(invokers []protocol.Invoker) { c.mutex.Lock() c.invokers = invokers c.mutex.Unlock() - - go func() { - c.notify <- struct{}{} - }() } // copyRouters make a snapshot copy from RouterChain's router list. @@ -142,18 +118,13 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) { return nil, perrors.Errorf("No routerFactory exits , create one please") } - chain := &RouterChain{ - last: time.Now(), - notify: make(chan struct{}), - } - routers := make([]router.PriorityRouter, 0, len(routerFactories)) for key, routerFactory := range routerFactories { if virtualServiceConfigByte == nil || destinationRuleConfigByte == nil { logger.Warnf("virtual Service Config or destinationRule Confi Byte may be empty, pls check your CONF_VIRTUAL_SERVICE_FILE_PATH and CONF_DEST_RULE_FILE_PATH env is correctly point to your yaml file\n") } - r, err := routerFactory().NewPriorityRouter(virtualServiceConfigByte, destinationRuleConfigByte, chain.notify) + r, err := routerFactory().NewPriorityRouter(virtualServiceConfigByte, destinationRuleConfigByte) if r == nil || err != nil { logger.Errorf("router chain build router fail! routerFactories key:%s error:%vv", key, err) continue @@ -168,36 +139,13 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) { routerNeedsUpdateInit := atomic.Bool{} routerNeedsUpdateInit.Store(false) - chain.routers = newRouters - chain.builtinRouters = routers - if url != nil { - chain.url = url - } - return chain, nil -} - -// isInvokersChanged compares new invokers on the right changes, compared with the old invokers on the left. -func isInvokersChanged(left []protocol.Invoker, right []protocol.Invoker) bool { - if len(right) != len(left) { - return true + chain := &RouterChain{ + routers: newRouters, + builtinRouters: routers, } - for _, r := range right { - found := false - rurl := r.GetURL() - for _, l := range left { - lurl := l.GetURL() - if common.GetCompareURLEqualFunc()(lurl, rurl, constant.TIMESTAMP_KEY, constant.REMOTE_TIMESTAMP_KEY) { - found = true - break - } - } - if !found { - return true - } - } - return false + return chain, nil } // sortRouter Sort router instance by priority with stable algorithm diff --git a/cluster/router/chain/invoker_cache.go b/cluster/router/chain/invoker_cache.go deleted file mode 100644 index 8fde0dde1c..0000000000 --- a/cluster/router/chain/invoker_cache.go +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package chain - -import ( - "github.com/RoaringBitmap/roaring" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/router" - "dubbo.apache.org/dubbo-go/v3/protocol" -) - -// Cache caches all addresses relevant info for a snapshot of received invokers. It keeps a snapshot of the received -// address list, and also keeps address pools and address metadata from routers based on the same address snapshot, if -// the router implements Poolable. -type InvokerCache struct { - // The snapshot of invokers - invokers []protocol.Invoker - - // The bitmap representation for invokers snapshot - bitmap *roaring.Bitmap - - // Address pool from routers which implement Poolable - pools map[string]router.AddrPool - - // Address metadata from routers which implement Poolable - metadatas map[string]router.AddrMetadata -} - -// BuildCache builds address cache from the given invokers. -func BuildCache(invokers []protocol.Invoker) *InvokerCache { - return &InvokerCache{ - invokers: invokers, - pools: make(map[string]router.AddrPool, 8), - metadatas: make(map[string]router.AddrMetadata, 8), - } -} - -// GetInvokers get invokers snapshot. -func (c *InvokerCache) GetInvokers() []protocol.Invoker { - return c.invokers -} - -// FindAddrPool finds address pool for a poolable router. -func (c *InvokerCache) FindAddrPool(p router.Poolable) router.AddrPool { - return c.pools[p.Name()] -} - -// FindAddrMeta finds address metadata for a poolable router. -func (c *InvokerCache) FindAddrMeta(p router.Poolable) router.AddrMetadata { - return c.metadatas[p.Name()] -} - -// SetAddrPool sets address pool for a poolable router, for unit test only -func (c *InvokerCache) SetAddrPool(name string, pool router.AddrPool) { - c.pools[name] = pool -} - -// SetAddrMeta sets address metadata for a poolable router, for unit test only -func (c *InvokerCache) SetAddrMeta(name string, meta router.AddrMetadata) { - c.metadatas[name] = meta -} diff --git a/cluster/router/router.go b/cluster/router/router.go index 5d653cdd87..d3d2fe53d5 100644 --- a/cluster/router/router.go +++ b/cluster/router/router.go @@ -30,7 +30,7 @@ import ( // PriorityRouterFactory creates creates priority router with url type PriorityRouterFactory interface { // NewPriorityRouter creates router instance with URL - NewPriorityRouter([]byte, []byte, chan struct{}) (PriorityRouter, error) + NewPriorityRouter([]byte, []byte) (PriorityRouter, error) } // Router diff --git a/cluster/router/rule.go b/cluster/router/rule.go deleted file mode 100644 index 42c08a7009..0000000000 --- a/cluster/router/rule.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package router - -// BaseRouterRule -type BaseRouterRule struct { - RawRule string - Runtime bool - Force bool - Valid bool - Enabled bool - Priority int - Dynamic bool - Scope string - Key string -} diff --git a/cluster/router/v3router/factory.go b/cluster/router/v3router/factory.go index 0b164e76ca..afd14af66d 100644 --- a/cluster/router/v3router/factory.go +++ b/cluster/router/v3router/factory.go @@ -30,6 +30,6 @@ func NewUniformRouterFactory() router.PriorityRouterFactory { } // NewPriorityRouter construct a new UniformRouteFactory as PriorityRouter -func (f *UniformRouteFactory) NewPriorityRouter(vsConfigBytes, distConfigBytes []byte, notify chan struct{}) (router.PriorityRouter, error) { - return NewUniformRouterChain(vsConfigBytes, distConfigBytes, notify) +func (f *UniformRouteFactory) NewPriorityRouter(vsConfigBytes, distConfigBytes []byte) (router.PriorityRouter, error) { + return NewUniformRouterChain(vsConfigBytes, distConfigBytes) } diff --git a/cluster/router/v3router/factory_test.go b/cluster/router/v3router/factory_test.go index 365d7552f4..a5ea41579c 100644 --- a/cluster/router/v3router/factory_test.go +++ b/cluster/router/v3router/factory_test.go @@ -29,7 +29,7 @@ import ( func TestUniformRouterFacotry(t *testing.T) { factory := NewUniformRouterFactory() assert.NotNil(t, factory) - router, err := factory.NewPriorityRouter([]byte{}, []byte{}, make(chan struct{})) + router, err := factory.NewPriorityRouter([]byte{}, []byte{}) assert.Nil(t, err) assert.NotNil(t, router) } diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index dc14c7325d..ce8269493d 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -48,9 +48,9 @@ type RouterChain struct { } // NewUniformRouterChain return -func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) (router.PriorityRouter, error) { +func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte) (router.PriorityRouter, error) { fromFileConfig := true - uniformRouters, err := parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig, notify) + uniformRouters, err := parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig) if err != nil { fromFileConfig = false logger.Warnf("parse router config form local file failed, error = %+v", err) @@ -59,7 +59,6 @@ func NewUniformRouterChain(virtualServiceConfig, destinationRuleConfig []byte, n virtualServiceConfigBytes: virtualServiceConfig, destinationRuleConfigBytes: destinationRuleConfig, routers: uniformRouters, - notify: notify, } if err := k8s_api.SetK8sEventListener(r); err != nil { logger.Warnf("try listen K8s router config failed, error = %+v", err) @@ -110,7 +109,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { logger.Error("Process change of virtual service: event.Value marshal error:", err) return } - r.routers, err = parseFromConfigToRouters(data, r.destinationRuleConfigBytes, r.notify) + r.routers, err = parseFromConfigToRouters(data, r.destinationRuleConfigBytes) if err != nil { logger.Error("Process change of virtual service: parseFromConfigToRouters:", err) return @@ -142,7 +141,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { logger.Error("Process change of dest rule: event.Value marshal error:", err) return } - r.routers, err = parseFromConfigToRouters(r.virtualServiceConfigBytes, data, r.notify) + r.routers, err = parseFromConfigToRouters(r.virtualServiceConfigBytes, data) if err != nil { logger.Error("Process change of dest rule: parseFromConfigToRouters:", err) return @@ -174,7 +173,7 @@ func (r *RouterChain) URL() *common.URL { } // parseFromConfigToRouters parse virtualService and destinationRule yaml file bytes to target router list -func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte, notify chan struct{}) ([]*UniformRouter, error) { +func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte) ([]*UniformRouter, error) { var virtualServiceConfigList []*config.VirtualServiceConfig destRuleConfigsMap := make(map[string]map[string]map[string]string) @@ -234,7 +233,7 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte logger.Error("Parse config to uniform rule err = ", err) return nil, err } - rtr, err := NewUniformRouter(newRule, notify) + rtr, err := NewUniformRouter(newRule) if err != nil { logger.Error("new uniform router err = ", err) return nil, err diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index 4ce4eef3b0..9e12da1eb3 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -51,7 +51,7 @@ const ( func TestNewUniformRouterChain(t *testing.T) { vsBytes, _ := yaml.LoadYMLConfig(mockVSConfigPath) drBytes, _ := yaml.LoadYMLConfig(mockDRConfigPath) - rc, err := NewUniformRouterChain(vsBytes, drBytes, make(chan struct{})) + rc, err := NewUniformRouterChain(vsBytes, drBytes) assert.Nil(t, err) assert.NotNil(t, rc) } @@ -72,7 +72,7 @@ type ruleTestItemStruct struct { func TestParseConfigFromFile(t *testing.T) { vsBytes, _ := yaml.LoadYMLConfig(mockVSConfigPath) drBytes, _ := yaml.LoadYMLConfig(mockDRConfigPath) - routers, err := parseFromConfigToRouters(vsBytes, drBytes, make(chan struct{}, 1)) + routers, err := parseFromConfigToRouters(vsBytes, drBytes) fmt.Println(routers, err) assert.Equal(t, len(routers), 1) assert.NotNil(t, routers[0].dubboRouter) @@ -199,7 +199,7 @@ func TestParseConfigFromFile(t *testing.T) { func TestRouterChain_Route(t *testing.T) { vsBytes, _ := yaml.LoadYMLConfig(mockVSConfigPath) drBytes, _ := yaml.LoadYMLConfig(mockDRConfigPath) - rc, err := NewUniformRouterChain(vsBytes, drBytes, make(chan struct{})) + rc, err := NewUniformRouterChain(vsBytes, drBytes) assert.Nil(t, err) assert.NotNil(t, rc) newGoodURL, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=&version=2.6.0") diff --git a/cluster/router/v3router/uniform_route.go b/cluster/router/v3router/uniform_route.go index f44eff1482..9ea12dd421 100644 --- a/cluster/router/v3router/uniform_route.go +++ b/cluster/router/v3router/uniform_route.go @@ -30,14 +30,12 @@ const ( // UniformRouter have type UniformRouter struct { dubboRouter *DubboRouterRule - notify chan struct{} } // NewUniformRouter construct an NewConnCheckRouter via url -func NewUniformRouter(dubboRouter *DubboRouterRule, notify chan struct{}) (*UniformRouter, error) { +func NewUniformRouter(dubboRouter *DubboRouterRule) (*UniformRouter, error) { r := &UniformRouter{ dubboRouter: dubboRouter, - notify: notify, } return r, nil } From 9f4b07a25f5dd5fbc26016b219dd30d43a4306c6 Mon Sep 17 00:00:00 2001 From: mark4z Date: Mon, 5 Jul 2021 11:00:13 +0800 Subject: [PATCH 9/9] performance optimization: change time.After => time.NewTimer --- protocol/grpc/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index 3466232cfb..e068999447 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -119,7 +119,8 @@ func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { t := time.NewTicker(50 * time.Millisecond) defer t.Stop() pLen := len(providerServices) - ta := time.After(10 * time.Second) + ta := time.NewTimer(10 * time.Second) + defer ta.Stop() for { select { @@ -128,7 +129,7 @@ func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { if pLen == mLen { return } - case <-ta: + case <-ta.C: panic("wait grpc exporter timeout when start grpc server") } }