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 001/148] 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 044d22ce1e04e26d9d1c5db44d626ef69a8de8e1 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 18 Jul 2021 02:17:02 +0800 Subject: [PATCH 002/148] config file enhance --- cluster/router/v3router/dubbo_rule.go | 4 +- .../judger/attachment_match_judger.go | 8 +- .../judger/attachment_match_judger_test.go | 14 +- .../v3router/judger/bool_match_judger.go | 8 +- .../v3router/judger/bool_match_judger_test.go | 13 +- .../v3router/judger/double_match_judger.go | 6 +- .../judger/double_match_judger_test.go | 21 +- .../judger/double_range_match_judger.go | 6 +- .../judger/double_range_match_judger_test.go | 11 +- .../judger/list_double_match_judger.go | 6 +- .../judger/list_double_match_judger_test.go | 29 +- .../judger/list_string_match_judger.go | 6 +- .../judger/list_string_match_judger_test.go | 13 +- .../v3router/judger/method_match_judger.go | 6 +- .../judger/method_match_judger_test.go | 24 +- .../v3router/judger/string_match_judger.go | 9 +- .../judger/string_match_judger_test.go | 17 +- .../v3router/k8s_api/listener_handler_impl.go | 22 +- cluster/router/v3router/router_chain.go | 16 +- cluster/router/v3router/router_chain_test.go | 6 +- cluster/router/v3router/uniform_rule.go | 10 +- common/constant/key.go | 24 +- config/application/application_config.go | 71 ++ config/application_config.go | 52 - config/base_config.go | 312 ----- config/base_config_test.go | 303 ----- config/{ => center}/config_center_config.go | 143 ++- config/config_api.go | 1094 ++++++++-------- config/config_api_test.go | 283 ++--- config/config_center_config_test.go | 75 -- config/config_loader.go | 1012 ++++++++------- config/config_loader_options.go | 273 ++-- config/config_loader_test.go | 1101 ++++++++--------- config/consumer/consumer_config.go | 142 +++ config/consumer_config.go | 143 --- config/{ => generic}/generic_service.go | 2 +- config/graceful_shutdown_test.go | 108 -- config/{ => instance}/service.go | 2 +- .../report}/metadata_report_config.go | 78 +- config/metadata_report_config_test.go | 52 - config/{ => method}/method_config.go | 2 +- config/{ => metric}/metric_config.go | 2 +- config/{ => metric}/metric_config_test.go | 5 +- config/{ => protocol}/protocol_config.go | 2 +- config/provider/provider_config.go | 105 ++ config/provider/provider_config_test.go | 52 + config/provider_config.go | 104 -- config/provider_config_test.go | 50 - config/reference/reference_config.go | 295 +++++ config/reference/reference_config_test.go | 411 ++++++ config/reference_config.go | 307 ----- config/reference_config_test.go | 404 ------ config/{ => registry}/registry_config.go | 2 +- config/{ => registry}/registry_config_test.go | 2 +- config/root/root_config.go | 56 + config/{ => router}/router_config.go | 2 +- config/{ => router}/router_config_test.go | 2 +- config/{ => router}/uniform_router_config.go | 2 +- .../discovery}/service_discovery_config.go | 8 +- config/service/service_config.go | 368 ++++++ config/service_config.go | 367 ------ config/service_config_test.go | 215 ---- config/{ => shutdown}/graceful_shutdown.go | 237 ++-- .../graceful_shutdown_config.go | 2 +- .../graceful_shutdown_config_test.go | 2 +- .../graceful_shutdown_signal_darwin.go | 2 +- .../graceful_shutdown_signal_linux.go | 2 +- .../graceful_shutdown_signal_windows.go | 2 +- config/shutdown/graceful_shutdown_test.go | 113 ++ config/testdata/application.yaml | 24 + config_center/apollo/impl_test.go | 5 +- filter/gshutdown/filter.go | 5 +- filter/gshutdown/filter_test.go | 3 +- go.mod | 4 + go.sum | 32 + .../service/exporter/configurable/exporter.go | 8 +- .../exporter/configurable/exporter_test.go | 26 +- protocol/dubbo3/common_test.go | 4 +- protocol/dubbo3/dubbo3_invoker.go | 3 +- protocol/dubbo3/dubbo3_protocol.go | 4 +- protocol/dubbo3/internal/client.go | 7 +- protocol/dubbo3/internal/server.go | 6 +- protocol/grpc/client.go | 3 +- protocol/grpc/grpc_protocol_test.go | 21 +- protocol/grpc/internal/helloworld/client.go | 7 +- protocol/grpc/internal/routeguide/client.go | 7 +- protocol/grpc/server.go | 8 +- protocol/jsonrpc/jsonrpc_protocol_test.go | 6 +- protocol/rest/rest_invoker_test.go | 6 +- protocol/rest/rest_protocol_test.go | 11 +- registry/directory/directory_test.go | 10 +- registry/etcdv3/service_discovery_test.go | 5 +- .../event/service_config_exported_event.go | 6 +- registry/file/service_discovery_test.go | 3 +- registry/nacos/service_discovery_test.go | 7 +- registry/protocol/protocol.go | 3 +- registry/protocol/protocol_test.go | 15 +- .../service_discovery_registry_test.go | 4 +- registry/zookeeper/service_discovery_test.go | 7 +- remoting/getty/config.go | 17 +- test/integrate/dubbo/go-client/user.go | 4 +- test/integrate/dubbo/go-server/user.go | 4 +- 102 files changed, 4100 insertions(+), 4833 deletions(-) create mode 100644 config/application/application_config.go delete mode 100644 config/application_config.go delete mode 100644 config/base_config.go delete mode 100644 config/base_config_test.go rename config/{ => center}/config_center_config.go (58%) delete mode 100644 config/config_center_config_test.go create mode 100644 config/consumer/consumer_config.go delete mode 100644 config/consumer_config.go rename config/{ => generic}/generic_service.go (98%) delete mode 100644 config/graceful_shutdown_test.go rename config/{ => instance}/service.go (99%) rename config/{ => medadata/report}/metadata_report_config.go (65%) delete mode 100644 config/metadata_report_config_test.go rename config/{ => method}/method_config.go (99%) rename config/{ => metric}/metric_config.go (98%) rename config/{ => metric}/metric_config_test.go (91%) rename config/{ => protocol}/protocol_config.go (98%) create mode 100644 config/provider/provider_config.go create mode 100644 config/provider/provider_config_test.go delete mode 100644 config/provider_config.go delete mode 100644 config/provider_config_test.go create mode 100644 config/reference/reference_config.go create mode 100644 config/reference/reference_config_test.go delete mode 100644 config/reference_config.go delete mode 100644 config/reference_config_test.go rename config/{ => registry}/registry_config.go (99%) rename config/{ => registry}/registry_config_test.go (99%) create mode 100644 config/root/root_config.go rename config/{ => router}/router_config.go (98%) rename config/{ => router}/router_config_test.go (99%) rename config/{ => router}/uniform_router_config.go (99%) rename config/{ => service/discovery}/service_discovery_config.go (90%) create mode 100644 config/service/service_config.go delete mode 100644 config/service_config.go delete mode 100644 config/service_config_test.go rename config/{ => shutdown}/graceful_shutdown.go (50%) rename config/{ => shutdown}/graceful_shutdown_config.go (99%) rename config/{ => shutdown}/graceful_shutdown_config_test.go (98%) rename config/{ => shutdown}/graceful_shutdown_signal_darwin.go (98%) rename config/{ => shutdown}/graceful_shutdown_signal_linux.go (98%) rename config/{ => shutdown}/graceful_shutdown_signal_windows.go (98%) create mode 100644 config/shutdown/graceful_shutdown_test.go create mode 100644 config/testdata/application.yaml diff --git a/cluster/router/v3router/dubbo_rule.go b/cluster/router/v3router/dubbo_rule.go index c809354b19..ec4903816e 100644 --- a/cluster/router/v3router/dubbo_rule.go +++ b/cluster/router/v3router/dubbo_rule.go @@ -19,7 +19,7 @@ package v3router import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -28,7 +28,7 @@ type DubboRouterRule struct { uniformRules []*UniformRule } -func newDubboRouterRule(dubboRoutes []*config.DubboRoute, +func newDubboRouterRule(dubboRoutes []*router.DubboRoute, destinationMap map[string]map[string]string) (*DubboRouterRule, error) { uniformRules := make([]*UniformRule, 0) diff --git a/cluster/router/v3router/judger/attachment_match_judger.go b/cluster/router/v3router/judger/attachment_match_judger.go index 31f46e05cf..f1d838aa81 100644 --- a/cluster/router/v3router/judger/attachment_match_judger.go +++ b/cluster/router/v3router/judger/attachment_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" "dubbo.apache.org/dubbo-go/v3/protocol" ) type AttachmentMatchJudger struct { - config.DubboAttachmentMatch + router.DubboAttachmentMatch } // nolint @@ -36,7 +36,7 @@ func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool { return amj.DubboContext == nil || judge(amj.DubboContext, invAttaMap) } -func judge(condition map[string]*config.StringMatch, invAttaMap map[string]interface{}) bool { +func judge(condition map[string]*router.StringMatch, invAttaMap map[string]interface{}) bool { for k, v := range condition { invAttaValue, ok := invAttaMap[k] if !ok { @@ -60,7 +60,7 @@ func judge(condition map[string]*config.StringMatch, invAttaMap map[string]inter } // nolint -func NewAttachmentMatchJudger(matchConf *config.DubboAttachmentMatch) *AttachmentMatchJudger { +func NewAttachmentMatchJudger(matchConf *router.DubboAttachmentMatch) *AttachmentMatchJudger { return &AttachmentMatchJudger{ DubboAttachmentMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/attachment_match_judger_test.go b/cluster/router/v3router/judger/attachment_match_judger_test.go index 26a8d5ed59..094cbde4a8 100644 --- a/cluster/router/v3router/judger/attachment_match_judger_test.go +++ b/cluster/router/v3router/judger/attachment_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -26,29 +27,28 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) func TestAttachmentMatchJudger(t *testing.T) { - conditionMap := make(map[string]*config.StringMatch) + conditionMap := make(map[string]*router.StringMatch) dubboIvkMap := make(map[string]interface{}) - conditionMap["test-key"] = &config.StringMatch{ + conditionMap["test-key"] = &router.StringMatch{ Exact: "abc", } dubboIvkMap["test-key"] = "abc" - assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + assert.True(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ DubboContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) - assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + assert.True(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) dubboIvkMap["test-key"] = "abd" - assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + assert.False(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ DubboContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) - assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ + assert.False(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) } diff --git a/cluster/router/v3router/judger/bool_match_judger.go b/cluster/router/v3router/judger/bool_match_judger.go index 4dcf2003a4..40cf365dc7 100644 --- a/cluster/router/v3router/judger/bool_match_judger.go +++ b/cluster/router/v3router/judger/bool_match_judger.go @@ -17,11 +17,13 @@ package judger -import "dubbo.apache.org/dubbo-go/v3/config" +import ( + "dubbo.apache.org/dubbo-go/v3/config/router" +) // nolint type BoolMatchJudger struct { - config.BoolMatch + router.BoolMatch } // nolint @@ -30,7 +32,7 @@ func (lsmj *BoolMatchJudger) Judge(input bool) bool { } // nolint -func newBoolMatchJudger(matchConf *config.BoolMatch) *BoolMatchJudger { +func newBoolMatchJudger(matchConf *router.BoolMatch) *BoolMatchJudger { return &BoolMatchJudger{ BoolMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/bool_match_judger_test.go b/cluster/router/v3router/judger/bool_match_judger_test.go index a86651e400..ef7a7400c0 100644 --- a/cluster/router/v3router/judger/bool_match_judger_test.go +++ b/cluster/router/v3router/judger/bool_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,24 +26,20 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestBoolMatchJudger(t *testing.T) { - assert.True(t, newBoolMatchJudger(&config.BoolMatch{ + assert.True(t, newBoolMatchJudger(&router.BoolMatch{ Exact: true, }).Judge(true)) - assert.True(t, newBoolMatchJudger(&config.BoolMatch{ + assert.True(t, newBoolMatchJudger(&router.BoolMatch{ Exact: false, }).Judge(false)) - assert.False(t, newBoolMatchJudger(&config.BoolMatch{ + assert.False(t, newBoolMatchJudger(&router.BoolMatch{ Exact: true, }).Judge(false)) - assert.False(t, newBoolMatchJudger(&config.BoolMatch{ + assert.False(t, newBoolMatchJudger(&router.BoolMatch{ Exact: false, }).Judge(true)) } diff --git a/cluster/router/v3router/judger/double_match_judger.go b/cluster/router/v3router/judger/double_match_judger.go index d5ec3844fd..79eda6fb9c 100644 --- a/cluster/router/v3router/judger/double_match_judger.go +++ b/cluster/router/v3router/judger/double_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" ) // nolint type DoubleMatchJudger struct { - config.DoubleMatch + router.DoubleMatch } // nolint @@ -42,7 +42,7 @@ func (dmj *DoubleMatchJudger) Judge(input float64) bool { } // nolint -func newDoubleMatchJudger(matchConf *config.DoubleMatch) *DoubleMatchJudger { +func newDoubleMatchJudger(matchConf *router.DoubleMatch) *DoubleMatchJudger { return &DoubleMatchJudger{ DoubleMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/double_match_judger_test.go b/cluster/router/v3router/judger/double_match_judger_test.go index a2ba18b255..4497b7b202 100644 --- a/cluster/router/v3router/judger/double_match_judger_test.go +++ b/cluster/router/v3router/judger/double_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,35 +26,31 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestDoubleMatchJudger(t *testing.T) { - assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ + assert.True(t, newDoubleMatchJudger(&router.DoubleMatch{ Exact: 3.14159, }).Judge(3.14159)) - assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ + assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ Exact: 3.14159, }).Judge(3.14155927)) - assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ - Range: &config.DoubleRangeMatch{ + assert.True(t, newDoubleMatchJudger(&router.DoubleMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, }).Judge(1.3)) - assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ - Range: &config.DoubleRangeMatch{ + assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, }).Judge(1.9)) - assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ - Range: &config.DoubleRangeMatch{ + assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, diff --git a/cluster/router/v3router/judger/double_range_match_judger.go b/cluster/router/v3router/judger/double_range_match_judger.go index 8897fc3c7d..1b783a5d44 100644 --- a/cluster/router/v3router/judger/double_range_match_judger.go +++ b/cluster/router/v3router/judger/double_range_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" ) // nolint type DoubleRangeMatchJudger struct { - config.DoubleRangeMatch + router.DoubleRangeMatch } // nolint @@ -32,7 +32,7 @@ func (drmj *DoubleRangeMatchJudger) Judge(input float64) bool { } // nolint -func newDoubleRangeMatchJudger(matchConf *config.DoubleRangeMatch) *DoubleRangeMatchJudger { +func newDoubleRangeMatchJudger(matchConf *router.DoubleRangeMatch) *DoubleRangeMatchJudger { return &DoubleRangeMatchJudger{ DoubleRangeMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/double_range_match_judger_test.go b/cluster/router/v3router/judger/double_range_match_judger_test.go index 9487e404c7..7ec62c3cca 100644 --- a/cluster/router/v3router/judger/double_range_match_judger_test.go +++ b/cluster/router/v3router/judger/double_range_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,22 +26,18 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestDoubleRangeMatchJudger(t *testing.T) { - assert.True(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ + assert.True(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(1.3)) - assert.False(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ + assert.False(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(1.9)) - assert.False(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ + assert.False(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(0.9)) diff --git a/cluster/router/v3router/judger/list_double_match_judger.go b/cluster/router/v3router/judger/list_double_match_judger.go index b968334e5e..746f350b4a 100644 --- a/cluster/router/v3router/judger/list_double_match_judger.go +++ b/cluster/router/v3router/judger/list_double_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" ) // nolint type ListDoubleMatchJudger struct { - config.ListDoubleMatch + router.ListDoubleMatch } // nolint @@ -37,7 +37,7 @@ func (lsmj *ListDoubleMatchJudger) Judge(input float64) bool { } // nolint -func newListDoubleMatchJudger(matchConf *config.ListDoubleMatch) *ListDoubleMatchJudger { +func newListDoubleMatchJudger(matchConf *router.ListDoubleMatch) *ListDoubleMatchJudger { return &ListDoubleMatchJudger{ ListDoubleMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/list_double_match_judger_test.go b/cluster/router/v3router/judger/list_double_match_judger_test.go index bc84c7801f..9b7dbb1a78 100644 --- a/cluster/router/v3router/judger/list_double_match_judger_test.go +++ b/cluster/router/v3router/judger/list_double_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,18 +26,14 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestListDoubleMatchJudger_Judge(t *testing.T) { - assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ - Oneof: []*config.DoubleMatch{ + assert.True(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ + Oneof: []*router.DoubleMatch{ { Exact: 3.14, }, { - Range: &config.DoubleRangeMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, @@ -47,13 +44,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.False(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ - Oneof: []*config.DoubleMatch{ + assert.False(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ + Oneof: []*router.DoubleMatch{ { Exact: 3.14, }, { - Range: &config.DoubleRangeMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, @@ -64,13 +61,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ - Oneof: []*config.DoubleMatch{ + assert.True(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ + Oneof: []*router.DoubleMatch{ { Exact: 3.14, }, { - Range: &config.DoubleRangeMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.2, End: 1.9, }, @@ -81,13 +78,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.False(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ - Oneof: []*config.DoubleMatch{ + assert.False(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ + Oneof: []*router.DoubleMatch{ { Exact: 3.14, }, { - Range: &config.DoubleRangeMatch{ + Range: &router.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, diff --git a/cluster/router/v3router/judger/list_string_match_judger.go b/cluster/router/v3router/judger/list_string_match_judger.go index a1df1e9d47..b96aa1e620 100644 --- a/cluster/router/v3router/judger/list_string_match_judger.go +++ b/cluster/router/v3router/judger/list_string_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" ) // nolint type ListStringMatchJudger struct { - config.ListStringMatch + router.ListStringMatch } // nolint @@ -37,7 +37,7 @@ func (lsmj *ListStringMatchJudger) Judge(input string) bool { } // nolint -func newListStringMatchJudger(matchConf *config.ListStringMatch) *ListStringMatchJudger { +func newListStringMatchJudger(matchConf *router.ListStringMatch) *ListStringMatchJudger { return &ListStringMatchJudger{ ListStringMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/list_string_match_judger_test.go b/cluster/router/v3router/judger/list_string_match_judger_test.go index 1816b9503f..6dfe42f81f 100644 --- a/cluster/router/v3router/judger/list_string_match_judger_test.go +++ b/cluster/router/v3router/judger/list_string_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,16 +26,12 @@ 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"}}, + assert.True(t, newListStringMatchJudger(&router.ListStringMatch{ + Oneof: []*router.StringMatch{{Exact: "abd"}}, }).Judge("abd")) - assert.False(t, newListStringMatchJudger(&config.ListStringMatch{ - Oneof: []*config.StringMatch{{Exact: "abc"}}, + assert.False(t, newListStringMatchJudger(&router.ListStringMatch{ + Oneof: []*router.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 e069ef9cca..19f69bcb58 100644 --- a/cluster/router/v3router/judger/method_match_judger.go +++ b/cluster/router/v3router/judger/method_match_judger.go @@ -18,13 +18,13 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config/router" "dubbo.apache.org/dubbo-go/v3/protocol" ) // nolint type MethodMatchJudger struct { - config.DubboMethodMatch + router.DubboMethodMatch } // Judge Method Match Judger only judge on @@ -83,7 +83,7 @@ func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { } // nolint -func NewMethodMatchJudger(matchConf *config.DubboMethodMatch) *MethodMatchJudger { +func NewMethodMatchJudger(matchConf *router.DubboMethodMatch) *MethodMatchJudger { return &MethodMatchJudger{ DubboMethodMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/method_match_judger_test.go b/cluster/router/v3router/judger/method_match_judger_test.go index 71e90aacb5..2f79663ae6 100644 --- a/cluster/router/v3router/judger/method_match_judger_test.go +++ b/cluster/router/v3router/judger/method_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "reflect" "testing" ) @@ -27,36 +28,35 @@ import ( ) 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{ + methodArgs := make([]*router.DubboMethodArg, 0) + methodArgs = append(methodArgs, &router.DubboMethodArg{ Index: 1, Type: "string", - StrValue: &config.ListStringMatch{Oneof: []*config.StringMatch{{Exact: "hello world"}}}, + StrValue: &router.ListStringMatch{Oneof: []*router.StringMatch{{Exact: "hello world"}}}, NumValue: nil, BoolValue: nil, }) - methodArgs = append(methodArgs, &config.DubboMethodArg{ + methodArgs = append(methodArgs, &router.DubboMethodArg{ Index: 2, Type: "bool", StrValue: nil, NumValue: nil, - BoolValue: &config.BoolMatch{Exact: true}, + BoolValue: &router.BoolMatch{Exact: true}, }) - methodArgs = append(methodArgs, &config.DubboMethodArg{ + methodArgs = append(methodArgs, &router.DubboMethodArg{ Index: 3, Type: "float64", StrValue: nil, - NumValue: &config.ListDoubleMatch{Oneof: []*config.DoubleMatch{{Exact: 10}}}, + NumValue: &router.ListDoubleMatch{Oneof: []*router.DoubleMatch{{Exact: 10}}}, BoolValue: nil, }) - methodMatch := &config.DubboMethodMatch{ - NameMatch: &config.StringMatch{Exact: "Greet"}, + methodMatch := &router.DubboMethodMatch{ + NameMatch: &router.StringMatch{Exact: "Greet"}, Argc: 3, Args: methodArgs, Argp: nil, @@ -71,7 +71,7 @@ func TestMethodMatchJudger(t *testing.T) { 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.False(t, NewMethodMatchJudger(&router.DubboMethodMatch{NameMatch: &router.StringMatch{Exact: "Great"}}).Judge(ivc)) + assert.False(t, NewMethodMatchJudger(&router.DubboMethodMatch{NameMatch: &router.StringMatch{Exact: "Greet"}, Argc: 1}).Judge(ivc)) assert.True(t, NewMethodMatchJudger(methodMatch).Judge(ivc)) } diff --git a/cluster/router/v3router/judger/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go index fae5278fb2..8902163d90 100644 --- a/cluster/router/v3router/judger/string_match_judger.go +++ b/cluster/router/v3router/judger/string_match_judger.go @@ -18,17 +18,14 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "regexp" "strings" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - // nolint type StringMatchJudger struct { - config.StringMatch + router.StringMatch } // nolint @@ -53,7 +50,7 @@ func (smj *StringMatchJudger) Judge(input string) bool { } // nolint -func NewStringMatchJudger(matchConf *config.StringMatch) *StringMatchJudger { +func NewStringMatchJudger(matchConf *router.StringMatch) *StringMatchJudger { return &StringMatchJudger{ StringMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/string_match_judger_test.go b/cluster/router/v3router/judger/string_match_judger_test.go index 968eda96f7..3f6c0c2ad3 100644 --- a/cluster/router/v3router/judger/string_match_judger_test.go +++ b/cluster/router/v3router/judger/string_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "testing" ) @@ -25,32 +26,28 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestNewStringMatchJudger(t *testing.T) { - assert.True(t, NewStringMatchJudger(&config.StringMatch{ + assert.True(t, NewStringMatchJudger(&router.StringMatch{ Exact: "abc", }).Judge("abc")) - assert.False(t, NewStringMatchJudger(&config.StringMatch{ + assert.False(t, NewStringMatchJudger(&router.StringMatch{ Exact: "abcd", }).Judge("abc")) - assert.True(t, NewStringMatchJudger(&config.StringMatch{ + assert.True(t, NewStringMatchJudger(&router.StringMatch{ Prefix: "abc", }).Judge("abcd")) - assert.False(t, NewStringMatchJudger(&config.StringMatch{ + assert.False(t, NewStringMatchJudger(&router.StringMatch{ Exact: "abcd", }).Judge("abdc")) - assert.True(t, NewStringMatchJudger(&config.StringMatch{ + assert.True(t, NewStringMatchJudger(&router.StringMatch{ Empty: "true", }).Judge("")) - assert.False(t, NewStringMatchJudger(&config.StringMatch{ + assert.False(t, NewStringMatchJudger(&router.StringMatch{ NoEmpty: "true", }).Judge("")) } diff --git a/cluster/router/v3router/k8s_api/listener_handler_impl.go b/cluster/router/v3router/k8s_api/listener_handler_impl.go index 64a8cf3f83..efc2455bad 100644 --- a/cluster/router/v3router/k8s_api/listener_handler_impl.go +++ b/cluster/router/v3router/k8s_api/listener_handler_impl.go @@ -18,6 +18,7 @@ package k8s_api import ( + "dubbo.apache.org/dubbo-go/v3/config/router" metav "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -27,7 +28,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_crd" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) @@ -47,7 +47,7 @@ type VirtualServiceListenerHandler struct { // nolint func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) { - if vsc, ok := obj.(*config.VirtualServiceConfig); ok { + if vsc, ok := obj.(*router.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -59,7 +59,7 @@ func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) { // nolint func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) { - if vsc, ok := newObj.(*config.VirtualServiceConfig); ok { + if vsc, ok := newObj.(*router.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -72,7 +72,7 @@ func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) { // nolint func (r *VirtualServiceListenerHandler) DeleteFunc(obj interface{}) { - if vsc, ok := obj.(*config.VirtualServiceConfig); ok { + if vsc, ok := obj.(*router.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -95,7 +95,7 @@ func (r *VirtualServiceListenerHandler) Watch(opts metav.ListOptions, restClient // nolint func (r *VirtualServiceListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) { - result := config.VirtualServiceConfigList{} + result := router.VirtualServiceConfigList{} err := restClient. Get(). Namespace(ns). @@ -109,7 +109,7 @@ func (r *VirtualServiceListenerHandler) List(opts metav.ListOptions, restClient // nolint func (r *VirtualServiceListenerHandler) GetObject() runtime.Object { - return &config.VirtualServiceConfig{} + return &router.VirtualServiceConfig{} } // nolint @@ -126,7 +126,7 @@ type DestRuleListenerHandler struct { // nolint func (r *DestRuleListenerHandler) AddFunc(obj interface{}) { - if drc, ok := obj.(*config.DestinationRuleConfig); ok { + if drc, ok := obj.(*router.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -139,7 +139,7 @@ func (r *DestRuleListenerHandler) AddFunc(obj interface{}) { // nolint func (r *DestRuleListenerHandler) UpdateFunc(oldObj, newObj interface{}) { - if drc, ok := newObj.(*config.DestinationRuleConfig); ok { + if drc, ok := newObj.(*router.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -151,7 +151,7 @@ func (r *DestRuleListenerHandler) UpdateFunc(oldObj, newObj interface{}) { // nolint func (r *DestRuleListenerHandler) DeleteFunc(obj interface{}) { - if drc, ok := obj.(*config.DestinationRuleConfig); ok { + if drc, ok := obj.(*router.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -174,7 +174,7 @@ func (r *DestRuleListenerHandler) Watch(opts metav.ListOptions, restClient *rest // nolint func (r *DestRuleListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) { - result := config.DestinationRuleConfigList{} + result := router.DestinationRuleConfigList{} err := restClient. Get(). Namespace(ns). @@ -188,7 +188,7 @@ func (r *DestRuleListenerHandler) List(opts metav.ListOptions, restClient *rest. // nolint func (r *DestRuleListenerHandler) GetObject() runtime.Object { - return &config.DestinationRuleConfig{} + return &router.DestinationRuleConfig{} } func newDestRuleListenerHandler(listener config_center.ConfigurationListener) k8s_crd.ListenerHandler { diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index ce8269493d..b81fc6c1e7 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -18,6 +18,7 @@ package v3router import ( + router2 "dubbo.apache.org/dubbo-go/v3/config/router" "encoding/json" "io" "strings" @@ -32,7 +33,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_api" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -83,7 +83,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { switch event.Key { case k8s_api.VirtualServiceEventKey: logger.Debug("virtul service event") - newVSValue, ok := event.Value.(*config.VirtualServiceConfig) + newVSValue, ok := event.Value.(*router2.VirtualServiceConfig) if !ok { logger.Error("event.Value assertion error") return @@ -95,7 +95,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { return } logger.Debugf("new virtual service json value = \n%v\n", newVSJsonValue) - newVirtualServiceConfig := &config.VirtualServiceConfig{} + newVirtualServiceConfig := &router2.VirtualServiceConfig{} if err := json.Unmarshal([]byte(newVSJsonValue), newVirtualServiceConfig); err != nil { logger.Error("on process json data unmarshal error = ", err) return @@ -116,7 +116,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { } case k8s_api.DestinationRuleEventKey: logger.Debug("handling dest rule event") - newDRValue, ok := event.Value.(*config.DestinationRuleConfig) + newDRValue, ok := event.Value.(*router2.DestinationRuleConfig) if !ok { logger.Error("event.Value assertion error") return @@ -127,7 +127,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 } - newDestRuleConfig := &config.DestinationRuleConfig{} + newDestRuleConfig := &router2.DestinationRuleConfig{} if err := json.Unmarshal([]byte(newDRJsonValue), newDestRuleConfig); err != nil { logger.Error("on process json data unmarshal error = ", err) return @@ -174,14 +174,14 @@ func (r *RouterChain) URL() *common.URL { // parseFromConfigToRouters parse virtualService and destinationRule yaml file bytes to target router list func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte) ([]*UniformRouter, error) { - var virtualServiceConfigList []*config.VirtualServiceConfig + var virtualServiceConfigList []*router2.VirtualServiceConfig destRuleConfigsMap := make(map[string]map[string]map[string]string) vsDecoder := yaml.NewDecoder(strings.NewReader(string(virtualServiceConfig))) drDecoder := yaml.NewDecoder(strings.NewReader(string(destinationRuleConfig))) // parse virtual service for { - virtualServiceCfg := &config.VirtualServiceConfig{} + virtualServiceCfg := &router2.VirtualServiceConfig{} err := vsDecoder.Decode(virtualServiceCfg) if err == io.EOF { @@ -197,7 +197,7 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte // parse destination rule for { - destRuleCfg := &config.DestinationRuleConfig{} + destRuleCfg := &router2.DestinationRuleConfig{} err := drDecoder.Decode(destRuleCfg) if err == io.EOF { break diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index 9e12da1eb3..1ccd88f576 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -18,6 +18,7 @@ package v3router import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "fmt" "testing" ) @@ -28,7 +29,6 @@ import ( 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" ) @@ -221,7 +221,7 @@ func TestRouterChain_Process(t *testing.T) { vsJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` rc := &RouterChain{} - mockVirtualServiceConfig := &config.VirtualServiceConfig{ + mockVirtualServiceConfig := &router.VirtualServiceConfig{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kubectl.kubernetes.io/last-applied-configuration": vsJson, @@ -239,7 +239,7 @@ func TestRouterChain_Process(t *testing.T) { // test destination rule config chage event destJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` - mockDestinationRuleConfig := &config.DestinationRuleConfig{ + mockDestinationRuleConfig := &router.DestinationRuleConfig{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kubectl.kubernetes.io/last-applied-configuration": destJson, diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go index 3b552b89f0..64f02e3fe1 100644 --- a/cluster/router/v3router/uniform_rule.go +++ b/cluster/router/v3router/uniform_rule.go @@ -18,6 +18,7 @@ package v3router import ( + "dubbo.apache.org/dubbo-go/v3/config/router" "math/rand" "time" ) @@ -30,7 +31,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/judger" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -38,7 +38,7 @@ import ( // if match, get result destination key, which should be defined in DestinationRule yaml file type VirtualServiceRule struct { // routerItem store match router list and destination list of this router - routerItem *config.DubboServiceRouterItem + routerItem *router.DubboServiceRouterItem // uniformRule is the upper struct ptr uniformRule *UniformRule @@ -79,7 +79,7 @@ func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invoca // tryGetSubsetFromRouterOfOneDestination is a recursion function // try from destination 's header to final fallback destination, when success, it return result destination, else return error -func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { +func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *router.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { subSet := desc.Destination.Subset labels, ok := vsr.uniformRule.DestinationLabelListMap[subSet] resultInvokers := make([]protocol.Invoker, 0) @@ -200,13 +200,13 @@ func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker // UniformRule type UniformRule struct { - services []*config.StringMatch + services []*router.StringMatch virtualServiceRules []VirtualServiceRule DestinationLabelListMap map[string]map[string]string } // NewDefaultConnChecker constructs a new DefaultConnChecker based on the url -func newUniformRule(dubboRoute *config.DubboRoute, destinationMap map[string]map[string]string) (*UniformRule, error) { +func newUniformRule(dubboRoute *router.DubboRoute, destinationMap map[string]map[string]string) (*UniformRule, error) { matchItems := dubboRoute.RouterDetail virtualServiceRules := make([]VirtualServiceRule, 0) newUniformRule := &UniformRule{ diff --git a/common/constant/key.go b/common/constant/key.go index 4d258bb05d..e3e992ae34 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -169,19 +169,19 @@ const ( ) const ( - RegistryConfigPrefix = "dubbo.registries." - SingleRegistryConfigPrefix = "dubbo.registry." - ReferenceConfigPrefix = "dubbo.reference." - ServiceConfigPrefix = "dubbo.service." - ConfigBasePrefix = "dubbo.base." - RemotePrefix = "dubbo.remote." - ServiceDiscPrefix = "dubbo.service-discovery." - ProtocolConfigPrefix = "dubbo.protocols." + RegistryConfigPrefix = "dubbo.registries" + SingleRegistryConfigPrefix = "dubbo.registry" + ReferenceConfigPrefix = "dubbo.reference" + ServiceConfigPrefix = "dubbo.service" + ConfigBasePrefix = "dubbo.base" + RemotePrefix = "dubbo.remote" + ServiceDiscPrefix = "dubbo.service-discovery" + ProtocolConfigPrefix = "dubbo.protocols" ProviderConfigPrefix = "dubbo.provider." - ConsumerConfigPrefix = "dubbo.consumer." - ShutdownConfigPrefix = "dubbo.shutdown." - MetadataReportPrefix = "dubbo.metadata-report." - RouterConfigPrefix = "dubbo.router." + ConsumerConfigPrefix = "dubbo.consumer" + ShutdownConfigPrefix = "dubbo.shutdown" + MetadataReportPrefix = "dubbo.metadata-report" + RouterConfigPrefix = "dubbo.router" ) const ( diff --git a/config/application/application_config.go b/config/application/application_config.go new file mode 100644 index 0000000000..b89ca1a3e7 --- /dev/null +++ b/config/application/application_config.go @@ -0,0 +1,71 @@ +/* + * 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 application + +import ( + "errors" + "github.com/creasty/defaults" + "github.com/go-playground/validator/v10" + "strings" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + +// Config is a configuration for current application, whether the application is a provider or a consumer +type Config struct { + Organization string `default:"dubbo.io" yaml:"organization" json:"organization,omitempty" property:"organization"` + Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"` + Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"` + Version string `default:"0.0.1" yaml:"version" json:"version,omitempty" property:"version"` + Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"` + Environment string `default:"dev" yaml:"environment" json:"environment,omitempty" property:"environment"` + // the metadata type. remote or local + MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` +} + +// Prefix dubbo.application +func (Config) Prefix() string { + return constant.DUBBO + ".application" +} + +func (c *Config) SetDefault() error { + return defaults.Set(c) +} + +func (c *Config) Validate(valid *validator.Validate) error { + if err := valid.Struct(c); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil +} + +// UnmarshalYAML unmarshal the Config by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err + } + type plain Config + return unmarshal((*plain)(c)) +} diff --git a/config/application_config.go b/config/application_config.go deleted file mode 100644 index 1b4291dc3f..0000000000 --- a/config/application_config.go +++ /dev/null @@ -1,52 +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 config - -import ( - "github.com/creasty/defaults" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" -) - -// ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer -type ApplicationConfig struct { - Organization string `yaml:"organization" json:"organization,omitempty" property:"organization"` - Name string `yaml:"name" json:"name,omitempty" property:"name"` - Module string `yaml:"module" json:"module,omitempty" property:"module"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Owner string `yaml:"owner" json:"owner,omitempty" property:"owner"` - Environment string `yaml:"environment" json:"environment,omitempty" property:"environment"` - // the metadata type. remote or local - MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` -} - -// nolint -func (*ApplicationConfig) Prefix() string { - return constant.DUBBO + ".application." -} - -// UnmarshalYAML unmarshals the ApplicationConfig by @unmarshal function -func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ApplicationConfig - return unmarshal((*plain)(c)) -} diff --git a/config/base_config.go b/config/base_config.go deleted file mode 100644 index 0259549149..0000000000 --- a/config/base_config.go +++ /dev/null @@ -1,312 +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 config - -import ( - "bytes" - "reflect" - "strconv" - "strings" -) - -import ( - perrors "github.com/pkg/errors" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/yaml" -) - -// BaseConfig is the common configuration for provider and consumer -type BaseConfig struct { - ConfigCenterConfig *ConfigCenterConfig `yaml:"config_center" json:"config_center,omitempty"` - - // since 1.5.0 version - Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service_discovery" json:"service_discovery,omitempty" property:"service_discovery"` - MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` - - // application config - ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` - - // prefix string - fatherConfig interface{} - EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` - MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` - fileStream *bytes.Buffer - - // cache file used to store the current used configurations. - CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` -} - -func (c *BaseConfig) Prefix() string { - return constant.ConfigBasePrefix -} - -func BaseInit(confBaseFile string) error { - if confBaseFile == "" { - return perrors.Errorf("application configure(base) file name is nil") - } - baseConfig = &BaseConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confBaseFile, baseConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - } - baseConfig.fileStream = bytes.NewBuffer(fileStream) - return nil -} - -// nolint -func (c *BaseConfig) GetServiceDiscoveries(name string) (config *ServiceDiscoveryConfig, ok bool) { - config, ok = c.ServiceDiscoveries[name] - return -} - -// GetRemoteConfig will return the remote's config with the name if found -func (c *BaseConfig) GetRemoteConfig(name string) (config *RemoteConfig, ok bool) { - config, ok = c.Remotes[name] - return -} - -func getKeyPrefix(val reflect.Value) []string { - var prefix string - configPrefixMethod := "Prefix" - if val.CanAddr() { - prefix = val.Addr().MethodByName(configPrefixMethod).Call(nil)[0].String() - } else { - prefix = val.MethodByName(configPrefixMethod).Call(nil)[0].String() - } - - return strings.Split(prefix, "|") -} - -func getPtrElement(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Ptr { - v = v.Elem() - if v.Kind() == reflect.Ptr { - return getPtrElement(v) - } - } - return v -} - -func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryConfiguration) { - for i := 0; i < val.NumField(); i++ { - if key := val.Type().Field(i).Tag.Get("property"); key != "-" && key != "" { - f := val.Field(i) - if f.IsValid() { - setBaseValue := func(f reflect.Value) { - var ( - ok bool - value string - idStr string - ) - - prefixes := getKeyPrefix(val) - - if id.Kind() == reflect.String { - idStr = id.Interface().(string) - } - - for _, pfx := range prefixes { - - if len(pfx) > 0 { - if len(idStr) > 0 { - ok, value = config.GetProperty(pfx + idStr + "." + key) - } - if len(value) == 0 || !ok { - ok, value = config.GetProperty(pfx + key) - } - - } else { - ok, value = config.GetProperty(key) - } - - if ok { - break - } - - } - if ok { - errMsg := func(structName string, fieldName string, errorDetails error) { - logger.Errorf("Dynamic change the configuration in struct {%v} field {%v} error ,error message is {%v}", - structName, fieldName, errorDetails) - } - switch f.Kind() { - case reflect.Int64: - x, err := strconv.Atoi(value) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } else { - if !f.OverflowInt(int64(x)) { - f.SetInt(int64(x)) - } else { - errMsg(val.Type().Name(), val.Type().Field(i).Name, perrors.Errorf("the int64 value {%v} from config center is overflow", int64(x))) - } - } - case reflect.String: - f.SetString(value) - case reflect.Bool: - x, err := strconv.ParseBool(value) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } - f.SetBool(x) - case reflect.Float64: - x, err := strconv.ParseFloat(value, 64) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } else { - if !f.OverflowFloat(x) { - f.SetFloat(x) - } else { - errMsg(val.Type().Name(), val.Type().Field(i).Name, perrors.Errorf("the float64 value {%v} from config center is overflow", x)) - } - } - default: - logger.Warnf("The kind of field {%v} is not supported ", f.Kind().String()) - } - - } - } - - if f.Kind() == reflect.Ptr { - f = getPtrElement(f) - if f.Kind() == reflect.Struct { - setFieldValue(f, reflect.Value{}, config) - } else { - setBaseValue(f) - } - } - - if f.Kind() == reflect.Struct { - setFieldValue(f, reflect.Value{}, config) - } - if f.Kind() == reflect.Slice { - for i := 0; i < f.Len(); i++ { - e := f.Index(i) - if e.Kind() == reflect.Ptr { - e = getPtrElement(e) - if e.Kind() == reflect.Struct { - setFieldValue(e, reflect.Value{}, config) - } else { - setBaseValue(e) - } - } - - } - } - if f.Kind() == reflect.Map { - - if f.Type().Elem().Kind() == reflect.Ptr { - // initiate config - s := reflect.New(f.Type().Elem().Elem()) - prefix := s.MethodByName("Prefix").Call(nil)[0].String() - for _, pfx := range strings.Split(prefix, "|") { - m := config.GetSubProperty(pfx) - for k := range m { - f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem())) - } - } - - } - - for _, k := range f.MapKeys() { - v := f.MapIndex(k) - switch v.Kind() { - case reflect.Ptr: - v = getPtrElement(v) - if v.Kind() == reflect.Struct { - setFieldValue(v, k, config) - } else { - setBaseValue(v) - } - case reflect.Int64, reflect.String, reflect.Bool, reflect.Float64: - setBaseValue(v) - default: - logger.Warnf("The kind of field {%v} is not supported ", v.Kind().String()) - } - } - } - setBaseValue(f) - } - } - } -} - -func (c *BaseConfig) fresh() { - configList := config.GetEnvInstance().Configuration() - for element := configList.Back(); element != nil; element = element.Prev() { - cfg := element.Value.(*config.InmemoryConfiguration) - c.freshInternalConfig(cfg) - } -} - -func (c *BaseConfig) freshInternalConfig(config *config.InmemoryConfiguration) { - // reflect to init struct - tp := reflect.ValueOf(c.fatherConfig).Elem().Type() - initializeStruct(tp, reflect.ValueOf(c.fatherConfig).Elem()) - - val := reflect.Indirect(reflect.ValueOf(c.fatherConfig)) - setFieldValue(val, reflect.Value{}, config) -} - -// SetFatherConfig sets father config by @fatherConfig -func (c *BaseConfig) SetFatherConfig(fatherConfig interface{}) { - c.fatherConfig = fatherConfig -} - -func initializeStruct(t reflect.Type, v reflect.Value) { - if v.Kind() != reflect.Struct { - return - } - for i := 0; i < v.NumField(); i++ { - f := v.Field(i) - ft := t.Field(i) - - if ft.Tag.Get("property") == "" { - continue - } - switch ft.Type.Kind() { - case reflect.Map: - if f.IsNil() { - f.Set(reflect.MakeMap(ft.Type)) - } - case reflect.Slice: - if f.IsNil() { - f.Set(reflect.MakeSlice(ft.Type, 0, 0)) - } - case reflect.Chan: - if f.IsNil() { - f.Set(reflect.MakeChan(ft.Type, 0)) - } - case reflect.Struct: - initializeStruct(ft.Type, f) - case reflect.Ptr: - if f.IsNil() { - fv := reflect.New(ft.Type.Elem()) - initializeStruct(ft.Type.Elem(), fv.Elem()) - f.Set(fv) - } - default: - } - } -} diff --git a/config/base_config_test.go b/config/base_config_test.go deleted file mode 100644 index 7d5fa5534b..0000000000 --- a/config/base_config_test.go +++ /dev/null @@ -1,303 +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 config - -import ( - "reflect" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" -) - -func getMockMap() map[string]string { - baseMockMap := map[string]string{ - "dubbo.registries.shanghai_reg1.protocol": "mock100", - "dubbo.reference.com.MockService.MockService.retries": "10", - "dubbo.com.MockService.MockService.GetUser.retries": "10", - "dubbo.consumer.check": "false", - "dubbo.application.name": "dubbo", - } - return baseMockMap -} - -var baseAppConfig = &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", -} - -var baseRegistries = map[string]*RegistryConfig{ - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, -} - -var baseMockRef = map[string]*ReferenceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, -} - -func TestRefresh(t *testing.T) { - c := &BaseConfig{} - c.fileStream = nil - mockMap := getMockMap() - mockMap["dubbo.shutdown.timeout"] = "12s" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - ShutdownConfig: &ShutdownConfig{ - Timeout: "12s", - StepTimeout: "2s", - RejectRequestHandler: "mock", - RejectRequest: false, - RequestsFinished: false, - }, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{false}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestAppExternalRefresh(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - mockMap["dubbo.reference.com.MockService.retries"] = "5" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - mockMap["dubbo.consumer.check"] = "true" - config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{true}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestAppExternalWithoutIDRefresh(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - delete(mockMap, "dubbo.reference.com.MockService.MockService.retries") - mockMap["dubbo.reference.com.MockService.retries"] = "10" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - mockMap["dubbo.consumer.check"] = "true" - config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap) - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{true}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestRefreshSingleRegistry(t *testing.T) { - c := &BaseConfig{} - mockMap := map[string]string{} - mockMap["dubbo.registry.address"] = "mock100://127.0.0.1:2181" - mockMap["dubbo.reference.com.MockService.MockService.retries"] = "10" - mockMap["dubbo.com.MockService.MockService.GetUser.retries"] = "10" - mockMap["dubbo.consumer.check"] = "false" - mockMap["dubbo.application.name"] = "dubbo" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: map[string]*RegistryConfig{}, - Registry: &RegistryConfig{}, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100://127.0.0.1:2181", father.Registry.Address) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{false}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestRefreshProvider(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - delete(mockMap, "dubbo.reference.com.MockService.MockService.retries") - mockMap["dubbo.service.com.MockService.MockService.retries"] = "10" - mockMap["dubbo.protocols.jsonrpc1.name"] = "jsonrpc" - mockMap["dubbo.protocols.jsonrpc1.ip"] = "127.0.0.1" - mockMap["dubbo.protocols.jsonrpc1.port"] = "20001" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, - }, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.Services["MockService"].Retries) - - assert.Equal(t, "10", father.Services["MockService"].Methods[0].Retries) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) - assert.Equal(t, "20001", father.Protocols["jsonrpc1"].Port) -} - -func TestInitializeStruct(t *testing.T) { - testConsumerConfig := &ConsumerConfig{} - tp := reflect.TypeOf(ConsumerConfig{}) - v := reflect.New(tp) - initializeStruct(tp, v.Elem()) - t.Logf("testConsumerConfig type:%s", reflect.ValueOf(testConsumerConfig).Elem().Type().String()) - reflect.ValueOf(testConsumerConfig).Elem().Set(v.Elem()) - - assert.Condition(t, func() (success bool) { - return testConsumerConfig.Registry != nil - }) - assert.Condition(t, func() (success bool) { - return testConsumerConfig.Registries != nil - }) - assert.Condition(t, func() (success bool) { - return testConsumerConfig.References != nil - }) -} diff --git a/config/config_center_config.go b/config/center/config_center_config.go similarity index 58% rename from config/config_center_config.go rename to config/center/config_center_config.go index 360818c8d3..db68b6a0e7 100644 --- a/config/config_center_config.go +++ b/config/center/config_center_config.go @@ -15,11 +15,11 @@ * limitations under the License. */ -package config +package center import ( + "google.golang.org/grpc/balancer/base" "net/url" - "reflect" ) import ( @@ -36,14 +36,14 @@ import ( "dubbo.apache.org/dubbo-go/v3/config_center" ) -// ConfigCenterConfig is configuration for config center +// Config is configuration for config center // // ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group, // those configs are already built-in in many professional third-party configuration centers. // In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups. // // ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo -type ConfigCenterConfig struct { +type Config struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` Address string `yaml:"address" json:"address,omitempty"` Cluster string `yaml:"cluster" json:"cluster,omitempty"` @@ -60,17 +60,17 @@ type ConfigCenterConfig struct { Params map[string]string `yaml:"params" json:"parameters,omitempty"` } -// UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function -func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the Config by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain ConfigCenterConfig + type plain Config return unmarshal((*plain)(c)) } -// GetUrlMap gets url map from ConfigCenterConfig -func (c *ConfigCenterConfig) GetUrlMap() url.Values { +// GetUrlMap gets url map from Config +func (c *Config) GetUrlMap() url.Values { urlMap := url.Values{} urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace) urlMap.Set(constant.CONFIG_GROUP_KEY, c.Group) @@ -87,45 +87,44 @@ func (c *ConfigCenterConfig) GetUrlMap() url.Values { return urlMap } -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) { - 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())) - } - rc, ok := baseConfig.GetRemoteConfig(remoteRef) - if !ok { - return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) - } - // set protocol if remote not set - if len(rc.Protocol) <= 0 { - rc.Protocol = baseConfig.ConfigCenterConfig.Protocol - } - newURL, err := rc.ToURL() - return newURL, err +// toURL will compatible with baseConfig.Config.Address and baseConfig.Config.RemoteRef before 1.6.0 +// After 1.6.0 will not compatible, only baseConfig.Config.RemoteRef +func (c *Config) toURL(baseConfig base.Config) (*common.URL, error) { + //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())) + //} + //rc, ok := baseConfig.GetRemoteConfig(remoteRef) + //if !ok { + // return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) + //} + //// set protocol if remote not set + //if len(rc.Protocol) <= 0 { + // rc.Protocol = baseConfig.ConfigCenterConfig.Protocol + //} + return common.NewURL(c.Address, + common.WithProtocol(c.Protocol), + common.WithParams(c.GetUrlMap())) } // startConfigCenter will start the config center. // it will prepare the environment -func (b *configCenter) startConfigCenter(baseConfig BaseConfig) error { - newUrl, err := b.toURL(baseConfig) +func (c *Config) startConfigCenter(baseConfig base.Config) error { + newUrl, err := c.toURL(baseConfig) if err != nil { return err } - if err = b.prepareEnvironment(baseConfig, newUrl); err != nil { + if err = c.prepareEnvironment(baseConfig, newUrl); err != nil { return perrors.WithMessagef(err, "start config center error!") } // c.fresh() return nil } -func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl *common.URL) error { +func (c *Config) prepareEnvironment(baseConfig base.Config, configCenterUrl *common.URL) error { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { @@ -134,47 +133,47 @@ func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl } envInstance := config.GetEnvInstance() envInstance.SetDynamicConfiguration(dynamicConfig) - content, err := dynamicConfig.GetProperties(baseConfig.ConfigCenterConfig.ConfigFile, - config_center.WithGroup(baseConfig.ConfigCenterConfig.Group)) + _, err = dynamicConfig.GetProperties(c.ConfigFile, + config_center.WithGroup(c.Group)) if err != nil { logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) return perrors.WithStack(err) } - var appGroup string - var appContent string - if providerConfig != nil && providerConfig.ApplicationConfig != nil && - reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ProviderConfig" { - appGroup = providerConfig.ApplicationConfig.Name - } else if consumerConfig != nil && consumerConfig.ApplicationConfig != nil && - reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ConsumerConfig" { - appGroup = consumerConfig.ApplicationConfig.Name - } - - if len(appGroup) != 0 { - configFile := baseConfig.ConfigCenterConfig.AppConfigFile - if len(configFile) == 0 { - configFile = baseConfig.ConfigCenterConfig.ConfigFile - } - appContent, err = dynamicConfig.GetProperties(configFile, config_center.WithGroup(appGroup)) - if err != nil { - return perrors.WithStack(err) - } - } - // global config file - mapContent, err := dynamicConfig.Parser().Parse(content) - if err != nil { - return perrors.WithStack(err) - } - envInstance.UpdateExternalConfigMap(mapContent) - - // appGroup config file - if len(appContent) != 0 { - appMapContent, err := dynamicConfig.Parser().Parse(appContent) - if err != nil { - return perrors.WithStack(err) - } - envInstance.UpdateAppExternalConfigMap(appMapContent) - } + //var appGroup string + //var appContent string + //if config2.providerConfig != nil && config2.providerConfig.ApplicationConfig != nil && + // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ProviderConfig" { + // appGroup = config2.providerConfig.ApplicationConfig.Name + //} else if config2.consumerConfig != nil && config2.consumerConfig.ApplicationConfig != nil && + // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ConsumerConfig" { + // appGroup = config2.consumerConfig.ApplicationConfig.Name + //} + // + //if len(appGroup) != 0 { + // configFile := baseConfig.ConfigCenterConfig.AppConfigFile + // if len(configFile) == 0 { + // configFile = baseConfig.ConfigCenterConfig.ConfigFile + // } + // appContent, err = dynamicConfig.GetProperties(configFile, config_center.WithGroup(appGroup)) + // if err != nil { + // return perrors.WithStack(err) + // } + //} + //// global config file + //mapContent, err := dynamicConfig.Parser().Parse(content) + //if err != nil { + // return perrors.WithStack(err) + //} + //envInstance.UpdateExternalConfigMap(mapContent) + // + //// appGroup config file + //if len(appContent) != 0 { + // appMapContent, err := dynamicConfig.Parser().Parse(appContent) + // if err != nil { + // return perrors.WithStack(err) + // } + // envInstance.UpdateAppExternalConfigMap(appMapContent) + //} return nil } diff --git a/config/config_api.go b/config/config_api.go index fc9ebdb6e1..3c06947392 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -1,545 +1,555 @@ /* - * 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. - */ +* 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 - -import ( - "time" -) - -//////////////////////////////////// default registry config -const ( - // defaultZKAddr is the default registry address of zookeeper - defaultZKAddr = "127.0.0.1:2181" - - // defaultNacosAddr is the default registry address of nacos - defaultNacosAddr = "127.0.0.1:8848" - - // defaultRegistryTimeout is the default registry timeout - defaultRegistryTimeout = "3s" -) - -// NewDefaultRegistryConfig New default registry config -// the input @protocol can only be: -// "zookeeper" with default addr "127.0.0.1:2181" -// "nacos" with default addr "127.0.0.1:8848" -func NewDefaultRegistryConfig(protocol string) *RegistryConfig { - switch protocol { - case "zookeeper": - return &RegistryConfig{ - Protocol: protocol, - Address: defaultZKAddr, - TimeoutStr: defaultRegistryTimeout, - } - case "nacos": - return &RegistryConfig{ - Protocol: protocol, - Address: defaultNacosAddr, - TimeoutStr: defaultRegistryTimeout, - } - default: - return &RegistryConfig{ - Protocol: protocol, - } - } -} - -///////////////////////////////////// registry config api -type RegistryConfigOpt func(config *RegistryConfig) *RegistryConfig - -// NewRegistryConfig creates New RegistryConfig with @opts -func NewRegistryConfig(opts ...RegistryConfigOpt) *RegistryConfig { - newRegistryConfig := NewDefaultRegistryConfig("") - for _, v := range opts { - newRegistryConfig = v(newRegistryConfig) - } - return newRegistryConfig -} - -// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name -func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Protocol = regProtocol - return config - } -} - -// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address -func WithRegistryAddress(addr string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Address = addr - return config - } -} - -// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config -func WithRegistryTimeOut(timeout string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.TimeoutStr = timeout - return config - } -} - -// WithRegistryGroup returns RegistryConfigOpt with given @group registry group -func WithRegistryGroup(group string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Group = group - return config - } -} - -// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl -func WithRegistryTTL(ttl string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.TTL = ttl - return config - } -} - -// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName -func WithRegistryUserName(userName string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Username = userName - return config - } -} - -// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password -func WithRegistryPassword(psw string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Password = psw - return config - } -} - -// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag -func WithRegistrySimplified(simplified bool) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Simplified = simplified - return config - } -} - -// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag -func WithRegistryPreferred(preferred bool) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Preferred = preferred - return config - } -} - -// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag -func WithRegistryWeight(weight int64) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Weight = weight - return config - } -} - -// WithRegistryParams returns RegistryConfigOpt with given registry @params -func WithRegistryParams(params map[string]string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Params = params - return config - } -} - -///////////////////////////////////// consumer config api -// ConsumerConfigOpt is the options to init ConsumerConfig -type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig - -// NewDefaultConsumerConfig returns default ConsumerConfig -// with connection timeout = 3s, request timeout = 3s -func NewDefaultConsumerConfig() *ConsumerConfig { - check := true - newConsumerConfig := &ConsumerConfig{ - BaseConfig: BaseConfig{}, - Registries: make(map[string]*RegistryConfig, 8), - References: make(map[string]*ReferenceConfig, 8), - ConnectTimeout: 3 * time.Second, - RequestTimeout: 3 * time.Second, - Check: &check, - } - return newConsumerConfig -} - -// NewConsumerConfig returns ConsumerConfig with @opts -func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { - newConfig := NewDefaultConsumerConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig -func WithConsumerAppConfig(appConfig *ApplicationConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ApplicationConfig = appConfig - return config - } -} - -// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig -func WithConsumerRegistryConfig(registryKey string, regConfig *RegistryConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.Registries[registryKey] = regConfig - return config - } -} - -// WithConsumerReferenceConfig returns ConsumerConfigOpt with -func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.References[referenceKey] = refConfig - return config - } -} - -// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout -func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ConnectTimeout = timeout - return config - } -} - -// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout -func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.RequestTimeout = timeout - return config - } -} - -// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig -func WithConsumerConfigCenterConfig(configCenterConfig *ConfigCenterConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ConfigCenterConfig = configCenterConfig - return config - } -} - -// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag -func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - *config.Check = check - return config - } -} - -//////////////////////////////////// reference config api -// ReferenceConfigOpt is consumer's reference config -type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig - -// NewDefaultReferenceConfig returns empty ReferenceConfig -func NewDefaultReferenceConfig() *ReferenceConfig { - newReferenceConfig := NewReferenceConfig("") - newReferenceConfig.Methods = make([]*MethodConfig, 0, 8) - newReferenceConfig.Params = make(map[string]string, 8) - return newReferenceConfig -} - -// NewReferenceConfigByAPI returns ReferenceConfig with given @opts -func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *ReferenceConfig { - newReferenceConfig := NewDefaultReferenceConfig() - for _, v := range opts { - v(newReferenceConfig) - } - return newReferenceConfig -} - -// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry -func WithReferenceRegistry(registry string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Registry = registry - return config - } -} - -// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol -func WithReferenceProtocol(protocol string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Protocol = protocol - return config - } -} - -// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName -func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.InterfaceName = interfaceName - return config - } -} - -// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster -func WithReferenceCluster(cluster string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Cluster = cluster - return config - } -} - -// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb -func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: methodName, - Retries: retries, - LoadBalance: lb, - }) - return config - } -} - -///////////////////////////////////// provider config api -// ProviderConfigOpt is the -type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig - -// NewDefaultProviderConfig returns ProviderConfig with default ApplicationConfig -func NewDefaultProviderConfig() *ProviderConfig { - newConsumerConfig := &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Name: "dubbo", - Module: "module", - Organization: "dubbo_org", - Owner: "dubbo", - }, - }, - Services: make(map[string]*ServiceConfig), - Registries: make(map[string]*RegistryConfig, 8), - Protocols: make(map[string]*ProtocolConfig, 8), - } - return newConsumerConfig -} - -// NewProviderConfig returns ProviderConfig with given @opts -func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { - newConfig := NewDefaultProviderConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -// WithProviderRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig -func WithProviderRegistryConfig(regConfig *RegistryConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Registries[regConfig.Protocol] = regConfig - return config - } -} - -// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig -func WithProviderAppConfig(appConfig *ApplicationConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.ApplicationConfig = appConfig - return config - } -} - -// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Services[serviceName] = serviceConfig - return config - } -} - -// WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port -func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Protocols[protocolKey] = &ProtocolConfig{ - Name: protocol, - Port: port, - } - return config - } -} - -// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig -func WithProviderRegistry(registryKey string, registryConfig *RegistryConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Registries[registryKey] = registryConfig - return config - } -} - -/////////////////////////////////////// service config api -// ServiceConfigOpt is the option to init ServiceConfig -type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig - -// NewDefaultServiceConfig returns default ServiceConfig -func NewDefaultServiceConfig() *ServiceConfig { - newServiceConfig := NewServiceConfig("") - newServiceConfig.Params = make(map[string]string) - newServiceConfig.Methods = make([]*MethodConfig, 0, 8) - return newServiceConfig -} - -// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared -// NewServiceConfigByAPI returns ServiceConfig with given @opts -func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig { - defaultServiceConfig := NewDefaultServiceConfig() - for _, v := range opts { - v(defaultServiceConfig) - } - return defaultServiceConfig -} - -// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry -func WithServiceRegistry(registry string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Registry = registry - return config - } -} - -// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol -func WithServiceProtocol(protocol string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Protocol = protocol - return config - } -} - -// WithServiceInterface returns ServiceConfigOpt with given @interfaceName -func WithServiceInterface(interfaceName string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.InterfaceName = interfaceName - return config - } -} - -// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb -func WithServiceLoadBalance(lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Loadbalance = lb - return config - } -} - -// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time -func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Warmup = warmUp - return config - } -} - -// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster -func WithServiceCluster(cluster string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Cluster = cluster - return config - } -} - -// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb -func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: name, - Retries: retries, - LoadBalance: lb, - }) - return config - } -} - -///////////////////////////////////////// Application config api -// ApplicationConfigOpt is option to init ApplicationConfig -type ApplicationConfigOpt func(config *ApplicationConfig) *ApplicationConfig - -// NewDefaultApplicationConfig returns ApplicationConfig with default -// name: dubbo.io -// module: sample -// organization: dubbo.io -// owner: dubbogo -// version: 0.0.1 -// environment dev -func NewDefaultApplicationConfig() *ApplicationConfig { - newAppConfig := &ApplicationConfig{ - Name: "dubbo.io", - Module: "sample", - Organization: "dubbo.io", - Owner: "dubbogo", - Version: "0.0.1", - Environment: "dev", - } - return newAppConfig -} - -// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared -// NewApplicationConfig returns ApplicationConfig with default application config -func NewApplicationConfig(opts ...ApplicationConfigOpt) *ApplicationConfig { - defaultServiceConfig := NewDefaultApplicationConfig() - for _, v := range opts { - v(defaultServiceConfig) - } - return defaultServiceConfig -} - -// WithAppName returns ApplicationConfigOpt with given @name -func WithAppName(name string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Name = name - return config - } -} - -// WithAppModule returns ApplicationConfigOpt with given @module -func WithAppModule(module string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Module = module - return config - } -} - -// WithAppOrganization returns ApplicationConfigOpt wight given organization @org -func WithAppOrganization(org string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Organization = org - return config - } -} - -// WithAppOwner returns ApplicationConfigOpt with given @owner -func WithAppOwner(owner string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Owner = owner - return config - } -} - -// WithAppVersion returns ApplicationConfigOpt with given version @version -func WithAppVersion(version string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Version = version - return config - } -} - -// WithAppEnvironment returns ApplicationConfigOpt with given environment @env -func WithAppEnvironment(env string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Environment = env - return config - } -} +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/config/application" +// "dubbo.apache.org/dubbo-go/v3/config/center" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "dubbo.apache.org/dubbo-go/v3/config/method" +// "dubbo.apache.org/dubbo-go/v3/config/protocol" +// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "dubbo.apache.org/dubbo-go/v3/config/reference" +// "dubbo.apache.org/dubbo-go/v3/config/registry" +// "dubbo.apache.org/dubbo-go/v3/config/service" +// "google.golang.org/grpc/balancer/base" +// "time" +//) +// +////////////////////////////////////// default registry config +//const ( +// // defaultZKAddr is the default registry address of zookeeper +// defaultZKAddr = "127.0.0.1:2181" +// +// // defaultNacosAddr is the default registry address of nacos +// defaultNacosAddr = "127.0.0.1:8848" +// +// // defaultRegistryTimeout is the default registry timeout +// defaultRegistryTimeout = "3s" +//) +// +//// NewDefaultRegistryConfig New default registry config +//// the input @protocol can only be: +//// "zookeeper" with default addr "127.0.0.1:2181" +//// "nacos" with default addr "127.0.0.1:8848" +//func NewDefaultRegistryConfig(protocol string) *registry.RegistryConfig { +// switch protocol { +// case "zookeeper": +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// Address: defaultZKAddr, +// TimeoutStr: defaultRegistryTimeout, +// } +// case "nacos": +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// Address: defaultNacosAddr, +// TimeoutStr: defaultRegistryTimeout, +// } +// default: +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// } +// } +//} +// +/////////////////////////////////////// registry config api +//type RegistryConfigOpt func(config *registry.RegistryConfig) *registry.RegistryConfig +// +//// NewRegistryConfig creates New RegistryConfig with @opts +//func NewRegistryConfig(opts ...RegistryConfigOpt) *registry.RegistryConfig { +// newRegistryConfig := NewDefaultRegistryConfig("") +// for _, v := range opts { +// newRegistryConfig = v(newRegistryConfig) +// } +// return newRegistryConfig +//} +// +//// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name +//func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Protocol = regProtocol +// return config +// } +//} +// +//// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address +//func WithRegistryAddress(addr string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Address = addr +// return config +// } +//} +// +//// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config +//func WithRegistryTimeOut(timeout string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.TimeoutStr = timeout +// return config +// } +//} +// +//// WithRegistryGroup returns RegistryConfigOpt with given @group registry group +//func WithRegistryGroup(group string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Group = group +// return config +// } +//} +// +//// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl +//func WithRegistryTTL(ttl string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.TTL = ttl +// return config +// } +//} +// +//// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName +//func WithRegistryUserName(userName string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Username = userName +// return config +// } +//} +// +//// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password +//func WithRegistryPassword(psw string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Password = psw +// return config +// } +//} +// +//// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag +//func WithRegistrySimplified(simplified bool) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Simplified = simplified +// return config +// } +//} +// +//// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag +//func WithRegistryPreferred(preferred bool) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Preferred = preferred +// return config +// } +//} +// +//// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag +//func WithRegistryWeight(weight int64) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Weight = weight +// return config +// } +//} +// +//// WithRegistryParams returns RegistryConfigOpt with given registry @params +//func WithRegistryParams(params map[string]string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Params = params +// return config +// } +//} +// +/////////////////////////////////////// consumer config api +//// ConsumerConfigOpt is the options to init Config +//type ConsumerConfigOpt func(config *consumer.Config) *consumer.Config +// +//// NewDefaultConsumerConfig returns default Config +//// with connection timeout = 3s, request timeout = 3s +//func NewDefaultConsumerConfig() *consumer.Config { +// check := true +// newConsumerConfig := &consumer.Config{ +// BaseConfig: base.Config{}, +// Registries: make(map[string]*registry.RegistryConfig, 8), +// References: make(map[string]*reference.ReferenceConfig, 8), +// ConnectTimeout: 3 * time.Second, +// RequestTimeout: 3 * time.Second, +// Check: &check, +// } +// return newConsumerConfig +//} +// +//// NewConsumerConfig returns Config with @opts +//func NewConsumerConfig(opts ...ConsumerConfigOpt) *consumer.Config { +// newConfig := NewDefaultConsumerConfig() +// for _, v := range opts { +// v(newConfig) +// } +// return newConfig +//} +// +//// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig +//func WithConsumerAppConfig(appConfig *application.Config) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.ApplicationConfig = appConfig +// return config +// } +//} +// +//// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig +//func WithConsumerRegistryConfig(registryKey string, regConfig *registry.RegistryConfig) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.Registries[registryKey] = regConfig +// return config +// } +//} +// +//// WithConsumerReferenceConfig returns ConsumerConfigOpt with +//func WithConsumerReferenceConfig(referenceKey string, refConfig *reference.ReferenceConfig) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.References[referenceKey] = refConfig +// return config +// } +//} +// +//// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout +//func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.ConnectTimeout = timeout +// return config +// } +//} +// +//// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout +//func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.RequestTimeout = timeout +// return config +// } +//} +// +//// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig +//func WithConsumerConfigCenterConfig(configCenterConfig *center.Config) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// config.ConfigCenterConfig = configCenterConfig +// return config +// } +//} +// +//// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag +//func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { +// return func(config *consumer.Config) *consumer.Config { +// *config.Check = check +// return config +// } +//} +// +////////////////////////////////////// reference config api +//// ReferenceConfigOpt is consumer's reference config +//type ReferenceConfigOpt func(config *reference.ReferenceConfig) *reference.ReferenceConfig +// +//// NewDefaultReferenceConfig returns empty ReferenceConfig +//func NewDefaultReferenceConfig() *reference.ReferenceConfig { +// newReferenceConfig := reference.NewReferenceConfig("") +// newReferenceConfig.Methods = make([]*method.MethodConfig, 0, 8) +// newReferenceConfig.Params = make(map[string]string, 8) +// return newReferenceConfig +//} +// +//// NewReferenceConfigByAPI returns ReferenceConfig with given @opts +//func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *reference.ReferenceConfig { +// newReferenceConfig := NewDefaultReferenceConfig() +// for _, v := range opts { +// v(newReferenceConfig) +// } +// return newReferenceConfig +//} +// +//// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry +//func WithReferenceRegistry(registry string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Registry = registry +// return config +// } +//} +// +//// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol +//func WithReferenceProtocol(protocol string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Protocol = protocol +// return config +// } +//} +// +//// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName +//func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.InterfaceName = interfaceName +// return config +// } +//} +// +//// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster +//func WithReferenceCluster(cluster string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Cluster = cluster +// return config +// } +//} +// +//// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb +//func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Methods = append(config.Methods, &method.MethodConfig{ +// Name: methodName, +// Retries: retries, +// LoadBalance: lb, +// }) +// return config +// } +//} +// +/////////////////////////////////////// provider config api +//// ProviderConfigOpt is the +//type ProviderConfigOpt func(config *provider.ProviderConfig) *provider.ProviderConfig +// +//// NewDefaultProviderConfig returns ProviderConfig with default Config +//func NewDefaultProviderConfig() *provider.ProviderConfig { +// newConsumerConfig := &provider.ProviderConfig{ +// BaseConfig: base.Config{ +// application.Config: &application.Config{ +// Name: "dubbo", +// Module: "module", +// Organization: "dubbo_org", +// Owner: "dubbo", +// }, +// }, +// Services: make(map[string]*service.Config), +// Registries: make(map[string]*registry.RegistryConfig, 8), +// Protocols: make(map[string]*protocol.ProtocolConfig, 8), +// } +// return newConsumerConfig +//} +// +//// NewProviderConfig returns ProviderConfig with given @opts +//func NewProviderConfig(opts ...ProviderConfigOpt) *provider.ProviderConfig { +// newConfig := NewDefaultProviderConfig() +// for _, v := range opts { +// v(newConfig) +// } +// return newConfig +//} +// +//// WithProviderRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig +//func WithProviderRegistryConfig(regConfig *registry.RegistryConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Registries[regConfig.Protocol] = regConfig +// return config +// } +//} +// +//// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig +//func WithProviderAppConfig(appConfig *application.Config) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.ApplicationConfig = appConfig +// return config +// } +//} +// +//// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig +//func WithProviderServices(serviceName string, serviceConfig *service.Config) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Services[serviceName] = serviceConfig +// return config +// } +//} +// +//// WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port +//func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Protocols[protocolKey] = &protocol.ProtocolConfig{ +// Name: protocol, +// Port: port, +// } +// return config +// } +//} +// +//// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig +//func WithProviderRegistry(registryKey string, registryConfig *registry.RegistryConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Registries[registryKey] = registryConfig +// return config +// } +//} +// +///////////////////////////////////////// service config api +//// ServiceConfigOpt is the option to init Config +//type ServiceConfigOpt func(config *service.Config) *service.Config +// +//// NewDefaultServiceConfig returns default Config +//func NewDefaultServiceConfig() *service.Config { +// newServiceConfig := service.NewServiceConfig("") +// newServiceConfig.Params = make(map[string]string) +// newServiceConfig.Methods = make([]*method.MethodConfig, 0, 8) +// return newServiceConfig +//} +// +//// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared +//// NewServiceConfigByAPI returns Config with given @opts +//func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *service.Config { +// defaultServiceConfig := NewDefaultServiceConfig() +// for _, v := range opts { +// v(defaultServiceConfig) +// } +// return defaultServiceConfig +//} +// +//// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry +//func WithServiceRegistry(registry string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Registry = registry +// return config +// } +//} +// +//// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol +//func WithServiceProtocol(protocol string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Protocol = protocol +// return config +// } +//} +// +//// WithServiceInterface returns ServiceConfigOpt with given @interfaceName +//func WithServiceInterface(interfaceName string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.InterfaceName = interfaceName +// return config +// } +//} +// +//// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb +//func WithServiceLoadBalance(lb string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Loadbalance = lb +// return config +// } +//} +// +//// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time +//func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Warmup = warmUp +// return config +// } +//} +// +//// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster +//func WithServiceCluster(cluster string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Cluster = cluster +// return config +// } +//} +// +//// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb +//func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { +// return func(config *service.Config) *service.Config { +// config.Methods = append(config.Methods, &method.MethodConfig{ +// Name: name, +// Retries: retries, +// LoadBalance: lb, +// }) +// return config +// } +//} +// +/////////////////////////////////////////// Application config api +//// ApplicationConfigOpt is option to init Config +//type ApplicationConfigOpt func(config *application.Config) *application.Config +// +//// NewDefaultApplicationConfig returns Config with default +//// name: dubbo.io +//// module: sample +//// organization: dubbo.io +//// owner: dubbogo +//// version: 0.0.1 +//// environment dev +//func NewDefaultApplicationConfig() *application.Config { +// newAppConfig := &application.Config{ +// Name: "dubbo.io", +// Module: "sample", +// Organization: "dubbo.io", +// Owner: "dubbogo", +// Version: "0.0.1", +// Environment: "dev", +// } +// return newAppConfig +//} +// +//// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared +//// NewApplicationConfig returns Config with default application config +//func NewApplicationConfig(opts ...ApplicationConfigOpt) *application.Config { +// defaultServiceConfig := NewDefaultApplicationConfig() +// for _, v := range opts { +// v(defaultServiceConfig) +// } +// return defaultServiceConfig +//} +// +//// WithAppName returns ApplicationConfigOpt with given @name +//func WithAppName(name string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Name = name +// return config +// } +//} +// +//// WithAppModule returns ApplicationConfigOpt with given @module +//func WithAppModule(module string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Module = module +// return config +// } +//} +// +//// WithAppOrganization returns ApplicationConfigOpt wight given organization @org +//func WithAppOrganization(org string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Organization = org +// return config +// } +//} +// +//// WithAppOwner returns ApplicationConfigOpt with given @owner +//func WithAppOwner(owner string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Owner = owner +// return config +// } +//} +// +//// WithAppVersion returns ApplicationConfigOpt with given version @version +//func WithAppVersion(version string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Version = version +// return config +// } +//} +// +//// WithAppEnvironment returns ApplicationConfigOpt with given environment @env +//func WithAppEnvironment(env string) ApplicationConfigOpt { +// return func(config *application.Config) *application.Config { +// config.Environment = env +// return config +// } +//} diff --git a/config/config_api_test.go b/config/config_api_test.go index aa70a60cf7..65899edbad 100644 --- a/config/config_api_test.go +++ b/config/config_api_test.go @@ -17,149 +17,140 @@ package config -import ( - "strconv" - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestNewDefaultServiceConfig(t *testing.T) { - serviceConfig := NewServiceConfigByAPI( - WithServiceCluster("test-cluster"), - WithServiceInterface("test-interface"), - WithServiceLoadBalance("test-loadbalance"), - WithServiceMethod("test-method1", "test-retries1", "test-lb1"), - WithServiceMethod("test-method2", "test-retries2", "test-lb2"), - WithServiceMethod("test-method3", "test-retries3", "test-lb3"), - WithServiceProtocol("test-protocol"), - WithServiceRegistry("test-registry"), - WithServiceWarmUpTime("test-warmup"), - ) - assert.Equal(t, serviceConfig.Cluster, "test-cluster") - assert.Equal(t, serviceConfig.InterfaceName, "test-interface") - assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance") - for i, v := range serviceConfig.Methods { - backFix := strconv.Itoa(i + 1) - assert.Equal(t, v.Name, "test-method"+backFix) - assert.Equal(t, v.Retries, "test-retries"+backFix) - assert.Equal(t, v.LoadBalance, "test-lb"+backFix) - } - assert.Equal(t, serviceConfig.Protocol, "test-protocol") - assert.Equal(t, serviceConfig.Registry, "test-registry") - assert.Equal(t, serviceConfig.Warmup, "test-warmup") -} - -func TestNewReferenceConfigByAPI(t *testing.T) { - refConfig := NewReferenceConfigByAPI( - WithReferenceCluster("test-cluster"), - WithReferenceInterface("test-interface"), - WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), - WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), - WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), - WithReferenceProtocol("test-protocol"), - WithReferenceRegistry("test-registry"), - ) - assert.Equal(t, refConfig.Cluster, "test-cluster") - assert.Equal(t, refConfig.InterfaceName, "test-interface") - for i, v := range refConfig.Methods { - backFix := strconv.Itoa(i + 1) - assert.Equal(t, v.Name, "test-method"+backFix) - assert.Equal(t, v.Retries, "test-retries"+backFix) - assert.Equal(t, v.LoadBalance, "test-lb"+backFix) - } - assert.Equal(t, refConfig.Protocol, "test-protocol") - assert.Equal(t, refConfig.Registry, "test-registry") -} - -func TestNewRegistryConfig(t *testing.T) { - regConfig := NewRegistryConfig( - WithRegistryTimeOut("test-timeout"), - WithRegistryProtocol("test-protocol"), - WithRegistryGroup("test-group"), - WithRegistryAddress("test-address"), - WithRegistrySimplified(true), - WithRegistryUserName("test-username"), - WithRegistryPassword("test-password"), - ) - assert.Equal(t, regConfig.TimeoutStr, "test-timeout") - assert.Equal(t, regConfig.Protocol, "test-protocol") - assert.Equal(t, regConfig.Group, "test-group") - assert.Equal(t, regConfig.Address, "test-address") - assert.Equal(t, regConfig.Simplified, true) - assert.Equal(t, regConfig.Username, "test-username") - assert.Equal(t, regConfig.Password, "test-password") -} - -func TestNewConsumerConfig(t *testing.T) { - referConfig := NewReferenceConfigByAPI( - WithReferenceCluster("test-cluster"), - WithReferenceInterface("test-interface"), - WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), - WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), - WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), - WithReferenceProtocol("test-protocol"), - WithReferenceRegistry("test-registry"), - ) - defaultZKRegistry := NewDefaultRegistryConfig("zookeeper") - assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr) - assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper") - assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout) - - testConsumerConfig := NewConsumerConfig( - WithConsumerConfigCheck(true), - WithConsumerConnTimeout(time.Minute), - WithConsumerRequestTimeout(time.Hour), - WithConsumerReferenceConfig("UserProvider", referConfig), - WithConsumerRegistryConfig("demoZK", defaultZKRegistry), - ) - - assert.Equal(t, *testConsumerConfig.Check, true) - assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute) - assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour) - assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry) - assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig) -} - -// TestNewProviderConfig test NewProviderConfig api -func TestNewProviderConfig(t *testing.T) { - serviceConfig := NewServiceConfigByAPI( - WithServiceCluster("test-cluster"), - WithServiceInterface("test-interface"), - WithServiceLoadBalance("test-loadbalance"), - WithServiceMethod("test-method1", "test-retries1", "test-lb1"), - WithServiceMethod("test-method2", "test-retries2", "test-lb2"), - WithServiceMethod("test-method3", "test-retries3", "test-lb3"), - WithServiceProtocol("test-protocol"), - WithServiceRegistry("test-registry"), - WithServiceWarmUpTime("test-warmup"), - ) - - defaultNacosRegistry := NewDefaultRegistryConfig("nacos") - assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr) - assert.Equal(t, defaultNacosRegistry.Protocol, "nacos") - assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout) - - testProviderConfig := NewProviderConfig( - WithProviderServices("UserProvider", serviceConfig), - WithProviderProtocol("dubbo", "dubbo", "20000"), - WithProviderRegistry("demoNacos", defaultNacosRegistry), - ) - - assert.NotNil(t, testProviderConfig.Services) - for k, v := range testProviderConfig.Services { - assert.Equal(t, k, "UserProvider") - assert.Equal(t, v, serviceConfig) - } - assert.NotNil(t, testProviderConfig.Registries) - - if registry, ok := testProviderConfig.Registries["demoNacos"]; ok { - assert.Equal(t, registry, defaultNacosRegistry) - } - assert.NotNil(t, testProviderConfig.Protocols) - assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo") - assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000") -} +// +//func TestNewDefaultServiceConfig(t *testing.T) { +// serviceConfig := NewServiceConfigByAPI( +// WithServiceCluster("test-cluster"), +// WithServiceInterface("test-interface"), +// WithServiceLoadBalance("test-loadbalance"), +// WithServiceMethod("test-method1", "test-retries1", "test-lb1"), +// WithServiceMethod("test-method2", "test-retries2", "test-lb2"), +// WithServiceMethod("test-method3", "test-retries3", "test-lb3"), +// WithServiceProtocol("test-protocol"), +// WithServiceRegistry("test-registry"), +// WithServiceWarmUpTime("test-warmup"), +// ) +// assert.Equal(t, serviceConfig.Cluster, "test-cluster") +// assert.Equal(t, serviceConfig.InterfaceName, "test-interface") +// assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance") +// for i, v := range serviceConfig.Methods { +// backFix := strconv.Itoa(i + 1) +// assert.Equal(t, v.Name, "test-method"+backFix) +// assert.Equal(t, v.Retries, "test-retries"+backFix) +// assert.Equal(t, v.LoadBalance, "test-lb"+backFix) +// } +// assert.Equal(t, serviceConfig.Protocol, "test-protocol") +// assert.Equal(t, serviceConfig.Registry, "test-registry") +// assert.Equal(t, serviceConfig.Warmup, "test-warmup") +//} +// +//func TestNewReferenceConfigByAPI(t *testing.T) { +// refConfig := NewReferenceConfigByAPI( +// WithReferenceCluster("test-cluster"), +// WithReferenceInterface("test-interface"), +// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), +// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), +// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), +// WithReferenceProtocol("test-protocol"), +// WithReferenceRegistry("test-registry"), +// ) +// assert.Equal(t, refConfig.Cluster, "test-cluster") +// assert.Equal(t, refConfig.InterfaceName, "test-interface") +// for i, v := range refConfig.Methods { +// backFix := strconv.Itoa(i + 1) +// assert.Equal(t, v.Name, "test-method"+backFix) +// assert.Equal(t, v.Retries, "test-retries"+backFix) +// assert.Equal(t, v.LoadBalance, "test-lb"+backFix) +// } +// assert.Equal(t, refConfig.Protocol, "test-protocol") +// assert.Equal(t, refConfig.Registry, "test-registry") +//} +// +//func TestNewRegistryConfig(t *testing.T) { +// regConfig := NewRegistryConfig( +// WithRegistryTimeOut("test-timeout"), +// WithRegistryProtocol("test-protocol"), +// WithRegistryGroup("test-group"), +// WithRegistryAddress("test-address"), +// WithRegistrySimplified(true), +// WithRegistryUserName("test-username"), +// WithRegistryPassword("test-password"), +// ) +// assert.Equal(t, regConfig.TimeoutStr, "test-timeout") +// assert.Equal(t, regConfig.Protocol, "test-protocol") +// assert.Equal(t, regConfig.Group, "test-group") +// assert.Equal(t, regConfig.Address, "test-address") +// assert.Equal(t, regConfig.Simplified, true) +// assert.Equal(t, regConfig.Username, "test-username") +// assert.Equal(t, regConfig.Password, "test-password") +//} +// +//func TestNewConsumerConfig(t *testing.T) { +// referConfig := NewReferenceConfigByAPI( +// WithReferenceCluster("test-cluster"), +// WithReferenceInterface("test-interface"), +// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), +// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), +// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), +// WithReferenceProtocol("test-protocol"), +// WithReferenceRegistry("test-registry"), +// ) +// defaultZKRegistry := NewDefaultRegistryConfig("zookeeper") +// assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr) +// assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper") +// assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout) +// +// testConsumerConfig := NewConsumerConfig( +// WithConsumerConfigCheck(true), +// WithConsumerConnTimeout(time.Minute), +// WithConsumerRequestTimeout(time.Hour), +// WithConsumerReferenceConfig("UserProvider", referConfig), +// WithConsumerRegistryConfig("demoZK", defaultZKRegistry), +// ) +// +// assert.Equal(t, *testConsumerConfig.Check, true) +// assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute) +// assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour) +// assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry) +// assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig) +//} +// +//// TestNewProviderConfig test NewProviderConfig api +//func TestNewProviderConfig(t *testing.T) { +// serviceConfig := NewServiceConfigByAPI( +// WithServiceCluster("test-cluster"), +// WithServiceInterface("test-interface"), +// WithServiceLoadBalance("test-loadbalance"), +// WithServiceMethod("test-method1", "test-retries1", "test-lb1"), +// WithServiceMethod("test-method2", "test-retries2", "test-lb2"), +// WithServiceMethod("test-method3", "test-retries3", "test-lb3"), +// WithServiceProtocol("test-protocol"), +// WithServiceRegistry("test-registry"), +// WithServiceWarmUpTime("test-warmup"), +// ) +// +// defaultNacosRegistry := NewDefaultRegistryConfig("nacos") +// assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr) +// assert.Equal(t, defaultNacosRegistry.Protocol, "nacos") +// assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout) +// +// testProviderConfig := NewProviderConfig( +// WithProviderServices("UserProvider", serviceConfig), +// WithProviderProtocol("dubbo", "dubbo", "20000"), +// WithProviderRegistry("demoNacos", defaultNacosRegistry), +// ) +// +// assert.NotNil(t, testProviderConfig.Services) +// for k, v := range testProviderConfig.Services { +// assert.Equal(t, k, "UserProvider") +// assert.Equal(t, v, serviceConfig) +// } +// assert.NotNil(t, testProviderConfig.Registries) +// +// if registry, ok := testProviderConfig.Registries["demoNacos"]; ok { +// assert.Equal(t, registry, defaultNacosRegistry) +// } +// assert.NotNil(t, testProviderConfig.Protocols) +// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo") +// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000") +//} diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go deleted file mode 100644 index ec11947e4d..0000000000 --- a/config/config_center_config_test.go +++ /dev/null @@ -1,75 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config_center" -) - -func TestStartConfigCenter(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - baseConfig := &BaseConfig{ConfigCenterConfig: &ConfigCenterConfig{ - Protocol: "mock", - Address: "172.0.0.1", - Group: "dubbo", - ConfigFile: "mockDubbo.properties", - }} - - c := &configCenter{} - err := c.startConfigCenter(*baseConfig) - assert.NoError(t, err) - b, v := config.GetEnvInstance().Configuration().Back().Value.(*config.InmemoryConfiguration).GetProperty("dubbo.application.organization") - assert.True(t, b) - assert.Equal(t, "ikurento.com", v) -} - -func TestStartConfigCenterWithRemoteRef(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - m := make(map[string]*RemoteConfig) - m["mock"] = &RemoteConfig{Protocol: "mock", 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.NoError(t, err) - b, v := config.GetEnvInstance().Configuration().Back().Value.(*config.InmemoryConfiguration).GetProperty("dubbo.application.organization") - assert.True(t, b) - assert.Equal(t, "ikurento.com", v) -} diff --git a/config/config_loader.go b/config/config_loader.go index 48af47e6aa..015c9b7c16 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,486 +18,650 @@ package config import ( - "flag" + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/root" "fmt" - "io/ioutil" + "github.com/go-playground/validator/v10" + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/json" + "github.com/knadh/koanf/parsers/toml" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/file" + "github.com/pkg/errors" "os" - "reflect" - "strconv" - "sync" - "time" + "path/filepath" + "runtime" + "strings" ) import ( - hessian "github.com/apache/dubbo-go-hessian2" - perrors "github.com/pkg/errors" -) - -import ( - "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/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/common/yaml" - "dubbo.apache.org/dubbo-go/v3/registry" ) var ( - consumerConfig *ConsumerConfig - providerConfig *ProviderConfig - // baseConfig = providerConfig.BaseConfig or consumerConfig - baseConfig *BaseConfig - sslEnabled = false - - // configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. - // it should be used combine with double-check to avoid the race condition - configAccessMutex sync.Mutex - - maxWait = 3 - confRouterFile string - confBaseFile string - uniformVirtualServiceConfigPath string - uniformDestRuleConfigPath string + // application config + applicationConfig *application.Config + rootConfig *root.Config + //consumerConfig *consumer.Config + //providerConfig *provider.ProviderConfig + //// baseConfig = providerConfig.BaseConfig or consumerConfig + //baseConfig *root.Config + //sslEnabled = false + // + //// configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. + //// it should be used combine with double-check to avoid the race condition + //configAccessMutex sync.Mutex + // + //maxWait = 3 + //confRouterFile string + //confBaseFile string + //uniformVirtualServiceConfigPath string + //uniformDestRuleConfigPath string ) -// loaded consumer & provider config from xxx.yml, and log config from xxx.xml -// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo -func DefaultInit() []LoaderInitOption { - var ( - confConFile string - confProFile string - ) - - fs := flag.NewFlagSet("config", flag.ContinueOnError) - fs.StringVar(&confConFile, "conConf", os.Getenv(constant.CONF_CONSUMER_FILE_PATH), "default client config path") - fs.StringVar(&confProFile, "proConf", os.Getenv(constant.CONF_PROVIDER_FILE_PATH), "default server config path") - fs.StringVar(&confRouterFile, "rouConf", os.Getenv(constant.CONF_ROUTER_FILE_PATH), "default router config path") - fs.StringVar(&uniformVirtualServiceConfigPath, "vsConf", os.Getenv(constant.CONF_VIRTUAL_SERVICE_FILE_PATH), "default virtual service of uniform router config path") - fs.StringVar(&uniformDestRuleConfigPath, "drConf", os.Getenv(constant.CONF_DEST_RULE_FILE_PATH), "default destination rule of uniform router config path") - fs.Parse(os.Args[1:]) - for len(fs.Args()) != 0 { - fs.Parse(fs.Args()[1:]) - } - // If user did not set the environment variables or flags, - // we provide default value - if confConFile == "" { - confConFile = constant.DEFAULT_CONSUMER_CONF_FILE_PATH - } - if confProFile == "" { - confProFile = constant.DEFAULT_PROVIDER_CONF_FILE_PATH - } - if confRouterFile == "" { - confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH - } - return []LoaderInitOption{RouterInitOption(confRouterFile), BaseInitOption(""), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} +type config struct { + // config file name default application + name string + // config file type default yaml + genre string + // config file path default ./conf + path string + // config file delim default . + delim string } -// setDefaultValue set default value for providerConfig or consumerConfig if it is null -func setDefaultValue(target interface{}) { - registryConfig := &RegistryConfig{ - Protocol: constant.DEFAULT_REGISTRY_ZK_PROTOCOL, - TimeoutStr: constant.DEFAULT_REGISTRY_ZK_TIMEOUT, - Address: constant.DEFAULT_REGISTRY_ZK_ADDRESS, - } - switch target.(type) { - case *ProviderConfig: - p := target.(*ProviderConfig) - if len(p.Registries) == 0 && p.Registry == nil { - p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig - } - if len(p.Protocols) == 0 { - p.Protocols[constant.DEFAULT_PROTOCOL] = &ProtocolConfig{ - Name: constant.DEFAULT_PROTOCOL, - Port: strconv.Itoa(constant.DEFAULT_PORT), - } - } - if p.ApplicationConfig == nil { - p.ApplicationConfig = NewDefaultApplicationConfig() - } - default: - c := target.(*ConsumerConfig) - if len(c.Registries) == 0 && c.Registry == nil { - c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig - } - if c.ApplicationConfig == nil { - c.ApplicationConfig = NewDefaultApplicationConfig() - } - } -} +type optionFunc func(*config) -func checkRegistries(registries map[string]*RegistryConfig, singleRegistry *RegistryConfig) { - if len(registries) == 0 && singleRegistry != nil { - registries[constant.DEFAULT_KEY] = singleRegistry - } +func (fn optionFunc) apply(vc *config) { + fn(vc) } -func checkApplicationName(config *ApplicationConfig) { - if config == nil || len(config.Name) == 0 { - errMsg := "application config must not be nil, pls check your configuration" - logger.Errorf(errMsg) - panic(errMsg) - } +type Option interface { + apply(vc *config) } -func loadConsumerConfig() { - if consumerConfig == nil { - logger.Warnf("consumerConfig is nil!") - return - } - // init other consumer config - conConfigType := consumerConfig.ConfigType - for key, value := range extension.GetDefaultConfigReader() { - if conConfigType != nil { - if v, ok := conConfigType[key]; ok { - value = v - } - } - if err := extension.GetConfigReaders(value).ReadConsumerConfig(consumerConfig.fileStream); err != nil { - logger.Errorf("ReadConsumerConfig error: %#v for %s", perrors.WithStack(err), value) - } - } - - checkApplicationName(consumerConfig.ApplicationConfig) - if err := configCenterRefreshConsumer(); err != nil { - logger.Errorf("[consumer config center refresh] %#v", err) - } - - // start the metadata report if config set - if err := startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { - logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) - return - } - - checkRegistries(consumerConfig.Registries, consumerConfig.Registry) - for key, ref := range consumerConfig.References { - if ref.Generic { - genericService := NewGenericService(key) - SetConsumerService(genericService) - } - rpcService := GetConsumerService(key) - if rpcService == nil { - logger.Warnf("%s does not exist!", key) - continue - } - ref.id = key - ref.Refer(rpcService) - ref.Implement(rpcService) - } - - // Write current configuration to cache file. - if consumerConfig.CacheFile != "" { - if data, err := yaml.MarshalYML(consumerConfig); err != nil { - logger.Errorf("Marshal consumer config err: %s", err.Error()) - } else { - if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0666); err != nil { - logger.Errorf("Write consumer config cache file err: %s", err.Error()) - } - } - } - - // wait for invoker is available, if wait over default 3s, then panic - var count int - for { - checkok := true - for _, refconfig := range consumerConfig.References { - if (refconfig.Check != nil && *refconfig.Check) || - (refconfig.Check == nil && consumerConfig.Check != nil && *consumerConfig.Check) || - (refconfig.Check == nil && consumerConfig.Check == nil) { // default to true - - if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { - checkok = false - count++ - if count > maxWait { - errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) - logger.Error(errMsg) - panic(errMsg) - } - time.Sleep(time.Second * 1) - break - } - if refconfig.invoker == nil { - logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) - } - } - } - if checkok { - break - } - } -} - -func loadProviderConfig() { - if providerConfig == nil { - logger.Warnf("providerConfig is nil!") - return - } - - // init other provider config - proConfigType := providerConfig.ConfigType - for key, value := range extension.GetDefaultConfigReader() { - if proConfigType != nil { - if v, ok := proConfigType[key]; ok { - value = v - } - } - if err := extension.GetConfigReaders(value).ReadProviderConfig(providerConfig.fileStream); err != nil { - logger.Errorf("ReadProviderConfig error: %#v for %s", perrors.WithStack(err), value) - } - } - - checkApplicationName(providerConfig.ApplicationConfig) - if err := configCenterRefreshProvider(); err != nil { - logger.Errorf("[provider config center refresh] %#v", err) +func Load(opts ...Option) { + // pares CommandLine + //parseCommandLine() + // conf + conf := &config{ + name: "application.yaml", + genre: "yaml", + path: "./conf", + delim: ".", } - // start the metadata report if config set - if err := startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { - logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) - return + for _, opt := range opts { + opt.apply(conf) } + rootConfig = new(root.Config) - checkRegistries(providerConfig.Registries, providerConfig.Registry) + k := getKoanf(conf) - // Write the current configuration to cache file. - if providerConfig.CacheFile != "" { - if data, err := yaml.MarshalYML(providerConfig); err != nil { - logger.Errorf("Marshal provider config err: %s", err.Error()) - } else { - if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0666); err != nil { - logger.Errorf("Write provider config cache file err: %s", err.Error()) - } - } + if err := k.Unmarshal(rootConfig.Prefix(), &rootConfig); err != nil { + panic(err) } - for key, svs := range providerConfig.Services { - rpcService := GetProviderService(key) - if rpcService == nil { - logger.Warnf("%s does not exist!", key) - continue - } - svs.id = key - svs.Implement(rpcService) - svs.Protocols = providerConfig.Protocols - if err := svs.Export(); err != nil { - panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) - } - } - registerServiceInstance() + rootConfig.SetKoanf(k) + rootConfig.Validate = validator.New() } -// registerServiceInstance register service instance -func registerServiceInstance() { - url := selectMetadataServiceExportedURL() - if url == nil { - return +// GetApplicationConfig get application config +func GetApplicationConfig() (*application.Config, error) { + if rootConfig == nil { + return nil, nil } - instance, err := createInstance(url) - if err != nil { - panic(err) + if applicationConfig != nil { + return applicationConfig, nil } - p := extension.GetProtocol(constant.REGISTRY_KEY) - var rp registry.RegistryFactory - var ok bool - if rp, ok = p.(registry.RegistryFactory); !ok { - panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") + conf := rootConfig.Application + if err := conf.SetDefault(); err != nil { + return nil, err } - rs := rp.GetRegistries() - for _, r := range rs { - var sdr registry.ServiceDiscoveryHolder - if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { - continue - } - err := sdr.GetServiceDiscovery().Register(instance) - if err != nil { - panic(err) - } - } - // todo publish metadata to remote - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { - remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) + if err := conf.Validate(rootConfig.Validate); err != nil { + return nil, err } + applicationConfig = conf + return conf, nil } -// nolint -func createInstance(url *common.URL) (registry.ServiceInstance, error) { - appConfig := GetApplicationConfig() - port, err := strconv.ParseInt(url.Port, 10, 32) - if err != nil { - return nil, perrors.WithMessage(err, "invalid port: "+url.Port) - } - - host := url.Ip - if len(host) == 0 { - host = common.GetLocalIp() - } - - // usually we will add more metadata - metadata := make(map[string]string, 8) - metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType - - return ®istry.DefaultServiceInstance{ - ServiceName: appConfig.Name, - Host: host, - Port: int(port), - ID: host + constant.KEY_SEPARATOR + url.Port, - Enable: true, - Healthy: true, - Metadata: metadata, - }, nil +//parseCommandLine parse command line +//func parseCommandLine() { +// flag.String("delim", ".", "config file delim") +// flag.String("name", "application.yaml", "config file name") +// flag.String("genre", "yaml", "config file type") +// flag.String("path", "./conf", "config file path default") +// +// pflag.CommandLine.AddGoFlagSet(flag.CommandLine) +// pflag.Parse() +// +// if err := viper.BindPFlags(pflag.CommandLine); err != nil { +// panic(err) +// } +//} + +// WithGenre set config genre +func WithGenre(genre string) Option { + return optionFunc(func(conf *config) { + conf.genre = strings.ToLower(genre) + }) } -// selectMetadataServiceExportedURL get already be exported url -func selectMetadataServiceExportedURL() *common.URL { - var selectedUrl *common.URL - metaDataService, err := extension.GetLocalMetadataService("") - if err != nil { - logger.Warn(err) - return nil - } - urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) - if err != nil { - panic(err) - } - if len(urlList) == 0 { - return nil - } - for _, url := range urlList { - selectedUrl = url - // rest first - if url.Protocol == "rest" { - break - } - } - return selectedUrl +// WithPath set config path +func WithPath(path string) Option { + return optionFunc(func(conf *config) { + conf.path = absolutePath(path) + }) } -func initRouter() { - if uniformDestRuleConfigPath != "" && uniformVirtualServiceConfigPath != "" { - if err := RouterInit(uniformVirtualServiceConfigPath, uniformDestRuleConfigPath); err != nil { - logger.Warnf("[routerConfig init] %#v", err) - } - } +// WithName set config name +func WithName(name string) Option { + return optionFunc(func(conf *config) { + conf.name = name + }) } -// Load Dubbo Init -func Load() { - options := DefaultInit() - LoadWithOptions(options...) +func WithDelim(delim string) Option { + return optionFunc(func(conf *config) { + conf.delim = delim + }) } -func LoadWithOptions(options ...LoaderInitOption) { - // register metadata info and service info - hessian.RegisterPOJO(&common.MetadataInfo{}) - hessian.RegisterPOJO(&common.ServiceInfo{}) - hessian.RegisterPOJO(&common.URL{}) +// absolutePath get absolut path +func absolutePath(inPath string) string { - for _, option := range options { - option.init() + if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { + inPath = userHomeDir() + inPath[5:] } - for _, option := range options { - option.apply() - } - // init router - initRouter() - // init the shutdown callback - GracefulShutdownInit() -} + if filepath.IsAbs(inPath) { + return filepath.Clean(inPath) + } -// GetRPCService get rpc service for consumer -func GetRPCService(name string) common.RPCService { - return consumerConfig.References[name].GetRPCService() -} + p, err := filepath.Abs(inPath) + if err == nil { + return filepath.Clean(p) + } -// RPCService create rpc service for consumer -func RPCService(service common.RPCService) { - consumerConfig.References[service.Reference()].Implement(service) + return "" } -// GetMetricConfig find the MetricConfig -// if it is nil, create a new one -// we use double-check to reduce race condition -// In general, it will be locked 0 or 1 time. -// So you don't need to worry about the race condition -func GetMetricConfig() *MetricConfig { - if GetBaseConfig().MetricConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if GetBaseConfig().MetricConfig == nil { - GetBaseConfig().MetricConfig = &MetricConfig{} +//userHomeDir get gopath +func userHomeDir() string { + if runtime.GOOS == "windows" { + home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + if home == "" { + home = os.Getenv("USERPROFILE") } + return home } - return GetBaseConfig().MetricConfig + return os.Getenv("HOME") } -// GetApplicationConfig find the application config -// if not, we will create one -// Usually applicationConfig will be initialized when system start -// we use double-check to reduce race condition -// In general, it will be locked 0 or 1 time. -// So you don't need to worry about the race condition -func GetApplicationConfig() *ApplicationConfig { - if GetBaseConfig().ApplicationConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if GetBaseConfig().ApplicationConfig == nil { - GetBaseConfig().ApplicationConfig = &ApplicationConfig{} - } - } - return GetBaseConfig().ApplicationConfig -} +func getKoanf(conf *config) *koanf.Koanf { + var ( + k *koanf.Koanf + err error + ) -// GetProviderConfig find the provider config -// if not found, create new one -func GetProviderConfig() ProviderConfig { - if providerConfig == nil { - if providerConfig == nil { - return ProviderConfig{} - } - } - return *providerConfig -} + k = koanf.New(conf.delim) -// GetConsumerConfig find the consumer config -// if not found, create new one -// we use double-check to reduce race condition -// In general, it will be locked 0 or 1 time. -// So you don't need to worry about the race condition -func GetConsumerConfig() ConsumerConfig { - if consumerConfig == nil { - if consumerConfig == nil { - return ConsumerConfig{} - } - } - return *consumerConfig -} + switch conf.genre { -func GetBaseConfig() *BaseConfig { - if baseConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if baseConfig == nil { - baseConfig = &BaseConfig{ - MetricConfig: &MetricConfig{}, - ConfigCenterConfig: &ConfigCenterConfig{}, - Remotes: make(map[string]*RemoteConfig), - ApplicationConfig: &ApplicationConfig{}, - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - } - } + case "yaml": + err = k.Load(file.Provider(conf.path), yaml.Parser()) + case "json": + err = k.Load(file.Provider(conf.path), json.Parser()) + case "toml": + err = k.Load(file.Provider(conf.path), toml.Parser()) + default: + err = errors.New(fmt.Sprintf("Unsupported %s file type", conf.genre)) } - return baseConfig -} -func GetSslEnabled() bool { - return sslEnabled -} - -func SetSslEnabled(enabled bool) { - sslEnabled = enabled + if err != nil { + panic(err) + } + return k } -func IsProvider() bool { - return providerConfig != nil -} +// +//// loaded consumer & provider config from xxx.yml, and log config from xxx.xml +//// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo +//func DefaultInit() []LoaderInitOption { +// var ( +// confConFile string +// confProFile string +// ) +// +// fs := flag.NewFlagSet("config", flag.ContinueOnError) +// fs.StringVar(&confConFile, "conConf", os.Getenv(constant.CONF_CONSUMER_FILE_PATH), "default client config path") +// fs.StringVar(&confProFile, "proConf", os.Getenv(constant.CONF_PROVIDER_FILE_PATH), "default server config path") +// fs.StringVar(&confRouterFile, "rouConf", os.Getenv(constant.CONF_ROUTER_FILE_PATH), "default router config path") +// fs.StringVar(&uniformVirtualServiceConfigPath, "vsConf", os.Getenv(constant.CONF_VIRTUAL_SERVICE_FILE_PATH), "default virtual service of uniform router config path") +// fs.StringVar(&uniformDestRuleConfigPath, "drConf", os.Getenv(constant.CONF_DEST_RULE_FILE_PATH), "default destination rule of uniform router config path") +// fs.Parse(os.Args[1:]) +// for len(fs.Args()) != 0 { +// fs.Parse(fs.Args()[1:]) +// } +// // If user did not set the environment variables or flags, +// // we provide default value +// if confConFile == "" { +// confConFile = constant.DEFAULT_CONSUMER_CONF_FILE_PATH +// } +// if confProFile == "" { +// confProFile = constant.DEFAULT_PROVIDER_CONF_FILE_PATH +// } +// if confRouterFile == "" { +// confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH +// } +// return []LoaderInitOption{RouterInitOption(confRouterFile), BaseInitOption(""), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} +//} +// +//// setDefaultValue set default value for providerConfig or consumerConfig if it is null +//func setDefaultValue(target interface{}) { +// registryConfig := ®istry2.RegistryConfig{ +// Protocol: constant.DEFAULT_REGISTRY_ZK_PROTOCOL, +// TimeoutStr: constant.DEFAULT_REGISTRY_ZK_TIMEOUT, +// Address: constant.DEFAULT_REGISTRY_ZK_ADDRESS, +// } +// switch target.(type) { +// case *provider.ProviderConfig: +// p := target.(*provider.ProviderConfig) +// if len(p.Registries) == 0 && p.Registry == nil { +// p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig +// } +// if len(p.Protocols) == 0 { +// p.Protocols[constant.DEFAULT_PROTOCOL] = &protocol.ProtocolConfig{ +// Name: constant.DEFAULT_PROTOCOL, +// Port: strconv.Itoa(constant.DEFAULT_PORT), +// } +// } +// if p.ApplicationConfig == nil { +// p.ApplicationConfig = NewDefaultApplicationConfig() +// } +// default: +// c := target.(*consumer.Config) +// if len(c.Registries) == 0 && c.Registry == nil { +// c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig +// } +// if c.ApplicationConfig == nil { +// c.ApplicationConfig = NewDefaultApplicationConfig() +// } +// } +//} +// +//func checkRegistries(registries map[string]*registry2.RegistryConfig, singleRegistry *registry2.RegistryConfig) { +// if len(registries) == 0 && singleRegistry != nil { +// registries[constant.DEFAULT_KEY] = singleRegistry +// } +//} +// +//func checkApplicationName(config *application.Config) { +// if config == nil || len(config.Name) == 0 { +// errMsg := "application config must not be nil, pls check your configuration" +// logger.Errorf(errMsg) +// panic(errMsg) +// } +//} +// +//func loadConsumerConfig() { +// if consumerConfig == nil { +// logger.Warnf("consumerConfig is nil!") +// return +// } +// // init other consumer config +// conConfigType := consumerConfig.ConfigType +// for key, value := range extension.GetDefaultConfigReader() { +// if conConfigType != nil { +// if v, ok := conConfigType[key]; ok { +// value = v +// } +// } +// if err := extension.GetConfigReaders(value).ReadConsumerConfig(consumerConfig.fileStream); err != nil { +// logger.Errorf("ReadConsumerConfig error: %#v for %s", perrors.WithStack(err), value) +// } +// } +// +// checkApplicationName(consumerConfig.ApplicationConfig) +// if err := consumer.configCenterRefreshConsumer(); err != nil { +// logger.Errorf("[consumer config center refresh] %#v", err) +// } +// +// // start the metadata report if config set +// if err := report.startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { +// logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) +// return +// } +// +// checkRegistries(consumerConfig.Registries, consumerConfig.Registry) +// for key, ref := range consumerConfig.References { +// if ref.Generic { +// genericService := generic.NewGenericService(key) +// instance.SetConsumerService(genericService) +// } +// rpcService := instance.GetConsumerService(key) +// if rpcService == nil { +// logger.Warnf("%s does not exist!", key) +// continue +// } +// ref.id = key +// ref.Refer(rpcService) +// ref.Implement(rpcService) +// } +// +// // Write current configuration to cache file. +// if consumerConfig.CacheFile != "" { +// if data, err := yaml.MarshalYML(consumerConfig); err != nil { +// logger.Errorf("Marshal consumer config err: %s", err.Error()) +// } else { +// if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0666); err != nil { +// logger.Errorf("Write consumer config cache file err: %s", err.Error()) +// } +// } +// } +// +// // wait for invoker is available, if wait over default 3s, then panic +// var count int +// for { +// checkok := true +// for _, refconfig := range consumerConfig.References { +// if (refconfig.Check != nil && *refconfig.Check) || +// (refconfig.Check == nil && consumerConfig.Check != nil && *consumerConfig.Check) || +// (refconfig.Check == nil && consumerConfig.Check == nil) { // default to true +// +// if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { +// checkok = false +// count++ +// if count > maxWait { +// errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) +// logger.Error(errMsg) +// panic(errMsg) +// } +// time.Sleep(time.Second * 1) +// break +// } +// if refconfig.invoker == nil { +// logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) +// } +// } +// } +// if checkok { +// break +// } +// } +//} +// +//func loadProviderConfig() { +// if providerConfig == nil { +// logger.Warnf("providerConfig is nil!") +// return +// } +// +// // init other provider config +// proConfigType := providerConfig.ConfigType +// for key, value := range extension.GetDefaultConfigReader() { +// if proConfigType != nil { +// if v, ok := proConfigType[key]; ok { +// value = v +// } +// } +// if err := extension.GetConfigReaders(value).ReadProviderConfig(providerConfig.fileStream); err != nil { +// logger.Errorf("ReadProviderConfig error: %#v for %s", perrors.WithStack(err), value) +// } +// } +// +// checkApplicationName(providerConfig.ApplicationConfig) +// if err := provider.configCenterRefreshProvider(); err != nil { +// logger.Errorf("[provider config center refresh] %#v", err) +// } +// +// // start the metadata report if config set +// if err := report.startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { +// logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) +// return +// } +// +// checkRegistries(providerConfig.Registries, providerConfig.Registry) +// +// // Write the current configuration to cache file. +// if providerConfig.CacheFile != "" { +// if data, err := yaml.MarshalYML(providerConfig); err != nil { +// logger.Errorf("Marshal provider config err: %s", err.Error()) +// } else { +// if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0666); err != nil { +// logger.Errorf("Write provider config cache file err: %s", err.Error()) +// } +// } +// } +// +// for key, svs := range providerConfig.Services { +// rpcService := instance.GetProviderService(key) +// if rpcService == nil { +// logger.Warnf("%s does not exist!", key) +// continue +// } +// svs.id = key +// svs.Implement(rpcService) +// svs.Protocols = providerConfig.Protocols +// if err := svs.Export(); err != nil { +// panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) +// } +// } +// registerServiceInstance() +//} +// +//// registerServiceInstance register service instance +//func registerServiceInstance() { +// url := selectMetadataServiceExportedURL() +// if url == nil { +// return +// } +// instance, err := createInstance(url) +// if err != nil { +// panic(err) +// } +// p := extension.GetProtocol(constant.REGISTRY_KEY) +// var rp registry.RegistryFactory +// var ok bool +// if rp, ok = p.(registry.RegistryFactory); !ok { +// panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") +// } +// rs := rp.GetRegistries() +// for _, r := range rs { +// var sdr registry.ServiceDiscoveryHolder +// if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { +// continue +// } +// err := sdr.GetServiceDiscovery().Register(instance) +// if err != nil { +// panic(err) +// } +// } +// // todo publish metadata to remote +// if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { +// remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) +// } +//} +// +//// nolint +//func createInstance(url *common.URL) (registry.ServiceInstance, error) { +// appConfig := GetApplicationConfig() +// port, err := strconv.ParseInt(url.Port, 10, 32) +// if err != nil { +// return nil, perrors.WithMessage(err, "invalid port: "+url.Port) +// } +// +// host := url.Ip +// if len(host) == 0 { +// host = common.GetLocalIp() +// } +// +// // usually we will add more metadata +// metadata := make(map[string]string, 8) +// metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType +// +// return ®istry.DefaultServiceInstance{ +// ServiceName: appConfig.Name, +// Host: host, +// Port: int(port), +// ID: host + constant.KEY_SEPARATOR + url.Port, +// Enable: true, +// Healthy: true, +// Metadata: metadata, +// }, nil +//} +// +//// selectMetadataServiceExportedURL get already be exported url +//func selectMetadataServiceExportedURL() *common.URL { +// var selectedUrl *common.URL +// metaDataService, err := extension.GetLocalMetadataService("") +// if err != nil { +// logger.Warn(err) +// return nil +// } +// urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) +// if err != nil { +// panic(err) +// } +// if len(urlList) == 0 { +// return nil +// } +// for _, url := range urlList { +// selectedUrl = url +// // rest first +// if url.Protocol == "rest" { +// break +// } +// } +// return selectedUrl +//} +// +//func initRouter() { +// if uniformDestRuleConfigPath != "" && uniformVirtualServiceConfigPath != "" { +// if err := router.RouterInit(uniformVirtualServiceConfigPath, uniformDestRuleConfigPath); err != nil { +// logger.Warnf("[routerConfig init] %#v", err) +// } +// } +//} +// +//// Load Dubbo Init +//func Load() { +// options := DefaultInit() +// LoadWithOptions(options...) +//} +// +//func LoadWithOptions(options ...LoaderInitOption) { +// // register metadata info and service info +// hessian.RegisterPOJO(&common.MetadataInfo{}) +// hessian.RegisterPOJO(&common.ServiceInfo{}) +// hessian.RegisterPOJO(&common.URL{}) +// +// for _, option := range options { +// option.init() +// } +// for _, option := range options { +// option.apply() +// } +// // init router +// initRouter() +// +// // init the shutdown callback +// shutdown.GracefulShutdownInit() +//} +// +//// GetRPCService get rpc service for consumer +//func GetRPCService(name string) common.RPCService { +// return consumerConfig.References[name].GetRPCService() +//} +// +//// RPCService create rpc service for consumer +//func RPCService(service common.RPCService) { +// consumerConfig.References[service.Reference()].Implement(service) +//} +// +//// GetMetricConfig find the MetricConfig +//// if it is nil, create a new one +//// we use double-check to reduce race condition +//// In general, it will be locked 0 or 1 time. +//// So you don't need to worry about the race condition +//func GetMetricConfig() *metric.MetricConfig { +// if GetBaseConfig().MetricConfig == nil { +// configAccessMutex.Lock() +// defer configAccessMutex.Unlock() +// if GetBaseConfig().MetricConfig == nil { +// GetBaseConfig().MetricConfig = &metric.MetricConfig{} +// } +// } +// return GetBaseConfig().MetricConfig +//} +// +//// GetApplicationConfig find the application config +//// if not, we will create one +//// Usually applicationConfig will be initialized when system start +//// we use double-check to reduce race condition +//// In general, it will be locked 0 or 1 time. +//// So you don't need to worry about the race condition +//func GetApplicationConfig() *application.Config { +// if GetBaseConfig().ApplicationConfig == nil { +// configAccessMutex.Lock() +// defer configAccessMutex.Unlock() +// if GetBaseConfig().ApplicationConfig == nil { +// GetBaseConfig().ApplicationConfig = &application.Config{} +// } +// } +// return GetBaseConfig().ApplicationConfig +//} +// +//// GetProviderConfig find the provider config +//// if not found, create new one +//func GetProviderConfig() provider.ProviderConfig { +// if providerConfig == nil { +// if providerConfig == nil { +// return provider.ProviderConfig{} +// } +// } +// return *providerConfig +//} +// +//// GetConsumerConfig find the consumer config +//// if not found, create new one +//// we use double-check to reduce race condition +//// In general, it will be locked 0 or 1 time. +//// So you don't need to worry about the race condition +//func GetConsumerConfig() consumer.Config { +// if consumerConfig == nil { +// if consumerConfig == nil { +// return consumer.Config{} +// } +// } +// return *consumerConfig +//} +// +//func GetBaseConfig() *base.Config { +// if baseConfig == nil { +// configAccessMutex.Lock() +// defer configAccessMutex.Unlock() +// if baseConfig == nil { +// baseConfig = &base.Config{ +// metric.MetricConfig: &metric.MetricConfig{}, +// ConfigCenterConfig: ¢er.Config{}, +// Remotes: make(map[string]*RemoteConfig), +// application.Config: &application.Config{}, +// ServiceDiscoveries: make(map[string]*discovery.Config), +// } +// } +// } +// return baseConfig +//} +// +//func GetSslEnabled() bool { +// return sslEnabled +//} +// +//func SetSslEnabled(enabled bool) { +// sslEnabled = enabled +//} +// +//func IsProvider() bool { +// return providerConfig != nil +//} diff --git a/config/config_loader_options.go b/config/config_loader_options.go index bc8aff1a17..4b4ca7727b 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -1,138 +1,141 @@ /* - * 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. - */ +* 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 - -import ( - "log" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" -) - -type LoaderInitOption interface { - init() - apply() -} - -type optionFunc struct { - initFunc func() - applyFunc func() -} - -func (f *optionFunc) init() { - f.initFunc() -} - -func (f *optionFunc) apply() { - f.applyFunc() -} - -func ConsumerInitOption(confConFile string) LoaderInitOption { - return consumerInitOption(confConFile, false) -} - -func ConsumerMustInitOption(confConFile string) LoaderInitOption { - return consumerInitOption(confConFile, true) -} - -func consumerInitOption(confConFile string, must bool) LoaderInitOption { - return &optionFunc{ - func() { - if consumerConfig != nil && !must { - return - } - if errCon := ConsumerInit(confConFile); errCon != nil { - log.Printf("[consumerInit] %#v", errCon) - consumerConfig = nil - } else if confBaseFile == "" { - // Check if there are some important key fields missing, - // if so, we set a default value for it - setDefaultValue(consumerConfig) - // Even though baseConfig has been initialized, we override it - // because we think read from config file is correct config - baseConfig = &consumerConfig.BaseConfig - } - }, - func() { - loadConsumerConfig() - }, - } -} - -func ProviderInitOption(confProFile string) LoaderInitOption { - return providerInitOption(confProFile, false) -} - -func ProviderMustInitOption(confProFile string) LoaderInitOption { - return providerInitOption(confProFile, true) -} - -func providerInitOption(confProFile string, must bool) LoaderInitOption { - return &optionFunc{ - func() { - if providerConfig != nil && !must { - return - } - if errPro := ProviderInit(confProFile); errPro != nil { - log.Printf("[providerInit] %#v", errPro) - providerConfig = nil - } else if confBaseFile == "" { - // Check if there are some important key fields missing, - // if so, we set a default value for it - setDefaultValue(providerConfig) - // Even though baseConfig has been initialized, we override it - // because we think read from config file is correct config - baseConfig = &providerConfig.BaseConfig - } - }, - func() { - loadProviderConfig() - }, - } -} - -func RouterInitOption(crf string) LoaderInitOption { - return &optionFunc{ - func() { - confRouterFile = crf - }, - func() { - initRouter() - }, - } -} - -func BaseInitOption(cbf string) LoaderInitOption { - return &optionFunc{ - func() { - if cbf == "" { - return - } - confBaseFile = cbf - if err := BaseInit(cbf); err != nil { - log.Printf("[BaseInit] %#v", err) - baseConfig = nil - } - }, - func() { - // init the global event dispatcher - extension.SetAndInitGlobalDispatcher(GetBaseConfig().EventDispatcherType) - }, - } -} +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/config/base" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "log" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common/extension" +//) +// +//type LoaderInitOption interface { +// init() +// apply() +//} +// +//type optionFunc struct { +// initFunc func() +// applyFunc func() +//} +// +//func (f *optionFunc) init() { +// f.initFunc() +//} +// +//func (f *optionFunc) apply() { +// f.applyFunc() +//} +// +//func ConsumerInitOption(confConFile string) LoaderInitOption { +// return consumerInitOption(confConFile, false) +//} +// +//func ConsumerMustInitOption(confConFile string) LoaderInitOption { +// return consumerInitOption(confConFile, true) +//} +// +//func consumerInitOption(confConFile string, must bool) LoaderInitOption { +// return &optionFunc{ +// func() { +// if consumerConfig != nil && !must { +// return +// } +// if errCon := consumer.ConsumerInit(confConFile); errCon != nil { +// log.Printf("[consumerInit] %#v", errCon) +// consumerConfig = nil +// } else if confBaseFile == "" { +// // Check if there are some important key fields missing, +// // if so, we set a default value for it +// setDefaultValue(consumerConfig) +// // Even though baseConfig has been initialized, we override it +// // because we think read from config file is correct config +// baseConfig = &consumerConfig.BaseConfig +// } +// }, +// func() { +// loadConsumerConfig() +// }, +// } +//} +// +//func ProviderInitOption(confProFile string) LoaderInitOption { +// return providerInitOption(confProFile, false) +//} +// +//func ProviderMustInitOption(confProFile string) LoaderInitOption { +// return providerInitOption(confProFile, true) +//} +// +//func providerInitOption(confProFile string, must bool) LoaderInitOption { +// return &optionFunc{ +// func() { +// if providerConfig != nil && !must { +// return +// } +// if errPro := provider.ProviderInit(confProFile); errPro != nil { +// log.Printf("[providerInit] %#v", errPro) +// providerConfig = nil +// } else if confBaseFile == "" { +// // Check if there are some important key fields missing, +// // if so, we set a default value for it +// setDefaultValue(providerConfig) +// // Even though baseConfig has been initialized, we override it +// // because we think read from config file is correct config +// baseConfig = &providerConfig.BaseConfig +// } +// }, +// func() { +// loadProviderConfig() +// }, +// } +//} +// +//func RouterInitOption(crf string) LoaderInitOption { +// return &optionFunc{ +// func() { +// confRouterFile = crf +// }, +// func() { +// initRouter() +// }, +// } +//} +// +//func BaseInitOption(cbf string) LoaderInitOption { +// return &optionFunc{ +// func() { +// if cbf == "" { +// return +// } +// confBaseFile = cbf +// if err := base.BaseInit(cbf); err != nil { +// log.Printf("[BaseInit] %#v", err) +// baseConfig = nil +// } +// }, +// func() { +// // init the global event dispatcher +// extension.SetAndInitGlobalDispatcher(GetBaseConfig().EventDispatcherType) +// }, +// } +//} diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 737b6f641d..fb5e616007 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,605 +18,528 @@ package config import ( - "context" - "path/filepath" - "sort" - "sync" + "fmt" "testing" ) - import ( - "github.com/Workiva/go-datastructures/slice/skip" - gxset "github.com/dubbogo/gost/container/set" - gxpage "github.com/dubbogo/gost/hash/page" "github.com/stretchr/testify/assert" - "go.uber.org/atomic" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/config" - "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/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" ) const ( - mockConsumerConfigPath = "./testdata/consumer_config.yml" - mockProviderConfigPath = "./testdata/provider_config.yml" + configPath = "./testdata/application.yaml" ) -func TestConfigLoader(t *testing.T) { - conPath, err := filepath.Abs(mockConsumerConfigPath) - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) - - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) - - err = ConsumerInit(conPath) - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - assert.Equal(t, "soa.com.ikurento.user.UserProvider", GetConsumerConfig().References["UserProvider"].Params["serviceid"]) -} - func TestLoad(t *testing.T) { - extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - - doInitConsumer() - doInitProvider() + Load(WithPath(configPath)) - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) - - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - GetApplicationConfig().MetadataType = "mock" - var mm *mockMetadataService - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil - }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - err := common.ServiceMap.UnRegister("com.MockService", "mock", - common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) + application, err := GetApplicationConfig() + fmt.Println(GetApplicationConfig()) assert.Nil(t, err) - consumerConfig = nil - providerConfig = nil -} - -func TestLoadWithSingleReg(t *testing.T) { - doInitConsumerWithSingleRegistry() - mockInitProviderWithSingleRegistry() - - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) - - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - var mm *mockMetadataService - GetApplicationConfig().MetadataType = "mock" - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil - }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - consumerConfig = nil - providerConfig = nil -} - -func TestWithNoRegLoad(t *testing.T) { - doInitConsumer() - doInitProvider() - providerConfig.Services["MockService"].Registry = "" - consumerConfig.References["MockService"].Registry = "" - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) - - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - var mm *mockMetadataService - GetApplicationConfig().MetadataType = "mock" - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil - }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - err := common.ServiceMap.UnRegister("com.MockService", "mock", - common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - assert.Nil(t, err) - common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - consumerConfig = nil - providerConfig = nil -} - -func TestSetDefaultValue(t *testing.T) { - proConfig := &ProviderConfig{Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig)} - assert.Nil(t, proConfig.ApplicationConfig) - setDefaultValue(proConfig) - assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181") - assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s") - assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper") - assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo") - assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") - assert.NotNil(t, proConfig.ApplicationConfig) - - conConfig := &ConsumerConfig{Registries: make(map[string]*RegistryConfig)} - assert.Nil(t, conConfig.ApplicationConfig) - setDefaultValue(conConfig) - assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") - assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s") - assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper") - assert.NotNil(t, conConfig.ApplicationConfig) - -} -func TestConfigLoaderWithConfigCenter(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) - - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) - - err = ConsumerInit(conPath) - assert.NoError(t, err) - err = configCenterRefreshConsumer() - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - err = configCenterRefreshProvider() - assert.NoError(t, err) - - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - - assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) - assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address) -} - -func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) { - consumerConfig = nil - providerConfig = nil - config.NewEnvInstance() - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{Content: ` - dubbo.consumer.request_timeout=5s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registry.address=mock://127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover - dubbo.protocols.jsonrpc1.name=jsonrpc - dubbo.protocols.jsonrpc1.ip=127.0.0.1 - dubbo.protocols.jsonrpc1.port=20001 -`} - }) - - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) - - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) - - err = ConsumerInit(conPath) - assert.NoError(t, err) - checkApplicationName(consumerConfig.ApplicationConfig) - err = configCenterRefreshConsumer() - checkRegistries(consumerConfig.Registries, consumerConfig.Registry) - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - checkApplicationName(providerConfig.ApplicationConfig) - err = configCenterRefreshProvider() - checkRegistries(providerConfig.Registries, providerConfig.Registry) - assert.NoError(t, err) - - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - - assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) - assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address) -} - -func TestGetBaseConfig(t *testing.T) { - bc := GetBaseConfig() - assert.NotNil(t, bc) - _, found := bc.GetRemoteConfig("mock") - assert.False(t, found) -} - -// mockInitProviderWithSingleRegistry will init a mocked providerConfig -func mockInitProviderWithSingleRegistry() { - providerConfig = &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "1.0.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &RegistryConfig{ - Address: "mock://127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - Registries: map[string]*RegistryConfig{}, - - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - }, - Protocols: map[string]*ProtocolConfig{ - "mock": { - Name: "mock", - Ip: "127.0.0.1", - Port: "20000", - }, - }, - } -} - -type mockMetadataService struct { - exportedServiceURLs *sync.Map - lock *sync.RWMutex -} - -func (m *mockMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { - panic("implement me") -} - -func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { - panic("implement me") -} - -func (m *mockMetadataService) Reference() string { - panic("implement me") -} - -func (m *mockMetadataService) ServiceName() (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) ExportURL(url *common.URL) (bool, error) { - return m.addURL(m.exportedServiceURLs, url), nil -} - -func (m *mockMetadataService) UnexportURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { - return nil -} - -func (m *mockMetadataService) MethodMapper() map[string]string { - panic("implement me") -} - -func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) Version() (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) addURL(targetMap *sync.Map, url *common.URL) bool { - var ( - urlSet interface{} - loaded bool - ) - logger.Debug(url.ServiceKey()) - if urlSet, loaded = targetMap.LoadOrStore(url.ServiceKey(), skip.New(uint64(0))); loaded { - m.lock.RLock() - wantedUrl := urlSet.(*skip.SkipList).Get(url) - if len(wantedUrl) > 0 && wantedUrl[0] != nil { - m.lock.RUnlock() - return false - } - m.lock.RUnlock() - } - m.lock.Lock() - // double chk - wantedUrl := urlSet.(*skip.SkipList).Get(url) - if len(wantedUrl) > 0 && wantedUrl[0] != nil { - m.lock.Unlock() - return false - } - urlSet.(*skip.SkipList).Insert(url) - m.lock.Unlock() - return true -} - -func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { - // using skip list to dedup and sorting - var res []*common.URL - services.Range(func(key, value interface{}) bool { - urls := value.(*skip.SkipList) - for i := uint64(0); i < urls.Len(); i++ { - url := urls.ByPosition(i).(*common.URL) - if url.GetParam(constant.INTERFACE_KEY, url.Path) != constant.METADATA_SERVICE_NAME { - res = append(res, url) - } - } - return true - }) - sort.Sort(common.URLSlice(res)) - return res -} - -type mockServiceDiscoveryRegistry struct{} - -func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) IsAvailable() bool { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Destroy() { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Register(*common.URL) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) UnRegister(*common.URL) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Subscribe(*common.URL, registry.NotifyListener) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery { - return &mockServiceDiscovery{} -} - -type mockServiceDiscovery struct{} - -func (m *mockServiceDiscovery) String() string { - panic("implement me") -} -func (m *mockServiceDiscovery) Destroy() error { - panic("implement me") -} - -func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { - return nil -} - -func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetDefaultPageSize() int { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { - panic("implement me") -} - -func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { - if len(urls) == 0 { - return []interface{}{} - } - - res := make([]interface{}, 0, len(urls)) - for _, u := range urls { - res = append(res, u.String()) - } - 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 -} + assert.Equal(t, application.Organization, "dubbo.io") + assert.Equal(t, application.Name, "dubbo-go") + assert.Equal(t, application.Module, "local") + assert.Equal(t, application.Version, "1.0.0") + assert.Equal(t, application.Owner, "zhaoyunxing") + assert.Equal(t, application.Environment, "dev") + assert.Equal(t, application.MetadataType, "local") +} + +// +//func TestLoadWithSingleReg(t *testing.T) { +// reference.doInitConsumerWithSingleRegistry() +// mockInitProviderWithSingleRegistry() +// +// ms := &MockService{} +// instance.SetConsumerService(ms) +// instance.SetProviderService(ms) +// +// extension.SetProtocol("registry", reference.GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) +// var mm *mockMetadataService +// GetApplicationConfig().MetadataType = "mock" +// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { +// if mm == nil { +// mm = &mockMetadataService{ +// exportedServiceURLs: new(sync.Map), +// lock: new(sync.RWMutex), +// } +// } +// return mm, nil +// }) +// Load() +// +// assert.Equal(t, ms, GetRPCService(ms.Reference())) +// ms2 := &struct { +// MockService +// }{} +// RPCService(ms2) +// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) +// +// service2.conServices = map[string]common.RPCService{} +// service2.proServices = map[string]common.RPCService{} +// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// consumerConfig = nil +// providerConfig = nil +//} +// +//func TestWithNoRegLoad(t *testing.T) { +// reference.doInitConsumer() +// service2.doInitProvider() +// providerConfig.Services["MockService"].Registry = "" +// consumerConfig.References["MockService"].Registry = "" +// ms := &MockService{} +// instance.SetConsumerService(ms) +// instance.SetProviderService(ms) +// +// extension.SetProtocol("registry", reference.GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) +// var mm *mockMetadataService +// GetApplicationConfig().MetadataType = "mock" +// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { +// if mm == nil { +// mm = &mockMetadataService{ +// exportedServiceURLs: new(sync.Map), +// lock: new(sync.RWMutex), +// } +// } +// return mm, nil +// }) +// Load() +// +// assert.Equal(t, ms, GetRPCService(ms.Reference())) +// ms2 := &struct { +// MockService +// }{} +// RPCService(ms2) +// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) +// +// service2.conServices = map[string]common.RPCService{} +// service2.proServices = map[string]common.RPCService{} +// err := common.ServiceMap.UnRegister("com.MockService", "mock", +// common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// assert.Nil(t, err) +// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// consumerConfig = nil +// providerConfig = nil +//} +// +//func TestSetDefaultValue(t *testing.T) { +// proConfig := &provider.ProviderConfig{Registries: make(map[string]*registry2.RegistryConfig), Protocols: make(map[string]*protocol2.ProtocolConfig)} +// assert.Nil(t, proConfig.ApplicationConfig) +// setDefaultValue(proConfig) +// assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181") +// assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s") +// assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper") +// assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo") +// assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") +// assert.NotNil(t, proConfig.ApplicationConfig) +// +// conConfig := &consumer.Config{Registries: make(map[string]*registry2.RegistryConfig)} +// assert.Nil(t, conConfig.ApplicationConfig) +// setDefaultValue(conConfig) +// assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") +// assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s") +// assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper") +// assert.NotNil(t, conConfig.ApplicationConfig) +// +//} +//func TestConfigLoaderWithConfigCenter(t *testing.T) { +// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { +// return &config_center.MockDynamicConfigurationFactory{} +// }) +// +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// proPath, err := filepath.Abs(mockProviderConfigPath) +// assert.NoError(t, err) +// +// assert.Nil(t, consumerConfig) +// assert.Equal(t, consumer.Config{}, GetConsumerConfig()) +// assert.Nil(t, providerConfig) +// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// err = consumer.ConsumerInit(conPath) +// assert.NoError(t, err) +// err = consumer.configCenterRefreshConsumer() +// assert.NoError(t, err) +// err = provider.ProviderInit(proPath) +// assert.NoError(t, err) +// err = provider.configCenterRefreshProvider() +// assert.NoError(t, err) +// +// assert.NotNil(t, consumerConfig) +// assert.NotEqual(t, consumer.Config{}, GetConsumerConfig()) +// assert.NotNil(t, providerConfig) +// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) +// assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address) +//} +// +//func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) { +// consumerConfig = nil +// providerConfig = nil +// config.NewEnvInstance() +// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { +// return &config_center.MockDynamicConfigurationFactory{Content: ` +// dubbo.consumer.request_timeout=5s +// dubbo.consumer.connect_timeout=5s +// dubbo.application.organization=ikurento.com +// dubbo.application.name=BDTService +// dubbo.application.module=dubbogo user-info server +// dubbo.application.version=0.0.1 +// dubbo.application.owner=ZX +// dubbo.application.environment=dev +// dubbo.registry.address=mock://127.0.0.1:2182 +// dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo +// dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider +// dubbo.service.com.ikurento.user.UserProvider.loadbalance=random +// dubbo.service.com.ikurento.user.UserProvider.warmup=100 +// dubbo.service.com.ikurento.user.UserProvider.cluster=failover +// dubbo.protocols.jsonrpc1.name=jsonrpc +// dubbo.protocols.jsonrpc1.ip=127.0.0.1 +// dubbo.protocols.jsonrpc1.port=20001 +//`} +// }) +// +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// proPath, err := filepath.Abs(mockProviderConfigPath) +// assert.NoError(t, err) +// +// assert.Nil(t, consumerConfig) +// assert.Equal(t, consumer.Config{}, GetConsumerConfig()) +// assert.Nil(t, providerConfig) +// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// err = consumer.ConsumerInit(conPath) +// assert.NoError(t, err) +// checkApplicationName(consumerConfig.ApplicationConfig) +// err = consumer.configCenterRefreshConsumer() +// checkRegistries(consumerConfig.Registries, consumerConfig.Registry) +// assert.NoError(t, err) +// err = provider.ProviderInit(proPath) +// assert.NoError(t, err) +// checkApplicationName(providerConfig.ApplicationConfig) +// err = provider.configCenterRefreshProvider() +// checkRegistries(providerConfig.Registries, providerConfig.Registry) +// assert.NoError(t, err) +// +// assert.NotNil(t, consumerConfig) +// assert.NotEqual(t, consumer.Config{}, GetConsumerConfig()) +// assert.NotNil(t, providerConfig) +// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) +// assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address) +//} +// +//func TestGetBaseConfig(t *testing.T) { +// bc := GetBaseConfig() +// assert.NotNil(t, bc) +// _, found := bc.GetRemoteConfig("mock") +// assert.False(t, found) +//} +// +//// mockInitProviderWithSingleRegistry will init a mocked providerConfig +//func mockInitProviderWithSingleRegistry() { +// providerConfig = &provider.ProviderConfig{ +// BaseConfig: base.Config{ +// application.Config: &application.Config{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "1.0.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registry: ®istry2.RegistryConfig{ +// Address: "mock://127.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// Registries: map[string]*registry2.RegistryConfig{}, +// +// Services: map[string]*service2.Config{ +// "MockService": { +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// Weight: 200, +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// Weight: 200, +// }, +// }, +// exported: new(atomic.Bool), +// }, +// }, +// Protocols: map[string]*protocol2.ProtocolConfig{ +// "mock": { +// Name: "mock", +// Ip: "127.0.0.1", +// Port: "20000", +// }, +// }, +// } +//} +// +//type mockMetadataService struct { +// exportedServiceURLs *sync.Map +// lock *sync.RWMutex +//} +// +//func (m *mockMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Reference() string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ServiceName() (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ExportURL(url *common.URL) (bool, error) { +// return m.addURL(m.exportedServiceURLs, url), nil +//} +// +//func (m *mockMetadataService) UnexportURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { +// return nil +//} +// +//func (m *mockMetadataService) MethodMapper() map[string]string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Version() (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) addURL(targetMap *sync.Map, url *common.URL) bool { +// var ( +// urlSet interface{} +// loaded bool +// ) +// logger.Debug(url.ServiceKey()) +// if urlSet, loaded = targetMap.LoadOrStore(url.ServiceKey(), skip.New(uint64(0))); loaded { +// m.lock.RLock() +// wantedUrl := urlSet.(*skip.SkipList).Get(url) +// if len(wantedUrl) > 0 && wantedUrl[0] != nil { +// m.lock.RUnlock() +// return false +// } +// m.lock.RUnlock() +// } +// m.lock.Lock() +// // double chk +// wantedUrl := urlSet.(*skip.SkipList).Get(url) +// if len(wantedUrl) > 0 && wantedUrl[0] != nil { +// m.lock.Unlock() +// return false +// } +// urlSet.(*skip.SkipList).Insert(url) +// m.lock.Unlock() +// return true +//} +// +//func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { +// // using skip list to dedup and sorting +// var res []*common.URL +// services.Range(func(key, value interface{}) bool { +// urls := value.(*skip.SkipList) +// for i := uint64(0); i < urls.Len(); i++ { +// url := urls.ByPosition(i).(*common.URL) +// if url.GetParam(constant.INTERFACE_KEY, url.Path) != constant.METADATA_SERVICE_NAME { +// res = append(res, url) +// } +// } +// return true +// }) +// sort.Sort(common.URLSlice(res)) +// return res +//} +// +//type mockServiceDiscoveryRegistry struct{} +// +//func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) IsAvailable() bool { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Destroy() { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Register(*common.URL) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) UnRegister(*common.URL) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Subscribe(*common.URL, registry.NotifyListener) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery { +// return &mockServiceDiscovery{} +//} +// +//type mockServiceDiscovery struct{} +// +//func (m *mockServiceDiscovery) String() string { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Destroy() error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { +// return nil +//} +// +//func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetDefaultPageSize() int { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { +// panic("implement me") +//} +// +//func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { +// if len(urls) == 0 { +// return []interface{}{} +// } +// +// res := make([]interface{}, 0, len(urls)) +// for _, u := range urls { +// res = append(res, u.String()) +// } +// 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/consumer/consumer_config.go b/config/consumer/consumer_config.go new file mode 100644 index 0000000000..e76a454bff --- /dev/null +++ b/config/consumer/consumer_config.go @@ -0,0 +1,142 @@ +/* + * 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 consumer + +import ( + "dubbo.apache.org/dubbo-go/v3/config/reference" + "dubbo.apache.org/dubbo-go/v3/config/registry" + "dubbo.apache.org/dubbo-go/v3/config/shutdown" + "time" +) + +import ( + "github.com/creasty/defaults" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + +const ( + MaxWheelTimeSpan = 900e9 // 900s, 15 minute +) + +// Config is Consumer default configuration +type Config struct { + //root.Config `yaml:",inline" property:"base"` + //center.Config `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + // client + Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` + ConnectTimeout time.Duration + + Registry *registry.RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries map[string]*registry.RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` + + Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` + RequestTimeout time.Duration + ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + Check *bool `yaml:"check" json:"check,omitempty" property:"check"` + + References map[string]*reference.ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *shutdown.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` +} + +// UnmarshalYAML unmarshal the Config by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err + } + type plain Config + return unmarshal((*plain)(c)) +} + +// Prefix dubbo.consumer +func (Config) Prefix() string { + return constant.ConsumerConfigPrefix +} + +// SetConsumerConfig sets consumerConfig by @c +//func SetConsumerConfig(c Config) { +// config.consumerConfig = &c +//} + +// ConsumerInit loads config file to init consumer config +func ConsumerInit(confConFile string) error { + //if confConFile == "" { + // return perrors.Errorf("application configure(consumer) file name is nil") + //} + //consumerConfig = &Config{} + //fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) + //if err != nil { + // return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) + //} + //consumerConfig.fileStream = bytes.NewBuffer(fileStream) + //// set method interfaceId & interfaceName + //for k, v := range consumerConfig.References { + // // set id for reference + // for _, n := range consumerConfig.References[k].Methods { + // n.InterfaceName = v.InterfaceName + // n.InterfaceId = k + // } + //} + //if consumerConfig.Request_Timeout != "" { + // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) + // } + // if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) { + // return perrors.WithMessagef(err, "request_timeout %s should be less than %s", + // consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan)) + // } + //} + //if consumerConfig.Connect_Timeout != "" { + // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) + // } + //} + // + //logger.Debugf("consumer config{%#v}\n", consumerConfig) + + return nil +} + +func configCenterRefreshConsumer() error { + //// fresh it + //var err error + //if consumerConfig.Request_Timeout != "" { + // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) + // } + //} + //if consumerConfig.Connect_Timeout != "" { + // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) + // } + //} + //if consumerConfig.ConfigCenterConfig != nil { + // consumerConfig.SetFatherConfig(consumerConfig) + // if err = consumerConfig.startConfigCenter((*consumerConfig).BaseConfig); err != nil { + // return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) + // } + // consumerConfig.fresh() + //} + return nil +} diff --git a/config/consumer_config.go b/config/consumer_config.go deleted file mode 100644 index e3c0e0adf9..0000000000 --- a/config/consumer_config.go +++ /dev/null @@ -1,143 +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 config - -import ( - "bytes" - "time" -) - -import ( - "github.com/creasty/defaults" - perrors "github.com/pkg/errors" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/yaml" -) - -const ( - MaxWheelTimeSpan = 900e9 // 900s, 15 minute -) - -// ConsumerConfig is Consumer default configuration -type ConsumerConfig struct { - BaseConfig `yaml:",inline" property:"base"` - configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - // client - Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` - ConnectTimeout time.Duration - - Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` - - Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` - RequestTimeout time.Duration - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Check *bool `yaml:"check" json:"check,omitempty" property:"check"` - - References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` -} - -// UnmarshalYAML unmarshals the ConsumerConfig by @unmarshal function -func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ConsumerConfig - return unmarshal((*plain)(c)) -} - -// nolint -func (*ConsumerConfig) Prefix() string { - return constant.ConsumerConfigPrefix -} - -// SetConsumerConfig sets consumerConfig by @c -func SetConsumerConfig(c ConsumerConfig) { - consumerConfig = &c -} - -// ConsumerInit loads config file to init consumer config -func ConsumerInit(confConFile string) error { - if confConFile == "" { - return perrors.Errorf("application configure(consumer) file name is nil") - } - consumerConfig = &ConsumerConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - } - consumerConfig.fileStream = bytes.NewBuffer(fileStream) - // set method interfaceId & interfaceName - for k, v := range consumerConfig.References { - // set id for reference - for _, n := range consumerConfig.References[k].Methods { - n.InterfaceName = v.InterfaceName - n.InterfaceId = k - } - } - if consumerConfig.Request_Timeout != "" { - if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) - } - if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) { - return perrors.WithMessagef(err, "request_timeout %s should be less than %s", - consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan)) - } - } - if consumerConfig.Connect_Timeout != "" { - if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) - } - } - - logger.Debugf("consumer config{%#v}\n", consumerConfig) - - return nil -} - -func configCenterRefreshConsumer() error { - // fresh it - var err error - if consumerConfig.Request_Timeout != "" { - if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) - } - } - if consumerConfig.Connect_Timeout != "" { - if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) - } - } - if consumerConfig.ConfigCenterConfig != nil { - consumerConfig.SetFatherConfig(consumerConfig) - if err = consumerConfig.startConfigCenter((*consumerConfig).BaseConfig); err != nil { - return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) - } - consumerConfig.fresh() - } - return nil -} diff --git a/config/generic_service.go b/config/generic/generic_service.go similarity index 98% rename from config/generic_service.go rename to config/generic/generic_service.go index a3332afe04..34f2f7d359 100644 --- a/config/generic_service.go +++ b/config/generic/generic_service.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package generic import "context" diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go deleted file mode 100644 index c30f6eabb6..0000000000 --- a/config/graceful_shutdown_test.go +++ /dev/null @@ -1,108 +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 config - -import ( - "testing" -) - -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.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - GracefulShutdownInit() -} - -func TestBeforeShutdown(t *testing.T) { - extension.SetProtocol("registry", func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - extension.SetProtocol(constant.DUBBO, func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - - extension.SetProtocol("mock", func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - - consumerReferences := map[string]*ReferenceConfig{} - consumerReferences[constant.DUBBO] = &ReferenceConfig{ - Protocol: constant.DUBBO, - } - - // without configuration - consumerConfig = nil - providerConfig = nil - BeforeShutdown() - - consumerConfig = &ConsumerConfig{ - References: consumerReferences, - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "1s", - }, - } - - providerProtocols := map[string]*ProtocolConfig{} - providerProtocols[constant.DUBBO] = &ProtocolConfig{ - Name: constant.DUBBO, - } - - providerProtocols["mock"] = &ProtocolConfig{ - Name: "mock", - } - - providerConfig = &ProviderConfig{ - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "1s", - }, - Protocols: providerProtocols, - } - // test destroy protocol - BeforeShutdown() - - providerConfig = &ProviderConfig{ - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "-1s", - }, - Protocols: providerProtocols, - } - - consumerConfig = &ConsumerConfig{ - References: consumerReferences, - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "-1s", - }, - } - - // test ignore steps - BeforeShutdown() -} diff --git a/config/service.go b/config/instance/service.go similarity index 99% rename from config/service.go rename to config/instance/service.go index 12cc91e90b..1c8737548f 100644 --- a/config/service.go +++ b/config/instance/service.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package instance import ( "dubbo.apache.org/dubbo-go/v3/common" diff --git a/config/metadata_report_config.go b/config/medadata/report/metadata_report_config.go similarity index 65% rename from config/metadata_report_config.go rename to config/medadata/report/metadata_report_config.go index 050339af7c..4f904d1c58 100644 --- a/config/metadata_report_config.go +++ b/config/medadata/report/metadata_report_config.go @@ -15,11 +15,7 @@ * limitations under the License. */ -package config - -import ( - "net/url" -) +package report import ( "github.com/creasty/defaults" @@ -32,25 +28,25 @@ import ( "dubbo.apache.org/dubbo-go/v3/config/instance" ) -// MethodConfig is method level configuration -type MetadataReportConfig struct { +// Config is method level configuration +type Config struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` RemoteRef string `required:"true" yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` Group string `yaml:"group" json:"group,omitempty" property:"group"` } -// nolint -func (c *MetadataReportConfig) Prefix() string { +// Prefix dubbo.metadata-report +func (Config) Prefix() string { return constant.MetadataReportPrefix } -// UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function -func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the Config by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return perrors.WithStack(err) } - type plain MetadataReportConfig + type plain Config if err := unmarshal((*plain)(c)); err != nil { return perrors.WithStack(err) } @@ -58,41 +54,41 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) } // nolint -func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { - urlMap := make(url.Values) - - if c.Params != nil { - for k, v := range c.Params { - urlMap.Set(k, v) - } - } - - rc, ok := GetBaseConfig().GetRemoteConfig(c.RemoteRef) - - if !ok { - return nil, perrors.New("Could not find out the remote ref config, name: " + c.RemoteRef) - } - - res, err := common.NewURL(rc.Address, - common.WithParams(urlMap), - common.WithUsername(rc.Username), - common.WithPassword(rc.Password), - common.WithLocation(rc.Address), - common.WithProtocol(c.Protocol), - ) - if err != nil || len(res.Protocol) == 0 { - return nil, perrors.New("Invalid MetadataReportConfig.") - } - res.SetParam("metadata", res.Protocol) - return res, nil +func (c *Config) ToUrl() (*common.URL, error) { + //urlMap := make(url.Values) + + //if c.Params != nil { + // for k, v := range c.Params { + // urlMap.Set(k, v) + // } + //} + // + //rc, ok := config.GetBaseConfig().GetRemoteConfig(c.RemoteRef) + // + //if !ok { + // return nil, perrors.New("Could not find out the remote ref config, name: " + c.RemoteRef) + //} + // + //res, err := common.NewURL(rc.Address, + // common.WithParams(urlMap), + // common.WithUsername(rc.Username), + // common.WithPassword(rc.Password), + // common.WithLocation(rc.Address), + // common.WithProtocol(c.Protocol), + //) + //if err != nil || len(res.Protocol) == 0 { + // return nil, perrors.New("Invalid Config.") + //} + //res.SetParam("metadata", res.Protocol) + return nil, nil } -func (c *MetadataReportConfig) IsValid() bool { +func (c *Config) IsValid() bool { return len(c.Protocol) != 0 } // StartMetadataReport: The entry of metadata report start -func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { +func startMetadataReport(metadataType string, metadataReportConfig *Config) error { if metadataReportConfig == nil || !metadataReportConfig.IsValid() { return nil } diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go deleted file mode 100644 index 46b7f83b3b..0000000000 --- a/config/metadata_report_config_test.go +++ /dev/null @@ -1,52 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestMetadataReportConfig_ToUrl(t *testing.T) { - GetBaseConfig().Remotes["mock"] = &RemoteConfig{ - Address: "127.0.0.1:2181", - Username: "test", - Password: "test", - TimeoutStr: "3s", - } - metadataReportConfig := MetadataReportConfig{ - Protocol: "mock", - RemoteRef: "mock", - Params: map[string]string{ - "k": "v", - }, - } - url, err := metadataReportConfig.ToUrl() - assert.NoError(t, err) - assert.Equal(t, "mock", url.Protocol) - assert.Equal(t, "127.0.0.1:2181", url.Location) - assert.Equal(t, "127.0.0.1", url.Ip) - assert.Equal(t, "2181", url.Port) - assert.Equal(t, "test", url.Username) - assert.Equal(t, "test", url.Password) - assert.Equal(t, "v", url.GetParam("k", "")) - assert.Equal(t, "mock", url.GetParam("metadata", "")) -} diff --git a/config/method_config.go b/config/method/method_config.go similarity index 99% rename from config/method_config.go rename to config/method/method_config.go index e76cf7cdc4..dc441ef7da 100644 --- a/config/method_config.go +++ b/config/method/method_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package method import ( "github.com/creasty/defaults" diff --git a/config/metric_config.go b/config/metric/metric_config.go similarity index 98% rename from config/metric_config.go rename to config/metric/metric_config.go index 9af1691dad..3091b7f0ea 100644 --- a/config/metric_config.go +++ b/config/metric/metric_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package metric var defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000} diff --git a/config/metric_config_test.go b/config/metric/metric_config_test.go similarity index 91% rename from config/metric_config_test.go rename to config/metric/metric_config_test.go index fe9d2493f3..30a1a476ad 100644 --- a/config/metric_config_test.go +++ b/config/metric/metric_config_test.go @@ -15,9 +15,10 @@ * limitations under the License. */ -package config +package metric import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +27,6 @@ import ( ) func TestGetMetricConfig(t *testing.T) { - empty := GetMetricConfig() + empty := config.GetMetricConfig() assert.NotNil(t, empty) } diff --git a/config/protocol_config.go b/config/protocol/protocol_config.go similarity index 98% rename from config/protocol_config.go rename to config/protocol/protocol_config.go index 92e93f11bc..cd02b0970e 100644 --- a/config/protocol_config.go +++ b/config/protocol/protocol_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package protocol import ( "strings" diff --git a/config/provider/provider_config.go b/config/provider/provider_config.go new file mode 100644 index 0000000000..710923e3f7 --- /dev/null +++ b/config/provider/provider_config.go @@ -0,0 +1,105 @@ +/* + * 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 provider + +import ( + "dubbo.apache.org/dubbo-go/v3/config/protocol" + "dubbo.apache.org/dubbo-go/v3/config/registry" + "dubbo.apache.org/dubbo-go/v3/config/service" + "dubbo.apache.org/dubbo-go/v3/config/shutdown" +) + +import ( + "github.com/creasty/defaults" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + +// ProviderConfig is the default configuration of service provider +type ProviderConfig struct { + //base.Config `yaml:",inline" property:"base"` + //center.configCenter `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + Services map[string]*service.Config `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*protocol.ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *shutdown.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + + Registry *registry.RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries map[string]*registry.RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` +} + +// UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function +func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err + } + type plain ProviderConfig + return unmarshal((*plain)(c)) +} + +// nolint +func (*ProviderConfig) Prefix() string { + return constant.ProviderConfigPrefix +} + +//// SetProviderConfig sets provider config by @p +//func SetProviderConfig(p ProviderConfig) { +// config.providerConfig = &p +//} +// +//// ProviderInit loads config file to init provider config +//func ProviderInit(confProFile string) error { +// if len(confProFile) == 0 { +// return perrors.Errorf("application configure(provider) file name is nil") +// } +// config.providerConfig = &ProviderConfig{} +// fileStream, err := yaml.UnmarshalYMLConfig(confProFile, config.providerConfig) +// if err != nil { +// return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) +// } +// +// config.providerConfig.fileStream = bytes.NewBuffer(fileStream) +// // set method interfaceId & interfaceName +// for k, v := range config.providerConfig.Services { +// // set id for reference +// for _, n := range config.providerConfig.Services[k].Methods { +// n.InterfaceName = v.InterfaceName +// n.InterfaceId = k +// } +// } +// +// return nil +//} +// +//func configCenterRefreshProvider() error { +// // fresh it +// if config.providerConfig.ConfigCenterConfig != nil { +// config.providerConfig.fatherConfig = config.providerConfig +// if err := config.providerConfig.startConfigCenter((*config.providerConfig).BaseConfig); err != nil { +// return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) +// } +// config.providerConfig.fresh() +// } +// return nil +//} diff --git a/config/provider/provider_config_test.go b/config/provider/provider_config_test.go new file mode 100644 index 0000000000..85c79539a3 --- /dev/null +++ b/config/provider/provider_config_test.go @@ -0,0 +1,52 @@ +/* + * 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 provider + +//import ( +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "path/filepath" +// "testing" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//func TestConsumerInit(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// assert.NoError(t, consumer.ConsumerInit(conPath)) +// assert.Equal(t, "default", config.consumerConfig.ProxyFactory) +// assert.Equal(t, "dubbo.properties", config.consumerConfig.ConfigCenterConfig.ConfigFile) +// assert.Equal(t, "100ms", config.consumerConfig.Connect_Timeout) +//} +// +//func TestConsumerInitWithDefaultProtocol(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/consumer_config_withoutProtocol.yml") +// assert.NoError(t, err) +// assert.NoError(t, consumer.ConsumerInit(conPath)) +// assert.Equal(t, "dubbo", config.consumerConfig.References["UserProvider"].Protocol) +//} +// +//func TestProviderInitWithDefaultProtocol(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/provider_config_withoutProtocol.yml") +// assert.NoError(t, err) +// assert.NoError(t, ProviderInit(conPath)) +// assert.Equal(t, "dubbo", config.providerConfig.Services["UserProvider"].Protocol) +//} diff --git a/config/provider_config.go b/config/provider_config.go deleted file mode 100644 index 8f1b562477..0000000000 --- a/config/provider_config.go +++ /dev/null @@ -1,104 +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 config - -import ( - "bytes" -) - -import ( - "github.com/creasty/defaults" - perrors "github.com/pkg/errors" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/yaml" -) - -// ProviderConfig is the default configuration of service provider -type ProviderConfig struct { - BaseConfig `yaml:",inline" property:"base"` - configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` - - Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` -} - -// UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ProviderConfig - return unmarshal((*plain)(c)) -} - -// nolint -func (*ProviderConfig) Prefix() string { - return constant.ProviderConfigPrefix -} - -// SetProviderConfig sets provider config by @p -func SetProviderConfig(p ProviderConfig) { - providerConfig = &p -} - -// ProviderInit loads config file to init provider config -func ProviderInit(confProFile string) error { - if len(confProFile) == 0 { - return perrors.Errorf("application configure(provider) file name is nil") - } - providerConfig = &ProviderConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - } - - providerConfig.fileStream = bytes.NewBuffer(fileStream) - // set method interfaceId & interfaceName - for k, v := range providerConfig.Services { - // set id for reference - for _, n := range providerConfig.Services[k].Methods { - n.InterfaceName = v.InterfaceName - n.InterfaceId = k - } - } - - return nil -} - -func configCenterRefreshProvider() error { - // fresh it - if providerConfig.ConfigCenterConfig != nil { - providerConfig.fatherConfig = providerConfig - if err := providerConfig.startConfigCenter((*providerConfig).BaseConfig); err != nil { - return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) - } - providerConfig.fresh() - } - return nil -} diff --git a/config/provider_config_test.go b/config/provider_config_test.go deleted file mode 100644 index e8a9c1f7a7..0000000000 --- a/config/provider_config_test.go +++ /dev/null @@ -1,50 +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 config - -import ( - "path/filepath" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestConsumerInit(t *testing.T) { - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - assert.NoError(t, ConsumerInit(conPath)) - assert.Equal(t, "default", consumerConfig.ProxyFactory) - assert.Equal(t, "dubbo.properties", consumerConfig.ConfigCenterConfig.ConfigFile) - assert.Equal(t, "100ms", consumerConfig.Connect_Timeout) -} - -func TestConsumerInitWithDefaultProtocol(t *testing.T) { - conPath, err := filepath.Abs("./testdata/consumer_config_withoutProtocol.yml") - assert.NoError(t, err) - assert.NoError(t, ConsumerInit(conPath)) - assert.Equal(t, "dubbo", consumerConfig.References["UserProvider"].Protocol) -} - -func TestProviderInitWithDefaultProtocol(t *testing.T) { - conPath, err := filepath.Abs("./testdata/provider_config_withoutProtocol.yml") - assert.NoError(t, err) - assert.NoError(t, ProviderInit(conPath)) - assert.Equal(t, "dubbo", providerConfig.Services["UserProvider"].Protocol) -} diff --git a/config/reference/reference_config.go b/config/reference/reference_config.go new file mode 100644 index 0000000000..bf9efbf8a2 --- /dev/null +++ b/config/reference/reference_config.go @@ -0,0 +1,295 @@ +/* + * 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 reference + +import ( + "dubbo.apache.org/dubbo-go/v3/config/method" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/proxy" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +// ReferenceConfig is the configuration of service consumer +type ReferenceConfig struct { + pxy *proxy.Proxy + id string + InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` + Check *bool `yaml:"check" json:"check,omitempty" property:"check"` + URL string `yaml:"url" json:"url,omitempty" property:"url"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` + Methods []*method.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` + Async bool `yaml:"async" json:"async,omitempty" property:"async"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + invoker protocol.Invoker + urls []*common.URL + Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` + Sticky bool `yaml:"sticky" json:"sticky,omitempty" property:"sticky"` + RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` + ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` +} + +//// nolint +//func (c *ReferenceConfig) Prefix() string { +// return constant.ReferenceConfigPrefix + c.InterfaceName + "." +//} +// +//// NewReferenceConfig The only way to get a new ReferenceConfig +//func NewReferenceConfig(id string) *ReferenceConfig { +// return &ReferenceConfig{id: id} +//} +// +//// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function +//func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// type rf ReferenceConfig +// raw := rf{} // Put your defaults here +// if err := unmarshal(&raw); err != nil { +// return err +// } +// +// *c = ReferenceConfig(raw) +// return defaults.Set(c) +//} + +// Refer ... +//func (c *ReferenceConfig) Refer(_ interface{}) { +// cfgURL := common.NewURLWithOptions( +// common.WithPath(c.InterfaceName), +// common.WithProtocol(c.Protocol), +// common.WithParams(c.getURLMap()), +// common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), +// ) +// if c.ForceTag { +// cfgURL.AddParam(constant.ForceUseTag, "true") +// } +// c.postProcessConfig(cfgURL) +// if c.URL != "" { +// // 1. user specified URL, could be peer-to-peer address, or register center's address. +// urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*") +// for _, urlStr := range urlStrings { +// serviceURL, err := common.NewURL(urlStr) +// if err != nil { +// panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) +// } +// if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { +// serviceURL.SubURL = cfgURL +// c.urls = append(c.urls, serviceURL) +// } else { +// if serviceURL.Path == "" { +// serviceURL.Path = "/" + c.InterfaceName +// } +// // merge url need to do +// newURL := common.MergeURL(serviceURL, cfgURL) +// c.urls = append(c.urls, newURL) +// } +// } +// } else { +// // 2. assemble SubURL from register center's configuration mode +// c.urls = registry.loadRegistries(c.Registry, config.consumerConfig.Registries, common.CONSUMER) +// +// // set url to regURLs +// for _, regURL := range c.urls { +// regURL.SubURL = cfgURL +// } +// } +// +// if len(c.urls) == 1 { +// c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) +// // c.URL != "" is direct call +// if c.URL != "" { +// //filter +// c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY) +// +// // cluster +// invokers := make([]protocol.Invoker, 0, len(c.urls)) +// invokers = append(invokers, c.invoker) +// // TODO(decouple from directory, config should not depend on directory module) +// var hitClu string +// // not a registry url, must be direct invoke. +// hitClu = constant.FAILOVER_CLUSTER_NAME +// if len(invokers) > 0 { +// u := invokers[0].GetURL() +// if nil != &u { +// hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) +// } +// } +// +// cluster := extension.GetCluster(hitClu) +// // If 'zone-aware' policy select, the invoker wrap sequence would be: +// // ZoneAwareClusterInvoker(StaticDirectory) -> +// // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker +// c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) +// } +// } else { +// invokers := make([]protocol.Invoker, 0, len(c.urls)) +// var regURL *common.URL +// for _, u := range c.urls { +// invoker := extension.GetProtocol(u.Protocol).Refer(u) +// // c.URL != "" is direct call +// if c.URL != "" { +// //filter +// invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) +// } +// invokers = append(invokers, invoker) +// if u.Protocol == constant.REGISTRY_PROTOCOL { +// regURL = u +// } +// } +// +// // TODO(decouple from directory, config should not depend on directory module) +// var hitClu string +// if regURL != nil { +// // for multi-subscription scenario, use 'zone-aware' policy by default +// hitClu = constant.ZONEAWARE_CLUSTER_NAME +// } else { +// // not a registry url, must be direct invoke. +// hitClu = constant.FAILOVER_CLUSTER_NAME +// if len(invokers) > 0 { +// u := invokers[0].GetURL() +// if nil != &u { +// hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) +// } +// } +// } +// +// cluster := extension.GetCluster(hitClu) +// // If 'zone-aware' policy select, the invoker wrap sequence would be: +// // ZoneAwareClusterInvoker(StaticDirectory) -> +// // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker +// c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) +// } +// // publish consumer metadata +// publishConsumerDefinition(cfgURL) +// // create proxy +// if c.Async { +// callback := instance.GetCallback(c.id) +// c.pxy = extension.GetProxyFactory(config.consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) +// } else { +// c.pxy = extension.GetProxyFactory(config.consumerConfig.ProxyFactory).GetProxy(c.invoker, cfgURL) +// } +//} +// +//// Implement +//// @v is service provider implemented RPCService +//func (c *ReferenceConfig) Implement(v common.RPCService) { +// c.pxy.Implement(v) +//} +// +//// GetRPCService gets RPCService from proxy +//func (c *ReferenceConfig) GetRPCService() common.RPCService { +// return c.pxy.Get() +//} +// +//// GetProxy gets proxy +//func (c *ReferenceConfig) GetProxy() *proxy.Proxy { +// return c.pxy +//} +// +//func (c *ReferenceConfig) getURLMap() url.Values { +// urlMap := url.Values{} +// // first set user params +// for k, v := range c.Params { +// urlMap.Set(k, v) +// } +// urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) +// urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) +// urlMap.Set(constant.CLUSTER_KEY, c.Cluster) +// urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) +// urlMap.Set(constant.RETRIES_KEY, c.Retries) +// urlMap.Set(constant.GROUP_KEY, c.Group) +// urlMap.Set(constant.VERSION_KEY, c.Version) +// urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(c.Generic)) +// urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) +// urlMap.Set(constant.PROVIDED_BY, c.ProvidedBy) +// urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) +// +// urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) +// urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) +// +// if len(c.RequestTimeout) != 0 { +// urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout) +// } +// // getty invoke async or sync +// urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) +// urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) +// +// // application info +// urlMap.Set(constant.APPLICATION_KEY, config.consumerConfig.ApplicationConfig.Name) +// urlMap.Set(constant.ORGANIZATION_KEY, config.consumerConfig.ApplicationConfig.Organization) +// urlMap.Set(constant.NAME_KEY, config.consumerConfig.ApplicationConfig.Name) +// urlMap.Set(constant.MODULE_KEY, config.consumerConfig.ApplicationConfig.Module) +// urlMap.Set(constant.APP_VERSION_KEY, config.consumerConfig.ApplicationConfig.Version) +// urlMap.Set(constant.OWNER_KEY, config.consumerConfig.ApplicationConfig.Owner) +// urlMap.Set(constant.ENVIRONMENT_KEY, config.consumerConfig.ApplicationConfig.Environment) +// +// // filter +// defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS +// if c.Generic { +// defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter +// } +// urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) +// +// for _, v := range c.Methods { +// urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) +// urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) +// urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky)) +// if len(v.RequestTimeout) != 0 { +// urlMap.Set("methods."+v.Name+"."+constant.TIMEOUT_KEY, v.RequestTimeout) +// } +// } +// +// return urlMap +//} +// +//// GenericLoad ... +//func (c *ReferenceConfig) GenericLoad(id string) { +// genericService := generic.NewGenericService(c.id) +// instance.SetConsumerService(genericService) +// c.id = id +// c.Refer(genericService) +// c.Implement(genericService) +//} +// +//// GetInvoker get invoker from ReferenceConfig +//func (c *ReferenceConfig) GetInvoker() protocol.Invoker { +// return c.invoker +//} +// +//func publishConsumerDefinition(url *common.URL) { +// if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { +// remoteMetadataService.PublishServiceDefinition(url) +// } +//} +// +//// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. +//func (c *ReferenceConfig) postProcessConfig(url *common.URL) { +// for _, p := range extension.GetConfigPostProcessors() { +// p.PostProcessReferenceConfig(url) +// } +//} diff --git a/config/reference/reference_config_test.go b/config/reference/reference_config_test.go new file mode 100644 index 0000000000..62eab977b6 --- /dev/null +++ b/config/reference/reference_config_test.go @@ -0,0 +1,411 @@ +/* + * 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 reference + +//import ( +// "context" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/application" +// "dubbo.apache.org/dubbo-go/v3/config/base" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "dubbo.apache.org/dubbo-go/v3/config/instance" +// "dubbo.apache.org/dubbo-go/v3/config/method" +// registry2 "dubbo.apache.org/dubbo-go/v3/config/registry" +// "sync" +// "testing" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" +// "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/filter" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/registry" +//) +// +//var regProtocol protocol.Protocol +// +//func doInitConsumer() { +// config.consumerConfig = &consumer.Config{ +// BaseConfig: base.Config{ +// application.Config: &application.Config{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "2.6.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registries: map[string]*registry2.RegistryConfig{ +// "shanghai_reg1": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "shanghai_idc", +// Address: "127.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "shanghai_reg2": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "shanghai_idc", +// Address: "127.0.0.2:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "hangzhou_reg1": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "hangzhou_idc", +// Address: "127.0.0.3:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "hangzhou_reg2": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "hangzhou_idc", +// Address: "127.0.0.4:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// }, +// +// References: map[string]*ReferenceConfig{ +// "MockService": { +// id: "MockProvider", +// Params: map[string]string{ +// "serviceid": "soa.mock", +// "forks": "5", +// }, +// Sticky: false, +// Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// Sticky: true, +// }, +// }, +// }, +// }, +// } +//} +// +//var mockProvider = new(MockProvider) +// +//type MockProvider struct{} +// +//func (m *MockProvider) Reference() string { +// return "MockProvider" +//} +// +//func (m *MockProvider) CallBack(res common.CallbackResponse) { +// // CallBack is a mock function. to implement the interface +//} +// +//func doInitConsumerAsync() { +// doInitConsumer() +// instance.SetConsumerService(mockProvider) +// for _, v := range config.consumerConfig.References { +// v.Async = true +// } +//} +// +//func doInitConsumerWithSingleRegistry() { +// config.consumerConfig = &consumer.Config{ +// BaseConfig: base.Config{ +// application.Config: &application.Config{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "2.6.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registry: ®istry2.RegistryConfig{ +// Address: "mock://27.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// Registries: map[string]*registry2.RegistryConfig{}, +// +// References: map[string]*ReferenceConfig{ +// "MockService": { +// Params: map[string]string{ +// "serviceid": "soa.mock", +// "forks": "5", +// }, +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// }, +// }, +// }, +// }, +// } +//} +// +//func TestReferMultiReg(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestRefer(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.Equal(t, "soa.mock", reference.Params["serviceid"]) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferAsync(t *testing.T) { +// doInitConsumerAsync() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.Equal(t, "soa.mock", reference.Params["serviceid"]) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// assert.NotNil(t, reference.pxy.GetCallback()) +// } +// config.consumerConfig = nil +//} +// +//func TestReferP2P(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferMultiP2P(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferMultiP2PWithReg(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestImplement(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// reference.Implement(&config.MockService{}) +// assert.NotNil(t, reference.GetRPCService()) +// +// } +// config.consumerConfig = nil +//} +// +//func TestForking(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// forks := int(reference.invoker.GetURL().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) +// assert.Equal(t, 5, forks) +// assert.NotNil(t, reference.pxy) +// assert.NotNil(t, reference.Cluster) +// } +// config.consumerConfig = nil +//} +// +//func TestSticky(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// reference := config.consumerConfig.References["MockService"] +// reference.Refer(nil) +// referenceSticky := reference.invoker.GetURL().GetParam(constant.STICKY_KEY, "false") +// assert.Equal(t, "false", referenceSticky) +// +// method0StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false") +// assert.Equal(t, "false", method0StickKey) +// method1StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false") +// assert.Equal(t, "true", method1StickKey) +//} +// +//func GetProtocol() protocol.Protocol { +// if regProtocol != nil { +// return regProtocol +// } +// return newRegistryProtocol() +//} +// +//func newRegistryProtocol() protocol.Protocol { +// return &mockRegistryProtocol{} +//} +// +//type mockRegistryProtocol struct { +//} +// +//func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { +// return protocol.NewBaseInvoker(url) +//} +// +//func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { +// registryURL := getRegistryURL(invoker) +// if registryURL.Protocol == "service-discovery" { +// metaDataService, err := extension.GetLocalMetadataService("") +// if err != nil { +// panic(err) +// } +// ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone()) +// if err != nil { +// panic(err) +// } +// if !ok { +// panic("The URL has been registry!") +// } +// } +// return protocol.NewBaseExporter("test", invoker, &sync.Map{}) +//} +// +//func (*mockRegistryProtocol) Destroy() { +// // Destroy is a mock function +//} +// +//func getRegistryURL(invoker protocol.Invoker) *common.URL { +// // here add * for return a new url +// url := invoker.GetURL() +// // if the protocol == registry ,set protocol the registry value in url.params +// if url.Protocol == constant.REGISTRY_PROTOCOL { +// protocol := url.GetParam(constant.REGISTRY_KEY, "") +// url.Protocol = protocol +// } +// return url +//} +// +//func (p *mockRegistryProtocol) GetRegistries() []registry.Registry { +// return []registry.Registry{&config.mockServiceDiscoveryRegistry{}} +//} +// +//func mockFilter() { +// consumerFiler := &mockShutdownFilter{} +// extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { +// return consumerFiler +// }) +//} +// +//type mockShutdownFilter struct { +//} +// +//// Invoke adds the requests count and block the new requests if application is closing +//func (gf *mockShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +// return invoker.Invoke(ctx, invocation) +//} +// +//// OnResponse reduces the number of active processes then return the process result +//func (gf *mockShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +// return result +//} diff --git a/config/reference_config.go b/config/reference_config.go deleted file mode 100644 index ff5f6b6ab9..0000000000 --- a/config/reference_config.go +++ /dev/null @@ -1,307 +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 config - -import ( - "fmt" - "net/url" - "strconv" - "time" -) - -import ( - "github.com/creasty/defaults" - gxstrings "github.com/dubbogo/gost/strings" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "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/proxy" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" -) - -// ReferenceConfig is the configuration of service consumer -type ReferenceConfig struct { - pxy *proxy.Proxy - id string - InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Check *bool `yaml:"check" json:"check,omitempty" property:"check"` - URL string `yaml:"url" json:"url,omitempty" property:"url"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` - Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` - Async bool `yaml:"async" json:"async,omitempty" property:"async"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - invoker protocol.Invoker - urls []*common.URL - Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` - Sticky bool `yaml:"sticky" json:"sticky,omitempty" property:"sticky"` - RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` - ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` -} - -// nolint -func (c *ReferenceConfig) Prefix() string { - return constant.ReferenceConfigPrefix + c.InterfaceName + "." -} - -// NewReferenceConfig The only way to get a new ReferenceConfig -func NewReferenceConfig(id string) *ReferenceConfig { - return &ReferenceConfig{id: id} -} - -// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function -func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - type rf ReferenceConfig - raw := rf{} // Put your defaults here - if err := unmarshal(&raw); err != nil { - return err - } - - *c = ReferenceConfig(raw) - return defaults.Set(c) -} - -// Refer ... -func (c *ReferenceConfig) Refer(_ interface{}) { - cfgURL := common.NewURLWithOptions( - common.WithPath(c.InterfaceName), - common.WithProtocol(c.Protocol), - common.WithParams(c.getURLMap()), - common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), - ) - if c.ForceTag { - cfgURL.AddParam(constant.ForceUseTag, "true") - } - c.postProcessConfig(cfgURL) - if c.URL != "" { - // 1. user specified URL, could be peer-to-peer address, or register center's address. - urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*") - for _, urlStr := range urlStrings { - serviceURL, err := common.NewURL(urlStr) - if err != nil { - panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) - } - if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { - serviceURL.SubURL = cfgURL - c.urls = append(c.urls, serviceURL) - } else { - if serviceURL.Path == "" { - serviceURL.Path = "/" + c.InterfaceName - } - // merge url need to do - newURL := common.MergeURL(serviceURL, cfgURL) - c.urls = append(c.urls, newURL) - } - } - } else { - // 2. assemble SubURL from register center's configuration mode - c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER) - - // set url to regURLs - for _, regURL := range c.urls { - regURL.SubURL = cfgURL - } - } - - if len(c.urls) == 1 { - c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) - // c.URL != "" is direct call - if c.URL != "" { - //filter - c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY) - - // cluster - invokers := make([]protocol.Invoker, 0, len(c.urls)) - invokers = append(invokers, c.invoker) - // TODO(decouple from directory, config should not depend on directory module) - var hitClu string - // not a registry url, must be direct invoke. - hitClu = constant.FAILOVER_CLUSTER_NAME - if len(invokers) > 0 { - u := invokers[0].GetURL() - if nil != &u { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) - } - } - - cluster := extension.GetCluster(hitClu) - // If 'zone-aware' policy select, the invoker wrap sequence would be: - // ZoneAwareClusterInvoker(StaticDirectory) -> - // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) - } - } else { - invokers := make([]protocol.Invoker, 0, len(c.urls)) - var regURL *common.URL - for _, u := range c.urls { - invoker := extension.GetProtocol(u.Protocol).Refer(u) - // c.URL != "" is direct call - if c.URL != "" { - //filter - invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) - } - invokers = append(invokers, invoker) - if u.Protocol == constant.REGISTRY_PROTOCOL { - regURL = u - } - } - - // TODO(decouple from directory, config should not depend on directory module) - var hitClu string - if regURL != nil { - // for multi-subscription scenario, use 'zone-aware' policy by default - hitClu = constant.ZONEAWARE_CLUSTER_NAME - } else { - // not a registry url, must be direct invoke. - hitClu = constant.FAILOVER_CLUSTER_NAME - if len(invokers) > 0 { - u := invokers[0].GetURL() - if nil != &u { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) - } - } - } - - cluster := extension.GetCluster(hitClu) - // If 'zone-aware' policy select, the invoker wrap sequence would be: - // ZoneAwareClusterInvoker(StaticDirectory) -> - // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) - } - // publish consumer metadata - publishConsumerDefinition(cfgURL) - // create proxy - if c.Async { - callback := GetCallback(c.id) - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) - } else { - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetProxy(c.invoker, cfgURL) - } -} - -// Implement -// @v is service provider implemented RPCService -func (c *ReferenceConfig) Implement(v common.RPCService) { - c.pxy.Implement(v) -} - -// GetRPCService gets RPCService from proxy -func (c *ReferenceConfig) GetRPCService() common.RPCService { - return c.pxy.Get() -} - -// GetProxy gets proxy -func (c *ReferenceConfig) GetProxy() *proxy.Proxy { - return c.pxy -} - -func (c *ReferenceConfig) getURLMap() url.Values { - urlMap := url.Values{} - // first set user params - for k, v := range c.Params { - urlMap.Set(k, v) - } - urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) - urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) - urlMap.Set(constant.CLUSTER_KEY, c.Cluster) - urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) - urlMap.Set(constant.RETRIES_KEY, c.Retries) - urlMap.Set(constant.GROUP_KEY, c.Group) - urlMap.Set(constant.VERSION_KEY, c.Version) - urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(c.Generic)) - urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) - urlMap.Set(constant.PROVIDED_BY, c.ProvidedBy) - urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) - - urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) - urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) - - if len(c.RequestTimeout) != 0 { - urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout) - } - // getty invoke async or sync - urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) - urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) - - // application info - urlMap.Set(constant.APPLICATION_KEY, consumerConfig.ApplicationConfig.Name) - urlMap.Set(constant.ORGANIZATION_KEY, consumerConfig.ApplicationConfig.Organization) - urlMap.Set(constant.NAME_KEY, consumerConfig.ApplicationConfig.Name) - urlMap.Set(constant.MODULE_KEY, consumerConfig.ApplicationConfig.Module) - urlMap.Set(constant.APP_VERSION_KEY, consumerConfig.ApplicationConfig.Version) - urlMap.Set(constant.OWNER_KEY, consumerConfig.ApplicationConfig.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, consumerConfig.ApplicationConfig.Environment) - - // filter - defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS - if c.Generic { - defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter - } - urlMap.Set(constant.REFERENCE_FILTER_KEY, mergeValue(consumerConfig.Filter, c.Filter, defaultReferenceFilter)) - - for _, v := range c.Methods { - urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) - urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) - urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky)) - if len(v.RequestTimeout) != 0 { - urlMap.Set("methods."+v.Name+"."+constant.TIMEOUT_KEY, v.RequestTimeout) - } - } - - return urlMap -} - -// GenericLoad ... -func (c *ReferenceConfig) GenericLoad(id string) { - genericService := NewGenericService(c.id) - SetConsumerService(genericService) - c.id = id - c.Refer(genericService) - c.Implement(genericService) -} - -// GetInvoker get invoker from ReferenceConfig -func (c *ReferenceConfig) GetInvoker() protocol.Invoker { - return c.invoker -} - -func publishConsumerDefinition(url *common.URL) { - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { - remoteMetadataService.PublishServiceDefinition(url) - } -} - -// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. -func (c *ReferenceConfig) postProcessConfig(url *common.URL) { - for _, p := range extension.GetConfigPostProcessors() { - p.PostProcessReferenceConfig(url) - } -} diff --git a/config/reference_config_test.go b/config/reference_config_test.go deleted file mode 100644 index fc76f1dbce..0000000000 --- a/config/reference_config_test.go +++ /dev/null @@ -1,404 +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 config - -import ( - "context" - "sync" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - "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/filter" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -var regProtocol protocol.Protocol - -func doInitConsumer() { - consumerConfig = &ConsumerConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registries: map[string]*RegistryConfig{ - "shanghai_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, - }, - - References: map[string]*ReferenceConfig{ - "MockService": { - id: "MockProvider", - Params: map[string]string{ - "serviceid": "soa.mock", - "forks": "5", - }, - Sticky: false, - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Sticky: true, - }, - }, - }, - }, - } -} - -var mockProvider = new(MockProvider) - -type MockProvider struct{} - -func (m *MockProvider) Reference() string { - return "MockProvider" -} - -func (m *MockProvider) CallBack(res common.CallbackResponse) { - // CallBack is a mock function. to implement the interface -} - -func doInitConsumerAsync() { - doInitConsumer() - SetConsumerService(mockProvider) - for _, v := range consumerConfig.References { - v.Async = true - } -} - -func doInitConsumerWithSingleRegistry() { - consumerConfig = &ConsumerConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &RegistryConfig{ - Address: "mock://27.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - Registries: map[string]*RegistryConfig{}, - - References: map[string]*ReferenceConfig{ - "MockService": { - Params: map[string]string{ - "serviceid": "soa.mock", - "forks": "5", - }, - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, - }, - } -} - -func TestReferMultiReg(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestRefer(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.Equal(t, "soa.mock", reference.Params["serviceid"]) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferAsync(t *testing.T) { - doInitConsumerAsync() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.Equal(t, "soa.mock", reference.Params["serviceid"]) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - assert.NotNil(t, reference.pxy.GetCallback()) - } - consumerConfig = nil -} - -func TestReferP2P(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferMultiP2P(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferMultiP2PWithReg(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestImplement(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - for _, reference := range consumerConfig.References { - reference.Refer(nil) - reference.Implement(&MockService{}) - assert.NotNil(t, reference.GetRPCService()) - - } - consumerConfig = nil -} - -func TestForking(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - forks := int(reference.invoker.GetURL().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) - assert.Equal(t, 5, forks) - assert.NotNil(t, reference.pxy) - assert.NotNil(t, reference.Cluster) - } - consumerConfig = nil -} - -func TestSticky(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - reference := consumerConfig.References["MockService"] - reference.Refer(nil) - referenceSticky := reference.invoker.GetURL().GetParam(constant.STICKY_KEY, "false") - assert.Equal(t, "false", referenceSticky) - - method0StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false") - assert.Equal(t, "false", method0StickKey) - method1StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false") - assert.Equal(t, "true", method1StickKey) -} - -func GetProtocol() protocol.Protocol { - if regProtocol != nil { - return regProtocol - } - return newRegistryProtocol() -} - -func newRegistryProtocol() protocol.Protocol { - return &mockRegistryProtocol{} -} - -type mockRegistryProtocol struct { -} - -func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { - return protocol.NewBaseInvoker(url) -} - -func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - registryURL := getRegistryURL(invoker) - if registryURL.Protocol == "service-discovery" { - metaDataService, err := extension.GetLocalMetadataService("") - if err != nil { - panic(err) - } - ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone()) - if err != nil { - panic(err) - } - if !ok { - panic("The URL has been registry!") - } - } - return protocol.NewBaseExporter("test", invoker, &sync.Map{}) -} - -func (*mockRegistryProtocol) Destroy() { - // Destroy is a mock function -} - -func getRegistryURL(invoker protocol.Invoker) *common.URL { - // here add * for return a new url - url := invoker.GetURL() - // if the protocol == registry ,set protocol the registry value in url.params - if url.Protocol == constant.REGISTRY_PROTOCOL { - protocol := url.GetParam(constant.REGISTRY_KEY, "") - url.Protocol = protocol - } - return url -} - -func (p *mockRegistryProtocol) GetRegistries() []registry.Registry { - return []registry.Registry{&mockServiceDiscoveryRegistry{}} -} - -func mockFilter() { - consumerFiler := &mockShutdownFilter{} - extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return consumerFiler - }) -} - -type mockShutdownFilter struct { -} - -// Invoke adds the requests count and block the new requests if application is closing -func (gf *mockShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - return invoker.Invoke(ctx, invocation) -} - -// OnResponse reduces the number of active processes then return the process result -func (gf *mockShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - return result -} diff --git a/config/registry_config.go b/config/registry/registry_config.go similarity index 99% rename from config/registry_config.go rename to config/registry/registry_config.go index 92d92a666d..37d48db605 100644 --- a/config/registry_config.go +++ b/config/registry/registry_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package registry import ( "net/url" diff --git a/config/registry_config_test.go b/config/registry/registry_config_test.go similarity index 99% rename from config/registry_config_test.go rename to config/registry/registry_config_test.go index 1ec85ca7d1..c156cf9875 100644 --- a/config/registry_config_test.go +++ b/config/registry/registry_config_test.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package config +package registry import ( "testing" diff --git a/config/root/root_config.go b/config/root/root_config.go new file mode 100644 index 0000000000..921dab76ab --- /dev/null +++ b/config/root/root_config.go @@ -0,0 +1,56 @@ +package root + +import ( + "bytes" +) + +import ( + "github.com/go-playground/validator/v10" + "github.com/knadh/koanf" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/center" + "dubbo.apache.org/dubbo-go/v3/config/medadata/report" + "dubbo.apache.org/dubbo-go/v3/config/metric" + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" +) + +// Config is the root config +type Config struct { + ConfigCenterConfig *center.Config `yaml:"config_center" json:"config_center,omitempty"` + + // since 1.5.0 version + //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + + ServiceDiscoveries map[string]*discovery.Config `yaml:"service_discovery" json:"service_discovery,omitempty" property:"service_discovery"` + + MetadataReportConfig *report.Config `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` + + // Application application config + Application *application.Config `yaml:"application" json:"application,omitempty" property:"application"` + + // prefix string + fatherConfig interface{} + EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` + MetricConfig *metric.MetricConfig `yaml:"metrics" json:"metrics,omitempty"` + fileStream *bytes.Buffer + + koanf *koanf.Koanf + // validate + Validate *validator.Validate + // cache file used to store the current used configurations. + CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` +} + +// Prefix dubbo +func (Config) Prefix() string { + return constant.DUBBO +} + +// SetKoanf set koanf +func (c *Config) SetKoanf(k *koanf.Koanf) { + c.koanf = k +} \ No newline at end of file diff --git a/config/router_config.go b/config/router/router_config.go similarity index 98% rename from config/router_config.go rename to config/router/router_config.go index fd3a838a43..5db311afe4 100644 --- a/config/router_config.go +++ b/config/router/router_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package router import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" diff --git a/config/router_config_test.go b/config/router/router_config_test.go similarity index 99% rename from config/router_config_test.go rename to config/router/router_config_test.go index 007a61153e..93dade98b0 100644 --- a/config/router_config_test.go +++ b/config/router/router_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package router import ( "strings" diff --git a/config/uniform_router_config.go b/config/router/uniform_router_config.go similarity index 99% rename from config/uniform_router_config.go rename to config/router/uniform_router_config.go index fa5d02db19..dc52413721 100644 --- a/config/uniform_router_config.go +++ b/config/router/uniform_router_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package router import ( "github.com/ghodss/yaml" diff --git a/config/service_discovery_config.go b/config/service/discovery/service_discovery_config.go similarity index 90% rename from config/service_discovery_config.go rename to config/service/discovery/service_discovery_config.go index 4362dd672b..f7bbc02aa1 100644 --- a/config/service_discovery_config.go +++ b/config/service/discovery/service_discovery_config.go @@ -15,12 +15,12 @@ * limitations under the License. */ -package config +package discovery import "dubbo.apache.org/dubbo-go/v3/common/constant" -// ServiceDiscoveryConfig will be used to create -type ServiceDiscoveryConfig struct { +// Config will be used to create +type Config struct { // Protocol indicate which implementation will be used. // for example, if the Protocol is nacos, it means that we will use nacosServiceDiscovery Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"` @@ -31,6 +31,6 @@ type ServiceDiscoveryConfig struct { RemoteRef string `yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` } -func (c *ServiceDiscoveryConfig) Prefix() string { +func (Config) Prefix() string { return constant.ServiceDiscPrefix } diff --git a/config/service/service_config.go b/config/service/service_config.go new file mode 100644 index 0000000000..c8714fa3f6 --- /dev/null +++ b/config/service/service_config.go @@ -0,0 +1,368 @@ +/* + * 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 service + +import ( + "container/list" + "dubbo.apache.org/dubbo-go/v3/config/method" + protocol2 "dubbo.apache.org/dubbo-go/v3/config/protocol" + "fmt" + "net/url" + "strconv" + "strings" + "sync" + "time" +) + +import ( + "github.com/creasty/defaults" + gxnet "github.com/dubbogo/gost/net" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" +) + +import ( + "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" +) + +// Config is the configuration of the service provider +type Config struct { + id string + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` + Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version" ` + Methods []*method.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` + Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Token string `yaml:"token" json:"token,omitempty" property:"token"` + AccessLog string `yaml:"accesslog" json:"accesslog,omitempty" property:"accesslog"` + TpsLimiter string `yaml:"tps.limiter" json:"tps.limiter,omitempty" property:"tps.limiter"` + TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"` + TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"` + TpsLimitStrategy string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"` + TpsLimitRejectedHandler string `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"` + ExecuteLimit string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"` + ExecuteLimitRejectedHandler string `yaml:"execute.limit.rejected.handler" json:"execute.limit.rejected.handler,omitempty" property:"execute.limit.rejected.handler"` + Auth string `yaml:"auth" json:"auth,omitempty" property:"auth"` + ParamSign string `yaml:"param.sign" json:"param.sign,omitempty" property:"param.sign"` + Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` + GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` + + Protocols map[string]*protocol2.ProtocolConfig + unexported *atomic.Bool + exported *atomic.Bool + export bool // a flag to control whether the current service should export or not + rpcService common.RPCService + cacheMutex sync.Mutex + cacheProtocol protocol.Protocol + + exportersLock sync.Mutex + exporters []protocol.Exporter +} + +// Prefix returns dubbo.service.${interface}. +func (c *Config) Prefix() string { + return constant.ServiceConfigPrefix + c.InterfaceName + "." +} + +// UnmarshalYAML unmarshal the Config by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err + } + type plain Config + if err := unmarshal((*plain)(c)); err != nil { + return err + } + c.exported = atomic.NewBool(false) + c.unexported = atomic.NewBool(false) + c.export = true + return nil +} + +// NewServiceConfig The only way to get a new Config +func NewServiceConfig(id string) *Config { + return &Config{ + id: id, + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + } +} + +// InitExported will set exported as false atom bool +func (c *Config) InitExported() { + c.exported = atomic.NewBool(false) +} + +// IsExport will return whether the service config is exported or not +func (c *Config) IsExport() bool { + return c.exported.Load() +} + +// Get Random Port +func getRandomPort(protocolConfigs []*protocol2.ProtocolConfig) *list.List { + ports := list.New() + for _, proto := range protocolConfigs { + if len(proto.Port) > 0 { + continue + } + + tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) + if err != nil { + panic(perrors.New(fmt.Sprintf("Get tcp port error, err is {%v}", err))) + } + defer tcp.Close() + ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) + } + return ports +} + +// Export exports the service +func (c *Config) Export() error { + // TODO: config center start here + + // TODO: delay export + if c.unexported != nil && c.unexported.Load() { + err := perrors.Errorf("The service %v has already unexported!", c.InterfaceName) + logger.Errorf(err.Error()) + return err + } + if c.unexported != nil && c.exported.Load() { + logger.Warnf("The service %v has already exported!", c.InterfaceName) + return nil + } + + //regUrls := config.loadRegistries(c.Registry, config.providerConfig.Registries, common.PROVIDER) + //urlMap := c.getUrlMap() + //protocolConfigs := config.loadProtocol(c.Protocol, c.Protocols) + //if len(protocolConfigs) == 0 { + // logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.InterfaceName, c.Protocol) + // return nil + //} + + //ports := getRandomPort(protocolConfigs) + //nextPort := ports.Front() + //proxyFactory := extension.GetProxyFactory(config.providerConfig.ProxyFactory) + //for _, proto := range protocolConfigs { + // // registry the service reflect + // methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.Group, c.Version, c.rpcService) + // if err != nil { + // formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", + // c.InterfaceName, proto.Name, err.Error()) + // logger.Errorf(formatErr.Error()) + // return formatErr + // } + // + // port := proto.Port + // if len(proto.Port) == 0 { + // port = nextPort.Value.(string) + // nextPort = nextPort.Next() + // } + // ivkURL := common.NewURLWithOptions( + // common.WithPath(c.InterfaceName), + // common.WithProtocol(proto.Name), + // common.WithIp(proto.Ip), + // common.WithPort(port), + // common.WithParams(urlMap), + // common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), + // common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), + // common.WithMethods(strings.Split(methods, ",")), + // common.WithToken(c.Token), + // ) + // if len(c.Tag) > 0 { + // ivkURL.AddParam(constant.Tagkey, c.Tag) + // } + // + // // post process the URL to be exported + // c.postProcessConfig(ivkURL) + // // config post processor may set "export" to false + // if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) { + // return nil + // } + // + // if len(regUrls) > 0 { + // c.cacheMutex.Lock() + // if c.cacheProtocol == nil { + // logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL)) + // c.cacheProtocol = extension.GetProtocol("registry") + // } + // c.cacheMutex.Unlock() + // + // for _, regUrl := range regUrls { + // regUrl.SubURL = ivkURL + // invoker := proxyFactory.GetInvoker(regUrl) + // exporter := c.cacheProtocol.Export(invoker) + // if exporter == nil { + // return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL)) + // } + // c.exporters = append(c.exporters, exporter) + // } + // } else { + // if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { + // ms, err := extension.GetLocalMetadataService("") + // if err != nil { + // return err + // } + // ms.SetMetadataServiceURL(ivkURL) + // } + // invoker := proxyFactory.GetInvoker(ivkURL) + // exporter := extension.GetProtocol(protocolwrapper.FILTER).Export(invoker) + // if exporter == nil { + // return perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error, url is {%v}", ivkURL)) + // } + // c.exporters = append(c.exporters, exporter) + // } + // publishServiceDefinition(ivkURL) + //} + //c.exported.Store(true) + return nil +} + +// Unexport will call unexport of all exporters service config exported +func (c *Config) Unexport() { + if !c.exported.Load() { + return + } + if c.unexported.Load() { + return + } + + func() { + c.exportersLock.Lock() + defer c.exportersLock.Unlock() + for _, exporter := range c.exporters { + exporter.Unexport() + } + c.exporters = nil + }() + + c.exported.Store(false) + c.unexported.Store(true) +} + +// Implement only store the @s and return +func (c *Config) Implement(s common.RPCService) { + c.rpcService = s +} + +func (c *Config) getUrlMap() url.Values { + urlMap := url.Values{} + // first set user params + for k, v := range c.Params { + urlMap.Set(k, v) + } + urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) + urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) + urlMap.Set(constant.CLUSTER_KEY, c.Cluster) + urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) + urlMap.Set(constant.WARMUP_KEY, c.Warmup) + urlMap.Set(constant.RETRIES_KEY, c.Retries) + urlMap.Set(constant.GROUP_KEY, c.Group) + urlMap.Set(constant.VERSION_KEY, c.Version) + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) + urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) + urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(c.GrpcMaxMessageSize)) + // todo: move + urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) + // application info + //urlMap.Set(constant.APPLICATION_KEY, config.providerConfig.ApplicationConfig.Name) + //urlMap.Set(constant.ORGANIZATION_KEY, config.providerConfig.ApplicationConfig.Organization) + //urlMap.Set(constant.NAME_KEY, config.providerConfig.ApplicationConfig.Name) + //urlMap.Set(constant.MODULE_KEY, config.providerConfig.ApplicationConfig.Module) + //urlMap.Set(constant.APP_VERSION_KEY, config.providerConfig.ApplicationConfig.Version) + //urlMap.Set(constant.OWNER_KEY, config.root.Application.Owner) + //urlMap.Set(constant.ENVIRONMENT_KEY, config.providerConfig.ApplicationConfig.Environment) + + // filter + //urlMap.Set(constant.SERVICE_FILTER_KEY, config.mergeValue(config.providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) + + // filter special config + urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) + // tps limiter + urlMap.Set(constant.TPS_LIMIT_STRATEGY_KEY, c.TpsLimitStrategy) + urlMap.Set(constant.TPS_LIMIT_INTERVAL_KEY, c.TpsLimitInterval) + urlMap.Set(constant.TPS_LIMIT_RATE_KEY, c.TpsLimitRate) + urlMap.Set(constant.TPS_LIMITER_KEY, c.TpsLimiter) + urlMap.Set(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, c.TpsLimitRejectedHandler) + + // execute limit filter + urlMap.Set(constant.EXECUTE_LIMIT_KEY, c.ExecuteLimit) + urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, c.ExecuteLimitRejectedHandler) + + // auth filter + urlMap.Set(constant.SERVICE_AUTH_KEY, c.Auth) + urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, c.ParamSign) + + // whether to export or not + urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(c.export)) + + for _, v := range c.Methods { + prefix := "methods." + v.Name + "." + urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.LoadBalance) + urlMap.Set(prefix+constant.RETRIES_KEY, v.Retries) + urlMap.Set(prefix+constant.WEIGHT_KEY, strconv.FormatInt(v.Weight, 10)) + + urlMap.Set(prefix+constant.TPS_LIMIT_STRATEGY_KEY, v.TpsLimitStrategy) + urlMap.Set(prefix+constant.TPS_LIMIT_INTERVAL_KEY, v.TpsLimitInterval) + urlMap.Set(prefix+constant.TPS_LIMIT_RATE_KEY, v.TpsLimitRate) + + urlMap.Set(constant.EXECUTE_LIMIT_KEY, v.ExecuteLimit) + urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, v.ExecuteLimitRejectedHandler) + } + + return urlMap +} + +// GetExportedUrls will return the url in service config's exporter +func (c *Config) GetExportedUrls() []*common.URL { + if c.exported.Load() { + var urls []*common.URL + for _, exporter := range c.exporters { + urls = append(urls, exporter.GetInvoker().GetURL()) + } + return urls + } + return nil +} + +func publishServiceDefinition(url *common.URL) { + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { + remoteMetadataService.PublishServiceDefinition(url) + + } +} + +// postProcessConfig asks registered ConfigPostProcessor to post-process the current Config. +func (c *Config) postProcessConfig(url *common.URL) { + for _, p := range extension.GetConfigPostProcessors() { + p.PostProcessServiceConfig(url) + } +} diff --git a/config/service_config.go b/config/service_config.go deleted file mode 100644 index ebcac9a520..0000000000 --- a/config/service_config.go +++ /dev/null @@ -1,367 +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 config - -import ( - "container/list" - "fmt" - "net/url" - "strconv" - "strings" - "sync" - "time" -) - -import ( - "github.com/creasty/defaults" - gxnet "github.com/dubbogo/gost/net" - perrors "github.com/pkg/errors" - "go.uber.org/atomic" -) - -import ( - "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" - "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" -) - -// ServiceConfig is the configuration of the service provider -type ServiceConfig struct { - id string - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' - InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version" ` - Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` - Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - Token string `yaml:"token" json:"token,omitempty" property:"token"` - AccessLog string `yaml:"accesslog" json:"accesslog,omitempty" property:"accesslog"` - TpsLimiter string `yaml:"tps.limiter" json:"tps.limiter,omitempty" property:"tps.limiter"` - TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"` - TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"` - TpsLimitStrategy string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"` - TpsLimitRejectedHandler string `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"` - ExecuteLimit string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"` - ExecuteLimitRejectedHandler string `yaml:"execute.limit.rejected.handler" json:"execute.limit.rejected.handler,omitempty" property:"execute.limit.rejected.handler"` - Auth string `yaml:"auth" json:"auth,omitempty" property:"auth"` - ParamSign string `yaml:"param.sign" json:"param.sign,omitempty" property:"param.sign"` - Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` - GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - - Protocols map[string]*ProtocolConfig - unexported *atomic.Bool - exported *atomic.Bool - export bool // a flag to control whether the current service should export or not - rpcService common.RPCService - cacheMutex sync.Mutex - cacheProtocol protocol.Protocol - - exportersLock sync.Mutex - exporters []protocol.Exporter -} - -// Prefix returns dubbo.service.${interface}. -func (c *ServiceConfig) Prefix() string { - return constant.ServiceConfigPrefix + c.InterfaceName + "." -} - -// UnmarshalYAML unmarshals the ServiceConfig by @unmarshal function -func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ServiceConfig - if err := unmarshal((*plain)(c)); err != nil { - return err - } - c.exported = atomic.NewBool(false) - c.unexported = atomic.NewBool(false) - c.export = true - return nil -} - -// NewServiceConfig The only way to get a new ServiceConfig -func NewServiceConfig(id string) *ServiceConfig { - return &ServiceConfig{ - id: id, - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, - } -} - -// InitExported will set exported as false atom bool -func (c *ServiceConfig) InitExported() { - c.exported = atomic.NewBool(false) -} - -// IsExport will return whether the service config is exported or not -func (c *ServiceConfig) IsExport() bool { - return c.exported.Load() -} - -// Get Random Port -func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { - ports := list.New() - for _, proto := range protocolConfigs { - if len(proto.Port) > 0 { - continue - } - - tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) - if err != nil { - panic(perrors.New(fmt.Sprintf("Get tcp port error, err is {%v}", err))) - } - defer tcp.Close() - ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) - } - return ports -} - -// Export exports the service -func (c *ServiceConfig) Export() error { - // TODO: config center start here - - // TODO: delay export - if c.unexported != nil && c.unexported.Load() { - err := perrors.Errorf("The service %v has already unexported!", c.InterfaceName) - logger.Errorf(err.Error()) - return err - } - if c.unexported != nil && c.exported.Load() { - logger.Warnf("The service %v has already exported!", c.InterfaceName) - return nil - } - - regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) - urlMap := c.getUrlMap() - protocolConfigs := loadProtocol(c.Protocol, c.Protocols) - if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.InterfaceName, c.Protocol) - return nil - } - - ports := getRandomPort(protocolConfigs) - nextPort := ports.Front() - proxyFactory := extension.GetProxyFactory(providerConfig.ProxyFactory) - for _, proto := range protocolConfigs { - // registry the service reflect - methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.Group, c.Version, c.rpcService) - if err != nil { - formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", - c.InterfaceName, proto.Name, err.Error()) - logger.Errorf(formatErr.Error()) - return formatErr - } - - port := proto.Port - if len(proto.Port) == 0 { - port = nextPort.Value.(string) - nextPort = nextPort.Next() - } - ivkURL := common.NewURLWithOptions( - common.WithPath(c.InterfaceName), - common.WithProtocol(proto.Name), - common.WithIp(proto.Ip), - common.WithPort(port), - common.WithParams(urlMap), - common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), - common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(GetSslEnabled())), - common.WithMethods(strings.Split(methods, ",")), - common.WithToken(c.Token), - ) - if len(c.Tag) > 0 { - ivkURL.AddParam(constant.Tagkey, c.Tag) - } - - // post process the URL to be exported - c.postProcessConfig(ivkURL) - // config post processor may set "export" to false - if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) { - return nil - } - - if len(regUrls) > 0 { - c.cacheMutex.Lock() - if c.cacheProtocol == nil { - logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL)) - c.cacheProtocol = extension.GetProtocol("registry") - } - c.cacheMutex.Unlock() - - for _, regUrl := range regUrls { - regUrl.SubURL = ivkURL - invoker := proxyFactory.GetInvoker(regUrl) - exporter := c.cacheProtocol.Export(invoker) - if exporter == nil { - return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL)) - } - c.exporters = append(c.exporters, exporter) - } - } else { - if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { - ms, err := extension.GetLocalMetadataService("") - if err != nil { - return err - } - ms.SetMetadataServiceURL(ivkURL) - } - invoker := proxyFactory.GetInvoker(ivkURL) - exporter := extension.GetProtocol(protocolwrapper.FILTER).Export(invoker) - if exporter == nil { - return perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error, url is {%v}", ivkURL)) - } - c.exporters = append(c.exporters, exporter) - } - publishServiceDefinition(ivkURL) - } - c.exported.Store(true) - return nil -} - -// Unexport will call unexport of all exporters service config exported -func (c *ServiceConfig) Unexport() { - if !c.exported.Load() { - return - } - if c.unexported.Load() { - return - } - - func() { - c.exportersLock.Lock() - defer c.exportersLock.Unlock() - for _, exporter := range c.exporters { - exporter.Unexport() - } - c.exporters = nil - }() - - c.exported.Store(false) - c.unexported.Store(true) -} - -// Implement only store the @s and return -func (c *ServiceConfig) Implement(s common.RPCService) { - c.rpcService = s -} - -func (c *ServiceConfig) getUrlMap() url.Values { - urlMap := url.Values{} - // first set user params - for k, v := range c.Params { - urlMap.Set(k, v) - } - urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) - urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) - urlMap.Set(constant.CLUSTER_KEY, c.Cluster) - urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) - urlMap.Set(constant.WARMUP_KEY, c.Warmup) - urlMap.Set(constant.RETRIES_KEY, c.Retries) - urlMap.Set(constant.GROUP_KEY, c.Group) - urlMap.Set(constant.VERSION_KEY, c.Version) - urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) - urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) - urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) - urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(c.GrpcMaxMessageSize)) - // todo: move - urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) - // application info - urlMap.Set(constant.APPLICATION_KEY, providerConfig.ApplicationConfig.Name) - urlMap.Set(constant.ORGANIZATION_KEY, providerConfig.ApplicationConfig.Organization) - urlMap.Set(constant.NAME_KEY, providerConfig.ApplicationConfig.Name) - urlMap.Set(constant.MODULE_KEY, providerConfig.ApplicationConfig.Module) - urlMap.Set(constant.APP_VERSION_KEY, providerConfig.ApplicationConfig.Version) - urlMap.Set(constant.OWNER_KEY, providerConfig.ApplicationConfig.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, providerConfig.ApplicationConfig.Environment) - - // filter - urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) - - // filter special config - urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) - // tps limiter - urlMap.Set(constant.TPS_LIMIT_STRATEGY_KEY, c.TpsLimitStrategy) - urlMap.Set(constant.TPS_LIMIT_INTERVAL_KEY, c.TpsLimitInterval) - urlMap.Set(constant.TPS_LIMIT_RATE_KEY, c.TpsLimitRate) - urlMap.Set(constant.TPS_LIMITER_KEY, c.TpsLimiter) - urlMap.Set(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, c.TpsLimitRejectedHandler) - - // execute limit filter - urlMap.Set(constant.EXECUTE_LIMIT_KEY, c.ExecuteLimit) - urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, c.ExecuteLimitRejectedHandler) - - // auth filter - urlMap.Set(constant.SERVICE_AUTH_KEY, c.Auth) - urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, c.ParamSign) - - // whether to export or not - urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(c.export)) - - for _, v := range c.Methods { - prefix := "methods." + v.Name + "." - urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.LoadBalance) - urlMap.Set(prefix+constant.RETRIES_KEY, v.Retries) - urlMap.Set(prefix+constant.WEIGHT_KEY, strconv.FormatInt(v.Weight, 10)) - - urlMap.Set(prefix+constant.TPS_LIMIT_STRATEGY_KEY, v.TpsLimitStrategy) - urlMap.Set(prefix+constant.TPS_LIMIT_INTERVAL_KEY, v.TpsLimitInterval) - urlMap.Set(prefix+constant.TPS_LIMIT_RATE_KEY, v.TpsLimitRate) - - urlMap.Set(constant.EXECUTE_LIMIT_KEY, v.ExecuteLimit) - urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, v.ExecuteLimitRejectedHandler) - } - - return urlMap -} - -// GetExportedUrls will return the url in service config's exporter -func (c *ServiceConfig) GetExportedUrls() []*common.URL { - if c.exported.Load() { - var urls []*common.URL - for _, exporter := range c.exporters { - urls = append(urls, exporter.GetInvoker().GetURL()) - } - return urls - } - return nil -} - -func publishServiceDefinition(url *common.URL) { - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { - remoteMetadataService.PublishServiceDefinition(url) - - } -} - -// postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig. -func (c *ServiceConfig) postProcessConfig(url *common.URL) { - for _, p := range extension.GetConfigPostProcessors() { - p.PostProcessServiceConfig(url) - } -} diff --git a/config/service_config_test.go b/config/service_config_test.go deleted file mode 100644 index 4c64c705b2..0000000000 --- a/config/service_config_test.go +++ /dev/null @@ -1,215 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" - "go.uber.org/atomic" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" -) - -func doInitProvider() { - providerConfig = &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - Remotes: map[string]*RemoteConfig{ - "test1": { - Address: "127.0.0.5:2181", - TimeoutStr: "5s", - Username: "user1", - Password: "pwd1", - Params: nil, - }, - }, - ServiceDiscoveries: map[string]*ServiceDiscoveryConfig{ - "mock_servicediscovery": { - Protocol: "mock", - RemoteRef: "test1", - }, - }, - MetadataReportConfig: &MetadataReportConfig{ - Protocol: "mock", - RemoteRef: "test1", - }, - }, - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - "MockServiceNoRightProtocol": { - InterfaceName: "com.MockService", - Protocol: "mock1", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - }, - - Registries: map[string]*RegistryConfig{ - "shanghai_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_service_discovery_reg": { - Protocol: "service-discovery", - Params: map[string]string{ - "service_discovery": "mock_servicediscovery", - "name_mapping": "in-memory", - "metadata": "default", - }, - }, - }, - - Protocols: map[string]*ProtocolConfig{ - "mock": { - Name: "mock", - Ip: "127.0.0.1", - Port: "20000", - }, - }, - } -} - -func TestExport(t *testing.T) { - doInitProvider() - extension.SetProtocol("registry", GetProtocol) - - for i := range providerConfig.Services { - service := providerConfig.Services[i] - service.Implement(&MockService{}) - service.Protocols = providerConfig.Protocols - err := service.Export() - assert.Nil(t, err) - } - providerConfig = nil -} - -func TestGetRandomPort(t *testing.T) { - protocolConfigs := make([]*ProtocolConfig, 0, 3) - - ip := common.GetLocalIp() - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - // assert.NoError(t, err) - ports := getRandomPort(protocolConfigs) - - assert.Equal(t, ports.Len(), len(protocolConfigs)) - - front := ports.Front() - for { - if front == nil { - break - } - t.Logf("port:%v", front.Value) - front = front.Next() - } - - protocolConfigs = make([]*ProtocolConfig, 0, 3) - ports = getRandomPort(protocolConfigs) - assert.Equal(t, ports.Len(), len(protocolConfigs)) -} diff --git a/config/graceful_shutdown.go b/config/shutdown/graceful_shutdown.go similarity index 50% rename from config/graceful_shutdown.go rename to config/shutdown/graceful_shutdown.go index 6d2b71687c..e2cda52e53 100644 --- a/config/graceful_shutdown.go +++ b/config/shutdown/graceful_shutdown.go @@ -15,12 +15,9 @@ * limitations under the License. */ -package config +package shutdown import ( - "os" - "os/signal" - "runtime/debug" "time" ) @@ -54,61 +51,61 @@ import ( const defaultShutDownTime = time.Second * 60 // nolint -func GracefulShutdownInit() { - signals := make(chan os.Signal, 1) - - signal.Notify(signals, ShutdownSignals...) - - // retrieve ShutdownConfig for gracefulShutdownFilter - if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(Setter); ok && GetConsumerConfig().ShutdownConfig != nil { - filter.Set(GracefulShutdownFilterShutdownConfig, GetConsumerConfig().ShutdownConfig) - } - if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(Setter); ok && GetProviderConfig().ShutdownConfig != nil { - filter.Set(GracefulShutdownFilterShutdownConfig, GetProviderConfig().ShutdownConfig) - } - - go func() { - select { - case sig := <-signals: - logger.Infof("get signal %s, application will shutdown.", sig) - // gracefulShutdownOnce.Do(func() { - time.AfterFunc(totalTimeout(), func() { - logger.Warn("Shutdown gracefully timeout, application will shutdown immediately. ") - os.Exit(0) - }) - BeforeShutdown() - // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior - for _, dumpSignal := range DumpHeapShutdownSignals { - if sig == dumpSignal { - debug.WriteHeapDump(os.Stdout.Fd()) - } - } - os.Exit(0) - } - }() -} +//func GracefulShutdownInit() { +// signals := make(chan os.Signal, 1) +// +// signal.Notify(signals, ShutdownSignals...) +// +// // retrieve ShutdownConfig for gracefulShutdownFilter +// if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(config.Setter); ok && config.GetConsumerConfig().ShutdownConfig != nil { +// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetConsumerConfig().ShutdownConfig) +// } +// if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(config.Setter); ok && config.GetProviderConfig().ShutdownConfig != nil { +// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetProviderConfig().ShutdownConfig) +// } +// +// go func() { +// select { +// case sig := <-signals: +// logger.Infof("get signal %s, application will shutdown.", sig) +// // gracefulShutdownOnce.Do(func() { +// time.AfterFunc(totalTimeout(), func() { +// logger.Warn("Shutdown gracefully timeout, application will shutdown immediately. ") +// os.Exit(0) +// }) +// BeforeShutdown() +// // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior +// for _, dumpSignal := range DumpHeapShutdownSignals { +// if sig == dumpSignal { +// debug.WriteHeapDump(os.Stdout.Fd()) +// } +// } +// os.Exit(0) +// } +// }() +//} // BeforeShutdown provides processing flow before shutdown func BeforeShutdown() { destroyAllRegistries() // waiting for a short time so that the clients have enough time to get the notification that server shutdowns // The value of configuration depends on how long the clients will get notification. - waitAndAcceptNewRequests() + //waitAndAcceptNewRequests() // reject the new request, but keeping waiting for accepting requests - waitForReceivingRequests() + //waitForReceivingRequests() // we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc - consumerProtocols := getConsumerProtocols() + //consumerProtocols := getConsumerProtocols() // If this application is not the provider, it will do nothing - destroyProviderProtocols(consumerProtocols) + //destroyProviderProtocols(consumerProtocols) // reject sending the new request, and waiting for response of sending requests - waitForSendingRequests() + //waitForSendingRequests() // If this application is not the consumer, it will do nothing - destroyConsumerProtocols(consumerProtocols) + //destroyConsumerProtocols(consumerProtocols) logger.Info("Graceful shutdown --- Execute the custom callbacks.") customCallbacks := extension.GetAllCustomShutdownCallbacks() @@ -132,59 +129,59 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { // destroyProviderProtocols destroys the provider's protocol. // if the protocol is consumer's protocol too, we will keep it -func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { - logger.Info("Graceful shutdown --- Destroy provider's protocols. ") - - if providerConfig == nil || providerConfig.Protocols == nil { - return - } - - for _, protocol := range providerConfig.Protocols { - - // the protocol is the consumer's protocol too, we can not destroy it. - if consumerProtocols.Contains(protocol.Name) { - continue - } - extension.GetProtocol(protocol.Name).Destroy() - } -} - -func waitAndAcceptNewRequests() { - logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") - if providerConfig == nil || providerConfig.ShutdownConfig == nil { - return - } - - timeout := providerConfig.ShutdownConfig.GetStepTimeout() - - // ignore this step - if timeout < 0 { - return - } - time.Sleep(timeout) -} +//func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { +// logger.Info("Graceful shutdown --- Destroy provider's protocols. ") +// +// if config.providerConfig == nil || config.providerConfig.Protocols == nil { +// return +// } +// +// for _, protocol := range config.providerConfig.Protocols { +// +// // the protocol is the consumer's protocol too, we can not destroy it. +// if consumerProtocols.Contains(protocol.Name) { +// continue +// } +// extension.GetProtocol(protocol.Name).Destroy() +// } +//} + +//func waitAndAcceptNewRequests() { +// logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") +// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { +// return +// } +// +// timeout := config.providerConfig.ShutdownConfig.GetStepTimeout() +// +// // ignore this step +// if timeout < 0 { +// return +// } +// time.Sleep(timeout) +//} // for provider. It will wait for processing receiving requests -func waitForReceivingRequests() { - logger.Info("Graceful shutdown --- Keep waiting until accepting requests finish or timeout. ") - if providerConfig == nil || providerConfig.ShutdownConfig == nil { - // ignore this step - return - } - providerConfig.ShutdownConfig.RejectRequest = true - waitingProcessedTimeout(providerConfig.ShutdownConfig) -} +//func waitForReceivingRequests() { +// logger.Info("Graceful shutdown --- Keep waiting until accepting requests finish or timeout. ") +// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { +// // ignore this step +// return +// } +// config.providerConfig.ShutdownConfig.RejectRequest = true +// waitingProcessedTimeout(config.providerConfig.ShutdownConfig) +//} // for consumer. It will wait for the response of sending requests -func waitForSendingRequests() { - logger.Info("Graceful shutdown --- Keep waiting until sending requests getting response or timeout ") - if consumerConfig == nil || consumerConfig.ShutdownConfig == nil { - // ignore this step - return - } - consumerConfig.ShutdownConfig.RejectRequest = true - waitingProcessedTimeout(consumerConfig.ShutdownConfig) -} +//func waitForSendingRequests() { +// logger.Info("Graceful shutdown --- Keep waiting until sending requests getting response or timeout ") +// if config.consumerConfig == nil || config.consumerConfig.ShutdownConfig == nil { +// // ignore this step +// return +// } +// config.consumerConfig.ShutdownConfig.RejectRequest = true +// waitingProcessedTimeout(config.consumerConfig.ShutdownConfig) +//} func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { timeout := shutdownConfig.GetStepTimeout() @@ -199,33 +196,33 @@ func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { } } -func totalTimeout() time.Duration { - providerShutdown := defaultShutDownTime - if providerConfig != nil && providerConfig.ShutdownConfig != nil { - providerShutdown = providerConfig.ShutdownConfig.GetTimeout() - } - - var consumerShutdown time.Duration - if consumerConfig != nil && consumerConfig.ShutdownConfig != nil { - consumerShutdown = consumerConfig.ShutdownConfig.GetTimeout() - } - - timeout := providerShutdown - if consumerShutdown > providerShutdown { - timeout = consumerShutdown - } - return timeout -} +//func totalTimeout() time.Duration { +// providerShutdown := defaultShutDownTime +// if config.providerConfig != nil && config.providerConfig.ShutdownConfig != nil { +// providerShutdown = config.providerConfig.ShutdownConfig.GetTimeout() +// } +// +// var consumerShutdown time.Duration +// if config.consumerConfig != nil && config.consumerConfig.ShutdownConfig != nil { +// consumerShutdown = config.consumerConfig.ShutdownConfig.GetTimeout() +// } +// +// timeout := providerShutdown +// if consumerShutdown > providerShutdown { +// timeout = consumerShutdown +// } +// return timeout +//} // we can not get the protocols from consumerConfig because some protocol don't have configuration, like jsonrpc. -func getConsumerProtocols() *gxset.HashSet { - result := gxset.NewSet() - if consumerConfig == nil || consumerConfig.References == nil { - return result - } - - for _, reference := range consumerConfig.References { - result.Add(reference.Protocol) - } - return result -} +//func getConsumerProtocols() *gxset.HashSet { +// result := gxset.NewSet() +// if config.consumerConfig == nil || config.consumerConfig.References == nil { +// return result +// } +// +// for _, reference := range config.consumerConfig.References { +// result.Add(reference.Protocol) +// } +// return result +//} diff --git a/config/graceful_shutdown_config.go b/config/shutdown/graceful_shutdown_config.go similarity index 99% rename from config/graceful_shutdown_config.go rename to config/shutdown/graceful_shutdown_config.go index fd0bfb41a8..57c97368a6 100644 --- a/config/graceful_shutdown_config.go +++ b/config/shutdown/graceful_shutdown_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package shutdown import ( "time" diff --git a/config/graceful_shutdown_config_test.go b/config/shutdown/graceful_shutdown_config_test.go similarity index 98% rename from config/graceful_shutdown_config_test.go rename to config/shutdown/graceful_shutdown_config_test.go index 43d2fc3c1b..7eca40c55c 100644 --- a/config/graceful_shutdown_config_test.go +++ b/config/shutdown/graceful_shutdown_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package shutdown import ( "testing" diff --git a/config/graceful_shutdown_signal_darwin.go b/config/shutdown/graceful_shutdown_signal_darwin.go similarity index 98% rename from config/graceful_shutdown_signal_darwin.go rename to config/shutdown/graceful_shutdown_signal_darwin.go index 9b694b5e09..e52b1c14f1 100644 --- a/config/graceful_shutdown_signal_darwin.go +++ b/config/shutdown/graceful_shutdown_signal_darwin.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package shutdown import ( "os" diff --git a/config/graceful_shutdown_signal_linux.go b/config/shutdown/graceful_shutdown_signal_linux.go similarity index 98% rename from config/graceful_shutdown_signal_linux.go rename to config/shutdown/graceful_shutdown_signal_linux.go index 9b694b5e09..e52b1c14f1 100644 --- a/config/graceful_shutdown_signal_linux.go +++ b/config/shutdown/graceful_shutdown_signal_linux.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package shutdown import ( "os" diff --git a/config/graceful_shutdown_signal_windows.go b/config/shutdown/graceful_shutdown_signal_windows.go similarity index 98% rename from config/graceful_shutdown_signal_windows.go rename to config/shutdown/graceful_shutdown_signal_windows.go index 17c209e8f5..08ce9f59b7 100644 --- a/config/graceful_shutdown_signal_windows.go +++ b/config/shutdown/graceful_shutdown_signal_windows.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package shutdown import ( "os" diff --git a/config/shutdown/graceful_shutdown_test.go b/config/shutdown/graceful_shutdown_test.go new file mode 100644 index 0000000000..3df535bc06 --- /dev/null +++ b/config/shutdown/graceful_shutdown_test.go @@ -0,0 +1,113 @@ +/* + * 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 shutdown +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// protocol2 "dubbo.apache.org/dubbo-go/v3/config/protocol" +// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "dubbo.apache.org/dubbo-go/v3/config/reference" +// "testing" +//) +// +//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.GracefulShutdownConsumerFilterKey, func() filter.Filter { +// return &config.mockGracefulShutdownFilter{} +// }) +// extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { +// return &config.mockGracefulShutdownFilter{} +// }) +// GracefulShutdownInit() +//} +// +//func TestBeforeShutdown(t *testing.T) { +// extension.SetProtocol("registry", func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// extension.SetProtocol(constant.DUBBO, func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// +// extension.SetProtocol("mock", func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// +// consumerReferences := map[string]*reference.ReferenceConfig{} +// consumerReferences[constant.DUBBO] = &reference.ReferenceConfig{ +// Protocol: constant.DUBBO, +// } +// +// // without configuration +// config.consumerConfig = nil +// config.providerConfig = nil +// BeforeShutdown() +// +// config.consumerConfig = &consumer.Config{ +// References: consumerReferences, +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "1s", +// }, +// } +// +// providerProtocols := map[string]*protocol2.ProtocolConfig{} +// providerProtocols[constant.DUBBO] = &protocol2.ProtocolConfig{ +// Name: constant.DUBBO, +// } +// +// providerProtocols["mock"] = &protocol2.ProtocolConfig{ +// Name: "mock", +// } +// +// config.providerConfig = &provider.ProviderConfig{ +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "1s", +// }, +// Protocols: providerProtocols, +// } +// // test destroy protocol +// BeforeShutdown() +// +// config.providerConfig = &provider.ProviderConfig{ +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "-1s", +// }, +// Protocols: providerProtocols, +// } +// +// config.consumerConfig = &consumer.Config{ +// References: consumerReferences, +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "-1s", +// }, +// } +// +// // test ignore steps +// BeforeShutdown() +//} diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml new file mode 100644 index 0000000000..752c039ddb --- /dev/null +++ b/config/testdata/application.yaml @@ -0,0 +1,24 @@ +dubbo: + application: + name: dubbo-go + module: local + version: 1.0.0 + owner: zhaoyunxing + registries: + nacos: + protocol: nacos + timeout: 5s + group: dev + address: 127.0.0.1:8848 + zk: + protocol: zk + timeout: 5s + group: dev + address: 127.0.0.1:2181 + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService + registry: nacos \ No newline at end of file diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 3392868223..f798b2280e 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -17,6 +17,8 @@ package apollo import ( + "dubbo.apache.org/dubbo-go/v3/config/base" + "dubbo.apache.org/dubbo-go/v3/config/center" "fmt" "net/http" "net/http/httptest" @@ -33,7 +35,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/parser" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -184,7 +185,7 @@ func TestGetConfigItem(t *testing.T) { } func initMockApollo(t *testing.T) *apolloConfiguration { - c := &config.BaseConfig{ConfigCenterConfig: &config.ConfigCenterConfig{ + c := &base.Config{ConfigCenterConfig: ¢er.Config{ Protocol: "apollo", Address: "106.12.25.204:8080", AppID: "testApplication_yang", diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go index 1bbc19774e..fb29205fff 100644 --- a/filter/gshutdown/filter.go +++ b/filter/gshutdown/filter.go @@ -19,6 +19,7 @@ package gshutdown import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/shutdown" "sync/atomic" ) @@ -43,7 +44,7 @@ func init() { type Filter struct { activeCount int32 - shutdownConfig *config.ShutdownConfig + shutdownConfig *shutdown.ShutdownConfig } // Invoke adds the requests count and block the new requests if application is closing @@ -69,7 +70,7 @@ func (f *Filter) OnResponse(ctx context.Context, result protocol.Result, invoker func (f *Filter) Set(name string, conf interface{}) { switch name { case config.GracefulShutdownFilterShutdownConfig: - if shutdownConfig, ok := conf.(*config.ShutdownConfig); !ok { + if shutdownConfig, ok := conf.(*shutdown.ShutdownConfig); !ok { f.shutdownConfig = shutdownConfig return } diff --git a/filter/gshutdown/filter_test.go b/filter/gshutdown/filter_test.go index d8b9dc6eff..5d244d0222 100644 --- a/filter/gshutdown/filter_test.go +++ b/filter/gshutdown/filter_test.go @@ -19,6 +19,7 @@ package gshutdown import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/shutdown" "net/url" "testing" ) @@ -56,7 +57,7 @@ func TestGenericFilterInvoke(t *testing.T) { assert.NotNil(t, result) assert.Nil(t, result.Error()) - providerConfig.ShutdownConfig = &config.ShutdownConfig{ + providerConfig.ShutdownConfig = &shutdown.ShutdownConfig{ RejectRequest: true, RejectRequestHandler: "mock", } diff --git a/go.mod b/go.mod index c1861c222d..d22e52353a 100644 --- a/go.mod +++ b/go.mod @@ -18,12 +18,14 @@ require ( github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 + github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 + github.com/knadh/koanf v1.1.1 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd @@ -33,6 +35,8 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.9.0 github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.7.1 github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 diff --git a/go.sum b/go.sum index 120647fc08..117960b9f0 100644 --- a/go.sum +++ b/go.sum @@ -191,6 +191,7 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -202,6 +203,14 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA= +github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= +github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= @@ -306,6 +315,7 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= +github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= @@ -313,7 +323,9 @@ github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -332,9 +344,12 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= +github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 h1:e1ok06zGrWJW91rzRroyl5nRNqraaBe4d5hiKcVZuHM= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= @@ -347,6 +362,7 @@ github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXT github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= @@ -372,6 +388,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= +github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -382,6 +400,8 @@ 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= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4= @@ -411,6 +431,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -423,6 +445,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -480,6 +504,8 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= @@ -534,6 +560,7 @@ github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULU github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -780,6 +807,7 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w 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= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -793,6 +821,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -854,6 +883,7 @@ google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -901,6 +931,7 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -917,6 +948,7 @@ gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index f3f285806b..5aaa8fe3e0 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,6 +18,8 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config/protocol" + service2 "dubbo.apache.org/dubbo-go/v3/config/service" "errors" "sync" ) @@ -33,7 +35,7 @@ import ( // MetadataServiceExporter is the ConfigurableMetadataServiceExporter which implement MetadataServiceExporter interface type MetadataServiceExporter struct { - ServiceConfig *config.ServiceConfig + ServiceConfig *service2.Config lock sync.RWMutex metadataService service.MetadataService } @@ -48,12 +50,12 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte // Export will export the metadataService func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { - serviceConfig := config.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) + serviceConfig := service2.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) serviceConfig.Protocol = constant.DEFAULT_PROTOCOL if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") } - serviceConfig.Protocols = map[string]*config.ProtocolConfig{ + serviceConfig.Protocols = map[string]*protocol.ProtocolConfig{ constant.DEFAULT_PROTOCOL: { Name: url.SubURL.Protocol, Port: url.SubURL.Port, diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 3ae67500ff..7cbf62d00d 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -18,6 +18,13 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/base" + "dubbo.apache.org/dubbo-go/v3/config/method" + "dubbo.apache.org/dubbo-go/v3/config/protocol" + "dubbo.apache.org/dubbo-go/v3/config/provider" + "dubbo.apache.org/dubbo-go/v3/config/registry" + "dubbo.apache.org/dubbo-go/v3/config/service" "testing" ) @@ -28,7 +35,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" @@ -78,10 +84,10 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &config.ProviderConfig{ + providerConfig := &provider.ProviderConfig{ - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{ + BaseConfig: base.Config{ + ApplicationConfig: &application.Config{ Organization: "dubbo_org", Name: "dubbo", Module: "module", @@ -91,14 +97,14 @@ func mockInitProviderWithSingleRegistry() { }, }, - Registry: &config.RegistryConfig{ + Registry: ®istry.RegistryConfig{ Address: "mock://127.0.0.1:2181", Username: "user1", Password: "pwd1", }, - Registries: map[string]*config.RegistryConfig{}, + Registries: map[string]*registry.RegistryConfig{}, - Services: map[string]*config.ServiceConfig{ + Services: map[string]*service.Config{ "MockService": { InterfaceName: "com.MockService", Protocol: "mock", @@ -107,7 +113,7 @@ func mockInitProviderWithSingleRegistry() { Retries: "3", Group: "huadong_idc", Version: "1.0.0", - Methods: []*config.MethodConfig{ + Methods: []*method.MethodConfig{ { Name: "GetUser", Retries: "2", @@ -123,7 +129,7 @@ func mockInitProviderWithSingleRegistry() { }, }, }, - Protocols: map[string]*config.ProtocolConfig{ + Protocols: map[string]*protocol.ProtocolConfig{ "mock": { Name: "mock", Ip: "127.0.0.1", @@ -132,5 +138,5 @@ func mockInitProviderWithSingleRegistry() { }, } providerConfig.Services["MockService"].InitExported() - config.SetProviderConfig(*providerConfig) + provider.SetProviderConfig(*providerConfig) } diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go index f137e848f6..5d1e83022c 100644 --- a/protocol/dubbo3/common_test.go +++ b/protocol/dubbo3/common_test.go @@ -19,6 +19,7 @@ package dubbo3 import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "fmt" ) @@ -27,7 +28,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" @@ -35,7 +35,7 @@ import ( // userd dubbo3 biz service func addService() { - config.SetProviderService(newGreeterProvider()) + instance.SetProviderService(newGreeterProvider()) } type greeterProvider struct { diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 5c152c774f..5061dc2f7b 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -19,6 +19,7 @@ package dubbo3 import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "reflect" "strconv" "strings" @@ -63,7 +64,7 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { } key := url.GetParam(constant.BEAN_NAME_KEY, "") - consumerService := config.GetConsumerService(key) + consumerService := instance.GetConsumerService(key) dubboSerializaerType := url.GetParam(constant.SERIALIZATION_KEY, constant.PROTOBUF_SERIALIZATION) triCodecType := tripleConstant.CodecType(dubboSerializaerType) diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index 25ca875478..b0aabbfc91 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -18,6 +18,7 @@ package dubbo3 import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "fmt" "reflect" "sync" @@ -35,7 +36,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) @@ -78,7 +78,7 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { key := url.GetParam(constant.BEAN_NAME_KEY, "") var service interface{} - service = config.GetProviderService(key) + service = instance.GetProviderService(key) serializationType := url.GetParam(constant.SERIALIZATION_KEY, constant.PROTOBUF_SERIALIZATION) var triSerializationType tripleConstant.CodecType diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index 2b1d8e07d2..df6eaf7cf5 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -19,18 +19,15 @@ package internal import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" ) import ( "github.com/dubbogo/triple/pkg/triple" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { - config.SetConsumerService(&GrpcGreeterImpl{}) + instance.SetConsumerService(&GrpcGreeterImpl{}) } // GrpcGreeterImpl diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 5761aca16d..e508f51eff 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -19,6 +19,8 @@ package internal import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config/provider" "log" ) @@ -56,9 +58,9 @@ func InitDubboServer() { config.WithServiceCluster("failover"), )), ) - config.SetProviderConfig(*providerConfig) // set to providerConfig ptr + provider.SetProviderConfig(*providerConfig) // set to providerConfig ptr - config.SetProviderService(&Server{ + instance.SetProviderService(&Server{ GreeterProviderBase: &GreeterProviderBase{}, }) config.Load() diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 66208c828a..74b6f1b192 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -18,6 +18,7 @@ package grpc import ( + "dubbo.apache.org/dubbo-go/v3/config/instance" "reflect" "strconv" ) @@ -117,7 +118,7 @@ func NewClient(url *common.URL) (*Client, error) { } key := url.GetParam(constant.BEAN_NAME_KEY, "") - impl := config.GetConsumerService(key) + impl := instance.GetConsumerService(key) invoker := getInvoker(impl, conn) return &Client{ diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 0570e470e0..46c6cf33bf 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -18,6 +18,12 @@ package grpc import ( + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/base" + "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config/method" + "dubbo.apache.org/dubbo-go/v3/config/provider" + "dubbo.apache.org/dubbo-go/v3/config/service" "testing" "time" ) @@ -28,15 +34,14 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal/helloworld" ) func doInitProvider() { - providerConfig := config.ProviderConfig{ - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{ + providerConfig := provider.ProviderConfig{ + BaseConfig: base.Config{ + ApplicationConfig: &application.Config{ Organization: "dubbo_org", Name: "BDTService", Module: "module", @@ -45,7 +50,7 @@ func doInitProvider() { Environment: "test", }, }, - Services: map[string]*config.ServiceConfig{ + Services: map[string]*service.Config{ "GrpcGreeterImpl": { InterfaceName: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", Protocol: "grpc", @@ -53,7 +58,7 @@ func doInitProvider() { Cluster: "failover", Loadbalance: "random", Retries: "3", - Methods: []*config.MethodConfig{ + Methods: []*method.MethodConfig{ { Name: "SayHello", Retries: "2", @@ -64,12 +69,12 @@ func doInitProvider() { }, }, } - config.SetProviderConfig(providerConfig) + provider.SetProviderConfig(providerConfig) } func TestGrpcProtocolExport(t *testing.T) { // Export - config.SetProviderService(helloworld.NewService()) + instance.SetProviderService(helloworld.NewService()) doInitProvider() url, err := common.NewURL(helloworldURL) diff --git a/protocol/grpc/internal/helloworld/client.go b/protocol/grpc/internal/helloworld/client.go index ec45dd5861..d59a2b5b5b 100644 --- a/protocol/grpc/internal/helloworld/client.go +++ b/protocol/grpc/internal/helloworld/client.go @@ -19,18 +19,15 @@ package helloworld import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" ) import ( "google.golang.org/grpc" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { - config.SetConsumerService(&GrpcGreeterImpl{}) + instance.SetConsumerService(&GrpcGreeterImpl{}) } // GrpcGreeterImpl diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 5f79ef0399..98bf61a2be 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -18,18 +18,15 @@ package routeguide import ( + "dubbo.apache.org/dubbo-go/v3/config/instance" "io" "log" "math/rand" "time" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { - config.SetConsumerService(&RouteGuideClientImpl{}) + instance.SetConsumerService(&RouteGuideClientImpl{}) } // printFeatures lists all the features within the given bounding Rectangle. diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index e068999447..42a45a38bc 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -18,6 +18,8 @@ package grpc import ( + "dubbo.apache.org/dubbo-go/v3/config/instance" + service2 "dubbo.apache.org/dubbo-go/v3/config/service" "fmt" "net" "sync" @@ -115,7 +117,7 @@ func getSyncMapLen(m *sync.Map) int { } // waitGrpcExporter wait until len(providerServices) = len(ExporterMap) -func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { +func waitGrpcExporter(providerServices map[string]*service2.Config) { t := time.NewTicker(50 * time.Millisecond) defer t.Stop() pLen := len(providerServices) @@ -136,9 +138,9 @@ func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { } // registerService SetProxyImpl invoker and grpc service -func registerService(providerServices map[string]*config.ServiceConfig, server *grpc.Server) { +func registerService(providerServices map[string]*service2.Config, server *grpc.Server) { for key, providerService := range providerServices { - service := config.GetProviderService(key) + service := instance.GetProviderService(key) ds, ok := service.(DubboGrpcService) if !ok { panic("illegal service type registered") diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 213cc40000..a314af10b8 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -18,6 +18,7 @@ package jsonrpc import ( + "dubbo.apache.org/dubbo-go/v3/config/consumer" "fmt" "strings" "testing" @@ -30,7 +31,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -74,11 +74,11 @@ func TestJsonrpcProtocolRefer(t *testing.T) { "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + "side=provider&timeout=3000×tamp=1556509797245") assert.NoError(t, err) - con := config.ConsumerConfig{ + con := consumer.Config{ ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } - config.SetConsumerConfig(con) + consumer.SetConsumerConfig(con) invoker := proto.Refer(url) // make sure url diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index 4141b6e00a..b426854207 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -19,6 +19,7 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" ) @@ -31,7 +32,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" @@ -67,8 +67,8 @@ func TestRestInvokerInvoke(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := config.ProviderConfig{} - config.SetProviderConfig(con) + con := provider.ProviderConfig{} + provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 2ee6b63fd3..7d2ed20daa 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -19,6 +19,8 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/consumer" + "dubbo.apache.org/dubbo-go/v3/config/provider" "errors" "fmt" "strings" @@ -34,7 +36,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" ) @@ -43,11 +44,11 @@ func TestRestProtocolRefer(t *testing.T) { proto := GetRestProtocol() url, err := common.NewURL(mockRestCommonUrl) assert.NoError(t, err) - con := config.ConsumerConfig{ + con := consumer.Config{ ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } - config.SetConsumerConfig(con) + consumer.SetConsumerConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ Client: "resty", @@ -74,8 +75,8 @@ func TestRestProtocolExport(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := config.ProviderConfig{} - config.SetProviderConfig(con) + con := provider.ProviderConfig{} + provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 15a395e865..39d2c5bf68 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,6 +18,9 @@ package directory import ( + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/base" + "dubbo.apache.org/dubbo-go/v3/config/consumer" "strconv" "testing" "time" @@ -32,7 +35,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "dubbo.apache.org/dubbo-go/v3/registry" @@ -40,9 +42,9 @@ import ( ) func init() { - config.SetConsumerConfig(config.ConsumerConfig{ - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, + consumer.SetConsumerConfig(consumer.Config{ + BaseConfig: base.Config{ + ApplicationConfig: &application.Config{Name: "test-application"}, }, }) } diff --git a/registry/etcdv3/service_discovery_test.go b/registry/etcdv3/service_discovery_test.go index a69db6d95b..a9d630413c 100644 --- a/registry/etcdv3/service_discovery_test.go +++ b/registry/etcdv3/service_discovery_test.go @@ -18,6 +18,7 @@ package etcdv3 import ( + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "testing" ) @@ -34,7 +35,7 @@ import ( var testName = "test" func setUp() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ Protocol: "etcdv3", RemoteRef: testName, } @@ -52,7 +53,7 @@ func Test_newEtcdV3ServiceDiscovery(t *testing.T) { // warn: log configure file name is nil assert.NotNil(t, err) - sdc := &config.ServiceDiscoveryConfig{ + sdc := &discovery.Config{ Protocol: "etcdv3", RemoteRef: "mock", } diff --git a/registry/event/service_config_exported_event.go b/registry/event/service_config_exported_event.go index af566e3b28..4b206c8812 100644 --- a/registry/event/service_config_exported_event.go +++ b/registry/event/service_config_exported_event.go @@ -18,22 +18,22 @@ package event import ( + "dubbo.apache.org/dubbo-go/v3/config/service" "time" ) import ( "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/config" ) // ServiceConfigExportedEvent represents an service was exported type ServiceConfigExportedEvent struct { observer.BaseEvent - ServiceConfig *config.ServiceConfig + ServiceConfig *service.Config } // NewServiceConfigExportedEvent create an instance -func NewServiceConfigExportedEvent(serviceConfig *config.ServiceConfig) *ServiceConfigExportedEvent { +func NewServiceConfigExportedEvent(serviceConfig *service.Config) *ServiceConfigExportedEvent { return &ServiceConfigExportedEvent{ BaseEvent: observer.BaseEvent{ Source: serviceConfig, diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index 2ca5915854..4914eff543 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -18,6 +18,7 @@ package file import ( + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "math/rand" "strconv" "testing" @@ -87,7 +88,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ Protocol: "file", } } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 03b1b9cb8c..3b26f930b3 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -18,6 +18,7 @@ package nacos import ( + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "math/rand" "strconv" "testing" @@ -46,10 +47,10 @@ func Test_newNacosServiceDiscovery(t *testing.T) { name := "nacos1" _, err := newNacosServiceDiscovery(name) - // the ServiceDiscoveryConfig not found + // the Config not found assert.NotNil(t, err) - sdc := &config.ServiceDiscoveryConfig{ + sdc := &discovery.Config{ Protocol: "nacos", RemoteRef: "mock", } @@ -178,7 +179,7 @@ func TestNacosServiceDiscovery_Destroy(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ Protocol: "nacos", RemoteRef: testName, } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 25204e6bb7..c0fd2513dc 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -19,6 +19,7 @@ package protocol import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "strings" "sync" ) @@ -248,7 +249,7 @@ func registerServiceMap(invoker protocol.Invoker) error { s := "reExport can not get serviceConfig" return perrors.New(s) } - rpcService := config.GetProviderService(id) + rpcService := instance.GetProviderService(id) if rpcService == nil { s := "reExport can not get RPCService" return perrors.New(s) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 45d60b154d..9e158cc70d 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -18,6 +18,10 @@ package protocol import ( + "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/base" + "dubbo.apache.org/dubbo-go/v3/config/consumer" + "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" ) @@ -33,7 +37,6 @@ import ( common_cfg "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" @@ -43,8 +46,8 @@ import ( ) func init() { - config.SetProviderConfig(config.ProviderConfig{BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, + provider.SetProviderConfig(provider.ProviderConfig{BaseConfig: base.Config{ + ApplicationConfig: &application.Config{Name: "test-application"}, }}) } @@ -68,9 +71,9 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { } func TestRefer(t *testing.T) { - config.SetConsumerConfig( - config.ConsumerConfig{BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, + consumer.SetConsumerConfig( + consumer.Config{BaseConfig: base.Config{ + ApplicationConfig: &application.Config{Name: "test-application"}, }}) regProtocol := newRegistryProtocol() referNormal(t, regProtocol) diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index 8c926429b2..fcfc5a684d 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -18,12 +18,12 @@ package servicediscovery import ( + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "testing" ) import ( gxset "github.com/dubbogo/gost/container/set" - "github.com/dubbogo/gost/hash/page" "github.com/stretchr/testify/assert" ) @@ -64,7 +64,7 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { }) extension.SetAndInitGlobalDispatcher("mock") - config.GetBaseConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ + config.GetBaseConfig().ServiceDiscoveries["mock"] = &discovery.Config{ Protocol: "mock", } registryURL, _ := common.NewURL("service-discovery://localhost:12345", diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index 512031bd4b..a5ac104fea 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -19,6 +19,7 @@ package zookeeper import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "strconv" "sync" "testing" @@ -53,7 +54,7 @@ func prepareData(t *testing.T) *zk.TestCluster { address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) //address := "127.0.0.1:2181" - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ Protocol: "zookeeper", RemoteRef: "test", } @@ -69,11 +70,11 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) { name := "zookeeper1" _, err := newZookeeperServiceDiscovery(name) - // the ServiceDiscoveryConfig not found + // the Config not found // err: could not init the instance because the config is invalid assert.NotNil(t, err) - sdc := &config.ServiceDiscoveryConfig{ + sdc := &discovery.Config{ Protocol: "zookeeper", RemoteRef: "mock", } diff --git a/remoting/getty/config.go b/remoting/getty/config.go index bd56291b38..0342730b7d 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -18,6 +18,7 @@ package getty import ( + "dubbo.apache.org/dubbo-go/v3/config/consumer" "time" ) @@ -25,10 +26,6 @@ import ( perrors "github.com/pkg/errors" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - type ( // GettySessionParam is session configuration for getty GettySessionParam struct { @@ -190,9 +187,9 @@ func (c *ClientConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(HeartbeatPeroid{%#v})", c.HeartbeatPeriod) } - if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { + if c.heartbeatPeriod >= time.Duration(consumer.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", - c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) + c.HeartbeatPeriod, time.Duration(consumer.MaxWheelTimeSpan)) } if len(c.HeartbeatTimeout) == 0 { @@ -218,9 +215,9 @@ func (c *ServerConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(HeartbeatPeroid{%#v})", c.HeartbeatPeriod) } - if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { + if c.heartbeatPeriod >= time.Duration(consumer.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", - c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) + c.HeartbeatPeriod, time.Duration(consumer.MaxWheelTimeSpan)) } if len(c.HeartbeatTimeout) == 0 { @@ -233,9 +230,9 @@ func (c *ServerConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(SessionTimeout{%#v})", c.SessionTimeout) } - if c.sessionTimeout >= time.Duration(config.MaxWheelTimeSpan) { + if c.sessionTimeout >= time.Duration(consumer.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "session_timeout %s should be less than %s", - c.SessionTimeout, time.Duration(config.MaxWheelTimeSpan)) + c.SessionTimeout, time.Duration(consumer.MaxWheelTimeSpan)) } return perrors.WithStack(c.GettySessionParam.CheckValidity()) diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go index 4aa6a53512..7565ce18d2 100644 --- a/test/integrate/dubbo/go-client/user.go +++ b/test/integrate/dubbo/go-client/user.go @@ -19,18 +19,18 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "time" ) import ( - "dubbo.apache.org/dubbo-go/v3/config" hessian "github.com/apache/dubbo-go-hessian2" ) var userProvider = new(UserProvider) func init() { - config.SetConsumerService(userProvider) + instance.SetConsumerService(userProvider) hessian.RegisterPOJO(&User{}) } diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go index 1d7e36b86c..e0b749675a 100644 --- a/test/integrate/dubbo/go-server/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -19,17 +19,17 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config/instance" "fmt" "time" ) import ( hessian "github.com/apache/dubbo-go-hessian2" - "dubbo.apache.org/dubbo-go/v3/config" ) func init() { - config.SetProviderService(new(UserProvider)) + instance.SetProviderService(new(UserProvider)) // ------for hessian2------ hessian.RegisterPOJO(&User{}) } From 9388db1c7b50bad08cb4d9fc78359fa9c84bf38c Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 18 Jul 2021 02:27:11 +0800 Subject: [PATCH 003/148] set Koanf --- config/config_loader.go | 2 +- config/root/root_config.go | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 015c9b7c16..4e5c7df2da 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -102,7 +102,7 @@ func Load(opts ...Option) { panic(err) } - rootConfig.SetKoanf(k) + rootConfig.Koanf = k rootConfig.Validate = validator.New() } diff --git a/config/root/root_config.go b/config/root/root_config.go index 921dab76ab..af8c3b95aa 100644 --- a/config/root/root_config.go +++ b/config/root/root_config.go @@ -38,7 +38,7 @@ type Config struct { MetricConfig *metric.MetricConfig `yaml:"metrics" json:"metrics,omitempty"` fileStream *bytes.Buffer - koanf *koanf.Koanf + Koanf *koanf.Koanf // validate Validate *validator.Validate // cache file used to store the current used configurations. @@ -48,9 +48,4 @@ type Config struct { // Prefix dubbo func (Config) Prefix() string { return constant.DUBBO -} - -// SetKoanf set koanf -func (c *Config) SetKoanf(k *koanf.Koanf) { - c.koanf = k } \ No newline at end of file From 0c4d7495d9390d3119a38afabebc29ea6a545d31 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Wed, 21 Jul 2021 11:53:33 +0800 Subject: [PATCH 004/148] add:registry config --- config/config_loader.go | 131 ++++++------------ config/config_loader_options.go | 87 ++++++++++++ config/config_loader_test.go | 42 ++++-- config/consumer/consumer_config.go | 6 +- config/method/method_config.go | 10 +- config/protocol/protocol_config.go | 10 +- config/provider/provider_config.go | 30 ++-- config/reference/reference_config.go | 26 ++-- config/registry/registry_config.go | 69 +++++---- config/registry/registry_config_test.go | 38 +++-- config/root/root_config.go | 6 +- config/service/service_config.go | 42 +++--- config/shutdown/graceful_shutdown.go | 2 +- config/shutdown/graceful_shutdown_config.go | 12 +- .../shutdown/graceful_shutdown_config_test.go | 6 +- config/testdata/application.yaml | 6 +- filter/gshutdown/filter.go | 4 +- filter/gshutdown/filter_test.go | 2 +- .../service/exporter/configurable/exporter.go | 2 +- .../exporter/configurable/exporter_test.go | 10 +- protocol/grpc/grpc_protocol_test.go | 4 +- protocol/rest/rest_invoker_test.go | 2 +- protocol/rest/rest_protocol_test.go | 2 +- registry/directory/directory.go | 6 +- registry/protocol/protocol_test.go | 2 +- 25 files changed, 328 insertions(+), 229 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 4e5c7df2da..790393b174 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -19,6 +19,7 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/registry" "dubbo.apache.org/dubbo-go/v3/config/root" "fmt" "github.com/go-playground/validator/v10" @@ -28,10 +29,6 @@ import ( "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/file" "github.com/pkg/errors" - "os" - "path/filepath" - "runtime" - "strings" ) import ( @@ -39,9 +36,11 @@ import ( ) var ( + rootConfig *root.Config // application config applicationConfig *application.Config - rootConfig *root.Config + // + registriesConfig map[string]*registry.Config //consumerConfig *consumer.Config //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig @@ -59,27 +58,6 @@ var ( //uniformDestRuleConfigPath string ) -type config struct { - // config file name default application - name string - // config file type default yaml - genre string - // config file path default ./conf - path string - // config file delim default . - delim string -} - -type optionFunc func(*config) - -func (fn optionFunc) apply(vc *config) { - fn(vc) -} - -type Option interface { - apply(vc *config) -} - func Load(opts ...Option) { // pares CommandLine //parseCommandLine() @@ -106,10 +84,17 @@ func Load(opts ...Option) { rootConfig.Validate = validator.New() } +func check() error { + if rootConfig == nil { + return errors.New("execute the config.Load() method first") + } + return nil +} + // GetApplicationConfig get application config func GetApplicationConfig() (*application.Config, error) { - if rootConfig == nil { - return nil, nil + if err := check(); err != nil { + return nil, err } if applicationConfig != nil { return applicationConfig, nil @@ -140,64 +125,6 @@ func GetApplicationConfig() (*application.Config, error) { // } //} -// WithGenre set config genre -func WithGenre(genre string) Option { - return optionFunc(func(conf *config) { - conf.genre = strings.ToLower(genre) - }) -} - -// WithPath set config path -func WithPath(path string) Option { - return optionFunc(func(conf *config) { - conf.path = absolutePath(path) - }) -} - -// WithName set config name -func WithName(name string) Option { - return optionFunc(func(conf *config) { - conf.name = name - }) -} - -func WithDelim(delim string) Option { - return optionFunc(func(conf *config) { - conf.delim = delim - }) -} - -// absolutePath get absolut path -func absolutePath(inPath string) string { - - if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { - inPath = userHomeDir() + inPath[5:] - } - - if filepath.IsAbs(inPath) { - return filepath.Clean(inPath) - } - - p, err := filepath.Abs(inPath) - if err == nil { - return filepath.Clean(p) - } - - return "" -} - -//userHomeDir get gopath -func userHomeDir() string { - if runtime.GOOS == "windows" { - home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") - if home == "" { - home = os.Getenv("USERPROFILE") - } - return home - } - return os.Getenv("HOME") -} - func getKoanf(conf *config) *koanf.Koanf { var ( k *koanf.Koanf @@ -224,6 +151,38 @@ func getKoanf(conf *config) *koanf.Koanf { return k } +func GetRegistriesConfig() (map[string]*registry.Config, error) { + if err := check(); err != nil { + return nil, err + } + if registriesConfig != nil { + return registriesConfig, nil + } + + registries := rootConfig.Registries + + if len(registries) <= 0 { + reg := new(registry.Config) + if err := reg.SetDefault(); err != nil { + return nil, err + } + registries = make(map[string]*registry.Config, 1) + registries["default"] = reg + return registries, nil + } + for _, reg := range registries { + if err := reg.SetDefault(); err != nil { + return nil, err + } + reg.TranslateRegistryAddress() + if err := reg.Validate(rootConfig.Validate); err != nil { + return nil, err + } + } + registriesConfig = registries + return registries, nil +} + // //// loaded consumer & provider config from xxx.yml, and log config from xxx.xml //// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 4b4ca7727b..3f01c01491 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -16,6 +16,93 @@ */ package config + +import ( + "os" + "path/filepath" + "runtime" + "strings" +) + +type config struct { + // config file name default application + name string + // config file type default yaml + genre string + // config file path default ./conf + path string + // config file delim default . + delim string +} + +type optionFunc func(*config) + +func (fn optionFunc) apply(vc *config) { + fn(vc) +} + +type Option interface { + apply(vc *config) +} + +// WithGenre set config genre +func WithGenre(genre string) Option { + return optionFunc(func(conf *config) { + conf.genre = strings.ToLower(genre) + }) +} + +// WithPath set config path +func WithPath(path string) Option { + return optionFunc(func(conf *config) { + conf.path = absolutePath(path) + }) +} + +// WithName set config name +func WithName(name string) Option { + return optionFunc(func(conf *config) { + conf.name = name + }) +} + +func WithDelim(delim string) Option { + return optionFunc(func(conf *config) { + conf.delim = delim + }) +} + +// absolutePath get absolut path +func absolutePath(inPath string) string { + + if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { + inPath = userHomeDir() + inPath[5:] + } + + if filepath.IsAbs(inPath) { + return filepath.Clean(inPath) + } + + p, err := filepath.Abs(inPath) + if err == nil { + return filepath.Clean(p) + } + + return "" +} + +//userHomeDir get gopath +func userHomeDir() string { + if runtime.GOOS == "windows" { + home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + if home == "" { + home = os.Getenv("USERPROFILE") + } + return home + } + return os.Getenv("HOME") +} + // //import ( // "dubbo.apache.org/dubbo-go/v3/config/base" diff --git a/config/config_loader_test.go b/config/config_loader_test.go index fb5e616007..eb703303e2 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,7 +18,6 @@ package config import ( - "fmt" "testing" ) import ( @@ -29,20 +28,41 @@ const ( configPath = "./testdata/application.yaml" ) +func TestNoLoad(t *testing.T) { + + application, err := GetApplicationConfig() + assert.NotNil(t, err) + assert.Nil(t, application) +} + func TestLoad(t *testing.T) { Load(WithPath(configPath)) - application, err := GetApplicationConfig() - fmt.Println(GetApplicationConfig()) - assert.Nil(t, err) + t.Run("application", func(t *testing.T) { + application, err := GetApplicationConfig() + assert.Nil(t, err) + application, err = GetApplicationConfig() + assert.Nil(t, err) + + assert.Equal(t, application.Organization, "dubbo.io") + assert.Equal(t, application.Name, "dubbo-go") + assert.Equal(t, application.Module, "local") + assert.Equal(t, application.Version, "1.0.0") + assert.Equal(t, application.Owner, "zhaoyunxing") + assert.Equal(t, application.Environment, "dev") + assert.Equal(t, application.MetadataType, "local") + }) + + t.Run("registries", func(t *testing.T) { + registries, err := GetRegistriesConfig() + registries, err = GetRegistriesConfig() + assert.Nil(t, err) + assert.Equal(t, 2, len(registries)) + //address= nacos://127.0.0.1:8848 Translate Registry Address + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "10s", registries["zk"].Timeout) + }) - assert.Equal(t, application.Organization, "dubbo.io") - assert.Equal(t, application.Name, "dubbo-go") - assert.Equal(t, application.Module, "local") - assert.Equal(t, application.Version, "1.0.0") - assert.Equal(t, application.Owner, "zhaoyunxing") - assert.Equal(t, application.Environment, "dev") - assert.Equal(t, application.MetadataType, "local") } // diff --git a/config/consumer/consumer_config.go b/config/consumer/consumer_config.go index e76a454bff..9d814cb2fb 100644 --- a/config/consumer/consumer_config.go +++ b/config/consumer/consumer_config.go @@ -45,8 +45,8 @@ type Config struct { Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` ConnectTimeout time.Duration - Registry *registry.RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*registry.RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Registry *registry.Config `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries map[string]*registry.Config `default:"{}" yaml:"registries" json:"registries" property:"registries"` Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` RequestTimeout time.Duration @@ -56,7 +56,7 @@ type Config struct { References map[string]*reference.ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *shutdown.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ShutdownConfig *shutdown.Config `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } diff --git a/config/method/method_config.go b/config/method/method_config.go index dc441ef7da..ce858c0466 100644 --- a/config/method/method_config.go +++ b/config/method/method_config.go @@ -25,8 +25,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// MethodConfig defines method config -type MethodConfig struct { +// Config defines method config +type Config struct { InterfaceId string InterfaceName string Name string `yaml:"name" json:"name,omitempty" property:"name"` @@ -43,7 +43,7 @@ type MethodConfig struct { } // nolint -func (c *MethodConfig) Prefix() string { +func (c *Config) Prefix() string { if len(c.InterfaceId) != 0 { return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "." } @@ -52,10 +52,10 @@ func (c *MethodConfig) Prefix() string { } // UnmarshalYAML unmarshals the MethodConfig by @unmarshal function -func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain MethodConfig + type plain Config return unmarshal((*plain)(c)) } diff --git a/config/protocol/protocol_config.go b/config/protocol/protocol_config.go index cd02b0970e..7219ecbeb4 100644 --- a/config/protocol/protocol_config.go +++ b/config/protocol/protocol_config.go @@ -25,20 +25,20 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// ProtocolConfig is protocol configuration -type ProtocolConfig struct { +// Config is protocol configuration +type Config struct { Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"` Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"` Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` } // nolint -func (c *ProtocolConfig) Prefix() string { +func (c *Config) Prefix() string { return constant.ProtocolConfigPrefix } -func loadProtocol(protocolsIds string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { - returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) +func loadProtocol(protocolsIds string, protocols map[string]*Config) []*Config { + returnProtocols := make([]*Config, 0, len(protocols)) for _, v := range strings.Split(protocolsIds, ",") { for k, protocol := range protocols { if v == k { diff --git a/config/provider/provider_config.go b/config/provider/provider_config.go index 710923e3f7..ed50ecbbd4 100644 --- a/config/provider/provider_config.go +++ b/config/provider/provider_config.go @@ -19,7 +19,6 @@ package provider import ( "dubbo.apache.org/dubbo-go/v3/config/protocol" - "dubbo.apache.org/dubbo-go/v3/config/registry" "dubbo.apache.org/dubbo-go/v3/config/service" "dubbo.apache.org/dubbo-go/v3/config/shutdown" ) @@ -32,34 +31,31 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// ProviderConfig is the default configuration of service provider -type ProviderConfig struct { +// Config is the default configuration of service provider +type Config struct { //base.Config `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*service.Config `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*protocol.ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *shutdown.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` - - Registry *registry.RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*registry.RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + Services map[string]*service.Config `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *shutdown.Config `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain ProviderConfig + type plain Config return unmarshal((*plain)(c)) } // nolint -func (*ProviderConfig) Prefix() string { +func (*Config) Prefix() string { return constant.ProviderConfigPrefix } diff --git a/config/reference/reference_config.go b/config/reference/reference_config.go index bf9efbf8a2..9fcbd37232 100644 --- a/config/reference/reference_config.go +++ b/config/reference/reference_config.go @@ -34,19 +34,19 @@ type ReferenceConfig struct { InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` URL string `yaml:"url" json:"url,omitempty" property:"url"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` - Methods []*method.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` - Async bool `yaml:"async" json:"async,omitempty" property:"async"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` + Methods []*method.Config `yaml:"methods" json:"methods,omitempty" property:"methods"` + Async bool `yaml:"async" json:"async,omitempty" property:"async"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` invoker protocol.Invoker urls []*common.URL Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` diff --git a/config/registry/registry_config.go b/config/registry/registry_config.go index 37d48db605..f042d44dae 100644 --- a/config/registry/registry_config.go +++ b/config/registry/registry_config.go @@ -18,6 +18,8 @@ package registry import ( + "errors" + "github.com/go-playground/validator/v10" "net/url" "strconv" "strings" @@ -33,14 +35,14 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// RegistryConfig is the configuration of the registry center -type RegistryConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second - Group string `yaml:"group" json:"group,omitempty" property:"group"` - TTL string `yaml:"ttl" default:"10m" json:"ttl,omitempty" property:"ttl"` // unit: minute +// Config is the configuration of the registry center +type Config struct { + Protocol string `default:"zookeeper" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second + Group string `yaml:"group" json:"group,omitempty" property:"group"` + TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry - Address string `yaml:"address" json:"address,omitempty" property:"address"` + Address string `default:"127.0.0.1:2181" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` Password string `yaml:"password" json:"password,omitempty" property:"password"` Simplified bool `yaml:"simplified" json:"simplified,omitempty" property:"simplified"` @@ -54,21 +56,39 @@ type RegistryConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -// UnmarshalYAML unmarshals the RegistryConfig by @unmarshal function -func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// SetDefault set default value +func (c *Config) SetDefault() error { + return defaults.Set(c) +} + +// Validate valida value +func (c *Config) Validate(valid *validator.Validate) error { + if err := valid.Struct(c); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil +} + +// UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function +func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain RegistryConfig + type plain Config return unmarshal((*plain)(c)) } -// nolint -func (*RegistryConfig) Prefix() string { - return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix +// Prefix dubbo.registries +func (Config) Prefix() string { + return constant.RegistryConfigPrefix } -func loadRegistries(targetRegistries string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { +func loadRegistries(targetRegistries string, registries map[string]*Config, roleType common.RoleType) []*common.URL { var urls []*common.URL trSlice := strings.Split(targetRegistries, ",") @@ -95,7 +115,7 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf if target { addresses := strings.Split(registryConf.Address, ",") address := addresses[0] - address = translateRegistryConf(address, registryConf) + address = registryConf.TranslateRegistryAddress() url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, common.WithParams(registryConf.getUrlMap(roleType)), common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), @@ -116,12 +136,12 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf return urls } -func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { +func (c *Config) getUrlMap(roleType common.RoleType) url.Values { urlMap := url.Values{} urlMap.Set(constant.GROUP_KEY, c.Group) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) urlMap.Set(constant.REGISTRY_KEY, c.Protocol) - urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.TimeoutStr) + urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.Timeout) // multi registry invoker weight label for load balance urlMap.Set(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, strconv.FormatBool(true)) urlMap.Set(constant.REGISTRY_KEY+"."+constant.PREFERRED_KEY, strconv.FormatBool(c.Preferred)) @@ -134,16 +154,17 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { return urlMap } -func translateRegistryConf(address string, registryConf *RegistryConfig) string { - if strings.Contains(address, "://") { - translatedUrl, err := url.Parse(address) +//TranslateRegistryAddress translate registry address +// eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos +func (c *Config) TranslateRegistryAddress() string { + if strings.Contains(c.Address, "://") { + translatedUrl, err := url.Parse(c.Address) if err != nil { logger.Errorf("The registry url is invalid, error: %#v", err) panic(err) } - address = translatedUrl.Host - registryConf.Protocol = translatedUrl.Scheme - registryConf.Address = strings.Replace(registryConf.Address, translatedUrl.Scheme+"://", "", -1) + c.Protocol = translatedUrl.Scheme + c.Address = strings.Replace(c.Address, translatedUrl.Scheme+"://", "", -1) } - return address + return c.Address } diff --git a/config/registry/registry_config_test.go b/config/registry/registry_config_test.go index c156cf9875..efd49908f2 100644 --- a/config/registry/registry_config_test.go +++ b/config/registry/registry_config_test.go @@ -30,15 +30,15 @@ import ( func TestLoadRegistries(t *testing.T) { target := "shanghai1" - regs := map[string]*RegistryConfig{ + regs := map[string]*Config{ "shanghai1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181,128.0.0.1:2181", - Username: "user1", - Password: "pwd1", + Protocol: "mock", + Timeout: "2s", + Group: "shanghai_idc", + Address: "127.0.0.2:2181,128.0.0.1:2181", + Username: "user1", + Password: "pwd1", }, } urls := loadRegistries(target, regs, common.CONSUMER) @@ -48,18 +48,28 @@ func TestLoadRegistries(t *testing.T) { func TestLoadRegistries1(t *testing.T) { target := "shanghai1" - regs := map[string]*RegistryConfig{ + regs := map[string]*Config{ "shanghai1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", + Protocol: "mock", + Timeout: "2s", + Group: "shanghai_idc", + Address: "127.0.0.2:2181", + Username: "user1", + Password: "pwd1", }, } urls := loadRegistries(target, regs, common.CONSUMER) t.Logf("loadRegistries() = urls:%v", urls) assert.Equal(t, "127.0.0.2:2181", urls[0].Location) } + +func TestTranslateRegistryAddress(t *testing.T) { + reg := new(Config) + reg.Address = "nacos://127.0.0.1:8848" + + address := reg.TranslateRegistryAddress() + + assert.Equal(t, "nacos", reg.Protocol) + assert.Equal(t, "127.0.0.1:8848", address) +} diff --git a/config/root/root_config.go b/config/root/root_config.go index af8c3b95aa..a493c8ad1c 100644 --- a/config/root/root_config.go +++ b/config/root/root_config.go @@ -2,6 +2,7 @@ package root import ( "bytes" + "dubbo.apache.org/dubbo-go/v3/config/registry" ) import ( @@ -32,6 +33,9 @@ type Config struct { // Application application config Application *application.Config `yaml:"application" json:"application,omitempty" property:"application"` + // Registries registry config + Registries map[string]*registry.Config `default:"{}" yaml:"registries" json:"registries" property:"registries"` + // prefix string fatherConfig interface{} EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` @@ -48,4 +52,4 @@ type Config struct { // Prefix dubbo func (Config) Prefix() string { return constant.DUBBO -} \ No newline at end of file +} diff --git a/config/service/service_config.go b/config/service/service_config.go index c8714fa3f6..d71a27fd2a 100644 --- a/config/service/service_config.go +++ b/config/service/service_config.go @@ -47,25 +47,25 @@ import ( // Config is the configuration of the service provider type Config struct { id string - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' - InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version" ` - Methods []*method.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` - Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - Token string `yaml:"token" json:"token,omitempty" property:"token"` - AccessLog string `yaml:"accesslog" json:"accesslog,omitempty" property:"accesslog"` - TpsLimiter string `yaml:"tps.limiter" json:"tps.limiter,omitempty" property:"tps.limiter"` - TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"` - TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"` - TpsLimitStrategy string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` + Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version" ` + Methods []*method.Config `yaml:"methods" json:"methods,omitempty" property:"methods"` + Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Token string `yaml:"token" json:"token,omitempty" property:"token"` + AccessLog string `yaml:"accesslog" json:"accesslog,omitempty" property:"accesslog"` + TpsLimiter string `yaml:"tps.limiter" json:"tps.limiter,omitempty" property:"tps.limiter"` + TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"` + TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"` + TpsLimitStrategy string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"` TpsLimitRejectedHandler string `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"` ExecuteLimit string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"` ExecuteLimitRejectedHandler string `yaml:"execute.limit.rejected.handler" json:"execute.limit.rejected.handler,omitempty" property:"execute.limit.rejected.handler"` @@ -74,7 +74,7 @@ type Config struct { Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - Protocols map[string]*protocol2.ProtocolConfig + Protocols map[string]*protocol2.Config unexported *atomic.Bool exported *atomic.Bool export bool // a flag to control whether the current service should export or not @@ -127,7 +127,7 @@ func (c *Config) IsExport() bool { } // Get Random Port -func getRandomPort(protocolConfigs []*protocol2.ProtocolConfig) *list.List { +func getRandomPort(protocolConfigs []*protocol2.Config) *list.List { ports := list.New() for _, proto := range protocolConfigs { if len(proto.Port) > 0 { diff --git a/config/shutdown/graceful_shutdown.go b/config/shutdown/graceful_shutdown.go index e2cda52e53..f4b04d8e82 100644 --- a/config/shutdown/graceful_shutdown.go +++ b/config/shutdown/graceful_shutdown.go @@ -183,7 +183,7 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { // waitingProcessedTimeout(config.consumerConfig.ShutdownConfig) //} -func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { +func waitingProcessedTimeout(shutdownConfig *Config) { timeout := shutdownConfig.GetStepTimeout() if timeout <= 0 { return diff --git a/config/shutdown/graceful_shutdown_config.go b/config/shutdown/graceful_shutdown_config.go index 57c97368a6..e90a97d0fb 100644 --- a/config/shutdown/graceful_shutdown_config.go +++ b/config/shutdown/graceful_shutdown_config.go @@ -31,8 +31,8 @@ const ( defaultStepTimeout = 10 * time.Second ) -// ShutdownConfig is used as configuration for graceful shutdown -type ShutdownConfig struct { +// Config is used as configuration for graceful shutdown +type Config struct { /* * Total timeout. Even though we don't release all resources, * the application will shutdown if the costing time is over this configuration. The unit is ms. @@ -57,13 +57,13 @@ type ShutdownConfig struct { RequestsFinished bool } -// nolint -func (config *ShutdownConfig) Prefix() string { +// Prefix dubbo.shutdown +func (config *Config) Prefix() string { return constant.ShutdownConfigPrefix } // nolint -func (config *ShutdownConfig) GetTimeout() time.Duration { +func (config *Config) GetTimeout() time.Duration { result, err := time.ParseDuration(config.Timeout) if err != nil { logger.Errorf("The Timeout configuration is invalid: %s, and we will use the default value: %s, err: %v", @@ -74,7 +74,7 @@ func (config *ShutdownConfig) GetTimeout() time.Duration { } // nolint -func (config *ShutdownConfig) GetStepTimeout() time.Duration { +func (config *Config) GetStepTimeout() time.Duration { result, err := time.ParseDuration(config.StepTimeout) if err != nil { logger.Errorf("The StepTimeout configuration is invalid: %s, and we will use the default value: %s, err: %v", diff --git a/config/shutdown/graceful_shutdown_config_test.go b/config/shutdown/graceful_shutdown_config_test.go index 7eca40c55c..766cb3f907 100644 --- a/config/shutdown/graceful_shutdown_config_test.go +++ b/config/shutdown/graceful_shutdown_config_test.go @@ -27,11 +27,11 @@ import ( ) func TestShutdownConfigGetTimeout(t *testing.T) { - config := ShutdownConfig{} + config := Config{} assert.False(t, config.RejectRequest) assert.False(t, config.RequestsFinished) - config = ShutdownConfig{ + config = Config{ Timeout: "60s", StepTimeout: "10s", } @@ -39,7 +39,7 @@ func TestShutdownConfigGetTimeout(t *testing.T) { assert.Equal(t, 60*time.Second, config.GetTimeout()) assert.Equal(t, 10*time.Second, config.GetStepTimeout()) - config = ShutdownConfig{ + config = Config{ Timeout: "34ms", StepTimeout: "79ms", } diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index 752c039ddb..5a9a06e9f0 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -6,13 +6,11 @@ dubbo: owner: zhaoyunxing registries: nacos: - protocol: nacos timeout: 5s group: dev - address: 127.0.0.1:8848 + address: nacos://127.0.0.1:8848 zk: - protocol: zk - timeout: 5s + protocol: zookeeper group: dev address: 127.0.0.1:2181 services: diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go index fb29205fff..f28861b283 100644 --- a/filter/gshutdown/filter.go +++ b/filter/gshutdown/filter.go @@ -44,7 +44,7 @@ func init() { type Filter struct { activeCount int32 - shutdownConfig *shutdown.ShutdownConfig + shutdownConfig *shutdown.Config } // Invoke adds the requests count and block the new requests if application is closing @@ -70,7 +70,7 @@ func (f *Filter) OnResponse(ctx context.Context, result protocol.Result, invoker func (f *Filter) Set(name string, conf interface{}) { switch name { case config.GracefulShutdownFilterShutdownConfig: - if shutdownConfig, ok := conf.(*shutdown.ShutdownConfig); !ok { + if shutdownConfig, ok := conf.(*shutdown.Config); !ok { f.shutdownConfig = shutdownConfig return } diff --git a/filter/gshutdown/filter_test.go b/filter/gshutdown/filter_test.go index 5d244d0222..97c5c58eac 100644 --- a/filter/gshutdown/filter_test.go +++ b/filter/gshutdown/filter_test.go @@ -57,7 +57,7 @@ func TestGenericFilterInvoke(t *testing.T) { assert.NotNil(t, result) assert.Nil(t, result.Error()) - providerConfig.ShutdownConfig = &shutdown.ShutdownConfig{ + providerConfig.ShutdownConfig = &shutdown.Config{ RejectRequest: true, RejectRequestHandler: "mock", } diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 5aaa8fe3e0..50ba72d11f 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -55,7 +55,7 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") } - serviceConfig.Protocols = map[string]*protocol.ProtocolConfig{ + serviceConfig.Protocols = map[string]*protocol.Config{ constant.DEFAULT_PROTOCOL: { Name: url.SubURL.Protocol, Port: url.SubURL.Port, diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 7cbf62d00d..4f3ebe75db 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -84,7 +84,7 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &provider.ProviderConfig{ + providerConfig := &provider.Config{ BaseConfig: base.Config{ ApplicationConfig: &application.Config{ @@ -97,12 +97,12 @@ func mockInitProviderWithSingleRegistry() { }, }, - Registry: ®istry.RegistryConfig{ + Registry: ®istry.Config{ Address: "mock://127.0.0.1:2181", Username: "user1", Password: "pwd1", }, - Registries: map[string]*registry.RegistryConfig{}, + Registries: map[string]*registry.Config{}, Services: map[string]*service.Config{ "MockService": { @@ -113,7 +113,7 @@ func mockInitProviderWithSingleRegistry() { Retries: "3", Group: "huadong_idc", Version: "1.0.0", - Methods: []*method.MethodConfig{ + Methods: []*method.Config{ { Name: "GetUser", Retries: "2", @@ -129,7 +129,7 @@ func mockInitProviderWithSingleRegistry() { }, }, }, - Protocols: map[string]*protocol.ProtocolConfig{ + Protocols: map[string]*protocol.Config{ "mock": { Name: "mock", Ip: "127.0.0.1", diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 46c6cf33bf..57a072d0f1 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -39,7 +39,7 @@ import ( ) func doInitProvider() { - providerConfig := provider.ProviderConfig{ + providerConfig := provider.Config{ BaseConfig: base.Config{ ApplicationConfig: &application.Config{ Organization: "dubbo_org", @@ -58,7 +58,7 @@ func doInitProvider() { Cluster: "failover", Loadbalance: "random", Retries: "3", - Methods: []*method.MethodConfig{ + Methods: []*method.Config{ { Name: "SayHello", Retries: "2", diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index b426854207..7f16cf4b42 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -67,7 +67,7 @@ func TestRestInvokerInvoke(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := provider.ProviderConfig{} + con := provider.Config{} provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 7d2ed20daa..592b2867cd 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -75,7 +75,7 @@ func TestRestProtocolExport(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := provider.ProviderConfig{} + con := provider.Config{} provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 7974ad4be6..6b7c2df337 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -486,8 +486,12 @@ type consumerConfigurationListener struct { func newConsumerConfigurationListener(dir *RegistryDirectory) *consumerConfigurationListener { listener := &consumerConfigurationListener{directory: dir} + application, err := config.GetApplicationConfig() + if err != nil { + panic(err) + } listener.InitWith( - config.GetConsumerConfig().ApplicationConfig.Name+constant.CONFIGURATORS_SUFFIX, + application.Name+constant.CONFIGURATORS_SUFFIX, listener, extension.GetDefaultConfiguratorFunc(), ) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 9e158cc70d..f67b2370e9 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -46,7 +46,7 @@ import ( ) func init() { - provider.SetProviderConfig(provider.ProviderConfig{BaseConfig: base.Config{ + provider.SetProviderConfig(provider.Config{BaseConfig: base.Config{ ApplicationConfig: &application.Config{Name: "test-application"}, }}) } From fa807b5fa25ee438b2eda47be12e8a183a55cb7e Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Wed, 21 Jul 2021 15:35:39 +0800 Subject: [PATCH 005/148] add:config center config --- common/constant/key.go | 1 + config/center/config_center_config.go | 108 ++++++++++++++---- config/config_loader.go | 65 +++++++---- config/config_loader_test.go | 40 +++++++ config/root/root_config.go | 3 +- config/testdata/application.yaml | 10 ++ .../config/center/conf-application.yaml | 6 + .../config/center/confApplication.yaml | 6 + .../config/center/conf_application.yaml | 6 + go.mod | 1 + go.sum | 2 + 11 files changed, 205 insertions(+), 43 deletions(-) create mode 100644 config/testdata/config/center/conf-application.yaml create mode 100644 config/testdata/config/center/confApplication.yaml create mode 100644 config/testdata/config/center/conf_application.yaml diff --git a/common/constant/key.go b/common/constant/key.go index e3e992ae34..22191478cc 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -170,6 +170,7 @@ const ( const ( RegistryConfigPrefix = "dubbo.registries" + ConfigCenterPrefix = "dubbo.config-center" SingleRegistryConfigPrefix = "dubbo.registry" ReferenceConfigPrefix = "dubbo.reference" ServiceConfigPrefix = "dubbo.service" diff --git a/config/center/config_center_config.go b/config/center/config_center_config.go index db68b6a0e7..10c12ee154 100644 --- a/config/center/config_center_config.go +++ b/config/center/config_center_config.go @@ -18,12 +18,16 @@ package center import ( - "google.golang.org/grpc/balancer/base" + "errors" + "github.com/knadh/koanf" "net/url" + "strings" ) import ( "github.com/creasty/defaults" + "github.com/go-playground/validator/v10" + "github.com/goinggo/mapstructure" perrors "github.com/pkg/errors" ) @@ -44,20 +48,67 @@ import ( // // ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type Config 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"` - Params map[string]string `yaml:"params" json:"parameters,omitempty"` + Protocol string `validate:"required" 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"` + Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"` + // Deprecated + RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"` + Params map[string]string `yaml:"params" json:"parameters,omitempty"` +} + +// Prefix dubbo.config-center +func (Config) Prefix() string { + return constant.ConfigCenterPrefix +} + +func GetConfigCenterConfig(conf *Config, k *koanf.Koanf) *Config { + if conf != nil { + return conf + } + conf = new(Config) + key := conf.Prefix() + + value := k.Get(key) + if value == nil { + key = strings.ReplaceAll(key, "-", "_") + value = k.Get(key) + } + + if value == nil { + return conf + } + + if err := mapstructure.Decode(value, conf); err != nil { + panic(err) + } + return conf +} + +// SetDefault set default value +func (c *Config) SetDefault() error { + return defaults.Set(c) +} + +// Validate valida value +func (c *Config) Validate(valid *validator.Validate) error { + if err := valid.Struct(c); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil } // UnmarshalYAML unmarshal the Config by @unmarshal function @@ -79,7 +130,7 @@ func (c *Config) GetUrlMap() url.Values { 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) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, c.Timeout) for key, val := range c.Params { urlMap.Set(key, val) @@ -87,9 +138,24 @@ func (c *Config) GetUrlMap() url.Values { return urlMap } +//TranslateConfigAddress translate config address +// eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos +func (c *Config) TranslateConfigAddress() string { + if strings.Contains(c.Address, "://") { + translatedUrl, err := url.Parse(c.Address) + if err != nil { + logger.Errorf("The config address:%s is invalid, error: %#v", c.Address, err) + panic(err) + } + c.Protocol = translatedUrl.Scheme + c.Address = strings.Replace(c.Address, translatedUrl.Scheme+"://", "", -1) + } + return c.Address +} + // toURL will compatible with baseConfig.Config.Address and baseConfig.Config.RemoteRef before 1.6.0 // After 1.6.0 will not compatible, only baseConfig.Config.RemoteRef -func (c *Config) toURL(baseConfig base.Config) (*common.URL, error) { +func (c *Config) toURL() (*common.URL, error) { //remoteRef := baseConfig.ConfigCenterConfig.RemoteRef //// if set remote ref use remote //if len(remoteRef) <= 0 { @@ -112,19 +178,19 @@ func (c *Config) toURL(baseConfig base.Config) (*common.URL, error) { // startConfigCenter will start the config center. // it will prepare the environment -func (c *Config) startConfigCenter(baseConfig base.Config) error { - newUrl, err := c.toURL(baseConfig) +func (c *Config) startConfigCenter() error { + newUrl, err := c.toURL() if err != nil { return err } - if err = c.prepareEnvironment(baseConfig, newUrl); err != nil { + if err = c.prepareEnvironment(newUrl); err != nil { return perrors.WithMessagef(err, "start config center error!") } // c.fresh() return nil } -func (c *Config) prepareEnvironment(baseConfig base.Config, configCenterUrl *common.URL) error { +func (c *Config) prepareEnvironment(configCenterUrl *common.URL) error { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { diff --git a/config/config_loader.go b/config/config_loader.go index 790393b174..9a5255fea7 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -19,6 +19,7 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config/center" "dubbo.apache.org/dubbo-go/v3/config/registry" "dubbo.apache.org/dubbo-go/v3/config/root" "fmt" @@ -41,6 +42,8 @@ var ( applicationConfig *application.Config // registriesConfig map[string]*registry.Config + + configCenterConfig *center.Config //consumerConfig *consumer.Config //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig @@ -63,7 +66,7 @@ func Load(opts ...Option) { //parseCommandLine() // conf conf := &config{ - name: "application.yaml", + name: "conf_application.yaml", genre: "yaml", path: "./conf", delim: ".", @@ -91,29 +94,10 @@ func check() error { return nil } -// GetApplicationConfig get application config -func GetApplicationConfig() (*application.Config, error) { - if err := check(); err != nil { - return nil, err - } - if applicationConfig != nil { - return applicationConfig, nil - } - conf := rootConfig.Application - if err := conf.SetDefault(); err != nil { - return nil, err - } - if err := conf.Validate(rootConfig.Validate); err != nil { - return nil, err - } - applicationConfig = conf - return conf, nil -} - //parseCommandLine parse command line //func parseCommandLine() { // flag.String("delim", ".", "config file delim") -// flag.String("name", "application.yaml", "config file name") +// flag.String("name", "conf_application.yaml", "config file name") // flag.String("genre", "yaml", "config file type") // flag.String("path", "./conf", "config file path default") // @@ -151,6 +135,25 @@ func getKoanf(conf *config) *koanf.Koanf { return k } +// GetApplicationConfig get application config +func GetApplicationConfig() (*application.Config, error) { + if err := check(); err != nil { + return nil, err + } + if applicationConfig != nil { + return applicationConfig, nil + } + conf := rootConfig.Application + if err := conf.SetDefault(); err != nil { + return nil, err + } + if err := conf.Validate(rootConfig.Validate); err != nil { + return nil, err + } + applicationConfig = conf + return conf, nil +} + func GetRegistriesConfig() (map[string]*registry.Config, error) { if err := check(); err != nil { return nil, err @@ -183,6 +186,26 @@ func GetRegistriesConfig() (map[string]*registry.Config, error) { return registries, nil } +func GetConfigCenterConfig() (*center.Config, error) { + if err := check(); err != nil { + return nil, err + } + if configCenterConfig != nil { + return configCenterConfig, nil + } + conf := center.GetConfigCenterConfig(rootConfig.ConfigCenter, rootConfig.Koanf) + + if err := conf.SetDefault(); err != nil { + return nil, err + } + conf.TranslateConfigAddress() + if err := conf.Validate(rootConfig.Validate); err != nil { + return nil, err + } + configCenterConfig = conf + return conf, nil +} + // //// loaded consumer & provider config from xxx.yml, and log config from xxx.xml //// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo diff --git a/config/config_loader_test.go b/config/config_loader_test.go index eb703303e2..5229886089 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -62,7 +62,47 @@ func TestLoad(t *testing.T) { assert.Equal(t, "nacos", registries["nacos"].Protocol) assert.Equal(t, "10s", registries["zk"].Timeout) }) + //config-center + t.Run("config-center", func(t *testing.T) { + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) + assert.Equal(t, "nacos", conf.Protocol) + //address= nacos://127.0.0.1:8848 Translate Registry Address + //assert.Equal(t, "nacos", registries["nacos"].Protocol) + //assert.Equal(t, "10s", registries["zk"].Timeout) + }) + +} + +//TestLoadConfigCenter test key config_center、config-center 、configCenter +func TestLoadConfigCenter(t *testing.T) { + + t.Run("config_center", func(t *testing.T) { + Load(WithPath("./testdata/config/center/conf_application.yaml")) + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) + assert.Equal(t, "nacos", conf.Protocol) + assert.Equal(t, "10s", conf.Timeout) + assert.Equal(t, "./logs", conf.LogDir) + }) + t.Run("configCenter", func(t *testing.T) { + Load(WithPath("./testdata/config/center/confApplication.yaml")) + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) + assert.Equal(t, "nacos", conf.Protocol) + assert.Equal(t, "10s", conf.Timeout) + assert.Equal(t, "./logs", conf.LogDir) + }) + + t.Run("config-center", func(t *testing.T) { + Load(WithPath("./testdata/config/center/conf-application.yaml")) + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) + assert.Equal(t, "nacos", conf.Protocol) + assert.Equal(t, "10s", conf.Timeout) + assert.Equal(t, "./logs", conf.LogDir) + }) } // diff --git a/config/root/root_config.go b/config/root/root_config.go index a493c8ad1c..d528b6fee8 100644 --- a/config/root/root_config.go +++ b/config/root/root_config.go @@ -21,7 +21,8 @@ import ( // Config is the root config type Config struct { - ConfigCenterConfig *center.Config `yaml:"config_center" json:"config_center,omitempty"` + + ConfigCenter *center.Config `yaml:"config-center" json:"config-center,omitempty"` // since 1.5.0 version //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index 5a9a06e9f0..ed345dd9d1 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -4,6 +4,16 @@ dubbo: module: local version: 1.0.0 owner: zhaoyunxing + config_center: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + logDir: ./logs + protocols: + dubbo: + name: dubbo + ip: 127.0.0.1 + port: 20000 registries: nacos: timeout: 5s diff --git a/config/testdata/config/center/conf-application.yaml b/config/testdata/config/center/conf-application.yaml new file mode 100644 index 0000000000..c9b0cf9db2 --- /dev/null +++ b/config/testdata/config/center/conf-application.yaml @@ -0,0 +1,6 @@ +dubbo: + config-center: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + logDir: ./logs \ No newline at end of file diff --git a/config/testdata/config/center/confApplication.yaml b/config/testdata/config/center/confApplication.yaml new file mode 100644 index 0000000000..497bcd339f --- /dev/null +++ b/config/testdata/config/center/confApplication.yaml @@ -0,0 +1,6 @@ +dubbo: + configCenter: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + logDir: ./logs \ No newline at end of file diff --git a/config/testdata/config/center/conf_application.yaml b/config/testdata/config/center/conf_application.yaml new file mode 100644 index 0000000000..dd086b1adf --- /dev/null +++ b/config/testdata/config/center/conf_application.yaml @@ -0,0 +1,6 @@ +dubbo: + config_center: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + logDir: ./logs \ No newline at end of file diff --git a/go.mod b/go.mod index d22e52353a..b917d1cf2a 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 + github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 // indirect github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 diff --git a/go.sum b/go.sum index 117960b9f0..fceb281454 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,8 @@ github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5 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/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 h1:wqckanyE9qc/XnvnybC6SHOb8Nyd62QXAZOzA8twFig= +github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9/go.mod h1:64ikIrMv84B+raz7akXOqbF7cK3/OQQ/6cClY10oy7A= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= From 639e01cf7b25f2f7972232fa6084ace37dc805da Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Wed, 21 Jul 2021 15:40:35 +0800 Subject: [PATCH 006/148] up:default config name --- config/config_loader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config_loader.go b/config/config_loader.go index 9a5255fea7..54f2b72fa1 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -66,7 +66,7 @@ func Load(opts ...Option) { //parseCommandLine() // conf conf := &config{ - name: "conf_application.yaml", + name: "application.yaml", genre: "yaml", path: "./conf", delim: ".", From fa700d865df6e217893095242d81bb3229ca010f Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 24 Jul 2021 00:17:01 +0800 Subject: [PATCH 007/148] =?UTF-8?q?up:=E8=B0=83=E6=95=B4=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/router/v3router/dubbo_rule.go | 4 +- .../judger/attachment_match_judger.go | 8 +- .../judger/attachment_match_judger_test.go | 14 +-- .../v3router/judger/bool_match_judger.go | 6 +- .../v3router/judger/bool_match_judger_test.go | 10 +- .../v3router/judger/double_match_judger.go | 6 +- .../judger/double_match_judger_test.go | 18 ++-- .../judger/double_range_match_judger.go | 6 +- .../judger/double_range_match_judger_test.go | 8 +- .../judger/list_double_match_judger.go | 6 +- .../judger/list_double_match_judger_test.go | 26 ++--- .../judger/list_string_match_judger.go | 6 +- .../judger/list_string_match_judger_test.go | 10 +- .../v3router/judger/method_match_judger.go | 6 +- .../judger/method_match_judger_test.go | 24 ++--- .../v3router/judger/string_match_judger.go | 6 +- .../judger/string_match_judger_test.go | 14 +-- .../v3router/k8s_api/listener_handler_impl.go | 22 ++--- cluster/router/v3router/router_chain.go | 16 +-- cluster/router/v3router/router_chain_test.go | 6 +- cluster/router/v3router/uniform_rule.go | 10 +- common/constant/key.go | 2 +- config/center/config_center_config.go | 4 +- config/config_api.go | 98 +++++++++---------- config/config_loader.go | 42 +++++--- config/config_loader_test.go | 29 +++--- config/consumer/consumer_config.go | 10 +- config/{shutdown => }/graceful_shutdown.go | 4 +- .../graceful_shutdown_config.go | 12 +-- .../graceful_shutdown_config_test.go | 8 +- .../graceful_shutdown_signal_darwin.go | 2 +- .../graceful_shutdown_signal_linux.go | 2 +- .../graceful_shutdown_signal_windows.go | 2 +- .../{shutdown => }/graceful_shutdown_test.go | 6 +- config/protocol/protocol_config.go | 20 +++- config/provider/provider_config.go | 21 ++-- config/{root => }/root_config.go | 19 ++-- config/{router => }/router_config.go | 2 +- config/{router => }/router_config_test.go | 2 +- config/{service => }/service_config.go | 38 +++---- .../service_discovery_config.go | 8 +- config/testdata/application.yaml | 4 +- config/{router => }/uniform_router_config.go | 2 +- config_center/apollo/impl.go | 2 +- filter/gshutdown/filter.go | 5 +- filter/gshutdown/filter_test.go | 3 +- filter/hystrix/filter.go | 6 +- go.mod | 6 +- go.sum | 2 + .../mapping/dynamic/service_name_mapping.go | 2 +- .../dynamic/service_name_mapping_test.go | 2 +- .../mapping/memory/service_name_mapping.go | 2 +- .../service/exporter/configurable/exporter.go | 7 +- .../exporter/configurable/exporter_test.go | 4 +- metadata/service/local/service.go | 2 +- protocol/grpc/grpc_protocol_test.go | 4 +- protocol/grpc/server.go | 5 +- .../rest/config/reader/rest_config_reader.go | 10 +- registry/directory/directory.go | 2 +- registry/etcdv3/service_discovery_test.go | 5 +- ...vent_publishing_service_deiscovery_test.go | 2 +- .../event/service_config_exported_event.go | 6 +- registry/file/service_discovery_test.go | 3 +- registry/nacos/service_discovery_test.go | 7 +- .../service_discovery_registry_test.go | 3 +- registry/zookeeper/service_discovery_test.go | 7 +- remoting/getty/getty_client.go | 2 +- samples | 1 - test/integrate/dubbo/go-client/client.go | 2 +- test/integrate/dubbo/go-server/server.go | 2 +- 70 files changed, 350 insertions(+), 323 deletions(-) rename config/{shutdown => }/graceful_shutdown.go (99%) rename config/{shutdown => }/graceful_shutdown_config.go (91%) rename config/{shutdown => }/graceful_shutdown_config_test.go (93%) rename config/{shutdown => }/graceful_shutdown_signal_darwin.go (98%) rename config/{shutdown => }/graceful_shutdown_signal_linux.go (98%) rename config/{shutdown => }/graceful_shutdown_signal_windows.go (98%) rename config/{shutdown => }/graceful_shutdown_test.go (96%) rename config/{root => }/root_config.go (72%) rename config/{router => }/router_config.go (98%) rename config/{router => }/router_config_test.go (99%) rename config/{service => }/service_config.go (94%) rename config/{service/discovery => }/service_discovery_config.go (90%) rename config/{router => }/uniform_router_config.go (99%) delete mode 160000 samples diff --git a/cluster/router/v3router/dubbo_rule.go b/cluster/router/v3router/dubbo_rule.go index ec4903816e..c809354b19 100644 --- a/cluster/router/v3router/dubbo_rule.go +++ b/cluster/router/v3router/dubbo_rule.go @@ -19,7 +19,7 @@ package v3router import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -28,7 +28,7 @@ type DubboRouterRule struct { uniformRules []*UniformRule } -func newDubboRouterRule(dubboRoutes []*router.DubboRoute, +func newDubboRouterRule(dubboRoutes []*config.DubboRoute, destinationMap map[string]map[string]string) (*DubboRouterRule, error) { uniformRules := make([]*UniformRule, 0) diff --git a/cluster/router/v3router/judger/attachment_match_judger.go b/cluster/router/v3router/judger/attachment_match_judger.go index f1d838aa81..31f46e05cf 100644 --- a/cluster/router/v3router/judger/attachment_match_judger.go +++ b/cluster/router/v3router/judger/attachment_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) type AttachmentMatchJudger struct { - router.DubboAttachmentMatch + config.DubboAttachmentMatch } // nolint @@ -36,7 +36,7 @@ func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool { return amj.DubboContext == nil || judge(amj.DubboContext, invAttaMap) } -func judge(condition map[string]*router.StringMatch, invAttaMap map[string]interface{}) bool { +func judge(condition map[string]*config.StringMatch, invAttaMap map[string]interface{}) bool { for k, v := range condition { invAttaValue, ok := invAttaMap[k] if !ok { @@ -60,7 +60,7 @@ func judge(condition map[string]*router.StringMatch, invAttaMap map[string]inter } // nolint -func NewAttachmentMatchJudger(matchConf *router.DubboAttachmentMatch) *AttachmentMatchJudger { +func NewAttachmentMatchJudger(matchConf *config.DubboAttachmentMatch) *AttachmentMatchJudger { return &AttachmentMatchJudger{ DubboAttachmentMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/attachment_match_judger_test.go b/cluster/router/v3router/judger/attachment_match_judger_test.go index 094cbde4a8..eabc312f35 100644 --- a/cluster/router/v3router/judger/attachment_match_judger_test.go +++ b/cluster/router/v3router/judger/attachment_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -31,24 +31,24 @@ import ( ) func TestAttachmentMatchJudger(t *testing.T) { - conditionMap := make(map[string]*router.StringMatch) + conditionMap := make(map[string]*config.StringMatch) dubboIvkMap := make(map[string]interface{}) - conditionMap["test-key"] = &router.StringMatch{ + conditionMap["test-key"] = &config.StringMatch{ Exact: "abc", } dubboIvkMap["test-key"] = "abc" - assert.True(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ + assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ DubboContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) - assert.True(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ + assert.True(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) dubboIvkMap["test-key"] = "abd" - assert.False(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ + assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ DubboContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) - assert.False(t, NewAttachmentMatchJudger(&router.DubboAttachmentMatch{ + assert.False(t, NewAttachmentMatchJudger(&config.DubboAttachmentMatch{ EagleeyeContext: conditionMap, }).Judge(invocation.NewRPCInvocation("method", nil, dubboIvkMap))) } diff --git a/cluster/router/v3router/judger/bool_match_judger.go b/cluster/router/v3router/judger/bool_match_judger.go index 40cf365dc7..5c4bb46e77 100644 --- a/cluster/router/v3router/judger/bool_match_judger.go +++ b/cluster/router/v3router/judger/bool_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" ) // nolint type BoolMatchJudger struct { - router.BoolMatch + config.BoolMatch } // nolint @@ -32,7 +32,7 @@ func (lsmj *BoolMatchJudger) Judge(input bool) bool { } // nolint -func newBoolMatchJudger(matchConf *router.BoolMatch) *BoolMatchJudger { +func newBoolMatchJudger(matchConf *config.BoolMatch) *BoolMatchJudger { return &BoolMatchJudger{ BoolMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/bool_match_judger_test.go b/cluster/router/v3router/judger/bool_match_judger_test.go index ef7a7400c0..fb7fc2086a 100644 --- a/cluster/router/v3router/judger/bool_match_judger_test.go +++ b/cluster/router/v3router/judger/bool_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,19 +27,19 @@ import ( ) func TestBoolMatchJudger(t *testing.T) { - assert.True(t, newBoolMatchJudger(&router.BoolMatch{ + assert.True(t, newBoolMatchJudger(&config.BoolMatch{ Exact: true, }).Judge(true)) - assert.True(t, newBoolMatchJudger(&router.BoolMatch{ + assert.True(t, newBoolMatchJudger(&config.BoolMatch{ Exact: false, }).Judge(false)) - assert.False(t, newBoolMatchJudger(&router.BoolMatch{ + assert.False(t, newBoolMatchJudger(&config.BoolMatch{ Exact: true, }).Judge(false)) - assert.False(t, newBoolMatchJudger(&router.BoolMatch{ + assert.False(t, newBoolMatchJudger(&config.BoolMatch{ Exact: false, }).Judge(true)) } diff --git a/cluster/router/v3router/judger/double_match_judger.go b/cluster/router/v3router/judger/double_match_judger.go index 79eda6fb9c..d5ec3844fd 100644 --- a/cluster/router/v3router/judger/double_match_judger.go +++ b/cluster/router/v3router/judger/double_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" ) // nolint type DoubleMatchJudger struct { - router.DoubleMatch + config.DoubleMatch } // nolint @@ -42,7 +42,7 @@ func (dmj *DoubleMatchJudger) Judge(input float64) bool { } // nolint -func newDoubleMatchJudger(matchConf *router.DoubleMatch) *DoubleMatchJudger { +func newDoubleMatchJudger(matchConf *config.DoubleMatch) *DoubleMatchJudger { return &DoubleMatchJudger{ DoubleMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/double_match_judger_test.go b/cluster/router/v3router/judger/double_match_judger_test.go index 4497b7b202..f15f604614 100644 --- a/cluster/router/v3router/judger/double_match_judger_test.go +++ b/cluster/router/v3router/judger/double_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,30 +27,30 @@ import ( ) func TestDoubleMatchJudger(t *testing.T) { - assert.True(t, newDoubleMatchJudger(&router.DoubleMatch{ + assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ Exact: 3.14159, }).Judge(3.14159)) - assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ + assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ Exact: 3.14159, }).Judge(3.14155927)) - assert.True(t, newDoubleMatchJudger(&router.DoubleMatch{ - Range: &router.DoubleRangeMatch{ + assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, }).Judge(1.3)) - assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ - Range: &router.DoubleRangeMatch{ + assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, }).Judge(1.9)) - assert.False(t, newDoubleMatchJudger(&router.DoubleMatch{ - Range: &router.DoubleRangeMatch{ + assert.False(t, newDoubleMatchJudger(&config.DoubleMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }, diff --git a/cluster/router/v3router/judger/double_range_match_judger.go b/cluster/router/v3router/judger/double_range_match_judger.go index 1b783a5d44..8897fc3c7d 100644 --- a/cluster/router/v3router/judger/double_range_match_judger.go +++ b/cluster/router/v3router/judger/double_range_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" ) // nolint type DoubleRangeMatchJudger struct { - router.DoubleRangeMatch + config.DoubleRangeMatch } // nolint @@ -32,7 +32,7 @@ func (drmj *DoubleRangeMatchJudger) Judge(input float64) bool { } // nolint -func newDoubleRangeMatchJudger(matchConf *router.DoubleRangeMatch) *DoubleRangeMatchJudger { +func newDoubleRangeMatchJudger(matchConf *config.DoubleRangeMatch) *DoubleRangeMatchJudger { return &DoubleRangeMatchJudger{ DoubleRangeMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/double_range_match_judger_test.go b/cluster/router/v3router/judger/double_range_match_judger_test.go index 7ec62c3cca..e8c6b6fd38 100644 --- a/cluster/router/v3router/judger/double_range_match_judger_test.go +++ b/cluster/router/v3router/judger/double_range_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,17 +27,17 @@ import ( ) func TestDoubleRangeMatchJudger(t *testing.T) { - assert.True(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ + assert.True(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(1.3)) - assert.False(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ + assert.False(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(1.9)) - assert.False(t, newDoubleRangeMatchJudger(&router.DoubleRangeMatch{ + assert.False(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ Start: 1.0, End: 1.5, }).Judge(0.9)) diff --git a/cluster/router/v3router/judger/list_double_match_judger.go b/cluster/router/v3router/judger/list_double_match_judger.go index 746f350b4a..b968334e5e 100644 --- a/cluster/router/v3router/judger/list_double_match_judger.go +++ b/cluster/router/v3router/judger/list_double_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" ) // nolint type ListDoubleMatchJudger struct { - router.ListDoubleMatch + config.ListDoubleMatch } // nolint @@ -37,7 +37,7 @@ func (lsmj *ListDoubleMatchJudger) Judge(input float64) bool { } // nolint -func newListDoubleMatchJudger(matchConf *router.ListDoubleMatch) *ListDoubleMatchJudger { +func newListDoubleMatchJudger(matchConf *config.ListDoubleMatch) *ListDoubleMatchJudger { return &ListDoubleMatchJudger{ ListDoubleMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/list_double_match_judger_test.go b/cluster/router/v3router/judger/list_double_match_judger_test.go index 9b7dbb1a78..696be6bef8 100644 --- a/cluster/router/v3router/judger/list_double_match_judger_test.go +++ b/cluster/router/v3router/judger/list_double_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,13 +27,13 @@ import ( ) func TestListDoubleMatchJudger_Judge(t *testing.T) { - assert.True(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ - Oneof: []*router.DoubleMatch{ + assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ + Oneof: []*config.DoubleMatch{ { Exact: 3.14, }, { - Range: &router.DoubleRangeMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, @@ -44,13 +44,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.False(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ - Oneof: []*router.DoubleMatch{ + assert.False(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ + Oneof: []*config.DoubleMatch{ { Exact: 3.14, }, { - Range: &router.DoubleRangeMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, @@ -61,13 +61,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.True(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ - Oneof: []*router.DoubleMatch{ + assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ + Oneof: []*config.DoubleMatch{ { Exact: 3.14, }, { - Range: &router.DoubleRangeMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.2, End: 1.9, }, @@ -78,13 +78,13 @@ func TestListDoubleMatchJudger_Judge(t *testing.T) { }, }).Judge(1.3)) - assert.False(t, newListDoubleMatchJudger(&router.ListDoubleMatch{ - Oneof: []*router.DoubleMatch{ + assert.False(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ + Oneof: []*config.DoubleMatch{ { Exact: 3.14, }, { - Range: &router.DoubleRangeMatch{ + Range: &config.DoubleRangeMatch{ Start: 1.5, End: 1.9, }, diff --git a/cluster/router/v3router/judger/list_string_match_judger.go b/cluster/router/v3router/judger/list_string_match_judger.go index b96aa1e620..a1df1e9d47 100644 --- a/cluster/router/v3router/judger/list_string_match_judger.go +++ b/cluster/router/v3router/judger/list_string_match_judger.go @@ -18,12 +18,12 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" ) // nolint type ListStringMatchJudger struct { - router.ListStringMatch + config.ListStringMatch } // nolint @@ -37,7 +37,7 @@ func (lsmj *ListStringMatchJudger) Judge(input string) bool { } // nolint -func newListStringMatchJudger(matchConf *router.ListStringMatch) *ListStringMatchJudger { +func newListStringMatchJudger(matchConf *config.ListStringMatch) *ListStringMatchJudger { return &ListStringMatchJudger{ ListStringMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/list_string_match_judger_test.go b/cluster/router/v3router/judger/list_string_match_judger_test.go index 6dfe42f81f..169ee57f2b 100644 --- a/cluster/router/v3router/judger/list_string_match_judger_test.go +++ b/cluster/router/v3router/judger/list_string_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,11 +27,11 @@ import ( ) func TestListStringMatchJudger(t *testing.T) { - assert.True(t, newListStringMatchJudger(&router.ListStringMatch{ - Oneof: []*router.StringMatch{{Exact: "abd"}}, + assert.True(t, newListStringMatchJudger(&config.ListStringMatch{ + Oneof: []*config.StringMatch{{Exact: "abd"}}, }).Judge("abd")) - assert.False(t, newListStringMatchJudger(&router.ListStringMatch{ - Oneof: []*router.StringMatch{{Exact: "abc"}}, + 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 19f69bcb58..e069ef9cca 100644 --- a/cluster/router/v3router/judger/method_match_judger.go +++ b/cluster/router/v3router/judger/method_match_judger.go @@ -18,13 +18,13 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) // nolint type MethodMatchJudger struct { - router.DubboMethodMatch + config.DubboMethodMatch } // Judge Method Match Judger only judge on @@ -83,7 +83,7 @@ func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { } // nolint -func NewMethodMatchJudger(matchConf *router.DubboMethodMatch) *MethodMatchJudger { +func NewMethodMatchJudger(matchConf *config.DubboMethodMatch) *MethodMatchJudger { return &MethodMatchJudger{ DubboMethodMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/method_match_judger_test.go b/cluster/router/v3router/judger/method_match_judger_test.go index 2f79663ae6..d0f5023075 100644 --- a/cluster/router/v3router/judger/method_match_judger_test.go +++ b/cluster/router/v3router/judger/method_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -32,31 +32,31 @@ import ( ) func TestMethodMatchJudger(t *testing.T) { - methodArgs := make([]*router.DubboMethodArg, 0) - methodArgs = append(methodArgs, &router.DubboMethodArg{ + methodArgs := make([]*config.DubboMethodArg, 0) + methodArgs = append(methodArgs, &config.DubboMethodArg{ Index: 1, Type: "string", - StrValue: &router.ListStringMatch{Oneof: []*router.StringMatch{{Exact: "hello world"}}}, + StrValue: &config.ListStringMatch{Oneof: []*config.StringMatch{{Exact: "hello world"}}}, NumValue: nil, BoolValue: nil, }) - methodArgs = append(methodArgs, &router.DubboMethodArg{ + methodArgs = append(methodArgs, &config.DubboMethodArg{ Index: 2, Type: "bool", StrValue: nil, NumValue: nil, - BoolValue: &router.BoolMatch{Exact: true}, + BoolValue: &config.BoolMatch{Exact: true}, }) - methodArgs = append(methodArgs, &router.DubboMethodArg{ + methodArgs = append(methodArgs, &config.DubboMethodArg{ Index: 3, Type: "float64", StrValue: nil, - NumValue: &router.ListDoubleMatch{Oneof: []*router.DoubleMatch{{Exact: 10}}}, + NumValue: &config.ListDoubleMatch{Oneof: []*config.DoubleMatch{{Exact: 10}}}, BoolValue: nil, }) - methodMatch := &router.DubboMethodMatch{ - NameMatch: &router.StringMatch{Exact: "Greet"}, + methodMatch := &config.DubboMethodMatch{ + NameMatch: &config.StringMatch{Exact: "Greet"}, Argc: 3, Args: methodArgs, Argp: nil, @@ -71,7 +71,7 @@ func TestMethodMatchJudger(t *testing.T) { invocation.WithParameterValues([]reflect.Value{stringValue, boolValue, numValue}), ) - assert.False(t, NewMethodMatchJudger(&router.DubboMethodMatch{NameMatch: &router.StringMatch{Exact: "Great"}}).Judge(ivc)) - assert.False(t, NewMethodMatchJudger(&router.DubboMethodMatch{NameMatch: &router.StringMatch{Exact: "Greet"}, Argc: 1}).Judge(ivc)) + 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/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go index 8902163d90..a502cc3b91 100644 --- a/cluster/router/v3router/judger/string_match_judger.go +++ b/cluster/router/v3router/judger/string_match_judger.go @@ -18,14 +18,14 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "regexp" "strings" ) // nolint type StringMatchJudger struct { - router.StringMatch + config.StringMatch } // nolint @@ -50,7 +50,7 @@ func (smj *StringMatchJudger) Judge(input string) bool { } // nolint -func NewStringMatchJudger(matchConf *router.StringMatch) *StringMatchJudger { +func NewStringMatchJudger(matchConf *config.StringMatch) *StringMatchJudger { return &StringMatchJudger{ StringMatch: *matchConf, } diff --git a/cluster/router/v3router/judger/string_match_judger_test.go b/cluster/router/v3router/judger/string_match_judger_test.go index 3f6c0c2ad3..c9da665bc6 100644 --- a/cluster/router/v3router/judger/string_match_judger_test.go +++ b/cluster/router/v3router/judger/string_match_judger_test.go @@ -18,7 +18,7 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,27 +27,27 @@ import ( ) func TestNewStringMatchJudger(t *testing.T) { - assert.True(t, NewStringMatchJudger(&router.StringMatch{ + assert.True(t, NewStringMatchJudger(&config.StringMatch{ Exact: "abc", }).Judge("abc")) - assert.False(t, NewStringMatchJudger(&router.StringMatch{ + assert.False(t, NewStringMatchJudger(&config.StringMatch{ Exact: "abcd", }).Judge("abc")) - assert.True(t, NewStringMatchJudger(&router.StringMatch{ + assert.True(t, NewStringMatchJudger(&config.StringMatch{ Prefix: "abc", }).Judge("abcd")) - assert.False(t, NewStringMatchJudger(&router.StringMatch{ + assert.False(t, NewStringMatchJudger(&config.StringMatch{ Exact: "abcd", }).Judge("abdc")) - assert.True(t, NewStringMatchJudger(&router.StringMatch{ + assert.True(t, NewStringMatchJudger(&config.StringMatch{ Empty: "true", }).Judge("")) - assert.False(t, NewStringMatchJudger(&router.StringMatch{ + assert.False(t, NewStringMatchJudger(&config.StringMatch{ NoEmpty: "true", }).Judge("")) } diff --git a/cluster/router/v3router/k8s_api/listener_handler_impl.go b/cluster/router/v3router/k8s_api/listener_handler_impl.go index efc2455bad..e6f660c50f 100644 --- a/cluster/router/v3router/k8s_api/listener_handler_impl.go +++ b/cluster/router/v3router/k8s_api/listener_handler_impl.go @@ -18,7 +18,7 @@ package k8s_api import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" metav "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -47,7 +47,7 @@ type VirtualServiceListenerHandler struct { // nolint func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) { - if vsc, ok := obj.(*router.VirtualServiceConfig); ok { + if vsc, ok := obj.(*config.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -59,7 +59,7 @@ func (r *VirtualServiceListenerHandler) AddFunc(obj interface{}) { // nolint func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) { - if vsc, ok := newObj.(*router.VirtualServiceConfig); ok { + if vsc, ok := newObj.(*config.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -72,7 +72,7 @@ func (r *VirtualServiceListenerHandler) UpdateFunc(oldObj, newObj interface{}) { // nolint func (r *VirtualServiceListenerHandler) DeleteFunc(obj interface{}) { - if vsc, ok := obj.(*router.VirtualServiceConfig); ok { + if vsc, ok := obj.(*config.VirtualServiceConfig); ok { event := &config_center.ConfigChangeEvent{ Key: VirtualServiceEventKey, Value: vsc, @@ -95,7 +95,7 @@ func (r *VirtualServiceListenerHandler) Watch(opts metav.ListOptions, restClient // nolint func (r *VirtualServiceListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) { - result := router.VirtualServiceConfigList{} + result := config.VirtualServiceConfigList{} err := restClient. Get(). Namespace(ns). @@ -109,7 +109,7 @@ func (r *VirtualServiceListenerHandler) List(opts metav.ListOptions, restClient // nolint func (r *VirtualServiceListenerHandler) GetObject() runtime.Object { - return &router.VirtualServiceConfig{} + return &config.VirtualServiceConfig{} } // nolint @@ -126,7 +126,7 @@ type DestRuleListenerHandler struct { // nolint func (r *DestRuleListenerHandler) AddFunc(obj interface{}) { - if drc, ok := obj.(*router.DestinationRuleConfig); ok { + if drc, ok := obj.(*config.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -139,7 +139,7 @@ func (r *DestRuleListenerHandler) AddFunc(obj interface{}) { // nolint func (r *DestRuleListenerHandler) UpdateFunc(oldObj, newObj interface{}) { - if drc, ok := newObj.(*router.DestinationRuleConfig); ok { + if drc, ok := newObj.(*config.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -151,7 +151,7 @@ func (r *DestRuleListenerHandler) UpdateFunc(oldObj, newObj interface{}) { // nolint func (r *DestRuleListenerHandler) DeleteFunc(obj interface{}) { - if drc, ok := obj.(*router.DestinationRuleConfig); ok { + if drc, ok := obj.(*config.DestinationRuleConfig); ok { event := &config_center.ConfigChangeEvent{ Key: DestinationRuleEventKey, Value: drc, @@ -174,7 +174,7 @@ func (r *DestRuleListenerHandler) Watch(opts metav.ListOptions, restClient *rest // nolint func (r *DestRuleListenerHandler) List(opts metav.ListOptions, restClient *rest.RESTClient, ns string) (runtime.Object, error) { - result := router.DestinationRuleConfigList{} + result := config.DestinationRuleConfigList{} err := restClient. Get(). Namespace(ns). @@ -188,7 +188,7 @@ func (r *DestRuleListenerHandler) List(opts metav.ListOptions, restClient *rest. // nolint func (r *DestRuleListenerHandler) GetObject() runtime.Object { - return &router.DestinationRuleConfig{} + return &config.DestinationRuleConfig{} } func newDestRuleListenerHandler(listener config_center.ConfigurationListener) k8s_crd.ListenerHandler { diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index b81fc6c1e7..b677d8f05c 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -18,7 +18,7 @@ package v3router import ( - router2 "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "encoding/json" "io" "strings" @@ -83,7 +83,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { switch event.Key { case k8s_api.VirtualServiceEventKey: logger.Debug("virtul service event") - newVSValue, ok := event.Value.(*router2.VirtualServiceConfig) + newVSValue, ok := event.Value.(*config.VirtualServiceConfig) if !ok { logger.Error("event.Value assertion error") return @@ -95,7 +95,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { return } logger.Debugf("new virtual service json value = \n%v\n", newVSJsonValue) - newVirtualServiceConfig := &router2.VirtualServiceConfig{} + newVirtualServiceConfig := &config.VirtualServiceConfig{} if err := json.Unmarshal([]byte(newVSJsonValue), newVirtualServiceConfig); err != nil { logger.Error("on process json data unmarshal error = ", err) return @@ -116,7 +116,7 @@ func (r *RouterChain) Process(event *config_center.ConfigChangeEvent) { } case k8s_api.DestinationRuleEventKey: logger.Debug("handling dest rule event") - newDRValue, ok := event.Value.(*router2.DestinationRuleConfig) + newDRValue, ok := event.Value.(*config.DestinationRuleConfig) if !ok { logger.Error("event.Value assertion error") return @@ -127,7 +127,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 } - newDestRuleConfig := &router2.DestinationRuleConfig{} + newDestRuleConfig := &config.DestinationRuleConfig{} if err := json.Unmarshal([]byte(newDRJsonValue), newDestRuleConfig); err != nil { logger.Error("on process json data unmarshal error = ", err) return @@ -174,14 +174,14 @@ func (r *RouterChain) URL() *common.URL { // parseFromConfigToRouters parse virtualService and destinationRule yaml file bytes to target router list func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte) ([]*UniformRouter, error) { - var virtualServiceConfigList []*router2.VirtualServiceConfig + var virtualServiceConfigList []*config.VirtualServiceConfig destRuleConfigsMap := make(map[string]map[string]map[string]string) vsDecoder := yaml.NewDecoder(strings.NewReader(string(virtualServiceConfig))) drDecoder := yaml.NewDecoder(strings.NewReader(string(destinationRuleConfig))) // parse virtual service for { - virtualServiceCfg := &router2.VirtualServiceConfig{} + virtualServiceCfg := &config.VirtualServiceConfig{} err := vsDecoder.Decode(virtualServiceCfg) if err == io.EOF { @@ -197,7 +197,7 @@ func parseFromConfigToRouters(virtualServiceConfig, destinationRuleConfig []byte // parse destination rule for { - destRuleCfg := &router2.DestinationRuleConfig{} + destRuleCfg := &config.DestinationRuleConfig{} err := drDecoder.Decode(destRuleCfg) if err == io.EOF { break diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index 1ccd88f576..e1af5328a5 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -18,7 +18,7 @@ package v3router import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "testing" ) @@ -221,7 +221,7 @@ func TestRouterChain_Process(t *testing.T) { vsJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` rc := &RouterChain{} - mockVirtualServiceConfig := &router.VirtualServiceConfig{ + mockVirtualServiceConfig := &config.VirtualServiceConfig{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kubectl.kubernetes.io/last-applied-configuration": vsJson, @@ -239,7 +239,7 @@ func TestRouterChain_Process(t *testing.T) { // test destination rule config chage event destJson := `{"apiVersion":"service.dubbo.apache.org/v1alpha2", "kind":"VirtualService", "name":"demo-route"}` - mockDestinationRuleConfig := &router.DestinationRuleConfig{ + mockDestinationRuleConfig := &config.DestinationRuleConfig{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ "kubectl.kubernetes.io/last-applied-configuration": destJson, diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go index 64f02e3fe1..ef4b16ca36 100644 --- a/cluster/router/v3router/uniform_rule.go +++ b/cluster/router/v3router/uniform_rule.go @@ -18,7 +18,7 @@ package v3router import ( - "dubbo.apache.org/dubbo-go/v3/config/router" + "dubbo.apache.org/dubbo-go/v3/config" "math/rand" "time" ) @@ -38,7 +38,7 @@ import ( // if match, get result destination key, which should be defined in DestinationRule yaml file type VirtualServiceRule struct { // routerItem store match router list and destination list of this router - routerItem *router.DubboServiceRouterItem + routerItem *config.DubboServiceRouterItem // uniformRule is the upper struct ptr uniformRule *UniformRule @@ -79,7 +79,7 @@ func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invoca // tryGetSubsetFromRouterOfOneDestination is a recursion function // try from destination 's header to final fallback destination, when success, it return result destination, else return error -func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *router.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { +func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { subSet := desc.Destination.Subset labels, ok := vsr.uniformRule.DestinationLabelListMap[subSet] resultInvokers := make([]protocol.Invoker, 0) @@ -200,13 +200,13 @@ func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker // UniformRule type UniformRule struct { - services []*router.StringMatch + services []*config.StringMatch virtualServiceRules []VirtualServiceRule DestinationLabelListMap map[string]map[string]string } // NewDefaultConnChecker constructs a new DefaultConnChecker based on the url -func newUniformRule(dubboRoute *router.DubboRoute, destinationMap map[string]map[string]string) (*UniformRule, error) { +func newUniformRule(dubboRoute *config.DubboRoute, destinationMap map[string]map[string]string) (*UniformRule, error) { matchItems := dubboRoute.RouterDetail virtualServiceRules := make([]VirtualServiceRule, 0) newUniformRule := &UniformRule{ diff --git a/common/constant/key.go b/common/constant/key.go index 22191478cc..9db943318c 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -178,7 +178,7 @@ const ( RemotePrefix = "dubbo.remote" ServiceDiscPrefix = "dubbo.service-discovery" ProtocolConfigPrefix = "dubbo.protocols" - ProviderConfigPrefix = "dubbo.provider." + ProviderConfigPrefix = "dubbo.provider" ConsumerConfigPrefix = "dubbo.consumer" ShutdownConfigPrefix = "dubbo.shutdown" MetadataReportPrefix = "dubbo.metadata-report" diff --git a/config/center/config_center_config.go b/config/center/config_center_config.go index 10c12ee154..ae3822f042 100644 --- a/config/center/config_center_config.go +++ b/config/center/config_center_config.go @@ -153,8 +153,8 @@ func (c *Config) TranslateConfigAddress() string { return c.Address } -// toURL will compatible with baseConfig.Config.Address and baseConfig.Config.RemoteRef before 1.6.0 -// After 1.6.0 will not compatible, only baseConfig.Config.RemoteRef +// toURL will compatible with baseConfig.ShutdownConfig.Address and baseConfig.ShutdownConfig.RemoteRef before 1.6.0 +// After 1.6.0 will not compatible, only baseConfig.ShutdownConfig.RemoteRef func (c *Config) toURL() (*common.URL, error) { //remoteRef := baseConfig.ConfigCenterConfig.RemoteRef //// if set remote ref use remote diff --git a/config/config_api.go b/config/config_api.go index 3c06947392..b251269fc2 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -169,15 +169,15 @@ package config //} // /////////////////////////////////////// consumer config api -//// ConsumerConfigOpt is the options to init Config -//type ConsumerConfigOpt func(config *consumer.Config) *consumer.Config +//// ConsumerConfigOpt is the options to init ShutdownConfig +//type ConsumerConfigOpt func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig // -//// NewDefaultConsumerConfig returns default Config +//// NewDefaultConsumerConfig returns default ShutdownConfig //// with connection timeout = 3s, request timeout = 3s -//func NewDefaultConsumerConfig() *consumer.Config { +//func NewDefaultConsumerConfig() *consumer.ShutdownConfig { // check := true -// newConsumerConfig := &consumer.Config{ -// BaseConfig: base.Config{}, +// newConsumerConfig := &consumer.ShutdownConfig{ +// BaseConfig: base.ShutdownConfig{}, // Registries: make(map[string]*registry.RegistryConfig, 8), // References: make(map[string]*reference.ReferenceConfig, 8), // ConnectTimeout: 3 * time.Second, @@ -187,8 +187,8 @@ package config // return newConsumerConfig //} // -//// NewConsumerConfig returns Config with @opts -//func NewConsumerConfig(opts ...ConsumerConfigOpt) *consumer.Config { +//// NewConsumerConfig returns ShutdownConfig with @opts +//func NewConsumerConfig(opts ...ConsumerConfigOpt) *consumer.ShutdownConfig { // newConfig := NewDefaultConsumerConfig() // for _, v := range opts { // v(newConfig) @@ -197,8 +197,8 @@ package config //} // //// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig -//func WithConsumerAppConfig(appConfig *application.Config) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +//func WithConsumerAppConfig(appConfig *application.ShutdownConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.ApplicationConfig = appConfig // return config // } @@ -206,7 +206,7 @@ package config // //// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig //func WithConsumerRegistryConfig(registryKey string, regConfig *registry.RegistryConfig) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.Registries[registryKey] = regConfig // return config // } @@ -214,7 +214,7 @@ package config // //// WithConsumerReferenceConfig returns ConsumerConfigOpt with //func WithConsumerReferenceConfig(referenceKey string, refConfig *reference.ReferenceConfig) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.References[referenceKey] = refConfig // return config // } @@ -222,7 +222,7 @@ package config // //// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout //func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.ConnectTimeout = timeout // return config // } @@ -230,15 +230,15 @@ package config // //// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout //func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.RequestTimeout = timeout // return config // } //} // //// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig -//func WithConsumerConfigCenterConfig(configCenterConfig *center.Config) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +//func WithConsumerConfigCenterConfig(configCenterConfig *center.ShutdownConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.ConfigCenterConfig = configCenterConfig // return config // } @@ -246,7 +246,7 @@ package config // //// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag //func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { -// return func(config *consumer.Config) *consumer.Config { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // *config.Check = check // return config // } @@ -321,18 +321,18 @@ package config //// ProviderConfigOpt is the //type ProviderConfigOpt func(config *provider.ProviderConfig) *provider.ProviderConfig // -//// NewDefaultProviderConfig returns ProviderConfig with default Config +//// NewDefaultProviderConfig returns ProviderConfig with default ShutdownConfig //func NewDefaultProviderConfig() *provider.ProviderConfig { // newConsumerConfig := &provider.ProviderConfig{ -// BaseConfig: base.Config{ -// application.Config: &application.Config{ +// BaseConfig: base.ShutdownConfig{ +// application.ShutdownConfig: &application.ShutdownConfig{ // Name: "dubbo", // Module: "module", // Organization: "dubbo_org", // Owner: "dubbo", // }, // }, -// Services: make(map[string]*service.Config), +// Services: make(map[string]*service.ShutdownConfig), // Registries: make(map[string]*registry.RegistryConfig, 8), // Protocols: make(map[string]*protocol.ProtocolConfig, 8), // } @@ -357,7 +357,7 @@ package config //} // //// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig -//func WithProviderAppConfig(appConfig *application.Config) ProviderConfigOpt { +//func WithProviderAppConfig(appConfig *application.ShutdownConfig) ProviderConfigOpt { // return func(config *provider.ProviderConfig) *provider.ProviderConfig { // config.ApplicationConfig = appConfig // return config @@ -365,7 +365,7 @@ package config //} // //// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -//func WithProviderServices(serviceName string, serviceConfig *service.Config) ProviderConfigOpt { +//func WithProviderServices(serviceName string, serviceConfig *service.ShutdownConfig) ProviderConfigOpt { // return func(config *provider.ProviderConfig) *provider.ProviderConfig { // config.Services[serviceName] = serviceConfig // return config @@ -392,11 +392,11 @@ package config //} // ///////////////////////////////////////// service config api -//// ServiceConfigOpt is the option to init Config -//type ServiceConfigOpt func(config *service.Config) *service.Config +//// ServiceConfigOpt is the option to init ShutdownConfig +//type ServiceConfigOpt func(config *service.ShutdownConfig) *service.ShutdownConfig // -//// NewDefaultServiceConfig returns default Config -//func NewDefaultServiceConfig() *service.Config { +//// NewDefaultServiceConfig returns default ShutdownConfig +//func NewDefaultServiceConfig() *service.ShutdownConfig { // newServiceConfig := service.NewServiceConfig("") // newServiceConfig.Params = make(map[string]string) // newServiceConfig.Methods = make([]*method.MethodConfig, 0, 8) @@ -404,8 +404,8 @@ package config //} // //// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared -//// NewServiceConfigByAPI returns Config with given @opts -//func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *service.Config { +//// NewServiceConfigByAPI returns ShutdownConfig with given @opts +//func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *service.ShutdownConfig { // defaultServiceConfig := NewDefaultServiceConfig() // for _, v := range opts { // v(defaultServiceConfig) @@ -415,7 +415,7 @@ package config // //// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry //func WithServiceRegistry(registry string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Registry = registry // return config // } @@ -423,7 +423,7 @@ package config // //// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol //func WithServiceProtocol(protocol string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Protocol = protocol // return config // } @@ -431,7 +431,7 @@ package config // //// WithServiceInterface returns ServiceConfigOpt with given @interfaceName //func WithServiceInterface(interfaceName string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.InterfaceName = interfaceName // return config // } @@ -439,7 +439,7 @@ package config // //// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb //func WithServiceLoadBalance(lb string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Loadbalance = lb // return config // } @@ -447,7 +447,7 @@ package config // //// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time //func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Warmup = warmUp // return config // } @@ -455,7 +455,7 @@ package config // //// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster //func WithServiceCluster(cluster string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Cluster = cluster // return config // } @@ -463,7 +463,7 @@ package config // //// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb //func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { -// return func(config *service.Config) *service.Config { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { // config.Methods = append(config.Methods, &method.MethodConfig{ // Name: name, // Retries: retries, @@ -474,18 +474,18 @@ package config //} // /////////////////////////////////////////// Application config api -//// ApplicationConfigOpt is option to init Config -//type ApplicationConfigOpt func(config *application.Config) *application.Config +//// ApplicationConfigOpt is option to init ShutdownConfig +//type ApplicationConfigOpt func(config *application.ShutdownConfig) *application.ShutdownConfig // -//// NewDefaultApplicationConfig returns Config with default +//// NewDefaultApplicationConfig returns ShutdownConfig with default //// name: dubbo.io //// module: sample //// organization: dubbo.io //// owner: dubbogo //// version: 0.0.1 //// environment dev -//func NewDefaultApplicationConfig() *application.Config { -// newAppConfig := &application.Config{ +//func NewDefaultApplicationConfig() *application.ShutdownConfig { +// newAppConfig := &application.ShutdownConfig{ // Name: "dubbo.io", // Module: "sample", // Organization: "dubbo.io", @@ -497,8 +497,8 @@ package config //} // //// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared -//// NewApplicationConfig returns Config with default application config -//func NewApplicationConfig(opts ...ApplicationConfigOpt) *application.Config { +//// NewApplicationConfig returns ShutdownConfig with default application config +//func NewApplicationConfig(opts ...ApplicationConfigOpt) *application.ShutdownConfig { // defaultServiceConfig := NewDefaultApplicationConfig() // for _, v := range opts { // v(defaultServiceConfig) @@ -508,7 +508,7 @@ package config // //// WithAppName returns ApplicationConfigOpt with given @name //func WithAppName(name string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Name = name // return config // } @@ -516,7 +516,7 @@ package config // //// WithAppModule returns ApplicationConfigOpt with given @module //func WithAppModule(module string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Module = module // return config // } @@ -524,7 +524,7 @@ package config // //// WithAppOrganization returns ApplicationConfigOpt wight given organization @org //func WithAppOrganization(org string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Organization = org // return config // } @@ -532,7 +532,7 @@ package config // //// WithAppOwner returns ApplicationConfigOpt with given @owner //func WithAppOwner(owner string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Owner = owner // return config // } @@ -540,7 +540,7 @@ package config // //// WithAppVersion returns ApplicationConfigOpt with given version @version //func WithAppVersion(version string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Version = version // return config // } @@ -548,7 +548,7 @@ package config // //// WithAppEnvironment returns ApplicationConfigOpt with given environment @env //func WithAppEnvironment(env string) ApplicationConfigOpt { -// return func(config *application.Config) *application.Config { +// return func(config *application.ShutdownConfig) *application.ShutdownConfig { // config.Environment = env // return config // } diff --git a/config/config_loader.go b/config/config_loader.go index 54f2b72fa1..a90cbaeceb 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -20,8 +20,8 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/config/application" "dubbo.apache.org/dubbo-go/v3/config/center" + "dubbo.apache.org/dubbo-go/v3/config/protocol" "dubbo.apache.org/dubbo-go/v3/config/registry" - "dubbo.apache.org/dubbo-go/v3/config/root" "fmt" "github.com/go-playground/validator/v10" "github.com/knadh/koanf" @@ -37,17 +37,18 @@ import ( ) var ( - rootConfig *root.Config + Koanf *koanf.Koanf + rootConfig *RootConfig // application config applicationConfig *application.Config // registriesConfig map[string]*registry.Config configCenterConfig *center.Config - //consumerConfig *consumer.Config + //consumerConfig *consumer.ShutdownConfig //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig - //baseConfig *root.Config + //baseConfig *root.ShutdownConfig //sslEnabled = false // //// configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. @@ -75,7 +76,7 @@ func Load(opts ...Option) { for _, opt := range opts { opt.apply(conf) } - rootConfig = new(root.Config) + rootConfig = new(RootConfig) k := getKoanf(conf) @@ -83,6 +84,7 @@ func Load(opts ...Option) { panic(err) } + Koanf = k rootConfig.Koanf = k rootConfig.Validate = validator.New() } @@ -206,6 +208,14 @@ func GetConfigCenterConfig() (*center.Config, error) { return conf, nil } +func GetProtocolsConfig() (map[string]*protocol.Config, error) { + if err := check(); err != nil { + return nil, err + } + + return protocol.GetProtocolsConfig(nil, rootConfig.Koanf), nil +} + // //// loaded consumer & provider config from xxx.yml, and log config from xxx.xml //// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo @@ -262,7 +272,7 @@ func GetConfigCenterConfig() (*center.Config, error) { // p.ApplicationConfig = NewDefaultApplicationConfig() // } // default: -// c := target.(*consumer.Config) +// c := target.(*consumer.ShutdownConfig) // if len(c.Registries) == 0 && c.Registry == nil { // c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig // } @@ -278,7 +288,7 @@ func GetConfigCenterConfig() (*center.Config, error) { // } //} // -//func checkApplicationName(config *application.Config) { +//func checkApplicationName(config *application.ShutdownConfig) { // if config == nil || len(config.Name) == 0 { // errMsg := "application config must not be nil, pls check your configuration" // logger.Errorf(errMsg) @@ -583,12 +593,12 @@ func GetConfigCenterConfig() (*center.Config, error) { //// we use double-check to reduce race condition //// In general, it will be locked 0 or 1 time. //// So you don't need to worry about the race condition -//func GetApplicationConfig() *application.Config { +//func GetApplicationConfig() *application.ShutdownConfig { // if GetBaseConfig().ApplicationConfig == nil { // configAccessMutex.Lock() // defer configAccessMutex.Unlock() // if GetBaseConfig().ApplicationConfig == nil { -// GetBaseConfig().ApplicationConfig = &application.Config{} +// GetBaseConfig().ApplicationConfig = &application.ShutdownConfig{} // } // } // return GetBaseConfig().ApplicationConfig @@ -610,26 +620,26 @@ func GetConfigCenterConfig() (*center.Config, error) { //// we use double-check to reduce race condition //// In general, it will be locked 0 or 1 time. //// So you don't need to worry about the race condition -//func GetConsumerConfig() consumer.Config { +//func GetConsumerConfig() consumer.ShutdownConfig { // if consumerConfig == nil { // if consumerConfig == nil { -// return consumer.Config{} +// return consumer.ShutdownConfig{} // } // } // return *consumerConfig //} // -//func GetBaseConfig() *base.Config { +//func GetBaseConfig() *base.ShutdownConfig { // if baseConfig == nil { // configAccessMutex.Lock() // defer configAccessMutex.Unlock() // if baseConfig == nil { -// baseConfig = &base.Config{ +// baseConfig = &base.ShutdownConfig{ // metric.MetricConfig: &metric.MetricConfig{}, -// ConfigCenterConfig: ¢er.Config{}, +// ConfigCenterConfig: ¢er.ShutdownConfig{}, // Remotes: make(map[string]*RemoteConfig), -// application.Config: &application.Config{}, -// ServiceDiscoveries: make(map[string]*discovery.Config), +// application.ShutdownConfig: &application.ShutdownConfig{}, +// ServiceDiscoveries: make(map[string]*discovery.ShutdownConfig), // } // } // } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 5229886089..fc545f4e59 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -67,9 +67,12 @@ func TestLoad(t *testing.T) { conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) - //address= nacos://127.0.0.1:8848 Translate Registry Address - //assert.Equal(t, "nacos", registries["nacos"].Protocol) - //assert.Equal(t, "10s", registries["zk"].Timeout) + }) + + //protocols + t.Run("protocols", func(t *testing.T) { + _, err := GetProtocolsConfig() + assert.Nil(t, err) }) } @@ -105,6 +108,10 @@ func TestLoadConfigCenter(t *testing.T) { }) } +func TestName(t *testing.T) { + +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() @@ -197,7 +204,7 @@ func TestLoadConfigCenter(t *testing.T) { // assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") // assert.NotNil(t, proConfig.ApplicationConfig) // -// conConfig := &consumer.Config{Registries: make(map[string]*registry2.RegistryConfig)} +// conConfig := &consumer.ShutdownConfig{Registries: make(map[string]*registry2.RegistryConfig)} // assert.Nil(t, conConfig.ApplicationConfig) // setDefaultValue(conConfig) // assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") @@ -217,7 +224,7 @@ func TestLoadConfigCenter(t *testing.T) { // assert.NoError(t, err) // // assert.Nil(t, consumerConfig) -// assert.Equal(t, consumer.Config{}, GetConsumerConfig()) +// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) // assert.Nil(t, providerConfig) // assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) // @@ -231,7 +238,7 @@ func TestLoadConfigCenter(t *testing.T) { // assert.NoError(t, err) // // assert.NotNil(t, consumerConfig) -// assert.NotEqual(t, consumer.Config{}, GetConsumerConfig()) +// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) // assert.NotNil(t, providerConfig) // assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) // @@ -271,7 +278,7 @@ func TestLoadConfigCenter(t *testing.T) { // assert.NoError(t, err) // // assert.Nil(t, consumerConfig) -// assert.Equal(t, consumer.Config{}, GetConsumerConfig()) +// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) // assert.Nil(t, providerConfig) // assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) // @@ -289,7 +296,7 @@ func TestLoadConfigCenter(t *testing.T) { // assert.NoError(t, err) // // assert.NotNil(t, consumerConfig) -// assert.NotEqual(t, consumer.Config{}, GetConsumerConfig()) +// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) // assert.NotNil(t, providerConfig) // assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) // @@ -307,8 +314,8 @@ func TestLoadConfigCenter(t *testing.T) { //// mockInitProviderWithSingleRegistry will init a mocked providerConfig //func mockInitProviderWithSingleRegistry() { // providerConfig = &provider.ProviderConfig{ -// BaseConfig: base.Config{ -// application.Config: &application.Config{ +// BaseConfig: base.ShutdownConfig{ +// application.ShutdownConfig: &application.ShutdownConfig{ // Organization: "dubbo_org", // Name: "dubbo", // Module: "module", @@ -325,7 +332,7 @@ func TestLoadConfigCenter(t *testing.T) { // }, // Registries: map[string]*registry2.RegistryConfig{}, // -// Services: map[string]*service2.Config{ +// Services: map[string]*service2.ShutdownConfig{ // "MockService": { // InterfaceName: "com.MockService", // Protocol: "mock", diff --git a/config/consumer/consumer_config.go b/config/consumer/consumer_config.go index 9d814cb2fb..9f78db3351 100644 --- a/config/consumer/consumer_config.go +++ b/config/consumer/consumer_config.go @@ -18,9 +18,9 @@ package consumer import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/reference" "dubbo.apache.org/dubbo-go/v3/config/registry" - "dubbo.apache.org/dubbo-go/v3/config/shutdown" "time" ) @@ -38,7 +38,7 @@ const ( // Config is Consumer default configuration type Config struct { - //root.Config `yaml:",inline" property:"base"` + //root.RootConfig `yaml:",inline" property:"base"` //center.Config `yaml:"-"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // client @@ -56,7 +56,7 @@ type Config struct { References map[string]*reference.ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *shutdown.Config `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } @@ -75,7 +75,7 @@ func (Config) Prefix() string { } // SetConsumerConfig sets consumerConfig by @c -//func SetConsumerConfig(c Config) { +//func SetConsumerConfig(c ShutdownConfig) { // config.consumerConfig = &c //} @@ -84,7 +84,7 @@ func ConsumerInit(confConFile string) error { //if confConFile == "" { // return perrors.Errorf("application configure(consumer) file name is nil") //} - //consumerConfig = &Config{} + //consumerConfig = &ShutdownConfig{} //fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) //if err != nil { // return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) diff --git a/config/shutdown/graceful_shutdown.go b/config/graceful_shutdown.go similarity index 99% rename from config/shutdown/graceful_shutdown.go rename to config/graceful_shutdown.go index f4b04d8e82..5f2ed175ce 100644 --- a/config/shutdown/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "time" @@ -183,7 +183,7 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { // waitingProcessedTimeout(config.consumerConfig.ShutdownConfig) //} -func waitingProcessedTimeout(shutdownConfig *Config) { +func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { timeout := shutdownConfig.GetStepTimeout() if timeout <= 0 { return diff --git a/config/shutdown/graceful_shutdown_config.go b/config/graceful_shutdown_config.go similarity index 91% rename from config/shutdown/graceful_shutdown_config.go rename to config/graceful_shutdown_config.go index e90a97d0fb..3c5b5b1c91 100644 --- a/config/shutdown/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "time" @@ -31,8 +31,8 @@ const ( defaultStepTimeout = 10 * time.Second ) -// Config is used as configuration for graceful shutdown -type Config struct { +// ShutdownConfig is used as configuration for graceful shutdown +type ShutdownConfig struct { /* * Total timeout. Even though we don't release all resources, * the application will shutdown if the costing time is over this configuration. The unit is ms. @@ -58,12 +58,12 @@ type Config struct { } // Prefix dubbo.shutdown -func (config *Config) Prefix() string { +func (config *ShutdownConfig) Prefix() string { return constant.ShutdownConfigPrefix } // nolint -func (config *Config) GetTimeout() time.Duration { +func (config *ShutdownConfig) GetTimeout() time.Duration { result, err := time.ParseDuration(config.Timeout) if err != nil { logger.Errorf("The Timeout configuration is invalid: %s, and we will use the default value: %s, err: %v", @@ -74,7 +74,7 @@ func (config *Config) GetTimeout() time.Duration { } // nolint -func (config *Config) GetStepTimeout() time.Duration { +func (config *ShutdownConfig) GetStepTimeout() time.Duration { result, err := time.ParseDuration(config.StepTimeout) if err != nil { logger.Errorf("The StepTimeout configuration is invalid: %s, and we will use the default value: %s, err: %v", diff --git a/config/shutdown/graceful_shutdown_config_test.go b/config/graceful_shutdown_config_test.go similarity index 93% rename from config/shutdown/graceful_shutdown_config_test.go rename to config/graceful_shutdown_config_test.go index 766cb3f907..43d2fc3c1b 100644 --- a/config/shutdown/graceful_shutdown_config_test.go +++ b/config/graceful_shutdown_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "testing" @@ -27,11 +27,11 @@ import ( ) func TestShutdownConfigGetTimeout(t *testing.T) { - config := Config{} + config := ShutdownConfig{} assert.False(t, config.RejectRequest) assert.False(t, config.RequestsFinished) - config = Config{ + config = ShutdownConfig{ Timeout: "60s", StepTimeout: "10s", } @@ -39,7 +39,7 @@ func TestShutdownConfigGetTimeout(t *testing.T) { assert.Equal(t, 60*time.Second, config.GetTimeout()) assert.Equal(t, 10*time.Second, config.GetStepTimeout()) - config = Config{ + config = ShutdownConfig{ Timeout: "34ms", StepTimeout: "79ms", } diff --git a/config/shutdown/graceful_shutdown_signal_darwin.go b/config/graceful_shutdown_signal_darwin.go similarity index 98% rename from config/shutdown/graceful_shutdown_signal_darwin.go rename to config/graceful_shutdown_signal_darwin.go index e52b1c14f1..9b694b5e09 100644 --- a/config/shutdown/graceful_shutdown_signal_darwin.go +++ b/config/graceful_shutdown_signal_darwin.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "os" diff --git a/config/shutdown/graceful_shutdown_signal_linux.go b/config/graceful_shutdown_signal_linux.go similarity index 98% rename from config/shutdown/graceful_shutdown_signal_linux.go rename to config/graceful_shutdown_signal_linux.go index e52b1c14f1..9b694b5e09 100644 --- a/config/shutdown/graceful_shutdown_signal_linux.go +++ b/config/graceful_shutdown_signal_linux.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "os" diff --git a/config/shutdown/graceful_shutdown_signal_windows.go b/config/graceful_shutdown_signal_windows.go similarity index 98% rename from config/shutdown/graceful_shutdown_signal_windows.go rename to config/graceful_shutdown_signal_windows.go index 08ce9f59b7..17c209e8f5 100644 --- a/config/shutdown/graceful_shutdown_signal_windows.go +++ b/config/graceful_shutdown_signal_windows.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config import ( "os" diff --git a/config/shutdown/graceful_shutdown_test.go b/config/graceful_shutdown_test.go similarity index 96% rename from config/shutdown/graceful_shutdown_test.go rename to config/graceful_shutdown_test.go index 3df535bc06..494f647c39 100644 --- a/config/shutdown/graceful_shutdown_test.go +++ b/config/graceful_shutdown_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package shutdown +package config // //import ( // "dubbo.apache.org/dubbo-go/v3/config" @@ -65,7 +65,7 @@ package shutdown // config.providerConfig = nil // BeforeShutdown() // -// config.consumerConfig = &consumer.Config{ +// config.consumerConfig = &consumer.ShutdownConfig{ // References: consumerReferences, // ShutdownConfig: &ShutdownConfig{ // Timeout: "1", @@ -100,7 +100,7 @@ package shutdown // Protocols: providerProtocols, // } // -// config.consumerConfig = &consumer.Config{ +// config.consumerConfig = &consumer.ShutdownConfig{ // References: consumerReferences, // ShutdownConfig: &ShutdownConfig{ // Timeout: "1", diff --git a/config/protocol/protocol_config.go b/config/protocol/protocol_config.go index 7219ecbeb4..0d9c2e0f2a 100644 --- a/config/protocol/protocol_config.go +++ b/config/protocol/protocol_config.go @@ -18,6 +18,8 @@ package protocol import ( + "dubbo.apache.org/dubbo-go/v3/config" + "github.com/knadh/koanf" "strings" ) @@ -32,11 +34,25 @@ type Config struct { Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` } -// nolint -func (c *Config) Prefix() string { +// Prefix dubbo.protocols +func (Config) Prefix() string { return constant.ProtocolConfigPrefix } +func GetProtocolsConfig(protocols map[string]*Config, k *koanf.Koanf) map[string]*Config { + if protocols != nil { + return protocols + } + + conf := new(Config) + if value := k.Get(conf.Prefix()); value != nil { + conf = value.(*Config) + } else { + + } + config.Koanf.Get(conf.Prefix()) + return nil +} func loadProtocol(protocolsIds string, protocols map[string]*Config) []*Config { returnProtocols := make([]*Config, 0, len(protocols)) for _, v := range strings.Split(protocolsIds, ",") { diff --git a/config/provider/provider_config.go b/config/provider/provider_config.go index ed50ecbbd4..b2fa83a846 100644 --- a/config/provider/provider_config.go +++ b/config/provider/provider_config.go @@ -18,9 +18,8 @@ package provider import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/protocol" - "dubbo.apache.org/dubbo-go/v3/config/service" - "dubbo.apache.org/dubbo-go/v3/config/shutdown" ) import ( @@ -33,16 +32,16 @@ import ( // Config is the default configuration of service provider type Config struct { - //base.Config `yaml:",inline" property:"base"` + //base.ShutdownConfig `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*service.Config `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *shutdown.Config `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + Services map[string]*config.ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function diff --git a/config/root/root_config.go b/config/root_config.go similarity index 72% rename from config/root/root_config.go rename to config/root_config.go index d528b6fee8..bd93c93791 100644 --- a/config/root/root_config.go +++ b/config/root_config.go @@ -1,7 +1,8 @@ -package root +package config import ( "bytes" + "dubbo.apache.org/dubbo-go/v3/config/protocol" "dubbo.apache.org/dubbo-go/v3/config/registry" ) @@ -16,26 +17,26 @@ import ( "dubbo.apache.org/dubbo-go/v3/config/center" "dubbo.apache.org/dubbo-go/v3/config/medadata/report" "dubbo.apache.org/dubbo-go/v3/config/metric" - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" ) -// Config is the root config -type Config struct { - +// RootConfig is the root config +type RootConfig struct { ConfigCenter *center.Config `yaml:"config-center" json:"config-center,omitempty"` // since 1.5.0 version //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - ServiceDiscoveries map[string]*discovery.Config `yaml:"service_discovery" json:"service_discovery,omitempty" property:"service_discovery"` + ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service_discovery"` - MetadataReportConfig *report.Config `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` + MetadataReportConfig *report.Config `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` // Application application config Application *application.Config `yaml:"application" json:"application,omitempty" property:"application"` // Registries registry config - Registries map[string]*registry.Config `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Registries map[string]*registry.Config `yaml:"registries" json:"registries" property:"registries"` + + Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols" property:"protocols"` // prefix string fatherConfig interface{} @@ -51,6 +52,6 @@ type Config struct { } // Prefix dubbo -func (Config) Prefix() string { +func (RootConfig) Prefix() string { return constant.DUBBO } diff --git a/config/router/router_config.go b/config/router_config.go similarity index 98% rename from config/router/router_config.go rename to config/router_config.go index 5db311afe4..fd3a838a43 100644 --- a/config/router/router_config.go +++ b/config/router_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package router +package config import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" diff --git a/config/router/router_config_test.go b/config/router_config_test.go similarity index 99% rename from config/router/router_config_test.go rename to config/router_config_test.go index 93dade98b0..007a61153e 100644 --- a/config/router/router_config_test.go +++ b/config/router_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package router +package config import ( "strings" diff --git a/config/service/service_config.go b/config/service_config.go similarity index 94% rename from config/service/service_config.go rename to config/service_config.go index d71a27fd2a..e4ddc46180 100644 --- a/config/service/service_config.go +++ b/config/service_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package service +package config import ( "container/list" @@ -44,8 +44,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) -// Config is the configuration of the service provider -type Config struct { +// ServiceConfig is the configuration of the service provider +type ServiceConfig struct { id string Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' @@ -87,16 +87,16 @@ type Config struct { } // Prefix returns dubbo.service.${interface}. -func (c *Config) Prefix() string { +func (c *ServiceConfig) Prefix() string { return constant.ServiceConfigPrefix + c.InterfaceName + "." } -// UnmarshalYAML unmarshal the Config by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function +func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain ServiceConfig if err := unmarshal((*plain)(c)); err != nil { return err } @@ -106,9 +106,9 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } -// NewServiceConfig The only way to get a new Config -func NewServiceConfig(id string) *Config { - return &Config{ +// NewServiceConfig The only way to get a new ServiceConfig +func NewServiceConfig(id string) *ServiceConfig { + return &ServiceConfig{ id: id, unexported: atomic.NewBool(false), exported: atomic.NewBool(false), @@ -117,12 +117,12 @@ func NewServiceConfig(id string) *Config { } // InitExported will set exported as false atom bool -func (c *Config) InitExported() { +func (c *ServiceConfig) InitExported() { c.exported = atomic.NewBool(false) } // IsExport will return whether the service config is exported or not -func (c *Config) IsExport() bool { +func (c *ServiceConfig) IsExport() bool { return c.exported.Load() } @@ -145,7 +145,7 @@ func getRandomPort(protocolConfigs []*protocol2.Config) *list.List { } // Export exports the service -func (c *Config) Export() error { +func (c *ServiceConfig) Export() error { // TODO: config center start here // TODO: delay export @@ -246,7 +246,7 @@ func (c *Config) Export() error { } // Unexport will call unexport of all exporters service config exported -func (c *Config) Unexport() { +func (c *ServiceConfig) Unexport() { if !c.exported.Load() { return } @@ -268,11 +268,11 @@ func (c *Config) Unexport() { } // Implement only store the @s and return -func (c *Config) Implement(s common.RPCService) { +func (c *ServiceConfig) Implement(s common.RPCService) { c.rpcService = s } -func (c *Config) getUrlMap() url.Values { +func (c *ServiceConfig) getUrlMap() url.Values { urlMap := url.Values{} // first set user params for k, v := range c.Params { @@ -342,7 +342,7 @@ func (c *Config) getUrlMap() url.Values { } // GetExportedUrls will return the url in service config's exporter -func (c *Config) GetExportedUrls() []*common.URL { +func (c *ServiceConfig) GetExportedUrls() []*common.URL { if c.exported.Load() { var urls []*common.URL for _, exporter := range c.exporters { @@ -360,8 +360,8 @@ func publishServiceDefinition(url *common.URL) { } } -// postProcessConfig asks registered ConfigPostProcessor to post-process the current Config. -func (c *Config) postProcessConfig(url *common.URL) { +// postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig. +func (c *ServiceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { p.PostProcessServiceConfig(url) } diff --git a/config/service/discovery/service_discovery_config.go b/config/service_discovery_config.go similarity index 90% rename from config/service/discovery/service_discovery_config.go rename to config/service_discovery_config.go index f7bbc02aa1..b08a16aa9a 100644 --- a/config/service/discovery/service_discovery_config.go +++ b/config/service_discovery_config.go @@ -15,12 +15,12 @@ * limitations under the License. */ -package discovery +package config import "dubbo.apache.org/dubbo-go/v3/common/constant" -// Config will be used to create -type Config struct { +// ServiceDiscoveryConfig will be used to create +type ServiceDiscoveryConfig struct { // Protocol indicate which implementation will be used. // for example, if the Protocol is nacos, it means that we will use nacosServiceDiscovery Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"` @@ -31,6 +31,6 @@ type Config struct { RemoteRef string `yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` } -func (Config) Prefix() string { +func (ServiceDiscoveryConfig) Prefix() string { return constant.ServiceDiscPrefix } diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index ed345dd9d1..ad5e69d098 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -29,4 +29,6 @@ dubbo: registry: nacos,zk orderService: interface: org.dubbo.service.OrderService - registry: nacos \ No newline at end of file + registry: nacos + provider: + filter: \ No newline at end of file diff --git a/config/router/uniform_router_config.go b/config/uniform_router_config.go similarity index 99% rename from config/router/uniform_router_config.go rename to config/uniform_router_config.go index dc52413721..fa5d02db19 100644 --- a/config/router/uniform_router_config.go +++ b/config/uniform_router_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package router +package config import ( "github.com/ghodss/yaml" diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 8a0a28d63f..95c754e84f 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -132,7 +132,7 @@ func (c *apolloConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (string, error) { /** - * when group is not null, we are getting startup configs(config file) from Config Center, for example: + * when group is not null, we are getting startup configs(config file) from ShutdownConfig Center, for example: * key=dubbo.propertie */ tmpConfig := agollo.GetConfig(key) diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go index f28861b283..1bbc19774e 100644 --- a/filter/gshutdown/filter.go +++ b/filter/gshutdown/filter.go @@ -19,7 +19,6 @@ package gshutdown import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/shutdown" "sync/atomic" ) @@ -44,7 +43,7 @@ func init() { type Filter struct { activeCount int32 - shutdownConfig *shutdown.Config + shutdownConfig *config.ShutdownConfig } // Invoke adds the requests count and block the new requests if application is closing @@ -70,7 +69,7 @@ func (f *Filter) OnResponse(ctx context.Context, result protocol.Result, invoker func (f *Filter) Set(name string, conf interface{}) { switch name { case config.GracefulShutdownFilterShutdownConfig: - if shutdownConfig, ok := conf.(*shutdown.Config); !ok { + if shutdownConfig, ok := conf.(*config.ShutdownConfig); !ok { f.shutdownConfig = shutdownConfig return } diff --git a/filter/gshutdown/filter_test.go b/filter/gshutdown/filter_test.go index 97c5c58eac..d8b9dc6eff 100644 --- a/filter/gshutdown/filter_test.go +++ b/filter/gshutdown/filter_test.go @@ -19,7 +19,6 @@ package gshutdown import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/shutdown" "net/url" "testing" ) @@ -57,7 +56,7 @@ func TestGenericFilterInvoke(t *testing.T) { assert.NotNil(t, result) assert.Nil(t, result.Error()) - providerConfig.ShutdownConfig = &shutdown.Config{ + providerConfig.ShutdownConfig = &config.ShutdownConfig{ RejectRequest: true, RejectRequestHandler: "mock", } diff --git a/filter/hystrix/filter.go b/filter/hystrix/filter.go index 8dbdae918b..39e06707d4 100644 --- a/filter/hystrix/filter.go +++ b/filter/hystrix/filter.go @@ -199,7 +199,7 @@ func newFilterConsumer() filter.Filter { // When first called, load the config in consumerConfigOnce.Do(func() { if err := initConfigConsumer(); err != nil { - logger.Warnf("[Hystrix Filter]Config load failed for consumer, error is: %v , will use default", err) + logger.Warnf("[Hystrix Filter]ShutdownConfig load failed for consumer, error is: %v , will use default", err) } }) return &Filter{COrP: true} @@ -209,7 +209,7 @@ func newFilterConsumer() filter.Filter { func newFilterProvider() filter.Filter { providerConfigOnce.Do(func() { if err := initConfigProvider(); err != nil { - logger.Warnf("[Hystrix Filter]Config load failed for provider, error is: %v , will use default", err) + logger.Warnf("[Hystrix Filter]ShutdownConfig load failed for provider, error is: %v , will use default", err) } }) return &Filter{COrP: false} @@ -300,7 +300,7 @@ type CommandConfigWithError struct { Error []string `yaml:"error_whitelist"` } -//Config: +//ShutdownConfig: //- Timeout: how long to wait for command to complete, in milliseconds //- MaxConcurrentRequests: how many commands of the same type can run at the same time //- RequestVolumeThreshold: the minimum number of requests needed before a circuit can be tripped due to health diff --git a/go.mod b/go.mod index b917d1cf2a..4c8378182c 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 - github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 // indirect + github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 @@ -36,8 +36,8 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.9.0 github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b - github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.7.1 + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.7.1 // indirect github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 diff --git a/go.sum b/go.sum index fceb281454..b3fa53949e 100644 --- a/go.sum +++ b/go.sum @@ -203,6 +203,7 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -364,6 +365,7 @@ github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXT github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= diff --git a/metadata/mapping/dynamic/service_name_mapping.go b/metadata/mapping/dynamic/service_name_mapping.go index b81423df36..e1dbb7dcfe 100644 --- a/metadata/mapping/dynamic/service_name_mapping.go +++ b/metadata/mapping/dynamic/service_name_mapping.go @@ -18,6 +18,7 @@ package dynamic import ( + "dubbo.apache.org/dubbo-go/v3/config" "strconv" "sync" "time" @@ -33,7 +34,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/mapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go index 1f5940cbd1..75aa80b2b0 100644 --- a/metadata/mapping/dynamic/service_name_mapping_test.go +++ b/metadata/mapping/dynamic/service_name_mapping_test.go @@ -18,6 +18,7 @@ package dynamic import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -28,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" ) diff --git a/metadata/mapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go index cc104399bc..3175a50607 100644 --- a/metadata/mapping/memory/service_name_mapping.go +++ b/metadata/mapping/memory/service_name_mapping.go @@ -18,6 +18,7 @@ package memory import ( + "dubbo.apache.org/dubbo-go/v3/config" "sync" ) @@ -27,7 +28,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 50ba72d11f..a83b0da470 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,8 +18,8 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/protocol" - service2 "dubbo.apache.org/dubbo-go/v3/config/service" "errors" "sync" ) @@ -28,14 +28,13 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" ) // MetadataServiceExporter is the ConfigurableMetadataServiceExporter which implement MetadataServiceExporter interface type MetadataServiceExporter struct { - ServiceConfig *service2.Config + ServiceConfig *config.ServiceConfig lock sync.RWMutex metadataService service.MetadataService } @@ -50,7 +49,7 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte // Export will export the metadataService func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { - serviceConfig := service2.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) + serviceConfig := config.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) serviceConfig.Protocol = constant.DEFAULT_PROTOCOL if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 4f3ebe75db..a910427cd3 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -18,13 +18,13 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/application" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/method" "dubbo.apache.org/dubbo-go/v3/config/protocol" "dubbo.apache.org/dubbo-go/v3/config/provider" "dubbo.apache.org/dubbo-go/v3/config/registry" - "dubbo.apache.org/dubbo-go/v3/config/service" "testing" ) @@ -104,7 +104,7 @@ func mockInitProviderWithSingleRegistry() { }, Registries: map[string]*registry.Config{}, - Services: map[string]*service.Config{ + Services: map[string]*config.ServiceConfig{ "MockService": { InterfaceName: "com.MockService", Protocol: "mock", diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go index 794d463aff..2d920952d9 100644 --- a/metadata/service/local/service.go +++ b/metadata/service/local/service.go @@ -17,6 +17,7 @@ package local import ( + "dubbo.apache.org/dubbo-go/v3/config" "sort" "sync" ) @@ -30,7 +31,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/service" ) diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 57a072d0f1..a416f6e302 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -18,12 +18,12 @@ package grpc import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/application" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/config/method" "dubbo.apache.org/dubbo-go/v3/config/provider" - "dubbo.apache.org/dubbo-go/v3/config/service" "testing" "time" ) @@ -50,7 +50,7 @@ func doInitProvider() { Environment: "test", }, }, - Services: map[string]*service.Config{ + Services: map[string]*config.ServiceConfig{ "GrpcGreeterImpl": { InterfaceName: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", Protocol: "grpc", diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index 42a45a38bc..5257272234 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -19,7 +19,6 @@ package grpc import ( "dubbo.apache.org/dubbo-go/v3/config/instance" - service2 "dubbo.apache.org/dubbo-go/v3/config/service" "fmt" "net" "sync" @@ -117,7 +116,7 @@ func getSyncMapLen(m *sync.Map) int { } // waitGrpcExporter wait until len(providerServices) = len(ExporterMap) -func waitGrpcExporter(providerServices map[string]*service2.Config) { +func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { t := time.NewTicker(50 * time.Millisecond) defer t.Stop() pLen := len(providerServices) @@ -138,7 +137,7 @@ func waitGrpcExporter(providerServices map[string]*service2.Config) { } // registerService SetProxyImpl invoker and grpc service -func registerService(providerServices map[string]*service2.Config, server *grpc.Server) { +func registerService(providerServices map[string]*config.ServiceConfig, server *grpc.Server) { for key, providerService := range providerServices { service := instance.GetProviderService(key) ds, ok := service.(DubboGrpcService) diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go index d72821c69d..2c56c22f44 100644 --- a/protocol/rest/config/reader/rest_config_reader.go +++ b/protocol/rest/config/reader/rest_config_reader.go @@ -54,7 +54,7 @@ func (cr *RestConfigReader) ReadConsumerConfig(reader *bytes.Buffer) error { restConsumerConfig := &config.RestConsumerConfig{} err := yaml.Unmarshal(reader.Bytes(), restConsumerConfig) if err != nil { - return perrors.Errorf("[Rest Config] unmarshal Consumer error %#v", perrors.WithStack(err)) + return perrors.Errorf("[Rest ShutdownConfig] unmarshal Consumer error %#v", perrors.WithStack(err)) } restConsumerServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restConsumerConfig.RestServiceConfigsMap)) @@ -72,7 +72,7 @@ func (cr *RestConfigReader) ReadProviderConfig(reader *bytes.Buffer) error { restProviderConfig := &config.RestProviderConfig{} err := yaml.Unmarshal(reader.Bytes(), restProviderConfig) if err != nil { - return perrors.Errorf("[Rest Config] unmarshal Provider error %#v", perrors.WithStack(err)) + return perrors.Errorf("[Rest ShutdownConfig] unmarshal Provider error %#v", perrors.WithStack(err)) } restProviderServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restProviderConfig.RestServiceConfigsMap)) for key, rc := range restProviderConfig.RestServiceConfigsMap { @@ -116,7 +116,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.PathParamsMap) == 0 && len(methodConfig.PathParams) > 0 { paramsMap, err := parseParamsString2Map(methodConfig.PathParams) if err != nil { - logger.Warnf("[Rest Config] Path Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Path Param parse error:%v", err) } else { methodConfig.PathParamsMap = paramsMap } @@ -124,7 +124,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.QueryParamsMap) == 0 && len(methodConfig.QueryParams) > 0 { paramsMap, err := parseParamsString2Map(methodConfig.QueryParams) if err != nil { - logger.Warnf("[Rest Config] Argument Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Argument Param parse error:%v", err) } else { methodConfig.QueryParamsMap = paramsMap } @@ -132,7 +132,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.HeadersMap) == 0 && len(methodConfig.Headers) > 0 { headersMap, err := parseParamsString2Map(methodConfig.Headers) if err != nil { - logger.Warnf("[Rest Config] Argument Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Argument Param parse error:%v", err) } else { methodConfig.HeadersMap = headersMap } diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 6b7c2df337..17ec5649e5 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -18,6 +18,7 @@ package directory import ( + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "net/url" "os" @@ -36,7 +37,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" _ "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/registry/etcdv3/service_discovery_test.go b/registry/etcdv3/service_discovery_test.go index a9d630413c..704297f95a 100644 --- a/registry/etcdv3/service_discovery_test.go +++ b/registry/etcdv3/service_discovery_test.go @@ -18,7 +18,6 @@ package etcdv3 import ( - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "testing" ) @@ -35,7 +34,7 @@ import ( var testName = "test" func setUp() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ Protocol: "etcdv3", RemoteRef: testName, } @@ -53,7 +52,7 @@ func Test_newEtcdV3ServiceDiscovery(t *testing.T) { // warn: log configure file name is nil assert.NotNil(t, err) - sdc := &discovery.Config{ + sdc := &config.ServiceConfig{ Protocol: "etcdv3", RemoteRef: "mock", } diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go index 13983b1188..51f472b83c 100644 --- a/registry/event/event_publishing_service_deiscovery_test.go +++ b/registry/event/event_publishing_service_deiscovery_test.go @@ -18,6 +18,7 @@ package event import ( + "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -33,7 +34,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" diff --git a/registry/event/service_config_exported_event.go b/registry/event/service_config_exported_event.go index 4b206c8812..d40c0273d3 100644 --- a/registry/event/service_config_exported_event.go +++ b/registry/event/service_config_exported_event.go @@ -18,7 +18,7 @@ package event import ( - "dubbo.apache.org/dubbo-go/v3/config/service" + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -29,11 +29,11 @@ import ( // ServiceConfigExportedEvent represents an service was exported type ServiceConfigExportedEvent struct { observer.BaseEvent - ServiceConfig *service.Config + ServiceConfig *config.ServiceConfig } // NewServiceConfigExportedEvent create an instance -func NewServiceConfigExportedEvent(serviceConfig *service.Config) *ServiceConfigExportedEvent { +func NewServiceConfigExportedEvent(serviceConfig *config.ServiceConfig) *ServiceConfigExportedEvent { return &ServiceConfigExportedEvent{ BaseEvent: observer.BaseEvent{ Source: serviceConfig, diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index 4914eff543..e1c8d3047c 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -18,7 +18,6 @@ package file import ( - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "math/rand" "strconv" "testing" @@ -88,7 +87,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ Protocol: "file", } } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 3b26f930b3..381f4679ce 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -18,7 +18,6 @@ package nacos import ( - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "math/rand" "strconv" "testing" @@ -47,10 +46,10 @@ func Test_newNacosServiceDiscovery(t *testing.T) { name := "nacos1" _, err := newNacosServiceDiscovery(name) - // the Config not found + // the ShutdownConfig not found assert.NotNil(t, err) - sdc := &discovery.Config{ + sdc := &config.ServiceConfig{ Protocol: "nacos", RemoteRef: "mock", } @@ -179,7 +178,7 @@ func TestNacosServiceDiscovery_Destroy(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ Protocol: "nacos", RemoteRef: testName, } diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index fcfc5a684d..580f9aaa4e 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -18,7 +18,6 @@ package servicediscovery import ( - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "testing" ) @@ -64,7 +63,7 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { }) extension.SetAndInitGlobalDispatcher("mock") - config.GetBaseConfig().ServiceDiscoveries["mock"] = &discovery.Config{ + config.GetBaseConfig().ServiceDiscoveries["mock"] = &config.ServiceConfig{ Protocol: "mock", } registryURL, _ := common.NewURL("service-discovery://localhost:12345", diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index a5ac104fea..3042bf1dff 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -19,7 +19,6 @@ package zookeeper import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/service/discovery" "strconv" "sync" "testing" @@ -54,7 +53,7 @@ func prepareData(t *testing.T) *zk.TestCluster { address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) //address := "127.0.0.1:2181" - config.GetBaseConfig().ServiceDiscoveries[testName] = &discovery.Config{ + config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ Protocol: "zookeeper", RemoteRef: "test", } @@ -70,11 +69,11 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) { name := "zookeeper1" _, err := newZookeeperServiceDiscovery(name) - // the Config not found + // the ShutdownConfig not found // err: could not init the instance because the config is invalid assert.NotNil(t, err) - sdc := &discovery.Config{ + sdc := &config.ServiceConfig{ Protocol: "zookeeper", RemoteRef: "mock", } diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index cbe8245eb3..7ca3a35789 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -89,7 +89,7 @@ func initClient(protocol string) { rand.Seed(time.Now().UnixNano()) } -// Config ClientConf +// ShutdownConfig ClientConf func SetClientConf(c ClientConfig) { clientConf = &c err := clientConf.CheckValidity() diff --git a/samples b/samples deleted file mode 160000 index ac38818cd1..0000000000 --- a/samples +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ac38818cd13ec2536fe59e51523a4fde3aee37da diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go index bcc3946616..2226f634de 100644 --- a/test/integrate/dubbo/go-client/client.go +++ b/test/integrate/dubbo/go-client/client.go @@ -19,6 +19,7 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) @@ -31,7 +32,6 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/test/integrate/dubbo/go-server/server.go b/test/integrate/dubbo/go-server/server.go index b1c16704c8..06af91581a 100644 --- a/test/integrate/dubbo/go-server/server.go +++ b/test/integrate/dubbo/go-server/server.go @@ -18,6 +18,7 @@ package main import ( + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -29,7 +30,6 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" From 7b269eddd8d8c271db2f9eb8beb8377be7138d95 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 24 Jul 2021 01:46:28 +0800 Subject: [PATCH 008/148] up:set config --- cluster/router/chain/chain.go | 2 +- .../{application => }/application_config.go | 64 +++++-- config/{center => }/config_center_config.go | 105 ++++++------ config/config_loader.go | 161 ++++++++---------- config/config_loader_test.go | 56 +++--- config/{protocol => }/protocol_config.go | 46 ++--- config/provider/provider_config.go | 17 +- config/root_config.go | 40 +++-- config/service_config.go | 5 +- config_center/apollo/impl_test.go | 4 +- .../service/exporter/configurable/exporter.go | 3 +- .../exporter/configurable/exporter_test.go | 6 +- protocol/grpc/grpc_protocol_test.go | 3 +- registry/directory/directory_test.go | 4 +- registry/protocol/protocol_test.go | 6 +- 15 files changed, 262 insertions(+), 260 deletions(-) rename config/{application => }/application_config.go (58%) rename config/{center => }/config_center_config.go (78%) rename config/{protocol => }/protocol_config.go (55%) diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 616909ab1e..81839f75d5 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -122,7 +122,7 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) { 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") + logger.Warnf("virtual Service ProtocolConfig 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) if r == nil || err != nil { diff --git a/config/application/application_config.go b/config/application_config.go similarity index 58% rename from config/application/application_config.go rename to config/application_config.go index b89ca1a3e7..90f1313896 100644 --- a/config/application/application_config.go +++ b/config/application_config.go @@ -15,12 +15,14 @@ * limitations under the License. */ -package application +package config import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" "errors" "github.com/creasty/defaults" "github.com/go-playground/validator/v10" + "github.com/mitchellh/mapstructure" "strings" ) @@ -28,8 +30,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// Config is a configuration for current application, whether the application is a provider or a consumer -type Config struct { +// ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer +type ApplicationConfig struct { Organization string `default:"dubbo.io" yaml:"organization" json:"organization,omitempty" property:"organization"` Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"` Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"` @@ -41,16 +43,12 @@ type Config struct { } // Prefix dubbo.application -func (Config) Prefix() string { +func (ApplicationConfig) Prefix() string { return constant.DUBBO + ".application" } -func (c *Config) SetDefault() error { - return defaults.Set(c) -} - -func (c *Config) Validate(valid *validator.Validate) error { - if err := valid.Struct(c); err != nil { +func (ac *ApplicationConfig) validate() error { + if err := validate.Struct(ac); err != nil { errs := err.(validator.ValidationErrors) var slice []string for _, msg := range errs { @@ -61,11 +59,47 @@ func (c *Config) Validate(valid *validator.Validate) error { return nil } -// UnmarshalYAML unmarshal the Config by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { +//GetApplicationConfig get application config +func GetApplicationConfig() *ApplicationConfig { + if err := check(); err != nil { + return nil + } + + application := rootConfig.Application + if application != nil { + if err := defaults.Set(application); err != nil { + logger.Error(err) + } + if err := application.validate(); err != nil { + logger.Error(err) + } + return application + } + + application = new(ApplicationConfig) + if value := viper.Get(application.Prefix()); value != nil { + // map to struct + if err := mapstructure.Decode(value, application); err != nil { + logger.Error(err) + } + } + + // set defaults + if err := defaults.Set(application); err != nil { + logger.Error(err) + } + // validate values + if err := application.validate(); err != nil { + logger.Error(err) + } + return application +} + +// UnmarshalYAML unmarshal the ApplicationConfig by @unmarshal function +func (ac *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(ac); err != nil { return err } - type plain Config - return unmarshal((*plain)(c)) + type plain ApplicationConfig + return unmarshal((*plain)(ac)) } diff --git a/config/center/config_center_config.go b/config/config_center_config.go similarity index 78% rename from config/center/config_center_config.go rename to config/config_center_config.go index ae3822f042..e2dde61631 100644 --- a/config/center/config_center_config.go +++ b/config/config_center_config.go @@ -15,39 +15,36 @@ * limitations under the License. */ -package center +package config import ( - "errors" - "github.com/knadh/koanf" "net/url" "strings" ) import ( "github.com/creasty/defaults" - "github.com/go-playground/validator/v10" "github.com/goinggo/mapstructure" - perrors "github.com/pkg/errors" + "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/config" + conf "dubbo.apache.org/dubbo-go/v3/common/config" "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/config_center" ) -// Config is configuration for config center +// CenterConfig is configuration for config center // // ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group, // those configs are already built-in in many professional third-party configuration centers. // In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups. // -// ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo -type Config struct { +// CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo +type CenterConfig struct { Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty"` Address string `yaml:"address" json:"address,omitempty"` Cluster string `yaml:"cluster" json:"cluster,omitempty"` @@ -66,62 +63,63 @@ type Config struct { } // Prefix dubbo.config-center -func (Config) Prefix() string { +func (CenterConfig) Prefix() string { return constant.ConfigCenterPrefix } -func GetConfigCenterConfig(conf *Config, k *koanf.Koanf) *Config { - if conf != nil { - return conf +// GetConfigCenterConfig get config center config +func GetConfigCenterConfig() *CenterConfig { + if err := check(); err != nil { + return nil + } + center := rootConfig.ConfigCenter + if center != nil { + if err := defaults.Set(center); err != nil { + logger.Error(err) + } + center.translateConfigAddress() + if err := verification(center); err != nil { + logger.Error(err) + } + return center } - conf = new(Config) - key := conf.Prefix() - value := k.Get(key) + center = new(CenterConfig) + key := center.Prefix() + value := viper.Get(key) if value == nil { key = strings.ReplaceAll(key, "-", "_") - value = k.Get(key) + value = viper.Get(key) } - if value == nil { - return conf + return nil } - if err := mapstructure.Decode(value, conf); err != nil { - panic(err) + if err := mapstructure.Decode(value, center); err != nil { + logger.Error(err) } - return conf -} -// SetDefault set default value -func (c *Config) SetDefault() error { - return defaults.Set(c) -} - -// Validate valida value -func (c *Config) Validate(valid *validator.Validate) error { - if err := valid.Struct(c); err != nil { - errs := err.(validator.ValidationErrors) - var slice []string - for _, msg := range errs { - slice = append(slice, msg.Error()) - } - return errors.New(strings.Join(slice, ",")) + if err := defaults.Set(center); err != nil { + logger.Error(err) } - return nil + center.translateConfigAddress() + if err := verification(center); err != nil { + logger.Error(err) + } + return center } -// UnmarshalYAML unmarshal the Config by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function +func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain CenterConfig return unmarshal((*plain)(c)) } -// GetUrlMap gets url map from Config -func (c *Config) GetUrlMap() url.Values { +// GetUrlMap gets url map from ConfigCenterConfig +func (c *CenterConfig) GetUrlMap() url.Values { urlMap := url.Values{} urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace) urlMap.Set(constant.CONFIG_GROUP_KEY, c.Group) @@ -138,9 +136,9 @@ func (c *Config) GetUrlMap() url.Values { return urlMap } -//TranslateConfigAddress translate config address +//translateConfigAddress translate config address // eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos -func (c *Config) TranslateConfigAddress() string { +func (c *CenterConfig) translateConfigAddress() string { if strings.Contains(c.Address, "://") { translatedUrl, err := url.Parse(c.Address) if err != nil { @@ -155,7 +153,7 @@ func (c *Config) TranslateConfigAddress() string { // toURL will compatible with baseConfig.ShutdownConfig.Address and baseConfig.ShutdownConfig.RemoteRef before 1.6.0 // After 1.6.0 will not compatible, only baseConfig.ShutdownConfig.RemoteRef -func (c *Config) toURL() (*common.URL, error) { +func (c *CenterConfig) toURL() (*common.URL, error) { //remoteRef := baseConfig.ConfigCenterConfig.RemoteRef //// if set remote ref use remote //if len(remoteRef) <= 0 { @@ -178,32 +176,31 @@ func (c *Config) toURL() (*common.URL, error) { // startConfigCenter will start the config center. // it will prepare the environment -func (c *Config) startConfigCenter() error { +func (c *CenterConfig) startConfigCenter() error { newUrl, err := c.toURL() if err != nil { return err } if err = c.prepareEnvironment(newUrl); err != nil { - return perrors.WithMessagef(err, "start config center error!") + return errors.WithMessagef(err, "start config center error!") } // c.fresh() return nil } -func (c *Config) prepareEnvironment(configCenterUrl *common.URL) error { +func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) error { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { logger.Errorf("Get dynamic configuration error , error message is %v", err) - return perrors.WithStack(err) + return errors.WithStack(err) } - envInstance := config.GetEnvInstance() + envInstance := conf.GetEnvInstance() envInstance.SetDynamicConfiguration(dynamicConfig) - _, err = dynamicConfig.GetProperties(c.ConfigFile, - config_center.WithGroup(c.Group)) + _, err = dynamicConfig.GetProperties(c.ConfigFile, config_center.WithGroup(c.Group)) if err != nil { logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) - return perrors.WithStack(err) + return errors.WithStack(err) } //var appGroup string //var appContent string diff --git a/config/config_loader.go b/config/config_loader.go index a90cbaeceb..6a406c26f6 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,33 +18,34 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/config/application" - "dubbo.apache.org/dubbo-go/v3/config/center" - "dubbo.apache.org/dubbo-go/v3/config/protocol" - "dubbo.apache.org/dubbo-go/v3/config/registry" + "errors" "fmt" +) +import ( "github.com/go-playground/validator/v10" "github.com/knadh/koanf" "github.com/knadh/koanf/parsers/json" "github.com/knadh/koanf/parsers/toml" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/file" - "github.com/pkg/errors" ) import ( _ "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" + "dubbo.apache.org/dubbo-go/v3/config/registry" ) var ( - Koanf *koanf.Koanf + viper *koanf.Koanf + validate *validator.Validate + rootConfig *RootConfig // application config - applicationConfig *application.Config + applicationConfig *ApplicationConfig // registriesConfig map[string]*registry.Config - configCenterConfig *center.Config + configCenterConfig *CenterConfig //consumerConfig *consumer.ShutdownConfig //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig @@ -62,6 +63,10 @@ var ( //uniformDestRuleConfigPath string ) +func init() { + validate = validator.New() +} + func Load(opts ...Option) { // pares CommandLine //parseCommandLine() @@ -78,19 +83,15 @@ func Load(opts ...Option) { } rootConfig = new(RootConfig) - k := getKoanf(conf) + viper = getKoanf(conf) - if err := k.Unmarshal(rootConfig.Prefix(), &rootConfig); err != nil { + if err := viper.Unmarshal(rootConfig.Prefix(), &rootConfig); err != nil { panic(err) } - - Koanf = k - rootConfig.Koanf = k - rootConfig.Validate = validator.New() } func check() error { - if rootConfig == nil { + if viper == nil || rootConfig == nil { return errors.New("execute the config.Load() method first") } return nil @@ -137,85 +138,57 @@ func getKoanf(conf *config) *koanf.Koanf { return k } -// GetApplicationConfig get application config -func GetApplicationConfig() (*application.Config, error) { - if err := check(); err != nil { - return nil, err - } - if applicationConfig != nil { - return applicationConfig, nil - } - conf := rootConfig.Application - if err := conf.SetDefault(); err != nil { - return nil, err - } - if err := conf.Validate(rootConfig.Validate); err != nil { - return nil, err - } - applicationConfig = conf - return conf, nil -} - -func GetRegistriesConfig() (map[string]*registry.Config, error) { - if err := check(); err != nil { - return nil, err - } - if registriesConfig != nil { - return registriesConfig, nil - } - - registries := rootConfig.Registries - - if len(registries) <= 0 { - reg := new(registry.Config) - if err := reg.SetDefault(); err != nil { - return nil, err - } - registries = make(map[string]*registry.Config, 1) - registries["default"] = reg - return registries, nil - } - for _, reg := range registries { - if err := reg.SetDefault(); err != nil { - return nil, err - } - reg.TranslateRegistryAddress() - if err := reg.Validate(rootConfig.Validate); err != nil { - return nil, err - } - } - registriesConfig = registries - return registries, nil -} - -func GetConfigCenterConfig() (*center.Config, error) { - if err := check(); err != nil { - return nil, err - } - if configCenterConfig != nil { - return configCenterConfig, nil - } - conf := center.GetConfigCenterConfig(rootConfig.ConfigCenter, rootConfig.Koanf) - - if err := conf.SetDefault(); err != nil { - return nil, err - } - conf.TranslateConfigAddress() - if err := conf.Validate(rootConfig.Validate); err != nil { - return nil, err - } - configCenterConfig = conf - return conf, nil -} - -func GetProtocolsConfig() (map[string]*protocol.Config, error) { - if err := check(); err != nil { - return nil, err - } - - return protocol.GetProtocolsConfig(nil, rootConfig.Koanf), nil -} - +//func GetRegistriesConfig() (map[string]*registry.ConfigCenterConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// if registriesConfig != nil { +// return registriesConfig, nil +// } +// +// registries := rootConfig.Registries +// +// if len(registries) <= 0 { +// reg := new(registry.ConfigCenterConfig) +// if err := reg.SetDefault(); err != nil { +// return nil, err +// } +// registries = make(map[string]*registry.ConfigCenterConfig, 1) +// registries["default"] = reg +// return registries, nil +// } +// for _, reg := range registries { +// if err := reg.SetDefault(); err != nil { +// return nil, err +// } +// reg.TranslateRegistryAddress() +// if err := reg.Validate(rootConfig.Validate); err != nil { +// return nil, err +// } +// } +// registriesConfig = registries +// return registries, nil +//} +// +//func GetConfigCenterConfig() (*center.ConfigCenterConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// if configCenterConfig != nil { +// return configCenterConfig, nil +// } +// conf := center.GetConfigCenterConfig(rootConfig.ConfigCenter, rootConfig.Koanf) +// +// if err := conf.SetDefault(); err != nil { +// return nil, err +// } +// conf.TranslateConfigAddress() +// if err := conf.Validate(rootConfig.Validate); err != nil { +// return nil, err +// } +// configCenterConfig = conf +// return conf, nil +//} // //// loaded consumer & provider config from xxx.yml, and log config from xxx.xml //// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo diff --git a/config/config_loader_test.go b/config/config_loader_test.go index fc545f4e59..addfb37ef6 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -30,8 +30,8 @@ const ( func TestNoLoad(t *testing.T) { - application, err := GetApplicationConfig() - assert.NotNil(t, err) + application:= GetApplicationConfig() + assert.Nil(t, application) } @@ -39,11 +39,7 @@ func TestLoad(t *testing.T) { Load(WithPath(configPath)) t.Run("application", func(t *testing.T) { - application, err := GetApplicationConfig() - assert.Nil(t, err) - application, err = GetApplicationConfig() - assert.Nil(t, err) - + application := GetApplicationConfig() assert.Equal(t, application.Organization, "dubbo.io") assert.Equal(t, application.Name, "dubbo-go") assert.Equal(t, application.Module, "local") @@ -53,27 +49,26 @@ func TestLoad(t *testing.T) { assert.Equal(t, application.MetadataType, "local") }) - t.Run("registries", func(t *testing.T) { - registries, err := GetRegistriesConfig() - registries, err = GetRegistriesConfig() - assert.Nil(t, err) - assert.Equal(t, 2, len(registries)) - //address= nacos://127.0.0.1:8848 Translate Registry Address - assert.Equal(t, "nacos", registries["nacos"].Protocol) - assert.Equal(t, "10s", registries["zk"].Timeout) - }) + //t.Run("registries", func(t *testing.T) { + // registries, err := GetRegistriesConfig() + // registries, err = GetRegistriesConfig() + // assert.Nil(t, err) + // assert.Equal(t, 2, len(registries)) + // //address= nacos://127.0.0.1:8848 Translate Registry Address + // assert.Equal(t, "nacos", registries["nacos"].Protocol) + // assert.Equal(t, "10s", registries["zk"].Timeout) + //}) //config-center t.Run("config-center", func(t *testing.T) { - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) + conf := GetConfigCenterConfig() assert.Equal(t, "nacos", conf.Protocol) }) - - //protocols - t.Run("protocols", func(t *testing.T) { - _, err := GetProtocolsConfig() - assert.Nil(t, err) - }) + // + ////protocols + //t.Run("protocols", func(t *testing.T) { + // _, err := GetProtocolsConfig() + // assert.Nil(t, err) + //}) } @@ -82,8 +77,7 @@ func TestLoadConfigCenter(t *testing.T) { t.Run("config_center", func(t *testing.T) { Load(WithPath("./testdata/config/center/conf_application.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) + conf := GetConfigCenterConfig() assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) @@ -91,8 +85,7 @@ func TestLoadConfigCenter(t *testing.T) { t.Run("configCenter", func(t *testing.T) { Load(WithPath("./testdata/config/center/confApplication.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) + conf := GetConfigCenterConfig() assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) @@ -100,18 +93,13 @@ func TestLoadConfigCenter(t *testing.T) { t.Run("config-center", func(t *testing.T) { Load(WithPath("./testdata/config/center/conf-application.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) + conf := GetConfigCenterConfig() assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) }) } -func TestName(t *testing.T) { - -} - // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/protocol/protocol_config.go b/config/protocol_config.go similarity index 55% rename from config/protocol/protocol_config.go rename to config/protocol_config.go index 0d9c2e0f2a..6bcff4d49c 100644 --- a/config/protocol/protocol_config.go +++ b/config/protocol_config.go @@ -15,11 +15,11 @@ * limitations under the License. */ -package protocol +package config import ( - "dubbo.apache.org/dubbo-go/v3/config" - "github.com/knadh/koanf" + "dubbo.apache.org/dubbo-go/v3/common/logger" + "github.com/creasty/defaults" "strings" ) @@ -27,34 +27,36 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// Config is protocol configuration -type Config struct { - Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"` - Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` +// ProtocolConfig is protocol configuration +type ProtocolConfig struct { + Name string `default:"dubbo" yaml:"name" json:"name,omitempty" property:"name"` + Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` + Port string `default:"20000" yaml:"port" json:"port,omitempty" property:"port"` } // Prefix dubbo.protocols -func (Config) Prefix() string { +func (ProtocolConfig) Prefix() string { return constant.ProtocolConfigPrefix } -func GetProtocolsConfig(protocols map[string]*Config, k *koanf.Koanf) map[string]*Config { - if protocols != nil { - return protocols - } - - conf := new(Config) - if value := k.Get(conf.Prefix()); value != nil { - conf = value.(*Config) +// GetProtocolsConfig get protocols config +func GetProtocolsConfig() map[string]*ProtocolConfig { + protocols := make(map[string]*ProtocolConfig) + conf := new(ProtocolConfig) + if value := viper.Get(conf.Prefix()); value != nil { + //conf = value.(map[string]*ProtocolConfig) + logger.Error("abc") } else { - + if err := defaults.Set(conf); err != nil { + panic(err) + } + protocols["default"] = conf } - config.Koanf.Get(conf.Prefix()) - return nil + return protocols } -func loadProtocol(protocolsIds string, protocols map[string]*Config) []*Config { - returnProtocols := make([]*Config, 0, len(protocols)) + +func loadProtocol(protocolsIds string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { + returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) for _, v := range strings.Split(protocolsIds, ",") { for k, protocol := range protocols { if v == k { diff --git a/config/provider/provider_config.go b/config/provider/provider_config.go index b2fa83a846..11c2cd74cd 100644 --- a/config/provider/provider_config.go +++ b/config/provider/provider_config.go @@ -19,7 +19,6 @@ package provider import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/protocol" ) import ( @@ -34,14 +33,14 @@ import ( type Config struct { //base.ShutdownConfig `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*config.ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + Services map[string]*config.ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*config.ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function diff --git a/config/root_config.go b/config/root_config.go index bd93c93791..cd4c742eaf 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -2,26 +2,22 @@ package config import ( "bytes" - "dubbo.apache.org/dubbo-go/v3/config/protocol" - "dubbo.apache.org/dubbo-go/v3/config/registry" -) - -import ( + "github.com/creasty/defaults" "github.com/go-playground/validator/v10" - "github.com/knadh/koanf" + "github.com/pkg/errors" + "strings" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config/application" - "dubbo.apache.org/dubbo-go/v3/config/center" "dubbo.apache.org/dubbo-go/v3/config/medadata/report" "dubbo.apache.org/dubbo-go/v3/config/metric" + "dubbo.apache.org/dubbo-go/v3/config/registry" ) // RootConfig is the root config type RootConfig struct { - ConfigCenter *center.Config `yaml:"config-center" json:"config-center,omitempty"` + ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` // since 1.5.0 version //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` @@ -31,12 +27,12 @@ type RootConfig struct { MetadataReportConfig *report.Config `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` // Application application config - Application *application.Config `yaml:"application" json:"application,omitempty" property:"application"` + Application *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` // Registries registry config Registries map[string]*registry.Config `yaml:"registries" json:"registries" property:"registries"` - Protocols map[string]*protocol.Config `yaml:"protocols" json:"protocols" property:"protocols"` + Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols" property:"protocols"` // prefix string fatherConfig interface{} @@ -44,9 +40,8 @@ type RootConfig struct { MetricConfig *metric.MetricConfig `yaml:"metrics" json:"metrics,omitempty"` fileStream *bytes.Buffer - Koanf *koanf.Koanf // validate - Validate *validator.Validate + //Validate *validator.Validate // cache file used to store the current used configurations. CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` } @@ -55,3 +50,22 @@ type RootConfig struct { func (RootConfig) Prefix() string { return constant.DUBBO } + +func setDefaults(s interface{}) error { + if err := defaults.Set(s); err != nil { + return err + } + return nil +} + +func verification(s interface{}) error { + if err := validate.Struct(s); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil +} diff --git a/config/service_config.go b/config/service_config.go index e4ddc46180..ef17b3b1cf 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -20,7 +20,6 @@ package config import ( "container/list" "dubbo.apache.org/dubbo-go/v3/config/method" - protocol2 "dubbo.apache.org/dubbo-go/v3/config/protocol" "fmt" "net/url" "strconv" @@ -74,7 +73,7 @@ type ServiceConfig struct { Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - Protocols map[string]*protocol2.Config + Protocols map[string]*ProtocolConfig unexported *atomic.Bool exported *atomic.Bool export bool // a flag to control whether the current service should export or not @@ -127,7 +126,7 @@ func (c *ServiceConfig) IsExport() bool { } // Get Random Port -func getRandomPort(protocolConfigs []*protocol2.Config) *list.List { +func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { ports := list.New() for _, proto := range protocolConfigs { if len(proto.Port) > 0 { diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index f798b2280e..fc8c64163d 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -17,8 +17,8 @@ package apollo import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/center" "fmt" "net/http" "net/http/httptest" @@ -185,7 +185,7 @@ func TestGetConfigItem(t *testing.T) { } func initMockApollo(t *testing.T) *apolloConfiguration { - c := &base.Config{ConfigCenterConfig: ¢er.Config{ + c := &base.Config{ConfigCenterConfig: &config.CenterConfig{ Protocol: "apollo", Address: "106.12.25.204:8080", AppID: "testApplication_yang", diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index a83b0da470..562ca7002c 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -19,7 +19,6 @@ package configurable import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/protocol" "errors" "sync" ) @@ -54,7 +53,7 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") } - serviceConfig.Protocols = map[string]*protocol.Config{ + serviceConfig.Protocols = map[string]*config.ProtocolConfig{ constant.DEFAULT_PROTOCOL: { Name: url.SubURL.Protocol, Port: url.SubURL.Port, diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index a910427cd3..99b6c4b29e 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -19,10 +19,8 @@ package configurable import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/application" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/method" - "dubbo.apache.org/dubbo-go/v3/config/protocol" "dubbo.apache.org/dubbo-go/v3/config/provider" "dubbo.apache.org/dubbo-go/v3/config/registry" "testing" @@ -87,7 +85,7 @@ func mockInitProviderWithSingleRegistry() { providerConfig := &provider.Config{ BaseConfig: base.Config{ - ApplicationConfig: &application.Config{ + ApplicationConfig: &config.ApplicationConfig{ Organization: "dubbo_org", Name: "dubbo", Module: "module", @@ -129,7 +127,7 @@ func mockInitProviderWithSingleRegistry() { }, }, }, - Protocols: map[string]*protocol.Config{ + Protocols: map[string]*config.ProtocolConfig{ "mock": { Name: "mock", Ip: "127.0.0.1", diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index a416f6e302..0af1459fb6 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -19,7 +19,6 @@ package grpc import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/application" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/config/method" @@ -41,7 +40,7 @@ import ( func doInitProvider() { providerConfig := provider.Config{ BaseConfig: base.Config{ - ApplicationConfig: &application.Config{ + ApplicationConfig: &config.ApplicationConfig{ Organization: "dubbo_org", Name: "BDTService", Module: "module", diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 39d2c5bf68..6228aee38a 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,7 +18,7 @@ package directory import ( - "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/consumer" "strconv" @@ -44,7 +44,7 @@ import ( func init() { consumer.SetConsumerConfig(consumer.Config{ BaseConfig: base.Config{ - ApplicationConfig: &application.Config{Name: "test-application"}, + ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }, }) } diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index f67b2370e9..8282cdc17e 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -18,7 +18,7 @@ package protocol import ( - "dubbo.apache.org/dubbo-go/v3/config/application" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/consumer" "dubbo.apache.org/dubbo-go/v3/config/provider" @@ -47,7 +47,7 @@ import ( func init() { provider.SetProviderConfig(provider.Config{BaseConfig: base.Config{ - ApplicationConfig: &application.Config{Name: "test-application"}, + ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }}) } @@ -73,7 +73,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { func TestRefer(t *testing.T) { consumer.SetConsumerConfig( consumer.Config{BaseConfig: base.Config{ - ApplicationConfig: &application.Config{Name: "test-application"}, + ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }}) regProtocol := newRegistryProtocol() referNormal(t, regProtocol) From d7f3e7cd51d3c884fc8723911c67d4ae032a7830 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 24 Jul 2021 01:48:41 +0800 Subject: [PATCH 009/148] add validate --- config/application_config.go | 19 ++----------------- config/root_config.go | 8 -------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 90f1313896..4f1d560d33 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -19,11 +19,8 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/common/logger" - "errors" "github.com/creasty/defaults" - "github.com/go-playground/validator/v10" "github.com/mitchellh/mapstructure" - "strings" ) import ( @@ -47,18 +44,6 @@ func (ApplicationConfig) Prefix() string { return constant.DUBBO + ".application" } -func (ac *ApplicationConfig) validate() error { - if err := validate.Struct(ac); err != nil { - errs := err.(validator.ValidationErrors) - var slice []string - for _, msg := range errs { - slice = append(slice, msg.Error()) - } - return errors.New(strings.Join(slice, ",")) - } - return nil -} - //GetApplicationConfig get application config func GetApplicationConfig() *ApplicationConfig { if err := check(); err != nil { @@ -70,7 +55,7 @@ func GetApplicationConfig() *ApplicationConfig { if err := defaults.Set(application); err != nil { logger.Error(err) } - if err := application.validate(); err != nil { + if err := verification(application); err != nil { logger.Error(err) } return application @@ -89,7 +74,7 @@ func GetApplicationConfig() *ApplicationConfig { logger.Error(err) } // validate values - if err := application.validate(); err != nil { + if err := verification(application); err != nil { logger.Error(err) } return application diff --git a/config/root_config.go b/config/root_config.go index cd4c742eaf..10f94b24af 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -2,7 +2,6 @@ package config import ( "bytes" - "github.com/creasty/defaults" "github.com/go-playground/validator/v10" "github.com/pkg/errors" "strings" @@ -51,13 +50,6 @@ func (RootConfig) Prefix() string { return constant.DUBBO } -func setDefaults(s interface{}) error { - if err := defaults.Set(s); err != nil { - return err - } - return nil -} - func verification(s interface{}) error { if err := validate.Struct(s); err != nil { errs := err.(validator.ValidationErrors) From c707ca7b861c04ab554ae7307c4736c583ed31b1 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 24 Jul 2021 15:03:53 +0800 Subject: [PATCH 010/148] add check genre --- config/application_config.go | 28 ++-------------- config/config_center_config.go | 57 +++++++++++---------------------- config/config_loader.go | 9 +----- config/config_loader_options.go | 24 ++++++++++++-- config/config_loader_test.go | 32 ++++++++++++------ config/root_config.go | 38 ++++++++++++++++++++++ 6 files changed, 105 insertions(+), 83 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 4f1d560d33..2124a2b117 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -18,7 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "github.com/creasty/defaults" "github.com/mitchellh/mapstructure" ) @@ -44,39 +43,18 @@ func (ApplicationConfig) Prefix() string { return constant.DUBBO + ".application" } -//GetApplicationConfig get application config -func GetApplicationConfig() *ApplicationConfig { - if err := check(); err != nil { - return nil - } - - application := rootConfig.Application +// getApplicationConfig get application config +func getApplicationConfig(application *ApplicationConfig) *ApplicationConfig { if application != nil { - if err := defaults.Set(application); err != nil { - logger.Error(err) - } - if err := verification(application); err != nil { - logger.Error(err) - } return application } application = new(ApplicationConfig) if value := viper.Get(application.Prefix()); value != nil { - // map to struct if err := mapstructure.Decode(value, application); err != nil { - logger.Error(err) + return application } } - - // set defaults - if err := defaults.Set(application); err != nil { - logger.Error(err) - } - // validate values - if err := verification(application); err != nil { - logger.Error(err) - } return application } diff --git a/config/config_center_config.go b/config/config_center_config.go index e2dde61631..8c7f5b536e 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -18,13 +18,13 @@ package config import ( + "github.com/goinggo/mapstructure" "net/url" "strings" ) import ( "github.com/creasty/defaults" - "github.com/goinggo/mapstructure" "github.com/pkg/errors" ) @@ -67,25 +67,22 @@ func (CenterConfig) Prefix() string { return constant.ConfigCenterPrefix } -// GetConfigCenterConfig get config center config -func GetConfigCenterConfig() *CenterConfig { - if err := check(); err != nil { - return nil - } - center := rootConfig.ConfigCenter - if center != nil { - if err := defaults.Set(center); err != nil { - logger.Error(err) - } - center.translateConfigAddress() - if err := verification(center); err != nil { - logger.Error(err) - } - return center +// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function +func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err } + type plain CenterConfig + return unmarshal((*plain)(c)) +} - center = new(CenterConfig) - key := center.Prefix() +// getConfigCenterConfig get config center config +func getConfigCenterConfig(c *CenterConfig) *CenterConfig { + if c != nil { + return nil + } + c = new(CenterConfig) + key := c.Prefix() value := viper.Get(key) if value == nil { key = strings.ReplaceAll(key, "-", "_") @@ -94,28 +91,10 @@ func GetConfigCenterConfig() *CenterConfig { if value == nil { return nil } - - if err := mapstructure.Decode(value, center); err != nil { - logger.Error(err) - } - - if err := defaults.Set(center); err != nil { - logger.Error(err) - } - center.translateConfigAddress() - if err := verification(center); err != nil { - logger.Error(err) - } - return center -} - -// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function -func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err + if err := mapstructure.Decode(value, c); err != nil { + return nil } - type plain CenterConfig - return unmarshal((*plain)(c)) + return c } // GetUrlMap gets url map from ConfigCenterConfig diff --git a/config/config_loader.go b/config/config_loader.go index 6a406c26f6..1fff1de398 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -32,7 +32,6 @@ import ( import ( _ "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config/registry" ) var ( @@ -40,12 +39,7 @@ var ( validate *validator.Validate rootConfig *RootConfig - // application config - applicationConfig *ApplicationConfig - // - registriesConfig map[string]*registry.Config - configCenterConfig *CenterConfig //consumerConfig *consumer.ShutdownConfig //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig @@ -121,8 +115,7 @@ func getKoanf(conf *config) *koanf.Koanf { k = koanf.New(conf.delim) switch conf.genre { - - case "yaml": + case "yaml", "yml": err = k.Load(file.Provider(conf.path), yaml.Parser()) case "json": err = k.Load(file.Provider(conf.path), json.Parser()) diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 3f01c01491..30072da2c6 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -13,16 +13,21 @@ * 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 import ( + "fmt" "os" "path/filepath" "runtime" + "sort" "strings" ) +import ( + "github.com/pkg/errors" +) type config struct { // config file name default application @@ -48,7 +53,11 @@ type Option interface { // WithGenre set config genre func WithGenre(genre string) Option { return optionFunc(func(conf *config) { - conf.genre = strings.ToLower(genre) + g := strings.ToLower(genre) + if err := checkGenre(g); err != nil { + panic(err) + } + conf.genre = g }) } @@ -103,6 +112,17 @@ func userHomeDir() string { return os.Getenv("HOME") } +// checkGenre check genre +func checkGenre(genre string) error { + genres := []string{"json", "toml", "yaml", "yml"} + sort.Strings(genres) + idx := sort.SearchStrings(genres, genre) + if genres[idx] != genre { + return errors.New(fmt.Sprintf("no support %s", genre)) + } + return nil +} + // //import ( // "dubbo.apache.org/dubbo-go/v3/config/base" diff --git a/config/config_loader_test.go b/config/config_loader_test.go index addfb37ef6..37d3be5128 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -30,8 +30,8 @@ const ( func TestNoLoad(t *testing.T) { - application:= GetApplicationConfig() - + application, err := GetApplicationConfig() + assert.NotNil(t, err) assert.Nil(t, application) } @@ -39,7 +39,8 @@ func TestLoad(t *testing.T) { Load(WithPath(configPath)) t.Run("application", func(t *testing.T) { - application := GetApplicationConfig() + application, err := GetApplicationConfig() + assert.Nil(t, err) assert.Equal(t, application.Organization, "dubbo.io") assert.Equal(t, application.Name, "dubbo-go") assert.Equal(t, application.Module, "local") @@ -60,7 +61,8 @@ func TestLoad(t *testing.T) { //}) //config-center t.Run("config-center", func(t *testing.T) { - conf := GetConfigCenterConfig() + conf, err := GetConfigCenterConfig() + assert.NotNil(t, err) assert.Equal(t, "nacos", conf.Protocol) }) // @@ -76,16 +78,18 @@ func TestLoad(t *testing.T) { func TestLoadConfigCenter(t *testing.T) { t.Run("config_center", func(t *testing.T) { - Load(WithPath("./testdata/config/center/conf_application.yaml")) - conf := GetConfigCenterConfig() + Load(WithGenre("yml"), WithPath("./testdata/config/center/conf_application.yaml")) + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) }) t.Run("configCenter", func(t *testing.T) { - Load(WithPath("./testdata/config/center/confApplication.yaml")) - conf := GetConfigCenterConfig() + Load(WithGenre("yaml"), WithPath("./testdata/config/center/confApplication.yaml")) + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) @@ -93,13 +97,23 @@ func TestLoadConfigCenter(t *testing.T) { t.Run("config-center", func(t *testing.T) { Load(WithPath("./testdata/config/center/conf-application.yaml")) - conf := GetConfigCenterConfig() + conf, err := GetConfigCenterConfig() + assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) }) } +func TestCheckGenre(t *testing.T) { + + err := checkGenre("abc") + assert.NotNil(t, err) + + err = checkGenre("json") + assert.Nil(t, err) +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/root_config.go b/config/root_config.go index 10f94b24af..e091632394 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -2,6 +2,7 @@ package config import ( "bytes" + "github.com/creasty/defaults" "github.com/go-playground/validator/v10" "github.com/pkg/errors" "strings" @@ -51,6 +52,7 @@ func (RootConfig) Prefix() string { } func verification(s interface{}) error { + if err := validate.Struct(s); err != nil { errs := err.(validator.ValidationErrors) var slice []string @@ -61,3 +63,39 @@ func verification(s interface{}) error { } return nil } + +// GetApplicationConfig get application config +func GetApplicationConfig() (*ApplicationConfig, error) { + if err := check(); err != nil { + return nil, err + } + application := getApplicationConfig(rootConfig.Application) + if err := defaults.Set(application); err != nil { + return nil, err + } + + if err := verification(application); err != nil { + return nil, err + } + rootConfig.Application = application + return application, nil +} + +// GetConfigCenterConfig get config center config +func GetConfigCenterConfig() (*CenterConfig, error) { + if err := check(); err != nil { + return nil, err + } + centerConfig := getConfigCenterConfig(rootConfig.ConfigCenter) + if centerConfig == nil { + return nil, errors.New("config center config is null") + } + if err := defaults.Set(centerConfig); err != nil { + return nil, err + } + centerConfig.translateConfigAddress() + if err := verification(centerConfig); err != nil { + return nil, err + } + return centerConfig, nil +} From c2a0aa9751ae1ac3d5feb63f077689931f6cb84b Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 24 Jul 2021 21:54:11 +0800 Subject: [PATCH 011/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/{consumer => }/consumer_config.go | 35 +++++++++---------- .../report => }/metadata_report_config.go | 22 ++++++------ config/{method => }/method_config.go | 12 +++---- config/{metric => }/metric_config.go | 2 +- config/{metric => }/metric_config_test.go | 11 ++---- config/{provider => }/provider_config.go | 16 ++++----- config/{provider => }/provider_config_test.go | 2 +- config/{reference => }/reference_config.go | 32 ++++++++--------- .../{reference => }/reference_config_test.go | 2 +- config/{registry => }/registry_config.go | 22 ++++++------ config/{registry => }/registry_config_test.go | 8 ++--- config/root_config.go | 11 +++--- config/service_config.go | 3 +- .../exporter/configurable/exporter_test.go | 10 +++--- protocol/grpc/grpc_protocol_test.go | 5 ++- protocol/jsonrpc/jsonrpc_protocol_test.go | 3 +- protocol/rest/rest_invoker_test.go | 3 +- protocol/rest/rest_protocol_test.go | 5 +-- registry/directory/directory_test.go | 2 +- registry/protocol/protocol_test.go | 4 +-- remoting/getty/config.go | 14 ++++---- 21 files changed, 102 insertions(+), 122 deletions(-) rename config/{consumer => }/consumer_config.go (76%) rename config/{medadata/report => }/metadata_report_config.go (84%) rename config/{method => }/method_config.go (91%) rename config/{metric => }/metric_config.go (98%) rename config/{metric => }/metric_config_test.go (84%) rename config/{provider => }/provider_config.go (93%) rename config/{provider => }/provider_config_test.go (99%) rename config/{reference => }/reference_config.go (88%) rename config/{reference => }/reference_config_test.go (99%) rename config/{registry => }/registry_config.go (91%) rename config/{registry => }/registry_config_test.go (94%) diff --git a/config/consumer/consumer_config.go b/config/consumer_config.go similarity index 76% rename from config/consumer/consumer_config.go rename to config/consumer_config.go index 9f78db3351..73aa2f8aaf 100644 --- a/config/consumer/consumer_config.go +++ b/config/consumer_config.go @@ -15,12 +15,9 @@ * limitations under the License. */ -package consumer +package config import ( - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/reference" - "dubbo.apache.org/dubbo-go/v3/config/registry" "time" ) @@ -36,41 +33,41 @@ const ( MaxWheelTimeSpan = 900e9 // 900s, 15 minute ) -// Config is Consumer default configuration -type Config struct { +// ConsumerConfig is Consumer default configuration +type ConsumerConfig struct { //root.RootConfig `yaml:",inline" property:"base"` - //center.Config `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + //center.ConsumerConfig `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // client Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` ConnectTimeout time.Duration - Registry *registry.Config `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*registry.Config `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` RequestTimeout time.Duration ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` - References map[string]*reference.ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } -// UnmarshalYAML unmarshal the Config by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the ConsumerConfig by @unmarshal function +func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain ConsumerConfig return unmarshal((*plain)(c)) } // Prefix dubbo.consumer -func (Config) Prefix() string { +func (ConsumerConfig) Prefix() string { return constant.ConsumerConfigPrefix } diff --git a/config/medadata/report/metadata_report_config.go b/config/metadata_report_config.go similarity index 84% rename from config/medadata/report/metadata_report_config.go rename to config/metadata_report_config.go index 4f904d1c58..8118be90e2 100644 --- a/config/medadata/report/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package report +package config import ( "github.com/creasty/defaults" @@ -28,8 +28,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/config/instance" ) -// Config is method level configuration -type Config struct { +// MetadataReportConfig is method level configuration +type MetadataReportConfig struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` RemoteRef string `required:"true" yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` @@ -37,16 +37,16 @@ type Config struct { } // Prefix dubbo.metadata-report -func (Config) Prefix() string { +func (MetadataReportConfig) Prefix() string { return constant.MetadataReportPrefix } -// UnmarshalYAML unmarshal the Config by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +// UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function +func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return perrors.WithStack(err) } - type plain Config + type plain MetadataReportConfig if err := unmarshal((*plain)(c)); err != nil { return perrors.WithStack(err) } @@ -54,7 +54,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { } // nolint -func (c *Config) ToUrl() (*common.URL, error) { +func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { //urlMap := make(url.Values) //if c.Params != nil { @@ -77,18 +77,18 @@ func (c *Config) ToUrl() (*common.URL, error) { // common.WithProtocol(c.Protocol), //) //if err != nil || len(res.Protocol) == 0 { - // return nil, perrors.New("Invalid Config.") + // return nil, perrors.New("Invalid MetadataReportConfig.") //} //res.SetParam("metadata", res.Protocol) return nil, nil } -func (c *Config) IsValid() bool { +func (c *MetadataReportConfig) IsValid() bool { return len(c.Protocol) != 0 } // StartMetadataReport: The entry of metadata report start -func startMetadataReport(metadataType string, metadataReportConfig *Config) error { +func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { if metadataReportConfig == nil || !metadataReportConfig.IsValid() { return nil } diff --git a/config/method/method_config.go b/config/method_config.go similarity index 91% rename from config/method/method_config.go rename to config/method_config.go index ce858c0466..e76cf7cdc4 100644 --- a/config/method/method_config.go +++ b/config/method_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package method +package config import ( "github.com/creasty/defaults" @@ -25,8 +25,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// Config defines method config -type Config struct { +// MethodConfig defines method config +type MethodConfig struct { InterfaceId string InterfaceName string Name string `yaml:"name" json:"name,omitempty" property:"name"` @@ -43,7 +43,7 @@ type Config struct { } // nolint -func (c *Config) Prefix() string { +func (c *MethodConfig) Prefix() string { if len(c.InterfaceId) != 0 { return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "." } @@ -52,10 +52,10 @@ func (c *Config) Prefix() string { } // UnmarshalYAML unmarshals the MethodConfig by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain MethodConfig return unmarshal((*plain)(c)) } diff --git a/config/metric/metric_config.go b/config/metric_config.go similarity index 98% rename from config/metric/metric_config.go rename to config/metric_config.go index 3091b7f0ea..9af1691dad 100644 --- a/config/metric/metric_config.go +++ b/config/metric_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package metric +package config var defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000} diff --git a/config/metric/metric_config_test.go b/config/metric_config_test.go similarity index 84% rename from config/metric/metric_config_test.go rename to config/metric_config_test.go index 30a1a476ad..2bcdd6d4a7 100644 --- a/config/metric/metric_config_test.go +++ b/config/metric_config_test.go @@ -15,18 +15,13 @@ * limitations under the License. */ -package metric +package config import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) -import ( - "github.com/stretchr/testify/assert" -) - func TestGetMetricConfig(t *testing.T) { - empty := config.GetMetricConfig() - assert.NotNil(t, empty) + //empty := GetMetricConfig() + //assert.NotNil(t, empty) } diff --git a/config/provider/provider_config.go b/config/provider_config.go similarity index 93% rename from config/provider/provider_config.go rename to config/provider_config.go index 11c2cd74cd..a98b543e1f 100644 --- a/config/provider/provider_config.go +++ b/config/provider_config.go @@ -15,11 +15,7 @@ * limitations under the License. */ -package provider - -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) +package config import ( "github.com/creasty/defaults" @@ -29,8 +25,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// Config is the default configuration of service provider -type Config struct { +// ProviderConfig is the default configuration of service provider +type ProviderConfig struct { //base.ShutdownConfig `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` @@ -44,16 +40,16 @@ type Config struct { } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain ProviderConfig return unmarshal((*plain)(c)) } // nolint -func (*Config) Prefix() string { +func (*ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } diff --git a/config/provider/provider_config_test.go b/config/provider_config_test.go similarity index 99% rename from config/provider/provider_config_test.go rename to config/provider_config_test.go index 85c79539a3..4427b0d9d3 100644 --- a/config/provider/provider_config_test.go +++ b/config/provider_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package provider +package config //import ( // "dubbo.apache.org/dubbo-go/v3/config" diff --git a/config/reference/reference_config.go b/config/reference_config.go similarity index 88% rename from config/reference/reference_config.go rename to config/reference_config.go index 9fcbd37232..35e86e10a3 100644 --- a/config/reference/reference_config.go +++ b/config/reference_config.go @@ -15,11 +15,7 @@ * limitations under the License. */ -package reference - -import ( - "dubbo.apache.org/dubbo-go/v3/config/method" -) +package config import ( "dubbo.apache.org/dubbo-go/v3/common" @@ -34,19 +30,19 @@ type ReferenceConfig struct { InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` URL string `yaml:"url" json:"url,omitempty" property:"url"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` - Methods []*method.Config `yaml:"methods" json:"methods,omitempty" property:"methods"` - Async bool `yaml:"async" json:"async,omitempty" property:"async"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` + Methods []*config.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` + Async bool `yaml:"async" json:"async,omitempty" property:"async"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` invoker protocol.Invoker urls []*common.URL Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` diff --git a/config/reference/reference_config_test.go b/config/reference_config_test.go similarity index 99% rename from config/reference/reference_config_test.go rename to config/reference_config_test.go index 62eab977b6..80993fbeae 100644 --- a/config/reference/reference_config_test.go +++ b/config/reference_config_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package reference +package config //import ( // "context" diff --git a/config/registry/registry_config.go b/config/registry_config.go similarity index 91% rename from config/registry/registry_config.go rename to config/registry_config.go index f042d44dae..744f75477c 100644 --- a/config/registry/registry_config.go +++ b/config/registry_config.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package registry +package config import ( "errors" @@ -35,8 +35,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// Config is the configuration of the registry center -type Config struct { +// RegistryConfig is the configuration of the registry center +type RegistryConfig struct { Protocol string `default:"zookeeper" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` @@ -57,12 +57,12 @@ type Config struct { } // SetDefault set default value -func (c *Config) SetDefault() error { +func (c *RegistryConfig) SetDefault() error { return defaults.Set(c) } // Validate valida value -func (c *Config) Validate(valid *validator.Validate) error { +func (c *RegistryConfig) Validate(valid *validator.Validate) error { if err := valid.Struct(c); err != nil { errs := err.(validator.ValidationErrors) var slice []string @@ -75,20 +75,20 @@ func (c *Config) Validate(valid *validator.Validate) error { } // UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain Config + type plain RegistryConfig return unmarshal((*plain)(c)) } // Prefix dubbo.registries -func (Config) Prefix() string { +func (RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix } -func loadRegistries(targetRegistries string, registries map[string]*Config, roleType common.RoleType) []*common.URL { +func loadRegistries(targetRegistries string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { var urls []*common.URL trSlice := strings.Split(targetRegistries, ",") @@ -136,7 +136,7 @@ func loadRegistries(targetRegistries string, registries map[string]*Config, role return urls } -func (c *Config) getUrlMap(roleType common.RoleType) url.Values { +func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { urlMap := url.Values{} urlMap.Set(constant.GROUP_KEY, c.Group) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) @@ -156,7 +156,7 @@ func (c *Config) getUrlMap(roleType common.RoleType) url.Values { //TranslateRegistryAddress translate registry address // eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos -func (c *Config) TranslateRegistryAddress() string { +func (c *RegistryConfig) TranslateRegistryAddress() string { if strings.Contains(c.Address, "://") { translatedUrl, err := url.Parse(c.Address) if err != nil { diff --git a/config/registry/registry_config_test.go b/config/registry_config_test.go similarity index 94% rename from config/registry/registry_config_test.go rename to config/registry_config_test.go index efd49908f2..2af172c3a5 100644 --- a/config/registry/registry_config_test.go +++ b/config/registry_config_test.go @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package registry +package config import ( "testing" @@ -30,7 +30,7 @@ import ( func TestLoadRegistries(t *testing.T) { target := "shanghai1" - regs := map[string]*Config{ + regs := map[string]*RegistryConfig{ "shanghai1": { Protocol: "mock", @@ -48,7 +48,7 @@ func TestLoadRegistries(t *testing.T) { func TestLoadRegistries1(t *testing.T) { target := "shanghai1" - regs := map[string]*Config{ + regs := map[string]*RegistryConfig{ "shanghai1": { Protocol: "mock", @@ -65,7 +65,7 @@ func TestLoadRegistries1(t *testing.T) { } func TestTranslateRegistryAddress(t *testing.T) { - reg := new(Config) + reg := new(RegistryConfig) reg.Address = "nacos://127.0.0.1:8848" address := reg.TranslateRegistryAddress() diff --git a/config/root_config.go b/config/root_config.go index e091632394..04c31e0c6f 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -10,9 +10,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config/medadata/report" - "dubbo.apache.org/dubbo-go/v3/config/metric" - "dubbo.apache.org/dubbo-go/v3/config/registry" ) // RootConfig is the root config @@ -24,20 +21,20 @@ type RootConfig struct { ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service_discovery"` - MetadataReportConfig *report.Config `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` + MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` // Application application config Application *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` // Registries registry config - Registries map[string]*registry.Config `yaml:"registries" json:"registries" property:"registries"` + Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols" property:"protocols"` // prefix string fatherConfig interface{} - EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` - MetricConfig *metric.MetricConfig `yaml:"metrics" json:"metrics,omitempty"` + EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` + MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` fileStream *bytes.Buffer // validate diff --git a/config/service_config.go b/config/service_config.go index ef17b3b1cf..d21764abb2 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -19,7 +19,6 @@ package config import ( "container/list" - "dubbo.apache.org/dubbo-go/v3/config/method" "fmt" "net/url" "strconv" @@ -54,7 +53,7 @@ type ServiceConfig struct { Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Group string `yaml:"group" json:"group,omitempty" property:"group"` Version string `yaml:"version" json:"version,omitempty" property:"version" ` - Methods []*method.Config `yaml:"methods" json:"methods,omitempty" property:"methods"` + Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` Warmup string `yaml:"warmup" json:"warmup,omitempty" property:"warmup"` Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 99b6c4b29e..8e7a35290b 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -20,9 +20,7 @@ package configurable import ( "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/method" "dubbo.apache.org/dubbo-go/v3/config/provider" - "dubbo.apache.org/dubbo-go/v3/config/registry" "testing" ) @@ -82,7 +80,7 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &provider.Config{ + providerConfig := &config.ProviderConfig{ BaseConfig: base.Config{ ApplicationConfig: &config.ApplicationConfig{ @@ -95,12 +93,12 @@ func mockInitProviderWithSingleRegistry() { }, }, - Registry: ®istry.Config{ + Registry: &config.RegistryConfig{ Address: "mock://127.0.0.1:2181", Username: "user1", Password: "pwd1", }, - Registries: map[string]*registry.Config{}, + Registries: map[string]*config.RegistryConfig{}, Services: map[string]*config.ServiceConfig{ "MockService": { @@ -111,7 +109,7 @@ func mockInitProviderWithSingleRegistry() { Retries: "3", Group: "huadong_idc", Version: "1.0.0", - Methods: []*method.Config{ + Methods: []*config.MethodConfig{ { Name: "GetUser", Retries: "2", diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 0af1459fb6..c4969b6d50 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -21,7 +21,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" "dubbo.apache.org/dubbo-go/v3/config/instance" - "dubbo.apache.org/dubbo-go/v3/config/method" "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" @@ -38,7 +37,7 @@ import ( ) func doInitProvider() { - providerConfig := provider.Config{ + providerConfig := config.ProviderConfig{ BaseConfig: base.Config{ ApplicationConfig: &config.ApplicationConfig{ Organization: "dubbo_org", @@ -57,7 +56,7 @@ func doInitProvider() { Cluster: "failover", Loadbalance: "random", Retries: "3", - Methods: []*method.Config{ + Methods: []*config.MethodConfig{ { Name: "SayHello", Retries: "2", diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index a314af10b8..78c0988811 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -18,6 +18,7 @@ package jsonrpc import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/consumer" "fmt" "strings" @@ -74,7 +75,7 @@ func TestJsonrpcProtocolRefer(t *testing.T) { "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + "side=provider&timeout=3000×tamp=1556509797245") assert.NoError(t, err) - con := consumer.Config{ + con := config.ConsumerConfig{ ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index 7f16cf4b42..c3bbd8d87b 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -19,6 +19,7 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" @@ -67,7 +68,7 @@ func TestRestInvokerInvoke(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := provider.Config{} + con := config.ProviderConfig{} provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 592b2867cd..b9f945149d 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -19,6 +19,7 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/consumer" "dubbo.apache.org/dubbo-go/v3/config/provider" "errors" @@ -44,7 +45,7 @@ func TestRestProtocolRefer(t *testing.T) { proto := GetRestProtocol() url, err := common.NewURL(mockRestCommonUrl) assert.NoError(t, err) - con := consumer.Config{ + con := config.ConsumerConfig{ ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } @@ -75,7 +76,7 @@ func TestRestProtocolExport(t *testing.T) { assert.NoError(t, err) _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) - con := provider.Config{} + con := config.ProviderConfig{} provider.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 6228aee38a..01cf2b59c7 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -42,7 +42,7 @@ import ( ) func init() { - consumer.SetConsumerConfig(consumer.Config{ + consumer.SetConsumerConfig(config.ConsumerConfig{ BaseConfig: base.Config{ ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }, diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 8282cdc17e..13e47c19f1 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -46,7 +46,7 @@ import ( ) func init() { - provider.SetProviderConfig(provider.Config{BaseConfig: base.Config{ + provider.SetProviderConfig(config.ProviderConfig{BaseConfig: base.Config{ ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }}) } @@ -72,7 +72,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { func TestRefer(t *testing.T) { consumer.SetConsumerConfig( - consumer.Config{BaseConfig: base.Config{ + config.ConsumerConfig{BaseConfig: base.Config{ ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, }}) regProtocol := newRegistryProtocol() diff --git a/remoting/getty/config.go b/remoting/getty/config.go index 0342730b7d..b1478da35b 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -18,7 +18,7 @@ package getty import ( - "dubbo.apache.org/dubbo-go/v3/config/consumer" + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -187,9 +187,9 @@ func (c *ClientConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(HeartbeatPeroid{%#v})", c.HeartbeatPeriod) } - if c.heartbeatPeriod >= time.Duration(consumer.MaxWheelTimeSpan) { + if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", - c.HeartbeatPeriod, time.Duration(consumer.MaxWheelTimeSpan)) + c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) } if len(c.HeartbeatTimeout) == 0 { @@ -215,9 +215,9 @@ func (c *ServerConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(HeartbeatPeroid{%#v})", c.HeartbeatPeriod) } - if c.heartbeatPeriod >= time.Duration(consumer.MaxWheelTimeSpan) { + if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", - c.HeartbeatPeriod, time.Duration(consumer.MaxWheelTimeSpan)) + c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) } if len(c.HeartbeatTimeout) == 0 { @@ -230,9 +230,9 @@ func (c *ServerConfig) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(SessionTimeout{%#v})", c.SessionTimeout) } - if c.sessionTimeout >= time.Duration(consumer.MaxWheelTimeSpan) { + if c.sessionTimeout >= time.Duration(config.MaxWheelTimeSpan) { return perrors.WithMessagef(err, "session_timeout %s should be less than %s", - c.SessionTimeout, time.Duration(consumer.MaxWheelTimeSpan)) + c.SessionTimeout, time.Duration(config.MaxWheelTimeSpan)) } return perrors.WithStack(c.GettySessionParam.CheckValidity()) From 4513152952040d92ce209f6bdeb4fffe70134f6c Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 25 Jul 2021 00:30:02 +0800 Subject: [PATCH 012/148] add registry config --- config/config_loader.go | 32 +----------- config/config_loader_test.go | 50 +++++++++++++++---- config/provider_config.go | 6 +-- config/reference_config.go | 2 +- config/registry_config.go | 28 ++++------- config/root_config.go | 19 +++++++ .../testdata/config/registry/application.yaml | 10 ++++ .../config/registry/empty_application.yaml | 2 + 8 files changed, 86 insertions(+), 63 deletions(-) create mode 100644 config/testdata/config/registry/application.yaml create mode 100644 config/testdata/config/registry/empty_application.yaml diff --git a/config/config_loader.go b/config/config_loader.go index 1fff1de398..39795a326f 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -131,37 +131,7 @@ func getKoanf(conf *config) *koanf.Koanf { return k } -//func GetRegistriesConfig() (map[string]*registry.ConfigCenterConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// if registriesConfig != nil { -// return registriesConfig, nil -// } -// -// registries := rootConfig.Registries -// -// if len(registries) <= 0 { -// reg := new(registry.ConfigCenterConfig) -// if err := reg.SetDefault(); err != nil { -// return nil, err -// } -// registries = make(map[string]*registry.ConfigCenterConfig, 1) -// registries["default"] = reg -// return registries, nil -// } -// for _, reg := range registries { -// if err := reg.SetDefault(); err != nil { -// return nil, err -// } -// reg.TranslateRegistryAddress() -// if err := reg.Validate(rootConfig.Validate); err != nil { -// return nil, err -// } -// } -// registriesConfig = registries -// return registries, nil -//} + // //func GetConfigCenterConfig() (*center.ConfigCenterConfig, error) { // if err := check(); err != nil { diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 37d3be5128..0cf7c0f4b2 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -50,15 +50,15 @@ func TestLoad(t *testing.T) { assert.Equal(t, application.MetadataType, "local") }) - //t.Run("registries", func(t *testing.T) { - // registries, err := GetRegistriesConfig() - // registries, err = GetRegistriesConfig() - // assert.Nil(t, err) - // assert.Equal(t, 2, len(registries)) - // //address= nacos://127.0.0.1:8848 Translate Registry Address - // assert.Equal(t, "nacos", registries["nacos"].Protocol) - // assert.Equal(t, "10s", registries["zk"].Timeout) - //}) + t.Run("registries", func(t *testing.T) { + registries, err := GetRegistriesConfig() + assert.Nil(t, err) + assert.Equal(t, 2, len(registries)) + //address= nacos://127.0.0.1:8848 Translate Registry Address + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "10s", registries["zk"].Timeout) + }) + //config-center t.Run("config-center", func(t *testing.T) { conf, err := GetConfigCenterConfig() @@ -114,6 +114,38 @@ func TestCheckGenre(t *testing.T) { assert.Nil(t, err) } +func TestGetRegistriesConfig(t *testing.T) { + + t.Run("empty registry", func(t *testing.T) { + Load(WithPath("./testdata/config/registry/empty_application.yaml")) + + registries, err := GetRegistriesConfig() + assert.Nil(t, err) + assert.Equal(t, 1, len(registries)) + assert.Equal(t, "zookeeper", registries["default"].Protocol) + assert.Equal(t, "10s", registries["default"].Timeout) + assert.Equal(t, "127.0.0.1:2181", registries["default"].Address) + }) + + t.Run("registry", func(t *testing.T) { + Load(WithPath("./testdata/config/registry/application.yaml")) + + registries, err := GetRegistriesConfig() + assert.Nil(t, err) + assert.Equal(t, 2, len(registries)) + // nacos + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "5s", registries["nacos"].Timeout) + assert.Equal(t, "127.0.0.1:8848", registries["nacos"].Address) + assert.Equal(t, "dev", registries["nacos"].Group) + // zk + assert.Equal(t, "zookeeper", registries["zk"].Protocol) + assert.Equal(t, "10s", registries["zk"].Timeout) + assert.Equal(t, "127.0.0.1:2181", registries["zk"].Address) + assert.Equal(t, "test", registries["zk"].Group) + }) +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/provider_config.go b/config/provider_config.go index a98b543e1f..f2188354ec 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -31,11 +31,11 @@ type ProviderConfig struct { //center.configCenter `yaml:"-"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*config.ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*config.ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *config.ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } diff --git a/config/reference_config.go b/config/reference_config.go index 35e86e10a3..6842696409 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -40,7 +40,7 @@ type ReferenceConfig struct { Version string `yaml:"version" json:"version,omitempty" property:"version"` Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` - Methods []*config.MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` + Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` Async bool `yaml:"async" json:"async,omitempty" property:"async"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` invoker protocol.Invoker diff --git a/config/registry_config.go b/config/registry_config.go index 744f75477c..5113d67998 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -18,8 +18,6 @@ package config import ( - "errors" - "github.com/go-playground/validator/v10" "net/url" "strconv" "strings" @@ -38,11 +36,11 @@ import ( // RegistryConfig is the configuration of the registry center type RegistryConfig struct { Protocol string `default:"zookeeper" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second + Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry - Address string `default:"127.0.0.1:2181" yaml:"address" json:"address,omitempty" property:"address"` + Address string `default:"zookeeper://127.0.0.1:2181" validate:"required" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` Password string `yaml:"password" json:"password,omitempty" property:"password"` Simplified bool `yaml:"simplified" json:"simplified,omitempty" property:"simplified"` @@ -56,22 +54,14 @@ type RegistryConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -// SetDefault set default value -func (c *RegistryConfig) SetDefault() error { - return defaults.Set(c) -} - -// Validate valida value -func (c *RegistryConfig) Validate(valid *validator.Validate) error { - if err := valid.Struct(c); err != nil { - errs := err.(validator.ValidationErrors) - var slice []string - for _, msg := range errs { - slice = append(slice, msg.Error()) - } - return errors.New(strings.Join(slice, ",")) +func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*RegistryConfig { + if registries == nil || len(registries) <= 0 { + registries = make(map[string]*RegistryConfig, 1) + reg := new(RegistryConfig) + registries["default"] = reg + return registries } - return nil + return registries } // UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function diff --git a/config/root_config.go b/config/root_config.go index 04c31e0c6f..5fb4bb9f47 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -96,3 +96,22 @@ func GetConfigCenterConfig() (*CenterConfig, error) { } return centerConfig, nil } + +// GetRegistriesConfig get registry config default zookeeper registry +func GetRegistriesConfig() (map[string]*RegistryConfig, error) { + if err := check(); err != nil { + return nil, err + } + + registries := getRegistriesConfig(rootConfig.Registries) + for _, reg := range registries { + if err := defaults.Set(reg); err != nil { + return nil, err + } + reg.TranslateRegistryAddress() + if err := verification(reg); err != nil { + return nil, err + } + } + return registries, nil +} diff --git a/config/testdata/config/registry/application.yaml b/config/testdata/config/registry/application.yaml new file mode 100644 index 0000000000..844353835a --- /dev/null +++ b/config/testdata/config/registry/application.yaml @@ -0,0 +1,10 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 \ No newline at end of file diff --git a/config/testdata/config/registry/empty_application.yaml b/config/testdata/config/registry/empty_application.yaml new file mode 100644 index 0000000000..9e7a20af2a --- /dev/null +++ b/config/testdata/config/registry/empty_application.yaml @@ -0,0 +1,2 @@ +dubbo: + registries: \ No newline at end of file From 590b3382801d8b2941ac683103e39b1389c22fb1 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 25 Jul 2021 01:04:10 +0800 Subject: [PATCH 013/148] add protocol --- config/config_loader_test.go | 27 +++++++++++++++++++ config/protocol_config.go | 20 +++++--------- config/provider_config.go | 18 ++++++------- config/root_config.go | 18 +++++++++++++ config/service_config.go | 6 ++--- .../testdata/config/protocol/application.yaml | 6 +++++ .../config/protocol/empty_application.yaml | 2 ++ 7 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 config/testdata/config/protocol/application.yaml create mode 100644 config/testdata/config/protocol/empty_application.yaml diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 0cf7c0f4b2..fc403459cf 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -146,6 +146,33 @@ func TestGetRegistriesConfig(t *testing.T) { }) } +func TestGetProtocolsConfig(t *testing.T) { + + t.Run("empty protocols", func(t *testing.T) { + Load(WithPath("./testdata/config/protocol/empty_application.yaml")) + + protocols, err := GetProtocolsConfig() + assert.Nil(t, err) + assert.NotNil(t, protocols) + // default + assert.Equal(t, "dubbo", protocols["default"].Name) + assert.Equal(t, "127.0.0.1", protocols["default"].Ip) + assert.Equal(t, 0, protocols["default"].Port) + }) + + t.Run("protocols", func(t *testing.T) { + Load(WithPath("./testdata/config/protocol/application.yaml")) + + protocols, err := GetProtocolsConfig() + assert.Nil(t, err) + assert.NotNil(t, protocols) + // default + assert.Equal(t, "dubbo", protocols["dubbo"].Name) + assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) + assert.Equal(t, 20000, protocols["dubbo"].Port) + }) +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/protocol_config.go b/config/protocol_config.go index 6bcff4d49c..f2abba1af5 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -18,8 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "github.com/creasty/defaults" "strings" ) @@ -31,7 +29,7 @@ import ( type ProtocolConfig struct { Name string `default:"dubbo" yaml:"name" json:"name,omitempty" property:"name"` Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `default:"20000" yaml:"port" json:"port,omitempty" property:"port"` + Port int `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } // Prefix dubbo.protocols @@ -39,17 +37,11 @@ func (ProtocolConfig) Prefix() string { return constant.ProtocolConfigPrefix } -// GetProtocolsConfig get protocols config -func GetProtocolsConfig() map[string]*ProtocolConfig { - protocols := make(map[string]*ProtocolConfig) - conf := new(ProtocolConfig) - if value := viper.Get(conf.Prefix()); value != nil { - //conf = value.(map[string]*ProtocolConfig) - logger.Error("abc") - } else { - if err := defaults.Set(conf); err != nil { - panic(err) - } +// getProtocolsConfig get protocols config default protocol +func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*ProtocolConfig { + if protocols == nil || len(protocols) <= 0 { + conf := new(ProtocolConfig) + protocols = make(map[string]*ProtocolConfig, 1) protocols["default"] = conf } return protocols diff --git a/config/provider_config.go b/config/provider_config.go index f2188354ec..049286d307 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -29,14 +29,14 @@ import ( type ProviderConfig struct { //base.ShutdownConfig `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + ProxyFactory string `yaml:"proxy-factory" default:"default" json:"proxy-factory,omitempty" property:"proxy-factory"` + Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function @@ -48,7 +48,7 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// nolint +// Prefix dubbo.provider func (*ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } diff --git a/config/root_config.go b/config/root_config.go index 5fb4bb9f47..e8d3e0ee86 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -115,3 +115,21 @@ func GetRegistriesConfig() (map[string]*RegistryConfig, error) { } return registries, nil } + +// GetProtocolsConfig get protocols config default dubbo protocol +func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { + if err := check(); err != nil { + return nil, err + } + + protocols := getProtocolsConfig(rootConfig.Protocols) + for _, protocol := range protocols { + if err := defaults.Set(protocol); err != nil { + return nil, err + } + if err := verification(protocol); err != nil { + return nil, err + } + } + return protocols, nil +} diff --git a/config/service_config.go b/config/service_config.go index d21764abb2..685fba4d35 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -128,9 +128,9 @@ func (c *ServiceConfig) IsExport() bool { func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { ports := list.New() for _, proto := range protocolConfigs { - if len(proto.Port) > 0 { - continue - } + //if len(proto.Port) > 0 { + // continue + //} tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) if err != nil { diff --git a/config/testdata/config/protocol/application.yaml b/config/testdata/config/protocol/application.yaml new file mode 100644 index 0000000000..0288dac8c4 --- /dev/null +++ b/config/testdata/config/protocol/application.yaml @@ -0,0 +1,6 @@ +dubbo: + protocols: + dubbo: + name: dubbo + ip: 127.0.0.1 + port: 20000 \ No newline at end of file diff --git a/config/testdata/config/protocol/empty_application.yaml b/config/testdata/config/protocol/empty_application.yaml new file mode 100644 index 0000000000..bc0aecba71 --- /dev/null +++ b/config/testdata/config/protocol/empty_application.yaml @@ -0,0 +1,2 @@ +dubbo: + protocols: \ No newline at end of file From ffc64cdf7b4bbf82cb2d30381c51760c21de5bc8 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 25 Jul 2021 04:25:49 +0800 Subject: [PATCH 014/148] add provider config --- common/constant/key.go | 1 + common/rpc_service.go | 5 +- config/config_loader_test.go | 30 ++++++- config/protocol_config.go | 6 +- config/provider_config.go | 41 ++++++--- config/registry_config.go | 8 +- config/registry_config_test.go | 2 +- config/root_config.go | 85 +++++++++++++++++-- config/{instance => }/service.go | 7 +- config/service_config.go | 66 ++++++++++---- config/testdata/application.yaml | 3 +- .../testdata/config/provider/application.yaml | 12 +++ .../provider/empty_registry_application.yaml | 3 + .../config/provider/registry_application.yaml | 10 +++ .../testdata/config/service/hello_service.go | 18 ++++ .../testdata/config/service/order_service.go | 18 ++++ protocol/dubbo3/common_test.go | 4 +- protocol/dubbo3/dubbo3_invoker.go | 3 +- protocol/dubbo3/dubbo3_protocol.go | 4 +- protocol/dubbo3/internal/client.go | 4 +- protocol/dubbo3/internal/server.go | 3 +- protocol/grpc/client.go | 3 +- protocol/grpc/grpc_protocol_test.go | 3 +- protocol/grpc/internal/helloworld/client.go | 4 +- protocol/grpc/internal/routeguide/client.go | 4 +- protocol/grpc/server.go | 3 +- registry/protocol/protocol.go | 3 +- test/integrate/dubbo/go-client/user.go | 4 +- test/integrate/dubbo/go-server/user.go | 4 +- 29 files changed, 285 insertions(+), 76 deletions(-) rename config/{instance => }/service.go (93%) create mode 100644 config/testdata/config/provider/application.yaml create mode 100644 config/testdata/config/provider/empty_registry_application.yaml create mode 100644 config/testdata/config/provider/registry_application.yaml create mode 100644 config/testdata/config/service/hello_service.go create mode 100644 config/testdata/config/service/order_service.go diff --git a/common/constant/key.go b/common/constant/key.go index 9db943318c..b1ec48ec73 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -53,6 +53,7 @@ const ( SSL_ENABLED_KEY = "ssl-enabled" // PARAMS_TYPE_Key key used in pass through invoker factory, to define param type PARAMS_TYPE_Key = "parameter-type-names" + DEFAULT_Key = "default" ) const ( diff --git a/common/rpc_service.go b/common/rpc_service.go index 57c8f1c4ea..9970f61011 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -37,8 +37,9 @@ import ( // RPCService // rpc service interface type RPCService interface { - // Reference: - // rpc service id or reference id + // Name rpc service id + Name() string + // Reference rpc service reference Reference() string } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index fc403459cf..4563646c4c 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,11 +18,18 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" "testing" ) -import ( - "github.com/stretchr/testify/assert" -) + +import "github.com/stretchr/testify/assert" + +import "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" + +func init() { + SetProviderService(new(service.OrderService)) + SetProviderService(new(service.HelloService)) +} const ( configPath = "./testdata/application.yaml" @@ -173,6 +180,23 @@ func TestGetProtocolsConfig(t *testing.T) { }) } +func TestGetProviderConfig(t *testing.T) { + // empty registry + t.Run("empty registry", func(t *testing.T) { + Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) + provider, err := GetProviderConfig() + assert.Nil(t, err) + assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) + }) + + t.Run("root registry", func(t *testing.T) { + Load(WithPath("./testdata/config/provider/registry_application.yaml")) + provider, err := GetProviderConfig() + assert.Nil(t, err) + assert.NotNil(t, provider) + }) +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/protocol_config.go b/config/protocol_config.go index f2abba1af5..cd3747564e 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -27,9 +27,9 @@ import ( // ProtocolConfig is protocol configuration type ProtocolConfig struct { - Name string `default:"dubbo" yaml:"name" json:"name,omitempty" property:"name"` + Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port int `default:"0" yaml:"port" json:"port,omitempty" property:"port"` + Port int `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } // Prefix dubbo.protocols @@ -42,7 +42,7 @@ func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*Protoc if protocols == nil || len(protocols) <= 0 { conf := new(ProtocolConfig) protocols = make(map[string]*ProtocolConfig, 1) - protocols["default"] = conf + protocols[constant.DEFAULT_Key] = conf } return protocols } diff --git a/config/provider_config.go b/config/provider_config.go index 049286d307..557bf7bb42 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -29,23 +29,28 @@ import ( type ProviderConfig struct { //base.ShutdownConfig `yaml:",inline" property:"base"` //center.configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy-factory" default:"default" json:"proxy-factory,omitempty" property:"proxy-factory"` - Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + // Register whether registration is required + Register bool `yaml:"register" json:"register" property:"register"` + // Registry registry ids + Registry []string `validate:"required" yaml:"registry" json:"registry" property:"registry"` + // Services services + Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + //ProxyFactory string `yaml:"proxy-factory" default:"default" json:"proxy-factory,omitempty" property:"proxy-factory"` + //Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + //ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + //FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + //ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { +func (pc *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(pc); err != nil { return err } type plain ProviderConfig - return unmarshal((*plain)(c)) + return unmarshal((*plain)(pc)) } // Prefix dubbo.provider @@ -53,6 +58,20 @@ func (*ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } +// getProviderConfig get provider config +func getProviderConfig(provider *ProviderConfig) *ProviderConfig { + if provider == nil { + provider = new(ProviderConfig) + } + provider.Register = len(proServices) > 0 + + if provider.Registry == nil || len(provider.Registry) <= 0 { + provider.Registry = getRegistryIds() + } + provider.Registry = translateRegistryIds(provider.Registry) + return provider +} + //// SetProviderConfig sets provider config by @p //func SetProviderConfig(p ProviderConfig) { // config.providerConfig = &p diff --git a/config/registry_config.go b/config/registry_config.go index 5113d67998..264eb6735b 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -58,7 +58,7 @@ func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*Regi if registries == nil || len(registries) <= 0 { registries = make(map[string]*RegistryConfig, 1) reg := new(RegistryConfig) - registries["default"] = reg + registries[constant.DEFAULT_Key] = reg return registries } return registries @@ -105,7 +105,7 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf if target { addresses := strings.Split(registryConf.Address, ",") address := addresses[0] - address = registryConf.TranslateRegistryAddress() + address = registryConf.translateRegistryAddress() url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, common.WithParams(registryConf.getUrlMap(roleType)), common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), @@ -144,9 +144,9 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { return urlMap } -//TranslateRegistryAddress translate registry address +//translateRegistryAddress translate registry address // eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos -func (c *RegistryConfig) TranslateRegistryAddress() string { +func (c *RegistryConfig) translateRegistryAddress() string { if strings.Contains(c.Address, "://") { translatedUrl, err := url.Parse(c.Address) if err != nil { diff --git a/config/registry_config_test.go b/config/registry_config_test.go index 2af172c3a5..4123584f49 100644 --- a/config/registry_config_test.go +++ b/config/registry_config_test.go @@ -68,7 +68,7 @@ func TestTranslateRegistryAddress(t *testing.T) { reg := new(RegistryConfig) reg.Address = "nacos://127.0.0.1:8848" - address := reg.TranslateRegistryAddress() + address := reg.translateRegistryAddress() assert.Equal(t, "nacos", reg.Protocol) assert.Equal(t, "127.0.0.1:8848", address) diff --git a/config/root_config.go b/config/root_config.go index e8d3e0ee86..3ab12df5da 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -2,16 +2,26 @@ package config import ( "bytes" + "strings" +) + +import ( "github.com/creasty/defaults" "github.com/go-playground/validator/v10" "github.com/pkg/errors" - "strings" ) import ( + "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" ) +var ( + consumerConfig *ConsumerConfig + + providerConfig *ProviderConfig +) + // RootConfig is the root config type RootConfig struct { ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` @@ -31,14 +41,15 @@ type RootConfig struct { Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols" property:"protocols"` + // provider config + Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` + // prefix string fatherConfig interface{} EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` fileStream *bytes.Buffer - // validate - //Validate *validator.Validate // cache file used to store the current used configurations. CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` } @@ -48,7 +59,7 @@ func (RootConfig) Prefix() string { return constant.DUBBO } -func verification(s interface{}) error { +func verify(s interface{}) error { if err := validate.Struct(s); err != nil { errs := err.(validator.ValidationErrors) @@ -61,6 +72,27 @@ func verification(s interface{}) error { return nil } +func removeDuplicateElement(items []string) []string { + result := make([]string, 0, len(items)) + temp := map[string]struct{}{} + for _, item := range items { + if _, ok := temp[item]; !ok && item != "" { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +} + +// translateRegistryIds string "nacos,zk" => ["nacos","zk"] +func translateRegistryIds(registryIds []string) []string { + ids := make([]string, 0) + for _, id := range registryIds { + ids = append(ids, strings.Split(id, ",")...) + } + return removeDuplicateElement(ids) +} + // GetApplicationConfig get application config func GetApplicationConfig() (*ApplicationConfig, error) { if err := check(); err != nil { @@ -71,7 +103,7 @@ func GetApplicationConfig() (*ApplicationConfig, error) { return nil, err } - if err := verification(application); err != nil { + if err := verify(application); err != nil { return nil, err } rootConfig.Application = application @@ -91,7 +123,7 @@ func GetConfigCenterConfig() (*CenterConfig, error) { return nil, err } centerConfig.translateConfigAddress() - if err := verification(centerConfig); err != nil { + if err := verify(centerConfig); err != nil { return nil, err } return centerConfig, nil @@ -108,8 +140,8 @@ func GetRegistriesConfig() (map[string]*RegistryConfig, error) { if err := defaults.Set(reg); err != nil { return nil, err } - reg.TranslateRegistryAddress() - if err := verification(reg); err != nil { + reg.translateRegistryAddress() + if err := verify(reg); err != nil { return nil, err } } @@ -127,9 +159,44 @@ func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { if err := defaults.Set(protocol); err != nil { return nil, err } - if err := verification(protocol); err != nil { + if err := verify(protocol); err != nil { return nil, err } } return protocols, nil } + +// GetProviderConfig get provider config +func GetProviderConfig() (*ProviderConfig, error) { + if err := check(); err != nil { + return nil, err + } + + if providerConfig != nil { + return providerConfig, nil + } + provider := getProviderConfig(rootConfig.Provider) + if err := defaults.Set(provider); err != nil { + return nil, err + } + if err := verify(provider); err != nil { + return nil, err + } + + provider.Services = getRegistryServices(common.PROVIDER, provider.Services, provider.Registry) + providerConfig = provider + return provider, nil +} + +// getRegistryIds get registry keys +func getRegistryIds() []string { + ids := make([]string, 0) + registries, err := GetRegistriesConfig() + if err != nil { + ids = append(ids, constant.DEFAULT_Key) + } + for key := range registries { + ids = append(ids, key) + } + return removeDuplicateElement(ids) +} diff --git a/config/instance/service.go b/config/service.go similarity index 93% rename from config/instance/service.go rename to config/service.go index 1c8737548f..3aa524d4ee 100644 --- a/config/instance/service.go +++ b/config/service.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package instance +package config import ( "dubbo.apache.org/dubbo-go/v3/common" @@ -51,6 +51,11 @@ func GetAllProviderService() map[string]common.RPCService { return proServices } +// GetAllConsumerService gets all ConsumerService +func GetAllConsumerService() map[string]common.RPCService { + return conServices +} + // GetCallback gets CallbackResponse by @name func GetCallback(name string) func(response common.CallbackResponse) { service := GetConsumerService(name) diff --git a/config/service_config.go b/config/service_config.go index 685fba4d35..0a1e86361f 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -46,9 +46,9 @@ import ( type ServiceConfig struct { id string Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' - InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Protocol []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + Interface string `validate:"required" yaml:"interface" json:"interface,omitempty" property:"interface"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Group string `yaml:"group" json:"group,omitempty" property:"group"` @@ -64,13 +64,13 @@ type ServiceConfig struct { TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"` TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"` TpsLimitStrategy string `yaml:"tps.limit.strategy" json:"tps.limit.strategy,omitempty" property:"tps.limit.strategy"` - TpsLimitRejectedHandler string `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"` - ExecuteLimit string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"` - ExecuteLimitRejectedHandler string `yaml:"execute.limit.rejected.handler" json:"execute.limit.rejected.handler,omitempty" property:"execute.limit.rejected.handler"` - Auth string `yaml:"auth" json:"auth,omitempty" property:"auth"` - ParamSign string `yaml:"param.sign" json:"param.sign,omitempty" property:"param.sign"` - Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` - GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` + TpsLimitRejectedHandler string `yaml:"tps.limit.rejected.handler" json:"tps.limit.rejected.handler,omitempty" property:"tps.limit.rejected.handler"` + ExecuteLimit string `yaml:"execute.limit" json:"execute.limit,omitempty" property:"execute.limit"` + ExecuteLimitRejectedHandler string `yaml:"execute.limit.rejected.handler" json:"execute.limit.rejected.handler,omitempty" property:"execute.limit.rejected.handler"` + Auth string `yaml:"auth" json:"auth,omitempty" property:"auth"` + ParamSign string `yaml:"param.sign" json:"param.sign,omitempty" property:"param.sign"` + Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` + GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` Protocols map[string]*ProtocolConfig unexported *atomic.Bool @@ -84,9 +84,9 @@ type ServiceConfig struct { exporters []protocol.Exporter } -// Prefix returns dubbo.service.${interface}. +// Prefix returns dubbo.service.${InterfaceName}. func (c *ServiceConfig) Prefix() string { - return constant.ServiceConfigPrefix + c.InterfaceName + "." + return constant.ServiceConfigPrefix + c.id } // UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function @@ -114,6 +114,42 @@ func NewServiceConfig(id string) *ServiceConfig { } } +//getRegistryServices get registry services +func getRegistryServices(side int, services map[string]*ServiceConfig, registryIds []string) map[string]*ServiceConfig { + var ( + svc *ServiceConfig + exist bool + initService map[string]common.RPCService + registryServices map[string]*ServiceConfig + ) + if side == common.PROVIDER { + initService = proServices + } else if side == common.CONSUMER { + initService = conServices + } + registryServices = make(map[string]*ServiceConfig, len(initService)) + for key := range initService { + //存在配置了使用用户的配置 + if svc, exist = services[key]; !exist { + svc = new(ServiceConfig) + } + defaults.MustSet(svc) + if len(svc.Registry) <= 0 { + svc.Registry = registryIds + } + svc.id = key + svc.export = true + svc.unexported = atomic.NewBool(false) + svc.exported = atomic.NewBool(false) + svc.Registry = translateRegistryIds(svc.Registry) + if err := verify(svc); err != nil { + return nil + } + registryServices[key] = svc + } + return registryServices +} + // InitExported will set exported as false atom bool func (c *ServiceConfig) InitExported() { c.exported = atomic.NewBool(false) @@ -148,12 +184,12 @@ func (c *ServiceConfig) Export() error { // TODO: delay export if c.unexported != nil && c.unexported.Load() { - err := perrors.Errorf("The service %v has already unexported!", c.InterfaceName) + err := perrors.Errorf("The service %v has already unexported!", c.Interface) logger.Errorf(err.Error()) return err } if c.unexported != nil && c.exported.Load() { - logger.Warnf("The service %v has already exported!", c.InterfaceName) + logger.Warnf("The service %v has already exported!", c.Interface) return nil } @@ -276,7 +312,7 @@ func (c *ServiceConfig) getUrlMap() url.Values { for k, v := range c.Params { urlMap.Set(k, v) } - urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) + urlMap.Set(constant.INTERFACE_KEY, c.Interface) urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) urlMap.Set(constant.CLUSTER_KEY, c.Cluster) urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index ad5e69d098..154b7aa724 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -31,4 +31,5 @@ dubbo: interface: org.dubbo.service.OrderService registry: nacos provider: - filter: \ No newline at end of file + register: true + services: \ No newline at end of file diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml new file mode 100644 index 0000000000..5e6696c04a --- /dev/null +++ b/config/testdata/config/provider/application.yaml @@ -0,0 +1,12 @@ +dubbo: + provider: + register: true + registry: + - nacos + - zk + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/provider/empty_registry_application.yaml b/config/testdata/config/provider/empty_registry_application.yaml new file mode 100644 index 0000000000..2eede2a44e --- /dev/null +++ b/config/testdata/config/provider/empty_registry_application.yaml @@ -0,0 +1,3 @@ +dubbo: + provider: + register: true \ No newline at end of file diff --git a/config/testdata/config/provider/registry_application.yaml b/config/testdata/config/provider/registry_application.yaml new file mode 100644 index 0000000000..f5b04deb25 --- /dev/null +++ b/config/testdata/config/provider/registry_application.yaml @@ -0,0 +1,10 @@ +dubbo: + provider: + register: true + registry: nacos,zk + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go new file mode 100644 index 0000000000..ff0726c998 --- /dev/null +++ b/config/testdata/config/service/hello_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "context" +) + +type HelloService struct { + // say hello + Say func(ctx context.Context, req []interface{}) error +} + +func (HelloService) Name() string { + return "helloService" +} + +func (HelloService) Reference() string { + return "org.github.dubbo.HelloService" +} diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go new file mode 100644 index 0000000000..07a256b0e0 --- /dev/null +++ b/config/testdata/config/service/order_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "context" +) + +type OrderService struct { + // GetOrders + GetOrders func(ctx context.Context, req []interface{}) error +} + +func (OrderService) Name() string { + return "orderService" +} + +func (OrderService) Reference() string { + return "org.github.dubbo.OrderService" +} diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go index 5d1e83022c..27150db7f1 100644 --- a/protocol/dubbo3/common_test.go +++ b/protocol/dubbo3/common_test.go @@ -19,7 +19,7 @@ package dubbo3 import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" ) @@ -35,7 +35,7 @@ import ( // userd dubbo3 biz service func addService() { - instance.SetProviderService(newGreeterProvider()) + config.SetProviderService(newGreeterProvider()) } type greeterProvider struct { diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 5061dc2f7b..5c152c774f 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -19,7 +19,6 @@ package dubbo3 import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" "reflect" "strconv" "strings" @@ -64,7 +63,7 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { } key := url.GetParam(constant.BEAN_NAME_KEY, "") - consumerService := instance.GetConsumerService(key) + consumerService := config.GetConsumerService(key) dubboSerializaerType := url.GetParam(constant.SERIALIZATION_KEY, constant.PROTOBUF_SERIALIZATION) triCodecType := tripleConstant.CodecType(dubboSerializaerType) diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index b0aabbfc91..df90c3b656 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -18,7 +18,7 @@ package dubbo3 import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "reflect" "sync" @@ -78,7 +78,7 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { key := url.GetParam(constant.BEAN_NAME_KEY, "") var service interface{} - service = instance.GetProviderService(key) + service = config.GetProviderService(key) serializationType := url.GetParam(constant.SERIALIZATION_KEY, constant.PROTOBUF_SERIALIZATION) var triSerializationType tripleConstant.CodecType diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index df6eaf7cf5..d85662c492 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -19,7 +19,7 @@ package internal import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" ) import ( @@ -27,7 +27,7 @@ import ( ) func init() { - instance.SetConsumerService(&GrpcGreeterImpl{}) + config.SetConsumerService(&GrpcGreeterImpl{}) } // GrpcGreeterImpl diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index e508f51eff..d23d62cfd9 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -19,7 +19,6 @@ package internal import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/config/provider" "log" ) @@ -60,7 +59,7 @@ func InitDubboServer() { ) provider.SetProviderConfig(*providerConfig) // set to providerConfig ptr - instance.SetProviderService(&Server{ + config.SetProviderService(&Server{ GreeterProviderBase: &GreeterProviderBase{}, }) config.Load() diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 74b6f1b192..66208c828a 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -18,7 +18,6 @@ package grpc import ( - "dubbo.apache.org/dubbo-go/v3/config/instance" "reflect" "strconv" ) @@ -118,7 +117,7 @@ func NewClient(url *common.URL) (*Client, error) { } key := url.GetParam(constant.BEAN_NAME_KEY, "") - impl := instance.GetConsumerService(key) + impl := config.GetConsumerService(key) invoker := getInvoker(impl, conn) return &Client{ diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index c4969b6d50..8ac4c8c0fe 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -20,7 +20,6 @@ package grpc import ( "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" @@ -72,7 +71,7 @@ func doInitProvider() { func TestGrpcProtocolExport(t *testing.T) { // Export - instance.SetProviderService(helloworld.NewService()) + config.SetProviderService(helloworld.NewService()) doInitProvider() url, err := common.NewURL(helloworldURL) diff --git a/protocol/grpc/internal/helloworld/client.go b/protocol/grpc/internal/helloworld/client.go index d59a2b5b5b..3c6fc9cea2 100644 --- a/protocol/grpc/internal/helloworld/client.go +++ b/protocol/grpc/internal/helloworld/client.go @@ -19,7 +19,7 @@ package helloworld import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" ) import ( @@ -27,7 +27,7 @@ import ( ) func init() { - instance.SetConsumerService(&GrpcGreeterImpl{}) + config.SetConsumerService(&GrpcGreeterImpl{}) } // GrpcGreeterImpl diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 98bf61a2be..9920115496 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -18,7 +18,7 @@ package routeguide import ( - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" "io" "log" "math/rand" @@ -26,7 +26,7 @@ import ( ) func init() { - instance.SetConsumerService(&RouteGuideClientImpl{}) + config.SetConsumerService(&RouteGuideClientImpl{}) } // printFeatures lists all the features within the given bounding Rectangle. diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index 5257272234..e068999447 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -18,7 +18,6 @@ package grpc import ( - "dubbo.apache.org/dubbo-go/v3/config/instance" "fmt" "net" "sync" @@ -139,7 +138,7 @@ func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) { // registerService SetProxyImpl invoker and grpc service func registerService(providerServices map[string]*config.ServiceConfig, server *grpc.Server) { for key, providerService := range providerServices { - service := instance.GetProviderService(key) + service := config.GetProviderService(key) ds, ok := service.(DubboGrpcService) if !ok { panic("illegal service type registered") diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index c0fd2513dc..25204e6bb7 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -19,7 +19,6 @@ package protocol import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" "strings" "sync" ) @@ -249,7 +248,7 @@ func registerServiceMap(invoker protocol.Invoker) error { s := "reExport can not get serviceConfig" return perrors.New(s) } - rpcService := instance.GetProviderService(id) + rpcService := config.GetProviderService(id) if rpcService == nil { s := "reExport can not get RPCService" return perrors.New(s) diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go index 7565ce18d2..75903f4370 100644 --- a/test/integrate/dubbo/go-client/user.go +++ b/test/integrate/dubbo/go-client/user.go @@ -19,7 +19,7 @@ package main import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -30,7 +30,7 @@ import ( var userProvider = new(UserProvider) func init() { - instance.SetConsumerService(userProvider) + config.SetConsumerService(userProvider) hessian.RegisterPOJO(&User{}) } diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go index e0b749675a..a87cae9758 100644 --- a/test/integrate/dubbo/go-server/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -19,7 +19,7 @@ package main import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/instance" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) @@ -29,7 +29,7 @@ import ( ) func init() { - instance.SetProviderService(new(UserProvider)) + config.SetProviderService(new(UserProvider)) // ------for hessian2------ hessian.RegisterPOJO(&User{}) } From 737ec30c27d3233b8917a309bcf1bdd7e6b2ffc6 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 25 Jul 2021 22:52:48 +0800 Subject: [PATCH 015/148] add comments --- config/root_config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/root_config.go b/config/root_config.go index 3ab12df5da..8bd584b86b 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -72,6 +72,7 @@ func verify(s interface{}) error { return nil } +// removeDuplicateElement remove duplicate element func removeDuplicateElement(items []string) []string { result := make([]string, 0, len(items)) temp := map[string]struct{}{} From 80c72a0c4cae5621331cb27963636196edc61a73 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Mon, 26 Jul 2021 14:27:23 +0800 Subject: [PATCH 016/148] up:service config --- config/application_config.go | 8 +- config/config_api.go | 30 +-- config/config_loader.go | 27 +-- config/config_loader_test.go | 45 +++-- config/consumer_config.go | 4 +- config/graceful_shutdown.go | 10 +- config/graceful_shutdown_config.go | 4 +- config/{ => options}/config_loader_options.go | 2 +- config/protocol_config.go | 13 +- config/provider_config.go | 5 +- config/reference_config.go | 2 +- config/reference_config_test.go | 8 +- config/registry_config.go | 16 +- config/root_config.go | 35 ++-- config/service_config.go | 191 +++++++++--------- .../testdata/config/provider/application.yaml | 4 +- 16 files changed, 208 insertions(+), 196 deletions(-) rename config/{ => options}/config_loader_options.go (99%) diff --git a/config/application_config.go b/config/application_config.go index 2124a2b117..4321d088ee 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -26,7 +26,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer +// ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer type ApplicationConfig struct { Organization string `default:"dubbo.io" yaml:"organization" json:"organization,omitempty" property:"organization"` Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"` @@ -38,12 +38,12 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` } -// Prefix dubbo.application +// Prefix dubbo.applicationConfig func (ApplicationConfig) Prefix() string { - return constant.DUBBO + ".application" + return constant.DUBBO + ".applicationConfig" } -// getApplicationConfig get application config +// getApplicationConfig get applicationConfig config func getApplicationConfig(application *ApplicationConfig) *ApplicationConfig { if application != nil { return application diff --git a/config/config_api.go b/config/config_api.go index b251269fc2..2ba0cafa46 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -18,7 +18,7 @@ package config // //import ( -// "dubbo.apache.org/dubbo-go/v3/config/application" +// "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" // "dubbo.apache.org/dubbo-go/v3/config/center" // "dubbo.apache.org/dubbo-go/v3/config/consumer" // "dubbo.apache.org/dubbo-go/v3/config/method" @@ -197,7 +197,7 @@ package config //} // //// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig -//func WithConsumerAppConfig(appConfig *application.ShutdownConfig) ConsumerConfigOpt { +//func WithConsumerAppConfig(appConfig *applicationConfig.ShutdownConfig) ConsumerConfigOpt { // return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { // config.ApplicationConfig = appConfig // return config @@ -325,7 +325,7 @@ package config //func NewDefaultProviderConfig() *provider.ProviderConfig { // newConsumerConfig := &provider.ProviderConfig{ // BaseConfig: base.ShutdownConfig{ -// application.ShutdownConfig: &application.ShutdownConfig{ +// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ // Name: "dubbo", // Module: "module", // Organization: "dubbo_org", @@ -357,7 +357,7 @@ package config //} // //// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig -//func WithProviderAppConfig(appConfig *application.ShutdownConfig) ProviderConfigOpt { +//func WithProviderAppConfig(appConfig *applicationConfig.ShutdownConfig) ProviderConfigOpt { // return func(config *provider.ProviderConfig) *provider.ProviderConfig { // config.ApplicationConfig = appConfig // return config @@ -475,7 +475,7 @@ package config // /////////////////////////////////////////// Application config api //// ApplicationConfigOpt is option to init ShutdownConfig -//type ApplicationConfigOpt func(config *application.ShutdownConfig) *application.ShutdownConfig +//type ApplicationConfigOpt func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig // //// NewDefaultApplicationConfig returns ShutdownConfig with default //// name: dubbo.io @@ -484,8 +484,8 @@ package config //// owner: dubbogo //// version: 0.0.1 //// environment dev -//func NewDefaultApplicationConfig() *application.ShutdownConfig { -// newAppConfig := &application.ShutdownConfig{ +//func NewDefaultApplicationConfig() *applicationConfig.ShutdownConfig { +// newAppConfig := &applicationConfig.ShutdownConfig{ // Name: "dubbo.io", // Module: "sample", // Organization: "dubbo.io", @@ -497,8 +497,8 @@ package config //} // //// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared -//// NewApplicationConfig returns ShutdownConfig with default application config -//func NewApplicationConfig(opts ...ApplicationConfigOpt) *application.ShutdownConfig { +//// NewApplicationConfig returns ShutdownConfig with default applicationConfig config +//func NewApplicationConfig(opts ...ApplicationConfigOpt) *applicationConfig.ShutdownConfig { // defaultServiceConfig := NewDefaultApplicationConfig() // for _, v := range opts { // v(defaultServiceConfig) @@ -508,7 +508,7 @@ package config // //// WithAppName returns ApplicationConfigOpt with given @name //func WithAppName(name string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Name = name // return config // } @@ -516,7 +516,7 @@ package config // //// WithAppModule returns ApplicationConfigOpt with given @module //func WithAppModule(module string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Module = module // return config // } @@ -524,7 +524,7 @@ package config // //// WithAppOrganization returns ApplicationConfigOpt wight given organization @org //func WithAppOrganization(org string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Organization = org // return config // } @@ -532,7 +532,7 @@ package config // //// WithAppOwner returns ApplicationConfigOpt with given @owner //func WithAppOwner(owner string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Owner = owner // return config // } @@ -540,7 +540,7 @@ package config // //// WithAppVersion returns ApplicationConfigOpt with given version @version //func WithAppVersion(version string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Version = version // return config // } @@ -548,7 +548,7 @@ package config // //// WithAppEnvironment returns ApplicationConfigOpt with given environment @env //func WithAppEnvironment(env string) ApplicationConfigOpt { -// return func(config *application.ShutdownConfig) *application.ShutdownConfig { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { // config.Environment = env // return config // } diff --git a/config/config_loader.go b/config/config_loader.go index 39795a326f..652a1c97a2 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,6 +18,7 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/config/options" "errors" "fmt" ) @@ -61,12 +62,12 @@ func init() { validate = validator.New() } -func Load(opts ...Option) { +func Load(opts ...options.Option) { // pares CommandLine //parseCommandLine() // conf - conf := &config{ - name: "application.yaml", + conf := &options.config{ + name: "applicationConfig.yaml", genre: "yaml", path: "./conf", delim: ".", @@ -106,7 +107,7 @@ func check() error { // } //} -func getKoanf(conf *config) *koanf.Koanf { +func getKoanf(conf *options.config) *koanf.Koanf { var ( k *koanf.Koanf err error @@ -218,15 +219,15 @@ func getKoanf(conf *config) *koanf.Koanf { // } //} // -//func checkRegistries(registries map[string]*registry2.RegistryConfig, singleRegistry *registry2.RegistryConfig) { -// if len(registries) == 0 && singleRegistry != nil { -// registries[constant.DEFAULT_KEY] = singleRegistry +//func checkRegistries(registriesConfig map[string]*registry2.RegistryConfig, singleRegistry *registry2.RegistryConfig) { +// if len(registriesConfig) == 0 && singleRegistry != nil { +// registriesConfig[constant.DEFAULT_KEY] = singleRegistry // } //} // -//func checkApplicationName(config *application.ShutdownConfig) { +//func checkApplicationName(config *applicationConfig.ShutdownConfig) { // if config == nil || len(config.Name) == 0 { -// errMsg := "application config must not be nil, pls check your configuration" +// errMsg := "applicationConfig config must not be nil, pls check your configuration" // logger.Errorf(errMsg) // panic(errMsg) // } @@ -523,18 +524,18 @@ func getKoanf(conf *config) *koanf.Koanf { // return GetBaseConfig().MetricConfig //} // -//// GetApplicationConfig find the application config +//// GetApplicationConfig find the applicationConfig config //// if not, we will create one //// Usually applicationConfig will be initialized when system start //// we use double-check to reduce race condition //// In general, it will be locked 0 or 1 time. //// So you don't need to worry about the race condition -//func GetApplicationConfig() *application.ShutdownConfig { +//func GetApplicationConfig() *applicationConfig.ShutdownConfig { // if GetBaseConfig().ApplicationConfig == nil { // configAccessMutex.Lock() // defer configAccessMutex.Unlock() // if GetBaseConfig().ApplicationConfig == nil { -// GetBaseConfig().ApplicationConfig = &application.ShutdownConfig{} +// GetBaseConfig().ApplicationConfig = &applicationConfig.ShutdownConfig{} // } // } // return GetBaseConfig().ApplicationConfig @@ -574,7 +575,7 @@ func getKoanf(conf *config) *koanf.Koanf { // metric.MetricConfig: &metric.MetricConfig{}, // ConfigCenterConfig: ¢er.ShutdownConfig{}, // Remotes: make(map[string]*RemoteConfig), -// application.ShutdownConfig: &application.ShutdownConfig{}, +// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{}, // ServiceDiscoveries: make(map[string]*discovery.ShutdownConfig), // } // } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 4563646c4c..72aff19437 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -19,6 +19,7 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/config/options" "testing" ) @@ -32,7 +33,7 @@ func init() { } const ( - configPath = "./testdata/application.yaml" + configPath = "./testdata/applicationConfig.yaml" ) func TestNoLoad(t *testing.T) { @@ -43,9 +44,9 @@ func TestNoLoad(t *testing.T) { } func TestLoad(t *testing.T) { - Load(WithPath(configPath)) + Load(options.WithPath(configPath)) - t.Run("application", func(t *testing.T) { + t.Run("applicationConfig", func(t *testing.T) { application, err := GetApplicationConfig() assert.Nil(t, err) assert.Equal(t, application.Organization, "dubbo.io") @@ -57,7 +58,7 @@ func TestLoad(t *testing.T) { assert.Equal(t, application.MetadataType, "local") }) - t.Run("registries", func(t *testing.T) { + t.Run("registriesConfig", func(t *testing.T) { registries, err := GetRegistriesConfig() assert.Nil(t, err) assert.Equal(t, 2, len(registries)) @@ -85,7 +86,7 @@ func TestLoad(t *testing.T) { func TestLoadConfigCenter(t *testing.T) { t.Run("config_center", func(t *testing.T) { - Load(WithGenre("yml"), WithPath("./testdata/config/center/conf_application.yaml")) + Load(options.WithGenre("yml"), options.WithPath("./testdata/config/center/conf_application.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -94,7 +95,7 @@ func TestLoadConfigCenter(t *testing.T) { }) t.Run("configCenter", func(t *testing.T) { - Load(WithGenre("yaml"), WithPath("./testdata/config/center/confApplication.yaml")) + Load(options.WithGenre("yaml"), options.WithPath("./testdata/config/center/confApplication.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -103,7 +104,7 @@ func TestLoadConfigCenter(t *testing.T) { }) t.Run("config-center", func(t *testing.T) { - Load(WithPath("./testdata/config/center/conf-application.yaml")) + Load(options.WithPath("./testdata/config/center/conf-applicationConfig.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -114,17 +115,17 @@ func TestLoadConfigCenter(t *testing.T) { func TestCheckGenre(t *testing.T) { - err := checkGenre("abc") + err := options.checkGenre("abc") assert.NotNil(t, err) - err = checkGenre("json") + err = options.checkGenre("json") assert.Nil(t, err) } func TestGetRegistriesConfig(t *testing.T) { t.Run("empty registry", func(t *testing.T) { - Load(WithPath("./testdata/config/registry/empty_application.yaml")) + Load(options.WithPath("./testdata/config/registry/empty_application.yaml")) registries, err := GetRegistriesConfig() assert.Nil(t, err) @@ -135,7 +136,7 @@ func TestGetRegistriesConfig(t *testing.T) { }) t.Run("registry", func(t *testing.T) { - Load(WithPath("./testdata/config/registry/application.yaml")) + Load(options.WithPath("./testdata/config/registry/applicationConfig.yaml")) registries, err := GetRegistriesConfig() assert.Nil(t, err) @@ -156,7 +157,7 @@ func TestGetRegistriesConfig(t *testing.T) { func TestGetProtocolsConfig(t *testing.T) { t.Run("empty protocols", func(t *testing.T) { - Load(WithPath("./testdata/config/protocol/empty_application.yaml")) + Load(options.WithPath("./testdata/config/protocol/empty_application.yaml")) protocols, err := GetProtocolsConfig() assert.Nil(t, err) @@ -168,7 +169,7 @@ func TestGetProtocolsConfig(t *testing.T) { }) t.Run("protocols", func(t *testing.T) { - Load(WithPath("./testdata/config/protocol/application.yaml")) + Load(options.WithPath("./testdata/config/protocol/applicationConfig.yaml")) protocols, err := GetProtocolsConfig() assert.Nil(t, err) @@ -183,14 +184,14 @@ func TestGetProtocolsConfig(t *testing.T) { func TestGetProviderConfig(t *testing.T) { // empty registry t.Run("empty registry", func(t *testing.T) { - Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) + Load(options.WithPath("./testdata/config/provider/empty_registry_application.yaml")) provider, err := GetProviderConfig() assert.Nil(t, err) assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) }) t.Run("root registry", func(t *testing.T) { - Load(WithPath("./testdata/config/provider/registry_application.yaml")) + Load(options.WithPath("./testdata/config/provider/registry_application.yaml")) provider, err := GetProviderConfig() assert.Nil(t, err) assert.NotNil(t, provider) @@ -339,12 +340,12 @@ func TestGetProviderConfig(t *testing.T) { // return &config_center.MockDynamicConfigurationFactory{Content: ` // dubbo.consumer.request_timeout=5s // dubbo.consumer.connect_timeout=5s -// dubbo.application.organization=ikurento.com -// dubbo.application.name=BDTService -// dubbo.application.module=dubbogo user-info server -// dubbo.application.version=0.0.1 -// dubbo.application.owner=ZX -// dubbo.application.environment=dev +// dubbo.applicationConfig.organization=ikurento.com +// dubbo.applicationConfig.name=BDTService +// dubbo.applicationConfig.module=dubbogo user-info server +// dubbo.applicationConfig.version=0.0.1 +// dubbo.applicationConfig.owner=ZX +// dubbo.applicationConfig.environment=dev // dubbo.registry.address=mock://127.0.0.1:2182 // dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo // dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider @@ -400,7 +401,7 @@ func TestGetProviderConfig(t *testing.T) { //func mockInitProviderWithSingleRegistry() { // providerConfig = &provider.ProviderConfig{ // BaseConfig: base.ShutdownConfig{ -// application.ShutdownConfig: &application.ShutdownConfig{ +// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ // Organization: "dubbo_org", // Name: "dubbo", // Module: "module", diff --git a/config/consumer_config.go b/config/consumer_config.go index 73aa2f8aaf..9e8396b183 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -43,7 +43,7 @@ type ConsumerConfig struct { ConnectTimeout time.Duration Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Registries map[string]*RegistryConfig `default:"{}" yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` RequestTimeout time.Duration @@ -79,7 +79,7 @@ func (ConsumerConfig) Prefix() string { // ConsumerInit loads config file to init consumer config func ConsumerInit(confConFile string) error { //if confConFile == "" { - // return perrors.Errorf("application configure(consumer) file name is nil") + // return perrors.Errorf("applicationConfig configure(consumer) file name is nil") //} //consumerConfig = &ShutdownConfig{} //fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index 5f2ed175ce..d37ad82733 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -67,10 +67,10 @@ const defaultShutDownTime = time.Second * 60 // go func() { // select { // case sig := <-signals: -// logger.Infof("get signal %s, application will shutdown.", sig) +// logger.Infof("get signal %s, applicationConfig will shutdown.", sig) // // gracefulShutdownOnce.Do(func() { // time.AfterFunc(totalTimeout(), func() { -// logger.Warn("Shutdown gracefully timeout, application will shutdown immediately. ") +// logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ") // os.Exit(0) // }) // BeforeShutdown() @@ -98,13 +98,13 @@ func BeforeShutdown() { // we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc //consumerProtocols := getConsumerProtocols() - // If this application is not the provider, it will do nothing + // If this applicationConfig is not the provider, it will do nothing //destroyProviderProtocols(consumerProtocols) // reject sending the new request, and waiting for response of sending requests //waitForSendingRequests() - // If this application is not the consumer, it will do nothing + // If this applicationConfig is not the consumer, it will do nothing //destroyConsumerProtocols(consumerProtocols) logger.Info("Graceful shutdown --- Execute the custom callbacks.") @@ -115,7 +115,7 @@ func BeforeShutdown() { } func destroyAllRegistries() { - logger.Info("Graceful shutdown --- Destroy all registries. ") + logger.Info("Graceful shutdown --- Destroy all registriesConfig. ") registryProtocol := extension.GetProtocol(constant.REGISTRY_KEY) registryProtocol.Destroy() } diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index 3c5b5b1c91..76720a31d2 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -35,7 +35,7 @@ const ( type ShutdownConfig struct { /* * Total timeout. Even though we don't release all resources, - * the application will shutdown if the costing time is over this configuration. The unit is ms. + * the applicationConfig will shutdown if the costing time is over this configuration. The unit is ms. * default value is 60 * 1000 ms = 1 minutes * In general, it should be bigger than 3 * StepTimeout. */ @@ -48,7 +48,7 @@ type ShutdownConfig struct { * maybe (10 + 2*3) * 1000ms is a good choice. */ StepTimeout string `default:"10s" yaml:"step_timeout" json:"step.timeout,omitempty" property:"step.timeout"` - // when we try to shutdown the application, we will reject the new requests. In most cases, you don't need to configure this. + // when we try to shutdown the applicationConfig, we will reject the new requests. In most cases, you don't need to configure this. RejectRequestHandler string `yaml:"reject_handler" json:"reject_handler,omitempty" property:"reject_handler"` // true -> new request will be rejected. RejectRequest bool diff --git a/config/config_loader_options.go b/config/options/config_loader_options.go similarity index 99% rename from config/config_loader_options.go rename to config/options/config_loader_options.go index 30072da2c6..d30c982dcd 100644 --- a/config/config_loader_options.go +++ b/config/options/config_loader_options.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package options import ( "fmt" diff --git a/config/protocol_config.go b/config/protocol_config.go index cd3747564e..b29be9d6d4 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -17,10 +17,6 @@ package config -import ( - "strings" -) - import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) @@ -29,7 +25,7 @@ import ( type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port int `default:"0" yaml:"port" json:"port,omitempty" property:"port"` + Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } // Prefix dubbo.protocols @@ -42,14 +38,15 @@ func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*Protoc if protocols == nil || len(protocols) <= 0 { conf := new(ProtocolConfig) protocols = make(map[string]*ProtocolConfig, 1) - protocols[constant.DEFAULT_Key] = conf + protocols[constant.DUBBO] = conf } return protocols } -func loadProtocol(protocolsIds string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { +//loadProtocol filter protocols by ids +func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) - for _, v := range strings.Split(protocolsIds, ",") { + for _, v := range protocolIds { for k, protocol := range protocols { if v == k { returnProtocols = append(returnProtocols, protocol) diff --git a/config/provider_config.go b/config/provider_config.go index 557bf7bb42..46672dae0d 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -36,7 +36,8 @@ type ProviderConfig struct { Registry []string `validate:"required" yaml:"registry" json:"registry" property:"registry"` // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - //ProxyFactory string `yaml:"proxy-factory" default:"default" json:"proxy-factory,omitempty" property:"proxy-factory"` + + ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` //Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` //ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` //FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` @@ -80,7 +81,7 @@ func getProviderConfig(provider *ProviderConfig) *ProviderConfig { //// ProviderInit loads config file to init provider config //func ProviderInit(confProFile string) error { // if len(confProFile) == 0 { -// return perrors.Errorf("application configure(provider) file name is nil") +// return perrors.Errorf("applicationConfig configure(provider) file name is nil") // } // config.providerConfig = &ProviderConfig{} // fileStream, err := yaml.UnmarshalYMLConfig(confProFile, config.providerConfig) diff --git a/config/reference_config.go b/config/reference_config.go index 6842696409..6cc2e40625 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -235,7 +235,7 @@ type ReferenceConfig struct { // urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) // urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) // -// // application info +// // applicationConfig info // urlMap.Set(constant.APPLICATION_KEY, config.consumerConfig.ApplicationConfig.Name) // urlMap.Set(constant.ORGANIZATION_KEY, config.consumerConfig.ApplicationConfig.Organization) // urlMap.Set(constant.NAME_KEY, config.consumerConfig.ApplicationConfig.Name) diff --git a/config/reference_config_test.go b/config/reference_config_test.go index 80993fbeae..84585876b0 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -20,7 +20,7 @@ package config //import ( // "context" // "dubbo.apache.org/dubbo-go/v3/config" -// "dubbo.apache.org/dubbo-go/v3/config/application" +// "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" // "dubbo.apache.org/dubbo-go/v3/config/base" // "dubbo.apache.org/dubbo-go/v3/config/consumer" // "dubbo.apache.org/dubbo-go/v3/config/instance" @@ -49,7 +49,7 @@ package config //func doInitConsumer() { // config.consumerConfig = &consumer.Config{ // BaseConfig: base.Config{ -// application.Config: &application.Config{ +// applicationConfig.Config: &applicationConfig.Config{ // Organization: "dubbo_org", // Name: "dubbo", // Module: "module", @@ -151,7 +151,7 @@ package config //func doInitConsumerWithSingleRegistry() { // config.consumerConfig = &consumer.Config{ // BaseConfig: base.Config{ -// application.Config: &application.Config{ +// applicationConfig.Config: &applicationConfig.Config{ // Organization: "dubbo_org", // Name: "dubbo", // Module: "module", @@ -400,7 +400,7 @@ package config //type mockShutdownFilter struct { //} // -//// Invoke adds the requests count and block the new requests if application is closing +//// Invoke adds the requests count and block the new requests if applicationConfig is closing //func (gf *mockShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { // return invoker.Invoke(ctx, invocation) //} diff --git a/config/registry_config.go b/config/registry_config.go index 264eb6735b..86e70af766 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -44,12 +44,12 @@ type RegistryConfig struct { Username string `yaml:"username" json:"username,omitempty" property:"username"` Password string `yaml:"password" json:"password,omitempty" property:"password"` Simplified bool `yaml:"simplified" json:"simplified,omitempty" property:"simplified"` - // Always use this registry first if set to true, useful when subscribe to multiple registries + // Always use this registry first if set to true, useful when subscribe to multiple registriesConfig Preferred bool `yaml:"preferred" json:"preferred,omitempty" property:"preferred"` // The region where the registry belongs, usually used to isolate traffics Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"` - // Affects traffic distribution among registries, - // useful when subscribe to multiple registries Take effect only when no preferred registry is specified. + // Affects traffic distribution among registriesConfig, + // useful when subscribe to multiple registriesConfig Take effect only when no preferred registry is specified. Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } @@ -73,14 +73,14 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// Prefix dubbo.registries +// Prefix dubbo.registriesConfig func (RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix } -func loadRegistries(targetRegistries string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { +func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { var urls []*common.URL - trSlice := strings.Split(targetRegistries, ",") + //trSlice := strings.Split(targetRegistries, ",") for k, registryConf := range registries { target := false @@ -90,11 +90,11 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf // if s does not contain sep and sep is not empty, SplitAfter returns // a slice of length 1 whose only element is s. So we have to add the // condition when targetRegistries string is not set (it will be "" when not set) - if len(trSlice) == 0 || (len(trSlice) == 1 && trSlice[0] == "") { + if len(registryIds) == 0 || (len(registryIds) == 1 && registryIds[0] == "") { target = true } else { // else if user config targetRegistries - for _, tr := range trSlice { + for _, tr := range registryIds { if tr == k { target = true break diff --git a/config/root_config.go b/config/root_config.go index 8bd584b86b..0ffa09691b 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -17,9 +17,13 @@ import ( ) var ( + applicationConfig *ApplicationConfig + consumerConfig *ConsumerConfig providerConfig *ProviderConfig + + registriesConfig map[string]*RegistryConfig ) // RootConfig is the root config @@ -33,11 +37,11 @@ type RootConfig struct { MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` - // Application application config - Application *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` + // Application applicationConfig config + Application *ApplicationConfig `yaml:"applicationConfig" json:"applicationConfig,omitempty" property:"applicationConfig"` // Registries registry config - Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` + Registries map[string]*RegistryConfig `yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols" property:"protocols"` @@ -94,21 +98,24 @@ func translateRegistryIds(registryIds []string) []string { return removeDuplicateElement(ids) } -// GetApplicationConfig get application config +// GetApplicationConfig get applicationConfig config func GetApplicationConfig() (*ApplicationConfig, error) { if err := check(); err != nil { return nil, err } - application := getApplicationConfig(rootConfig.Application) - if err := defaults.Set(application); err != nil { + if applicationConfig != nil { + return applicationConfig, nil + } + applicationConfig = getApplicationConfig(rootConfig.Application) + if err := defaults.Set(applicationConfig); err != nil { return nil, err } - if err := verify(application); err != nil { + if err := verify(applicationConfig); err != nil { return nil, err } - rootConfig.Application = application - return application, nil + + return applicationConfig, nil } // GetConfigCenterConfig get config center config @@ -136,8 +143,11 @@ func GetRegistriesConfig() (map[string]*RegistryConfig, error) { return nil, err } - registries := getRegistriesConfig(rootConfig.Registries) - for _, reg := range registries { + if registriesConfig != nil { + return registriesConfig, nil + } + registriesConfig = getRegistriesConfig(rootConfig.Registries) + for _, reg := range registriesConfig { if err := defaults.Set(reg); err != nil { return nil, err } @@ -146,7 +156,8 @@ func GetRegistriesConfig() (map[string]*RegistryConfig, error) { return nil, err } } - return registries, nil + + return registriesConfig, nil } // GetProtocolsConfig get protocols config default dubbo protocol diff --git a/config/service_config.go b/config/service_config.go index 0a1e86361f..add72400ce 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -19,6 +19,7 @@ package config import ( "container/list" + "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "fmt" "net/url" "strconv" @@ -164,9 +165,9 @@ func (c *ServiceConfig) IsExport() bool { func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { ports := list.New() for _, proto := range protocolConfigs { - //if len(proto.Port) > 0 { - // continue - //} + if len(proto.Port) > 0 { + continue + } tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) if err != nil { @@ -193,89 +194,89 @@ func (c *ServiceConfig) Export() error { return nil } - //regUrls := config.loadRegistries(c.Registry, config.providerConfig.Registries, common.PROVIDER) - //urlMap := c.getUrlMap() - //protocolConfigs := config.loadProtocol(c.Protocol, c.Protocols) - //if len(protocolConfigs) == 0 { - // logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.InterfaceName, c.Protocol) - // return nil - //} - - //ports := getRandomPort(protocolConfigs) - //nextPort := ports.Front() - //proxyFactory := extension.GetProxyFactory(config.providerConfig.ProxyFactory) - //for _, proto := range protocolConfigs { - // // registry the service reflect - // methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.Group, c.Version, c.rpcService) - // if err != nil { - // formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", - // c.InterfaceName, proto.Name, err.Error()) - // logger.Errorf(formatErr.Error()) - // return formatErr - // } - // - // port := proto.Port - // if len(proto.Port) == 0 { - // port = nextPort.Value.(string) - // nextPort = nextPort.Next() - // } - // ivkURL := common.NewURLWithOptions( - // common.WithPath(c.InterfaceName), - // common.WithProtocol(proto.Name), - // common.WithIp(proto.Ip), - // common.WithPort(port), - // common.WithParams(urlMap), - // common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), - // common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), - // common.WithMethods(strings.Split(methods, ",")), - // common.WithToken(c.Token), - // ) - // if len(c.Tag) > 0 { - // ivkURL.AddParam(constant.Tagkey, c.Tag) - // } - // - // // post process the URL to be exported - // c.postProcessConfig(ivkURL) - // // config post processor may set "export" to false - // if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) { - // return nil - // } - // - // if len(regUrls) > 0 { - // c.cacheMutex.Lock() - // if c.cacheProtocol == nil { - // logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL)) - // c.cacheProtocol = extension.GetProtocol("registry") - // } - // c.cacheMutex.Unlock() - // - // for _, regUrl := range regUrls { - // regUrl.SubURL = ivkURL - // invoker := proxyFactory.GetInvoker(regUrl) - // exporter := c.cacheProtocol.Export(invoker) - // if exporter == nil { - // return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL)) - // } - // c.exporters = append(c.exporters, exporter) - // } - // } else { - // if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { - // ms, err := extension.GetLocalMetadataService("") - // if err != nil { - // return err - // } - // ms.SetMetadataServiceURL(ivkURL) - // } - // invoker := proxyFactory.GetInvoker(ivkURL) - // exporter := extension.GetProtocol(protocolwrapper.FILTER).Export(invoker) - // if exporter == nil { - // return perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error, url is {%v}", ivkURL)) - // } - // c.exporters = append(c.exporters, exporter) - // } - // publishServiceDefinition(ivkURL) - //} - //c.exported.Store(true) + regUrls := loadRegistries(c.Registry, registriesConfig, common.PROVIDER) + urlMap := c.getUrlMap() + protocolConfigs := loadProtocol(c.Protocol, c.Protocols) + if len(protocolConfigs) == 0 { + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.Interface, c.Protocol) + return nil + } + + ports := getRandomPort(protocolConfigs) + nextPort := ports.Front() + proxyFactory := extension.GetProxyFactory(providerConfig.ProxyFactory) + for _, proto := range protocolConfigs { + // registry the service reflect + methods, err := common.ServiceMap.Register(c.Interface, proto.Name, c.Group, c.Version, c.rpcService) + if err != nil { + formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", + c.Interface, proto.Name, err.Error()) + logger.Errorf(formatErr.Error()) + return formatErr + } + + port := proto.Port + if len(proto.Port) == 0 { + port = nextPort.Value.(string) + nextPort = nextPort.Next() + } + ivkURL := common.NewURLWithOptions( + common.WithPath(c.Interface), + common.WithProtocol(proto.Name), + common.WithIp(proto.Ip), + common.WithPort(port), + common.WithParams(urlMap), + common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), + //common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), + common.WithMethods(strings.Split(methods, ",")), + common.WithToken(c.Token), + ) + if len(c.Tag) > 0 { + ivkURL.AddParam(constant.Tagkey, c.Tag) + } + + // post process the URL to be exported + c.postProcessConfig(ivkURL) + // config post processor may set "export" to false + if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) { + return nil + } + + if len(regUrls) > 0 { + c.cacheMutex.Lock() + if c.cacheProtocol == nil { + logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL)) + c.cacheProtocol = extension.GetProtocol("registry") + } + c.cacheMutex.Unlock() + + for _, regUrl := range regUrls { + regUrl.SubURL = ivkURL + invoker := proxyFactory.GetInvoker(regUrl) + exporter := c.cacheProtocol.Export(invoker) + if exporter == nil { + return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL)) + } + c.exporters = append(c.exporters, exporter) + } + } else { + if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { + ms, err := extension.GetLocalMetadataService("") + if err != nil { + return err + } + ms.SetMetadataServiceURL(ivkURL) + } + invoker := proxyFactory.GetInvoker(ivkURL) + exporter := extension.GetProtocol(protocolwrapper.FILTER).Export(invoker) + if exporter == nil { + return perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error, url is {%v}", ivkURL)) + } + c.exporters = append(c.exporters, exporter) + } + publishServiceDefinition(ivkURL) + } + c.exported.Store(true) return nil } @@ -326,17 +327,17 @@ func (c *ServiceConfig) getUrlMap() url.Values { urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(c.GrpcMaxMessageSize)) // todo: move urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) - // application info - //urlMap.Set(constant.APPLICATION_KEY, config.providerConfig.ApplicationConfig.Name) - //urlMap.Set(constant.ORGANIZATION_KEY, config.providerConfig.ApplicationConfig.Organization) - //urlMap.Set(constant.NAME_KEY, config.providerConfig.ApplicationConfig.Name) - //urlMap.Set(constant.MODULE_KEY, config.providerConfig.ApplicationConfig.Module) - //urlMap.Set(constant.APP_VERSION_KEY, config.providerConfig.ApplicationConfig.Version) - //urlMap.Set(constant.OWNER_KEY, config.root.Application.Owner) - //urlMap.Set(constant.ENVIRONMENT_KEY, config.providerConfig.ApplicationConfig.Environment) + // application config info + urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) + urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) + urlMap.Set(constant.NAME_KEY, applicationConfig.Name) + urlMap.Set(constant.MODULE_KEY, applicationConfig.Module) + urlMap.Set(constant.APP_VERSION_KEY, applicationConfig.Version) + urlMap.Set(constant.OWNER_KEY, applicationConfig.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) // filter - //urlMap.Set(constant.SERVICE_FILTER_KEY, config.mergeValue(config.providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) + urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) // filter special config urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml index 5e6696c04a..45e7231273 100644 --- a/config/testdata/config/provider/application.yaml +++ b/config/testdata/config/provider/application.yaml @@ -2,8 +2,8 @@ dubbo: provider: register: true registry: - - nacos - - zk + - nacos + - zk services: helloService: interface: org.dubbo.service.HelloService From 5e20c9f989b2cdabfe4997fe052ecd44a3f66535 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 01:25:51 +0800 Subject: [PATCH 017/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=A3=E6=9E=90tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application_config.go | 12 +-- config/config_center_config.go | 12 +-- config/config_loader.go | 15 +--- config/{options => }/config_loader_options.go | 84 ++++++++++--------- config/config_loader_options_test.go | 61 ++++++++++++++ config/config_loader_test.go | 32 +++---- config/registry_config_test.go | 4 +- config/root_config.go | 12 +-- .../config/center/conf-application.yaml | 4 +- 9 files changed, 138 insertions(+), 98 deletions(-) rename config/{options => }/config_loader_options.go (76%) create mode 100644 config/config_loader_options_test.go diff --git a/config/application_config.go b/config/application_config.go index 4321d088ee..31fbd80d18 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -18,7 +18,6 @@ package config import ( - "github.com/creasty/defaults" "github.com/mitchellh/mapstructure" ) @@ -56,13 +55,4 @@ func getApplicationConfig(application *ApplicationConfig) *ApplicationConfig { } } return application -} - -// UnmarshalYAML unmarshal the ApplicationConfig by @unmarshal function -func (ac *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(ac); err != nil { - return err - } - type plain ApplicationConfig - return unmarshal((*plain)(ac)) -} +} \ No newline at end of file diff --git a/config/config_center_config.go b/config/config_center_config.go index 8c7f5b536e..a80bbaf4bd 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -51,14 +51,14 @@ type CenterConfig struct { 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"` + 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"` + 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"` Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"` // Deprecated - RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"` + RemoteRef string `required:"false" yaml:"remote-ref" json:"remote-ref,omitempty"` Params map[string]string `yaml:"params" json:"parameters,omitempty"` } @@ -79,7 +79,7 @@ func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // getConfigCenterConfig get config center config func getConfigCenterConfig(c *CenterConfig) *CenterConfig { if c != nil { - return nil + return c } c = new(CenterConfig) key := c.Prefix() diff --git a/config/config_loader.go b/config/config_loader.go index 652a1c97a2..e9b812b3f8 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,7 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/config/options" "errors" "fmt" ) @@ -62,16 +61,11 @@ func init() { validate = validator.New() } -func Load(opts ...options.Option) { +func Load(opts ...LoaderConfOption) { // pares CommandLine //parseCommandLine() // conf - conf := &options.config{ - name: "applicationConfig.yaml", - genre: "yaml", - path: "./conf", - delim: ".", - } + conf := NewLoaderConf(opts...) for _, opt := range opts { opt.apply(conf) @@ -80,7 +74,7 @@ func Load(opts ...options.Option) { viper = getKoanf(conf) - if err := viper.Unmarshal(rootConfig.Prefix(), &rootConfig); err != nil { + if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { panic(err) } } @@ -107,7 +101,7 @@ func check() error { // } //} -func getKoanf(conf *options.config) *koanf.Koanf { +func getKoanf(conf *loaderConf) *koanf.Koanf { var ( k *koanf.Koanf err error @@ -132,7 +126,6 @@ func getKoanf(conf *options.config) *koanf.Koanf { return k } - // //func GetConfigCenterConfig() (*center.ConfigCenterConfig, error) { // if err := check(); err != nil { diff --git a/config/options/config_loader_options.go b/config/config_loader_options.go similarity index 76% rename from config/options/config_loader_options.go rename to config/config_loader_options.go index d30c982dcd..685447ad07 100644 --- a/config/options/config_loader_options.go +++ b/config/config_loader_options.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package options +package config import ( "fmt" @@ -29,30 +29,41 @@ import ( "github.com/pkg/errors" ) -type config struct { - // config file name default application - name string - // config file type default yaml +type loaderConf struct { + // loaderConf file type default yaml genre string - // config file path default ./conf + // loaderConf file path default ./conf path string - // config file delim default . + // loaderConf file delim default . delim string } -type optionFunc func(*config) +func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { + conf := &loaderConf{ + genre: "yaml", + path: "./conf/application.yaml", + delim: ".", + } -func (fn optionFunc) apply(vc *config) { - fn(vc) + for _, opt := range opts { + opt.apply(conf) + } + return conf +} + +type LoaderConfOption interface { + apply(vc *loaderConf) } -type Option interface { - apply(vc *config) +type loaderConfigFunc func(*loaderConf) + +func (fn loaderConfigFunc) apply(vc *loaderConf) { + fn(vc) } -// WithGenre set config genre -func WithGenre(genre string) Option { - return optionFunc(func(conf *config) { +// WithGenre set loaderConf Genre +func WithGenre(genre string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { g := strings.ToLower(genre) if err := checkGenre(g); err != nil { panic(err) @@ -61,22 +72,15 @@ func WithGenre(genre string) Option { }) } -// WithPath set config path -func WithPath(path string) Option { - return optionFunc(func(conf *config) { +// WithPath set loaderConf path +func WithPath(path string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { conf.path = absolutePath(path) }) } -// WithName set config name -func WithName(name string) Option { - return optionFunc(func(conf *config) { - conf.name = name - }) -} - -func WithDelim(delim string) Option { - return optionFunc(func(conf *config) { +func WithDelim(delim string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { conf.delim = delim }) } @@ -112,7 +116,7 @@ func userHomeDir() string { return os.Getenv("HOME") } -// checkGenre check genre +// checkGenre check Genre func checkGenre(genre string) error { genres := []string{"json", "toml", "yaml", "yml"} sort.Strings(genres) @@ -125,9 +129,9 @@ func checkGenre(genre string) error { // //import ( -// "dubbo.apache.org/dubbo-go/v3/config/base" -// "dubbo.apache.org/dubbo-go/v3/config/consumer" -// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "dubbo.apache.org/dubbo-go/v3/loaderConf/base" +// "dubbo.apache.org/dubbo-go/v3/loaderConf/consumer" +// "dubbo.apache.org/dubbo-go/v3/loaderConf/provider" // "log" //) // @@ -140,16 +144,16 @@ func checkGenre(genre string) error { // apply() //} // -//type optionFunc struct { +//type loaderConfigFunc struct { // initFunc func() // applyFunc func() //} // -//func (f *optionFunc) init() { +//func (f *loaderConfigFunc) init() { // f.initFunc() //} // -//func (f *optionFunc) apply() { +//func (f *loaderConfigFunc) apply() { // f.applyFunc() //} // @@ -162,7 +166,7 @@ func checkGenre(genre string) error { //} // //func consumerInitOption(confConFile string, must bool) LoaderInitOption { -// return &optionFunc{ +// return &loaderConfigFunc{ // func() { // if consumerConfig != nil && !must { // return @@ -175,7 +179,7 @@ func checkGenre(genre string) error { // // if so, we set a default value for it // setDefaultValue(consumerConfig) // // Even though baseConfig has been initialized, we override it -// // because we think read from config file is correct config +// // because we think read from loaderConf file is correct loaderConf // baseConfig = &consumerConfig.BaseConfig // } // }, @@ -194,7 +198,7 @@ func checkGenre(genre string) error { //} // //func providerInitOption(confProFile string, must bool) LoaderInitOption { -// return &optionFunc{ +// return &loaderConfigFunc{ // func() { // if providerConfig != nil && !must { // return @@ -207,7 +211,7 @@ func checkGenre(genre string) error { // // if so, we set a default value for it // setDefaultValue(providerConfig) // // Even though baseConfig has been initialized, we override it -// // because we think read from config file is correct config +// // because we think read from loaderConf file is correct loaderConf // baseConfig = &providerConfig.BaseConfig // } // }, @@ -218,7 +222,7 @@ func checkGenre(genre string) error { //} // //func RouterInitOption(crf string) LoaderInitOption { -// return &optionFunc{ +// return &loaderConfigFunc{ // func() { // confRouterFile = crf // }, @@ -229,7 +233,7 @@ func checkGenre(genre string) error { //} // //func BaseInitOption(cbf string) LoaderInitOption { -// return &optionFunc{ +// return &loaderConfigFunc{ // func() { // if cbf == "" { // return diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go new file mode 100644 index 0000000000..000489823e --- /dev/null +++ b/config/config_loader_options_test.go @@ -0,0 +1,61 @@ +/* +* 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 + +import ( + "testing" +) + +import "github.com/stretchr/testify/assert" + +func TestCheckGenre(t *testing.T) { + + err := checkGenre("abc") + assert.NotNil(t, err) + + err = checkGenre("json") + assert.Nil(t, err) +} + +func TestNewLoaderConf(t *testing.T) { + conf := NewLoaderConf() + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} + +func TestWithDelim(t *testing.T) { + conf := NewLoaderConf(WithDelim(":")) + assert.Equal(t, ":", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} + +func TestWithPath(t *testing.T) { + conf := NewLoaderConf(WithPath("./conf/app.yaml")) + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, absolutePath("./conf/app.yaml"), conf.path) +} + +func TestWithGenre(t *testing.T) { + conf := NewLoaderConf(WithGenre("json")) + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "json", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 72aff19437..ed49100a36 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -19,7 +19,6 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config/options" "testing" ) @@ -33,7 +32,7 @@ func init() { } const ( - configPath = "./testdata/applicationConfig.yaml" + configPath = "./testdata/application.yaml" ) func TestNoLoad(t *testing.T) { @@ -44,7 +43,7 @@ func TestNoLoad(t *testing.T) { } func TestLoad(t *testing.T) { - Load(options.WithPath(configPath)) + Load(WithPath(configPath)) t.Run("applicationConfig", func(t *testing.T) { application, err := GetApplicationConfig() @@ -86,7 +85,7 @@ func TestLoad(t *testing.T) { func TestLoadConfigCenter(t *testing.T) { t.Run("config_center", func(t *testing.T) { - Load(options.WithGenre("yml"), options.WithPath("./testdata/config/center/conf_application.yaml")) + Load(WithGenre("yml"), WithPath("./testdata/config/center/conf_application.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -95,7 +94,7 @@ func TestLoadConfigCenter(t *testing.T) { }) t.Run("configCenter", func(t *testing.T) { - Load(options.WithGenre("yaml"), options.WithPath("./testdata/config/center/confApplication.yaml")) + Load(WithGenre("yaml"), WithPath("./testdata/config/center/confApplication.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -104,7 +103,7 @@ func TestLoadConfigCenter(t *testing.T) { }) t.Run("config-center", func(t *testing.T) { - Load(options.WithPath("./testdata/config/center/conf-applicationConfig.yaml")) + Load(WithPath("./testdata/config/center/conf-application.yaml")) conf, err := GetConfigCenterConfig() assert.Nil(t, err) assert.Equal(t, "nacos", conf.Protocol) @@ -113,19 +112,10 @@ func TestLoadConfigCenter(t *testing.T) { }) } -func TestCheckGenre(t *testing.T) { - - err := options.checkGenre("abc") - assert.NotNil(t, err) - - err = options.checkGenre("json") - assert.Nil(t, err) -} - func TestGetRegistriesConfig(t *testing.T) { t.Run("empty registry", func(t *testing.T) { - Load(options.WithPath("./testdata/config/registry/empty_application.yaml")) + Load(WithPath("./testdata/config/registry/empty_application.yaml")) registries, err := GetRegistriesConfig() assert.Nil(t, err) @@ -136,7 +126,7 @@ func TestGetRegistriesConfig(t *testing.T) { }) t.Run("registry", func(t *testing.T) { - Load(options.WithPath("./testdata/config/registry/applicationConfig.yaml")) + Load(WithPath("./testdata/config/registry/application.yaml")) registries, err := GetRegistriesConfig() assert.Nil(t, err) @@ -157,7 +147,7 @@ func TestGetRegistriesConfig(t *testing.T) { func TestGetProtocolsConfig(t *testing.T) { t.Run("empty protocols", func(t *testing.T) { - Load(options.WithPath("./testdata/config/protocol/empty_application.yaml")) + Load(WithPath("./testdata/config/protocol/empty_application.yaml")) protocols, err := GetProtocolsConfig() assert.Nil(t, err) @@ -169,7 +159,7 @@ func TestGetProtocolsConfig(t *testing.T) { }) t.Run("protocols", func(t *testing.T) { - Load(options.WithPath("./testdata/config/protocol/applicationConfig.yaml")) + Load(WithPath("./testdata/config/protocol/application.yaml")) protocols, err := GetProtocolsConfig() assert.Nil(t, err) @@ -184,14 +174,14 @@ func TestGetProtocolsConfig(t *testing.T) { func TestGetProviderConfig(t *testing.T) { // empty registry t.Run("empty registry", func(t *testing.T) { - Load(options.WithPath("./testdata/config/provider/empty_registry_application.yaml")) + Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) provider, err := GetProviderConfig() assert.Nil(t, err) assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) }) t.Run("root registry", func(t *testing.T) { - Load(options.WithPath("./testdata/config/provider/registry_application.yaml")) + Load(WithPath("./testdata/config/provider/registry_application.yaml")) provider, err := GetProviderConfig() assert.Nil(t, err) assert.NotNil(t, provider) diff --git a/config/registry_config_test.go b/config/registry_config_test.go index 4123584f49..f1f4716d30 100644 --- a/config/registry_config_test.go +++ b/config/registry_config_test.go @@ -29,7 +29,7 @@ import ( ) func TestLoadRegistries(t *testing.T) { - target := "shanghai1" + target := []string{"shanghai1"} regs := map[string]*RegistryConfig{ "shanghai1": { @@ -47,7 +47,7 @@ func TestLoadRegistries(t *testing.T) { } func TestLoadRegistries1(t *testing.T) { - target := "shanghai1" + target := []string{"shanghai1"} regs := map[string]*RegistryConfig{ "shanghai1": { diff --git a/config/root_config.go b/config/root_config.go index 0ffa09691b..e15f39bb91 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -123,18 +123,18 @@ func GetConfigCenterConfig() (*CenterConfig, error) { if err := check(); err != nil { return nil, err } - centerConfig := getConfigCenterConfig(rootConfig.ConfigCenter) - if centerConfig == nil { + conf := rootConfig.ConfigCenter + if conf == nil { return nil, errors.New("config center config is null") } - if err := defaults.Set(centerConfig); err != nil { + if err := defaults.Set(conf); err != nil { return nil, err } - centerConfig.translateConfigAddress() - if err := verify(centerConfig); err != nil { + conf.translateConfigAddress() + if err := verify(conf); err != nil { return nil, err } - return centerConfig, nil + return conf, nil } // GetRegistriesConfig get registry config default zookeeper registry diff --git a/config/testdata/config/center/conf-application.yaml b/config/testdata/config/center/conf-application.yaml index c9b0cf9db2..b14f356d70 100644 --- a/config/testdata/config/center/conf-application.yaml +++ b/config/testdata/config/center/conf-application.yaml @@ -3,4 +3,6 @@ dubbo: address: nacos://127.0.0.1:8848 cluster: dev namespace: dubbo - logDir: ./logs \ No newline at end of file + log-dir: ./logs + config-file: dubbo.yaml + app-id: dubbo \ No newline at end of file From 02b535b9bb2135b8666b5f702707a73608cd31ae Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 03:00:48 +0800 Subject: [PATCH 018/148] registries: --- config/application_config.go | 19 +-- config/config_center_config.go | 19 +-- config/config_loader.go | 10 +- config/config_loader_test.go | 56 ++------ config/protocol_config.go | 2 + config/provider_config.go | 2 +- config/registry_config.go | 15 +- config/root_config.go | 136 +++++++++--------- config/testdata/application.yaml | 4 +- config/testdata/config/app/application.yaml | 6 + .../provider/empty_registry_application.yaml | 5 + 11 files changed, 125 insertions(+), 149 deletions(-) create mode 100644 config/testdata/config/app/application.yaml diff --git a/config/application_config.go b/config/application_config.go index 31fbd80d18..98ef9bb0c6 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -17,12 +17,9 @@ package config -import ( - "github.com/mitchellh/mapstructure" -) - import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" ) // ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer @@ -44,15 +41,9 @@ func (ApplicationConfig) Prefix() string { // getApplicationConfig get applicationConfig config func getApplicationConfig(application *ApplicationConfig) *ApplicationConfig { - if application != nil { - return application - } - - application = new(ApplicationConfig) - if value := viper.Get(application.Prefix()); value != nil { - if err := mapstructure.Decode(value, application); err != nil { - return application - } + if application == nil { + application = new(ApplicationConfig) } + defaults.MustSet(application) return application -} \ No newline at end of file +} diff --git a/config/config_center_config.go b/config/config_center_config.go index a80bbaf4bd..a3ca4a134e 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -18,7 +18,6 @@ package config import ( - "github.com/goinggo/mapstructure" "net/url" "strings" ) @@ -78,21 +77,13 @@ func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // getConfigCenterConfig get config center config func getConfigCenterConfig(c *CenterConfig) *CenterConfig { - if c != nil { + if c == nil { return c } - c = new(CenterConfig) - key := c.Prefix() - value := viper.Get(key) - if value == nil { - key = strings.ReplaceAll(key, "-", "_") - value = viper.Get(key) - } - if value == nil { - return nil - } - if err := mapstructure.Decode(value, c); err != nil { - return nil + defaults.MustSet(c) + c.translateConfigAddress() + if err := verify(c); err != nil { + panic(err) } return c } diff --git a/config/config_loader.go b/config/config_loader.go index e9b812b3f8..4fe70a178d 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -66,17 +66,23 @@ func Load(opts ...LoaderConfOption) { //parseCommandLine() // conf conf := NewLoaderConf(opts...) - for _, opt := range opts { opt.apply(conf) } rootConfig = new(RootConfig) - viper = getKoanf(conf) if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { panic(err) } + if rootConfig.ConfigCenter != nil { + //监听远程配置刷新本地指定配置 + } + rootConfig.Init() + + if err := verify(rootConfig); err != nil { + panic(err) + } } func check() error { diff --git a/config/config_loader_test.go b/config/config_loader_test.go index ed49100a36..2cec6e27b9 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -35,19 +35,12 @@ const ( configPath = "./testdata/application.yaml" ) -func TestNoLoad(t *testing.T) { - - application, err := GetApplicationConfig() - assert.NotNil(t, err) - assert.Nil(t, application) -} - func TestLoad(t *testing.T) { Load(WithPath(configPath)) - t.Run("applicationConfig", func(t *testing.T) { - application, err := GetApplicationConfig() - assert.Nil(t, err) + t.Run("application", func(t *testing.T) { + application := rootConfig.Application + assert.Equal(t, application.Organization, "dubbo.io") assert.Equal(t, application.Name, "dubbo-go") assert.Equal(t, application.Module, "local") @@ -57,9 +50,9 @@ func TestLoad(t *testing.T) { assert.Equal(t, application.MetadataType, "local") }) - t.Run("registriesConfig", func(t *testing.T) { - registries, err := GetRegistriesConfig() - assert.Nil(t, err) + t.Run("registries", func(t *testing.T) { + registries := rootConfig.Registries + assert.Equal(t, 2, len(registries)) //address= nacos://127.0.0.1:8848 Translate Registry Address assert.Equal(t, "nacos", registries["nacos"].Protocol) @@ -68,16 +61,10 @@ func TestLoad(t *testing.T) { //config-center t.Run("config-center", func(t *testing.T) { - conf, err := GetConfigCenterConfig() - assert.NotNil(t, err) + conf := rootConfig.ConfigCenter + assert.Equal(t, "nacos", conf.Protocol) }) - // - ////protocols - //t.Run("protocols", func(t *testing.T) { - // _, err := GetProtocolsConfig() - // assert.Nil(t, err) - //}) } @@ -114,22 +101,11 @@ func TestLoadConfigCenter(t *testing.T) { func TestGetRegistriesConfig(t *testing.T) { - t.Run("empty registry", func(t *testing.T) { - Load(WithPath("./testdata/config/registry/empty_application.yaml")) - - registries, err := GetRegistriesConfig() - assert.Nil(t, err) - assert.Equal(t, 1, len(registries)) - assert.Equal(t, "zookeeper", registries["default"].Protocol) - assert.Equal(t, "10s", registries["default"].Timeout) - assert.Equal(t, "127.0.0.1:2181", registries["default"].Address) - }) - t.Run("registry", func(t *testing.T) { Load(WithPath("./testdata/config/registry/application.yaml")) - registries, err := GetRegistriesConfig() - assert.Nil(t, err) + registries := rootConfig.Registries + assert.Equal(t, 2, len(registries)) // nacos assert.Equal(t, "nacos", registries["nacos"].Protocol) @@ -149,8 +125,7 @@ func TestGetProtocolsConfig(t *testing.T) { t.Run("empty protocols", func(t *testing.T) { Load(WithPath("./testdata/config/protocol/empty_application.yaml")) - protocols, err := GetProtocolsConfig() - assert.Nil(t, err) + protocols := rootConfig.Protocols assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["default"].Name) @@ -161,8 +136,7 @@ func TestGetProtocolsConfig(t *testing.T) { t.Run("protocols", func(t *testing.T) { Load(WithPath("./testdata/config/protocol/application.yaml")) - protocols, err := GetProtocolsConfig() - assert.Nil(t, err) + protocols := rootConfig.Protocols assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) @@ -175,15 +149,13 @@ func TestGetProviderConfig(t *testing.T) { // empty registry t.Run("empty registry", func(t *testing.T) { Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) - provider, err := GetProviderConfig() - assert.Nil(t, err) + provider := rootConfig.Provider assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) }) t.Run("root registry", func(t *testing.T) { Load(WithPath("./testdata/config/provider/registry_application.yaml")) - provider, err := GetProviderConfig() - assert.Nil(t, err) + provider := rootConfig.Provider assert.NotNil(t, provider) }) } diff --git a/config/protocol_config.go b/config/protocol_config.go index b29be9d6d4..763939e604 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -19,6 +19,7 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" ) // ProtocolConfig is protocol configuration @@ -38,6 +39,7 @@ func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*Protoc if protocols == nil || len(protocols) <= 0 { conf := new(ProtocolConfig) protocols = make(map[string]*ProtocolConfig, 1) + defaults.MustSet(conf) protocols[constant.DUBBO] = conf } return protocols diff --git a/config/provider_config.go b/config/provider_config.go index 46672dae0d..28b1fe9417 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -33,7 +33,7 @@ type ProviderConfig struct { // Register whether registration is required Register bool `yaml:"register" json:"register" property:"register"` // Registry registry ids - Registry []string `validate:"required" yaml:"registry" json:"registry" property:"registry"` + Registry []string `yaml:"registry" json:"registry" property:"registry"` // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` diff --git a/config/registry_config.go b/config/registry_config.go index 86e70af766..0ea910b217 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -35,12 +35,12 @@ import ( // RegistryConfig is the configuration of the registry center type RegistryConfig struct { - Protocol string `default:"zookeeper" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry - Address string `default:"zookeeper://127.0.0.1:2181" validate:"required" yaml:"address" json:"address,omitempty" property:"address"` + Address string `validate:"required" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` Password string `yaml:"password" json:"password,omitempty" property:"password"` Simplified bool `yaml:"simplified" json:"simplified,omitempty" property:"simplified"` @@ -55,11 +55,12 @@ type RegistryConfig struct { } func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*RegistryConfig { - if registries == nil || len(registries) <= 0 { - registries = make(map[string]*RegistryConfig, 1) - reg := new(RegistryConfig) - registries[constant.DEFAULT_Key] = reg - return registries + for _, reg := range registries { + defaults.MustSet(reg) + reg.translateRegistryAddress() + if err := verify(reg); err != nil { + panic(err) + } } return registries } diff --git a/config/root_config.go b/config/root_config.go index e15f39bb91..06abcf2848 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -12,7 +12,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" ) @@ -33,17 +32,17 @@ type RootConfig struct { // since 1.5.0 version //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service_discovery"` + ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` // Application applicationConfig config - Application *ApplicationConfig `yaml:"applicationConfig" json:"applicationConfig,omitempty" property:"applicationConfig"` + Application *ApplicationConfig `validate:"required" yaml:"application" json:"application,omitempty" property:"application"` // Registries registry config - Registries map[string]*RegistryConfig `yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` + Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` - Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols" property:"protocols"` + Protocols map[string]*ProtocolConfig `validate:"required" yaml:"protocols" json:"protocols" property:"protocols"` // provider config Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` @@ -98,6 +97,13 @@ func translateRegistryIds(registryIds []string) []string { return removeDuplicateElement(ids) } +func (rc *RootConfig) Init() { + rc.Application = getApplicationConfig(rc.Application) + rc.Protocols = getProtocolsConfig(rc.Protocols) + rc.Registries = getRegistriesConfig(rc.Registries) + rc.ConfigCenter = getConfigCenterConfig(rc.ConfigCenter) +} + // GetApplicationConfig get applicationConfig config func GetApplicationConfig() (*ApplicationConfig, error) { if err := check(); err != nil { @@ -138,76 +144,72 @@ func GetConfigCenterConfig() (*CenterConfig, error) { } // GetRegistriesConfig get registry config default zookeeper registry -func GetRegistriesConfig() (map[string]*RegistryConfig, error) { - if err := check(); err != nil { - return nil, err - } - - if registriesConfig != nil { - return registriesConfig, nil - } - registriesConfig = getRegistriesConfig(rootConfig.Registries) - for _, reg := range registriesConfig { - if err := defaults.Set(reg); err != nil { - return nil, err - } - reg.translateRegistryAddress() - if err := verify(reg); err != nil { - return nil, err - } - } - - return registriesConfig, nil -} +//func GetRegistriesConfig() (map[string]*RegistryConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// if registriesConfig != nil { +// return registriesConfig, nil +// } +// registriesConfig = getRegistriesConfig(rootConfig.Registries) +// for _, reg := range registriesConfig { +// if err := defaults.Set(reg); err != nil { +// return nil, err +// } +// reg.translateRegistryAddress() +// if err := verify(reg); err != nil { +// return nil, err +// } +// } +// +// return registriesConfig, nil +//} // GetProtocolsConfig get protocols config default dubbo protocol -func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { - if err := check(); err != nil { - return nil, err - } - - protocols := getProtocolsConfig(rootConfig.Protocols) - for _, protocol := range protocols { - if err := defaults.Set(protocol); err != nil { - return nil, err - } - if err := verify(protocol); err != nil { - return nil, err - } - } - return protocols, nil -} +//func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// protocols := getProtocolsConfig(rootConfig.Protocols) +// for _, protocol := range protocols { +// if err := defaults.Set(protocol); err != nil { +// return nil, err +// } +// if err := verify(protocol); err != nil { +// return nil, err +// } +// } +// return protocols, nil +//} // GetProviderConfig get provider config -func GetProviderConfig() (*ProviderConfig, error) { - if err := check(); err != nil { - return nil, err - } - - if providerConfig != nil { - return providerConfig, nil - } - provider := getProviderConfig(rootConfig.Provider) - if err := defaults.Set(provider); err != nil { - return nil, err - } - if err := verify(provider); err != nil { - return nil, err - } - - provider.Services = getRegistryServices(common.PROVIDER, provider.Services, provider.Registry) - providerConfig = provider - return provider, nil -} +//func GetProviderConfig() (*ProviderConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// if providerConfig != nil { +// return providerConfig, nil +// } +// provider := getProviderConfig(rootConfig.Provider) +// if err := defaults.Set(provider); err != nil { +// return nil, err +// } +// if err := verify(provider); err != nil { +// return nil, err +// } +// +// provider.Services = getRegistryServices(common.PROVIDER, provider.Services, provider.Registry) +// providerConfig = provider +// return provider, nil +//} // getRegistryIds get registry keys func getRegistryIds() []string { ids := make([]string, 0) - registries, err := GetRegistriesConfig() - if err != nil { - ids = append(ids, constant.DEFAULT_Key) - } - for key := range registries { + for key := range rootConfig.Registries { ids = append(ids, key) } return removeDuplicateElement(ids) diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index 154b7aa724..f0876a125d 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -4,11 +4,11 @@ dubbo: module: local version: 1.0.0 owner: zhaoyunxing - config_center: + config-center: address: nacos://127.0.0.1:8848 cluster: dev namespace: dubbo - logDir: ./logs + log-dir: ./logs protocols: dubbo: name: dubbo diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml new file mode 100644 index 0000000000..9c7e6c873f --- /dev/null +++ b/config/testdata/config/app/application.yaml @@ -0,0 +1,6 @@ +dubbo: + application: + name: dubbo-go + module: local + version: 1.0.0 + owner: zhaoyunxing \ No newline at end of file diff --git a/config/testdata/config/provider/empty_registry_application.yaml b/config/testdata/config/provider/empty_registry_application.yaml index 2eede2a44e..c171c86bda 100644 --- a/config/testdata/config/provider/empty_registry_application.yaml +++ b/config/testdata/config/provider/empty_registry_application.yaml @@ -1,3 +1,8 @@ dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 provider: register: true \ No newline at end of file From b7863d79717e3f7fe47949d9dfa0d60570fb1a45 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 03:04:47 +0800 Subject: [PATCH 019/148] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_loader_test.go | 21 +----- config/root_config.go | 71 +++++++++---------- .../config/center/confApplication.yaml | 6 -- .../config/center/conf_application.yaml | 6 -- 4 files changed, 36 insertions(+), 68 deletions(-) delete mode 100644 config/testdata/config/center/confApplication.yaml delete mode 100644 config/testdata/config/center/conf_application.yaml diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 2cec6e27b9..663bdf60f8 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -71,28 +71,9 @@ func TestLoad(t *testing.T) { //TestLoadConfigCenter test key config_center、config-center 、configCenter func TestLoadConfigCenter(t *testing.T) { - t.Run("config_center", func(t *testing.T) { - Load(WithGenre("yml"), WithPath("./testdata/config/center/conf_application.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) - assert.Equal(t, "nacos", conf.Protocol) - assert.Equal(t, "10s", conf.Timeout) - assert.Equal(t, "./logs", conf.LogDir) - }) - - t.Run("configCenter", func(t *testing.T) { - Load(WithGenre("yaml"), WithPath("./testdata/config/center/confApplication.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) - assert.Equal(t, "nacos", conf.Protocol) - assert.Equal(t, "10s", conf.Timeout) - assert.Equal(t, "./logs", conf.LogDir) - }) - t.Run("config-center", func(t *testing.T) { Load(WithPath("./testdata/config/center/conf-application.yaml")) - conf, err := GetConfigCenterConfig() - assert.Nil(t, err) + conf := rootConfig.ConfigCenter assert.Equal(t, "nacos", conf.Protocol) assert.Equal(t, "10s", conf.Timeout) assert.Equal(t, "./logs", conf.LogDir) diff --git a/config/root_config.go b/config/root_config.go index 06abcf2848..916cb1cef0 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -6,7 +6,6 @@ import ( ) import ( - "github.com/creasty/defaults" "github.com/go-playground/validator/v10" "github.com/pkg/errors" ) @@ -105,43 +104,43 @@ func (rc *RootConfig) Init() { } // GetApplicationConfig get applicationConfig config -func GetApplicationConfig() (*ApplicationConfig, error) { - if err := check(); err != nil { - return nil, err - } - if applicationConfig != nil { - return applicationConfig, nil - } - applicationConfig = getApplicationConfig(rootConfig.Application) - if err := defaults.Set(applicationConfig); err != nil { - return nil, err - } - - if err := verify(applicationConfig); err != nil { - return nil, err - } - - return applicationConfig, nil -} +//func GetApplicationConfig() (*ApplicationConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// if applicationConfig != nil { +// return applicationConfig, nil +// } +// applicationConfig = getApplicationConfig(rootConfig.Application) +// if err := defaults.Set(applicationConfig); err != nil { +// return nil, err +// } +// +// if err := verify(applicationConfig); err != nil { +// return nil, err +// } +// +// return applicationConfig, nil +//} // GetConfigCenterConfig get config center config -func GetConfigCenterConfig() (*CenterConfig, error) { - if err := check(); err != nil { - return nil, err - } - conf := rootConfig.ConfigCenter - if conf == nil { - return nil, errors.New("config center config is null") - } - if err := defaults.Set(conf); err != nil { - return nil, err - } - conf.translateConfigAddress() - if err := verify(conf); err != nil { - return nil, err - } - return conf, nil -} +//func GetConfigCenterConfig() (*CenterConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// conf := rootConfig.ConfigCenter +// if conf == nil { +// return nil, errors.New("config center config is null") +// } +// if err := defaults.Set(conf); err != nil { +// return nil, err +// } +// conf.translateConfigAddress() +// if err := verify(conf); err != nil { +// return nil, err +// } +// return conf, nil +//} // GetRegistriesConfig get registry config default zookeeper registry //func GetRegistriesConfig() (map[string]*RegistryConfig, error) { diff --git a/config/testdata/config/center/confApplication.yaml b/config/testdata/config/center/confApplication.yaml deleted file mode 100644 index 497bcd339f..0000000000 --- a/config/testdata/config/center/confApplication.yaml +++ /dev/null @@ -1,6 +0,0 @@ -dubbo: - configCenter: - address: nacos://127.0.0.1:8848 - cluster: dev - namespace: dubbo - logDir: ./logs \ No newline at end of file diff --git a/config/testdata/config/center/conf_application.yaml b/config/testdata/config/center/conf_application.yaml deleted file mode 100644 index dd086b1adf..0000000000 --- a/config/testdata/config/center/conf_application.yaml +++ /dev/null @@ -1,6 +0,0 @@ -dubbo: - config_center: - address: nacos://127.0.0.1:8848 - cluster: dev - namespace: dubbo - logDir: ./logs \ No newline at end of file From 6118ef2ae83e67e667c7124e1c1f709441bb3d68 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 03:05:30 +0800 Subject: [PATCH 020/148] =?UTF-8?q?=E6=B7=BB=E5=8A=A0registry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/testdata/config/center/conf-application.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/testdata/config/center/conf-application.yaml b/config/testdata/config/center/conf-application.yaml index b14f356d70..bc0a93f0f1 100644 --- a/config/testdata/config/center/conf-application.yaml +++ b/config/testdata/config/center/conf-application.yaml @@ -1,4 +1,9 @@ dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 config-center: address: nacos://127.0.0.1:8848 cluster: dev From aba8707026a5f34817afb242d385cc36b7d7916d Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 12:21:41 +0800 Subject: [PATCH 021/148] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_loader.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 4fe70a178d..c69d2412db 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -66,9 +66,7 @@ func Load(opts ...LoaderConfOption) { //parseCommandLine() // conf conf := NewLoaderConf(opts...) - for _, opt := range opts { - opt.apply(conf) - } + rootConfig = new(RootConfig) viper = getKoanf(conf) From e4af3899aabab087e7374a8436f64b9b3185382a Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 31 Jul 2021 17:49:40 +0800 Subject: [PATCH 022/148] fix: make new config struct runnable --- common/rpc_service.go | 4 +- config/application_config.go | 20 +- config/config_api.go | 3 +- config/config_center_config.go | 27 +- config/config_loader.go | 166 +++-- config/config_loader_test.go | 22 +- config/config_utils.go | 42 ++ config/consumer_config.go | 171 ++++- config/graceful_shutdown_test.go | 1 + config/metadata_report_config.go | 40 +- config/protocol_config.go | 33 +- config/provider_config.go | 137 +++- config/reference_config.go | 588 ++++++++++-------- config/registry_config.go | 66 +- config/root_config.go | 192 +++--- config/service_config.go | 196 +++++- config_center/apollo/impl_test.go | 5 +- go.mod | 3 - go.sum | 8 - .../service/exporter/configurable/exporter.go | 6 +- .../exporter/configurable/exporter_test.go | 91 ++- protocol/dubbo3/internal/server.go | 3 +- protocol/grpc/client.go | 6 +- protocol/grpc/grpc_protocol_test.go | 52 +- protocol/grpc/server.go | 2 +- protocol/jsonrpc/jsonrpc_protocol_test.go | 3 +- protocol/rest/rest_invoker_test.go | 3 +- protocol/rest/rest_protocol_test.go | 6 +- registry/directory/directory.go | 5 +- registry/directory/directory_test.go | 8 +- registry/etcdv3/service_discovery.go | 4 +- registry/etcdv3/service_discovery_test.go | 10 +- registry/file/service_discovery.go | 2 +- registry/file/service_discovery_test.go | 2 +- registry/nacos/service_discovery.go | 4 +- registry/nacos/service_discovery_test.go | 10 +- registry/protocol/protocol.go | 7 +- registry/protocol/protocol_test.go | 16 +- .../service_discovery_registry.go | 2 +- .../service_discovery_registry_test.go | 2 +- registry/zookeeper/service_discovery.go | 4 +- registry/zookeeper/service_discovery_test.go | 8 +- 42 files changed, 1210 insertions(+), 770 deletions(-) diff --git a/common/rpc_service.go b/common/rpc_service.go index 9970f61011..1bca7d9a58 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -37,8 +37,8 @@ import ( // RPCService // rpc service interface type RPCService interface { - // Name rpc service id - Name() string + //// Name rpc service id + //Name() string // Reference rpc service reference Reference() string } diff --git a/config/application_config.go b/config/application_config.go index 98ef9bb0c6..55981a4749 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -34,16 +34,22 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` } +func NewApplicationConfig() *ApplicationConfig { + return &ApplicationConfig{} +} + // Prefix dubbo.applicationConfig func (ApplicationConfig) Prefix() string { return constant.DUBBO + ".applicationConfig" } -// getApplicationConfig get applicationConfig config -func getApplicationConfig(application *ApplicationConfig) *ApplicationConfig { - if application == nil { - application = new(ApplicationConfig) - } - defaults.MustSet(application) - return application +func (a *ApplicationConfig) CheckConfig() error { + // todo check + defaults.MustSet(a) + return verify(a) +} + +func (a *ApplicationConfig) Validate() { + defaults.MustSet(a) + // todo set default application } diff --git a/config/config_api.go b/config/config_api.go index 2ba0cafa46..ebcabd4ab0 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -13,9 +13,10 @@ * 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 + // //import ( // "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" diff --git a/config/config_center_config.go b/config/config_center_config.go index a3ca4a134e..d3c1976569 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -44,7 +44,7 @@ import ( // // CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type CenterConfig struct { - Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty"` + Protocol string `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"` @@ -61,9 +61,15 @@ type CenterConfig struct { Params map[string]string `yaml:"params" json:"parameters,omitempty"` } -// Prefix dubbo.config-center -func (CenterConfig) Prefix() string { - return constant.ConfigCenterPrefix +func (c *CenterConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + c.translateConfigAddress() + return verify(c) +} + +func (c *CenterConfig) Validate() { + // todo set default application } // UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function @@ -75,19 +81,6 @@ func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return unmarshal((*plain)(c)) } -// getConfigCenterConfig get config center config -func getConfigCenterConfig(c *CenterConfig) *CenterConfig { - if c == nil { - return c - } - defaults.MustSet(c) - c.translateConfigAddress() - if err := verify(c); err != nil { - panic(err) - } - return c -} - // GetUrlMap gets url map from ConfigCenterConfig func (c *CenterConfig) GetUrlMap() url.Values { urlMap := url.Values{} diff --git a/config/config_loader.go b/config/config_loader.go index 4fe70a178d..634eb22a29 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,11 +18,11 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common" "errors" "fmt" ) import ( - "github.com/go-playground/validator/v10" "github.com/knadh/koanf" "github.com/knadh/koanf/parsers/json" "github.com/knadh/koanf/parsers/toml" @@ -35,9 +35,6 @@ import ( ) var ( - viper *koanf.Koanf - validate *validator.Validate - rootConfig *RootConfig //consumerConfig *consumer.ShutdownConfig @@ -50,17 +47,9 @@ var ( //// it should be used combine with double-check to avoid the race condition //configAccessMutex sync.Mutex // - //maxWait = 3 - //confRouterFile string - //confBaseFile string - //uniformVirtualServiceConfigPath string - //uniformDestRuleConfigPath string + maxWait = 3 ) -func init() { - validate = validator.New() -} - func Load(opts ...LoaderConfOption) { // pares CommandLine //parseCommandLine() @@ -69,8 +58,10 @@ func Load(opts ...LoaderConfOption) { for _, opt := range opts { opt.apply(conf) } - rootConfig = new(RootConfig) - viper = getKoanf(conf) + + // init config + rootConfig = NewRootConfig() + viper := getKoanf(conf) if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { panic(err) @@ -78,15 +69,20 @@ func Load(opts ...LoaderConfOption) { if rootConfig.ConfigCenter != nil { //监听远程配置刷新本地指定配置 } - rootConfig.Init() - - if err := verify(rootConfig); err != nil { + if err := rootConfig.CheckConfig(); err != nil { panic(err) } + rootConfig.Validate() + // root config init finish + + // todo why this line + //extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) + rootConfig.Provider.Load() + rootConfig.Consumer.Load() } func check() error { - if viper == nil || rootConfig == nil { + if rootConfig == nil { return errors.New("execute the config.Load() method first") } return nil @@ -497,51 +493,55 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // shutdown.GracefulShutdownInit() //} // -//// GetRPCService get rpc service for consumer -//func GetRPCService(name string) common.RPCService { -// return consumerConfig.References[name].GetRPCService() -//} -// -//// RPCService create rpc service for consumer -//func RPCService(service common.RPCService) { -// consumerConfig.References[service.Reference()].Implement(service) -//} -// -//// GetMetricConfig find the MetricConfig -//// if it is nil, create a new one -//// we use double-check to reduce race condition -//// In general, it will be locked 0 or 1 time. -//// So you don't need to worry about the race condition -//func GetMetricConfig() *metric.MetricConfig { -// if GetBaseConfig().MetricConfig == nil { -// configAccessMutex.Lock() -// defer configAccessMutex.Unlock() -// if GetBaseConfig().MetricConfig == nil { -// GetBaseConfig().MetricConfig = &metric.MetricConfig{} -// } -// } -// return GetBaseConfig().MetricConfig -//} -// -//// GetApplicationConfig find the applicationConfig config -//// if not, we will create one -//// Usually applicationConfig will be initialized when system start -//// we use double-check to reduce race condition -//// In general, it will be locked 0 or 1 time. -//// So you don't need to worry about the race condition -//func GetApplicationConfig() *applicationConfig.ShutdownConfig { -// if GetBaseConfig().ApplicationConfig == nil { -// configAccessMutex.Lock() -// defer configAccessMutex.Unlock() -// if GetBaseConfig().ApplicationConfig == nil { -// GetBaseConfig().ApplicationConfig = &applicationConfig.ShutdownConfig{} -// } -// } -// return GetBaseConfig().ApplicationConfig +// GetRPCService get rpc service for consumer +func GetRPCService(name string) common.RPCService { + return rootConfig.Consumer.References[name].GetRPCService() +} + +// RPCService create rpc service for consumer +func RPCService(service common.RPCService) { + rootConfig.Consumer.References[service.Reference()].Implement(service) +} + +// GetMetricConfig find the MetricConfig +// if it is nil, create a new one +// we use double-check to reduce race condition +// In general, it will be locked 0 or 1 time. +// So you don't need to worry about the race condition +func GetMetricConfig() *MetricConfig { + // todo + //if GetBaseConfig().MetricConfig == nil { + // configAccessMutex.Lock() + // defer configAccessMutex.Unlock() + // if GetBaseConfig().MetricConfig == nil { + // GetBaseConfig().MetricConfig = &metric.MetricConfig{} + // } + //} + //return GetBaseConfig().MetricConfig + return rootConfig.MetricConfig +} + +// GetApplicationConfig find the applicationConfig config +// if not, we will create one +// Usually applicationConfig will be initialized when system start +// we use double-check to reduce race condition +// In general, it will be locked 0 or 1 time. +// So you don't need to worry about the race condition +//func GetApplicationConfig() *ShutdownConfig { +// // todo +// //if GetBaseConfig().ApplicationConfig == nil { +// // configAccessMutex.Lock() +// // defer configAccessMutex.Unlock() +// // if GetBaseConfig().ApplicationConfig == nil { +// // GetBaseConfig().ApplicationConfig = &applicationConfig.ShutdownConfig{} +// // } +// //} +// //return GetBaseConfig().ApplicationConfig +// return rootConfig. //} -// -//// GetProviderConfig find the provider config -//// if not found, create new one + +// GetProviderConfig find the provider config +// if not found, create new one //func GetProviderConfig() provider.ProviderConfig { // if providerConfig == nil { // if providerConfig == nil { @@ -550,12 +550,12 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // } // return *providerConfig //} -// -//// GetConsumerConfig find the consumer config -//// if not found, create new one -//// we use double-check to reduce race condition -//// In general, it will be locked 0 or 1 time. -//// So you don't need to worry about the race condition + +// GetConsumerConfig find the consumer config +// if not found, create new one +// we use double-check to reduce race condition +// In general, it will be locked 0 or 1 time. +// So you don't need to worry about the race condition //func GetConsumerConfig() consumer.ShutdownConfig { // if consumerConfig == nil { // if consumerConfig == nil { @@ -564,24 +564,7 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // } // return *consumerConfig //} -// -//func GetBaseConfig() *base.ShutdownConfig { -// if baseConfig == nil { -// configAccessMutex.Lock() -// defer configAccessMutex.Unlock() -// if baseConfig == nil { -// baseConfig = &base.ShutdownConfig{ -// metric.MetricConfig: &metric.MetricConfig{}, -// ConfigCenterConfig: ¢er.ShutdownConfig{}, -// Remotes: make(map[string]*RemoteConfig), -// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{}, -// ServiceDiscoveries: make(map[string]*discovery.ShutdownConfig), -// } -// } -// } -// return baseConfig -//} -// + //func GetSslEnabled() bool { // return sslEnabled //} @@ -589,7 +572,8 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { //func SetSslEnabled(enabled bool) { // sslEnabled = enabled //} -// -//func IsProvider() bool { -// return providerConfig != nil -//} + +func IsProvider() bool { + // FixME + return rootConfig.Provider != nil +} diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 663bdf60f8..a3fade14b8 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -103,16 +103,16 @@ func TestGetRegistriesConfig(t *testing.T) { func TestGetProtocolsConfig(t *testing.T) { - t.Run("empty protocols", func(t *testing.T) { - Load(WithPath("./testdata/config/protocol/empty_application.yaml")) - - protocols := rootConfig.Protocols - assert.NotNil(t, protocols) - // default - assert.Equal(t, "dubbo", protocols["default"].Name) - assert.Equal(t, "127.0.0.1", protocols["default"].Ip) - assert.Equal(t, 0, protocols["default"].Port) - }) + //t.Run("empty protocols", func(t *testing.T) { + // Load(WithPath("./testdata/config/protocol/empty_application.yaml")) + // + // protocols := rootConfig.Protocols + // assert.NotNil(t, protocols) + // // default + // assert.Equal(t, "dubbo", protocols["default"].Name) + // assert.Equal(t, "127.0.0.1", protocols["default"].Ip) + // assert.Equal(t, 0, protocols["default"].Port) + //}) t.Run("protocols", func(t *testing.T) { Load(WithPath("./testdata/config/protocol/application.yaml")) @@ -122,7 +122,7 @@ func TestGetProtocolsConfig(t *testing.T) { // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) - assert.Equal(t, 20000, protocols["dubbo"].Port) + assert.Equal(t, string("20000"), protocols["dubbo"].Port) }) } diff --git a/config/config_utils.go b/config/config_utils.go index 5464502065..868567f6d1 100644 --- a/config/config_utils.go +++ b/config/config_utils.go @@ -19,6 +19,8 @@ package config import ( "fmt" + "github.com/go-playground/validator/v10" + "github.com/pkg/errors" "regexp" "strings" ) @@ -27,6 +29,12 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) +var validate *validator.Validate + +func init() { + validate = validator.New() +} + func mergeValue(str1, str2, def string) string { if str1 == "" && str2 == "" { return def @@ -63,3 +71,37 @@ func removeMinus(strArr []string) string { normalStr = reg.ReplaceAllString(strings.Trim(normalStr, ","), ",") return normalStr } + +// removeDuplicateElement remove duplicate element +func removeDuplicateElement(items []string) []string { + result := make([]string, 0, len(items)) + temp := map[string]struct{}{} + for _, item := range items { + if _, ok := temp[item]; !ok && item != "" { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +} + +// translateRegistryIds string "nacos,zk" => ["nacos","zk"] +func translateRegistryIds(registryIds []string) []string { + ids := make([]string, 0) + for _, id := range registryIds { + ids = append(ids, strings.Split(id, ",")...) + } + return removeDuplicateElement(ids) +} + +func verify(s interface{}) error { + if err := validate.Struct(s); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil +} diff --git a/config/consumer_config.go b/config/consumer_config.go index 9e8396b183..163f9469d3 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -18,6 +18,9 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config/generic" + "fmt" "time" ) @@ -42,19 +45,26 @@ type ConsumerConfig struct { Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` ConnectTimeout time.Duration - Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + //Registries map[string]*RegistryConfig `default:"{}" yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` RequestTimeout time.Duration ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` - References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + + rootConfig *RootConfig +} + +// Prefix dubbo.consumer +func (ConsumerConfig) Prefix() string { + return constant.ConsumerConfigPrefix } // UnmarshalYAML unmarshal the ConsumerConfig by @unmarshal function @@ -66,15 +76,83 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// Prefix dubbo.consumer -func (ConsumerConfig) Prefix() string { - return constant.ConsumerConfigPrefix +func (c *ConsumerConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *ConsumerConfig) Validate(rootConfig *RootConfig) { + for k, _ := range c.References { + c.References[k].Validate(rootConfig) + } + c.rootConfig = rootConfig + // todo set default application +} + +func (c *ConsumerConfig) Load() { + for key, ref := range c.References { + if ref.Generic { + genericService := generic.NewGenericService(key) + SetConsumerService(genericService) + } + rpcService := GetConsumerService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue + } + ref.id = key + ref.Refer(rpcService) + ref.Implement(rpcService) + } + + // todo Write current configuration to cache file. + //if c.CacheFile != "" { + // if data, err := yaml.MarshalYML(c); err != nil { + // logger.Errorf("Marshal consumer config err: %s", err.Error()) + // } else { + // if err := ioutil.WriteFile(c.CacheFile, data, 0666); err != nil { + // logger.Errorf("Write consumer config cache file err: %s", err.Error()) + // } + // } + //} + + // wait for invoker is available, if wait over default 3s, then panic + var count int + for { + checkok := true + for _, refconfig := range c.References { + if (refconfig.Check != nil && *refconfig.Check) || + (refconfig.Check == nil && c.Check != nil && *c.Check) || + (refconfig.Check == nil && c.Check == nil) { // default to true + + if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { + checkok = false + count++ + if count > maxWait { + errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) + logger.Error(errMsg) + panic(errMsg) + } + time.Sleep(time.Second * 1) + break + } + if refconfig.invoker == nil { + logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) + } + } + } + if checkok { + break + } + } + } // SetConsumerConfig sets consumerConfig by @c -//func SetConsumerConfig(c ShutdownConfig) { -// config.consumerConfig = &c -//} +func SetConsumerConfig(c ConsumerConfig) { + rootConfig.Consumer = &c +} // ConsumerInit loads config file to init consumer config func ConsumerInit(confConFile string) error { @@ -137,3 +215,70 @@ func configCenterRefreshConsumer() error { //} return nil } + +///////////////////////////////////// consumer config api +// ConsumerConfigOpt is the options to init ConsumerConfig +type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig + +// NewEmptyConsumerConfig returns default ConsumerConfig +// with connection timeout = 3s, request timeout = 3s +func NewEmptyConsumerConfig() *ConsumerConfig { + check := true + newConsumerConfig := &ConsumerConfig{ + //Registries: make(map[string]*RegistryConfig, 8), + References: make(map[string]*ReferenceConfig, 8), + ConnectTimeout: 3 * time.Second, + RequestTimeout: 3 * time.Second, + Check: &check, + } + return newConsumerConfig +} + +// NewConsumerConfig returns ConsumerConfig with @opts +func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { + newConfig := NewEmptyConsumerConfig() + for _, v := range opts { + v(newConfig) + } + return newConfig +} + +// WithRootConfig returns ConsumerConfigOpt with given @rootConfig +func WithRootConfig(rootConfig *RootConfig) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.rootConfig = rootConfig + return config + } +} + +// WithConsumerReferenceConfig returns ConsumerConfigOpt with +func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.References[referenceKey] = refConfig + return config + } +} + +// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout +func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.ConnectTimeout = timeout + return config + } +} + +// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout +func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.RequestTimeout = timeout + return config + } +} + +// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag +func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + *config.Check = check + return config + } +} diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go index 494f647c39..825ba7e27f 100644 --- a/config/graceful_shutdown_test.go +++ b/config/graceful_shutdown_test.go @@ -16,6 +16,7 @@ */ package config + // //import ( // "dubbo.apache.org/dubbo-go/v3/config" diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 8118be90e2..6b59e210d7 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -24,21 +24,17 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/config/instance" ) -// MetadataReportConfig is method level configuration +// MetadataReportConfig is app level configuration type MetadataReportConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - RemoteRef string `required:"true" yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` -} - -// Prefix dubbo.metadata-report -func (MetadataReportConfig) Prefix() string { - return constant.MetadataReportPrefix + Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` + Address string `required:"true" yaml:"address" json:"address"` + Username string `yaml:"username" json:"username,omitempty"` + Password string `yaml:"password" json:"password,omitempty"` + Timeout string `yaml:"timeout" json:"timeout,omitempty"` + Group string `yaml:"group" json:"group,omitempty"` } // UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function @@ -53,6 +49,17 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) return nil } +func (c *MetadataReportConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *MetadataReportConfig) Validate() { + + // todo set default application +} + // nolint func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { //urlMap := make(url.Values) @@ -88,14 +95,15 @@ func (c *MetadataReportConfig) IsValid() bool { } // StartMetadataReport: The entry of metadata report start -func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { +func (c *MetadataReportConfig) StartMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { if metadataReportConfig == nil || !metadataReportConfig.IsValid() { return nil } - - if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.RemoteRef) == 0 { - return perrors.New("MetadataConfig remote ref can not be empty.") - } + // todo + // + //if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.RemoteRef) == 0 { + // return perrors.New("MetadataConfig remote ref can not be empty.") + //} if tmpUrl, err := metadataReportConfig.ToUrl(); err == nil { instance.GetMetadataReportInstance(tmpUrl) diff --git a/config/protocol_config.go b/config/protocol_config.go index 763939e604..cddfdd746c 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -18,7 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "github.com/creasty/defaults" ) @@ -26,34 +25,16 @@ import ( type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` + Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } -// Prefix dubbo.protocols -func (ProtocolConfig) Prefix() string { - return constant.ProtocolConfigPrefix +func (p *ProtocolConfig) CheckConfig() error { + // todo check + defaults.MustSet(p) + return verify(p) } -// getProtocolsConfig get protocols config default protocol -func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*ProtocolConfig { - if protocols == nil || len(protocols) <= 0 { - conf := new(ProtocolConfig) - protocols = make(map[string]*ProtocolConfig, 1) - defaults.MustSet(conf) - protocols[constant.DUBBO] = conf - } - return protocols -} +func (p *ProtocolConfig) Validate() { -//loadProtocol filter protocols by ids -func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { - returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) - for _, v := range protocolIds { - for k, protocol := range protocols { - if v == k { - returnProtocols = append(returnProtocols, protocol) - } - } - } - return returnProtocols + // todo set default application } diff --git a/config/provider_config.go b/config/provider_config.go index 28b1fe9417..ea9a518479 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -18,6 +18,8 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "fmt" "github.com/creasty/defaults" ) @@ -37,63 +39,94 @@ type ProviderConfig struct { // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` - //Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - //ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - //FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - //ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` + Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` +} + +func (c *ProviderConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *ProviderConfig) Validate(r *RootConfig) { + ids := make([]string, 0) + for key := range r.Registries { + ids = append(ids, key) + } + c.Registry = removeDuplicateElement(ids) + for k, _ := range c.Services { + c.Services[k].Validate(r) + } + // todo set default application } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (pc *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(pc); err != nil { +func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { return err } type plain ProviderConfig - return unmarshal((*plain)(pc)) + return unmarshal((*plain)(c)) } // Prefix dubbo.provider -func (*ProviderConfig) Prefix() string { +func (c *ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } -// getProviderConfig get provider config -func getProviderConfig(provider *ProviderConfig) *ProviderConfig { - if provider == nil { - provider = new(ProviderConfig) - } - provider.Register = len(proServices) > 0 +func (c *ProviderConfig) Load() { + // todo Write the current configuration to cache file. + //if c.CacheFile != "" { + // if data, err := yaml.MarshalYML(providerConfig); err != nil { + // logger.Errorf("Marshal provider config err: %s", err.Error()) + // } else { + // if err := ioutil.WriteFile(provider CacheFile, data, 0666); err != nil { + // logger.Errorf("Write provider config cache file err: %s", err.Error()) + // } + // } + //} - if provider.Registry == nil || len(provider.Registry) <= 0 { - provider.Registry = getRegistryIds() + for key, svs := range c.Services { + rpcService := GetProviderService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue + } + svs.id = key + svs.Implement(rpcService) + if err := svs.Export(); err != nil { + panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) + } } - provider.Registry = translateRegistryIds(provider.Registry) - return provider } -//// SetProviderConfig sets provider config by @p -//func SetProviderConfig(p ProviderConfig) { -// config.providerConfig = &p -//} +// SetProviderConfig sets provider config by @p +func SetProviderConfig(p ProviderConfig) { + rootConfig.Provider = &p +} + // //// ProviderInit loads config file to init provider config //func ProviderInit(confProFile string) error { // if len(confProFile) == 0 { // return perrors.Errorf("applicationConfig configure(provider) file name is nil") // } -// config.providerConfig = &ProviderConfig{} -// fileStream, err := yaml.UnmarshalYMLConfig(confProFile, config.providerConfig) +// providerConfig = &ProviderConfig{} +// fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) // if err != nil { // return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) // } // -// config.providerConfig.fileStream = bytes.NewBuffer(fileStream) +// provider fileStream = bytes.NewBuffer(fileStream) // // set method interfaceId & interfaceName -// for k, v := range config.providerConfig.Services { +// for k, v := range provider Services { // // set id for reference -// for _, n := range config.providerConfig.Services[k].Methods { +// for _, n := range provider Services[k].Methods { // n.InterfaceName = v.InterfaceName // n.InterfaceId = k // } @@ -104,12 +137,50 @@ func getProviderConfig(provider *ProviderConfig) *ProviderConfig { // //func configCenterRefreshProvider() error { // // fresh it -// if config.providerConfig.ConfigCenterConfig != nil { -// config.providerConfig.fatherConfig = config.providerConfig -// if err := config.providerConfig.startConfigCenter((*config.providerConfig).BaseConfig); err != nil { +// if provider ConfigCenterConfig != nil { +// provider fatherConfig = providerConfig +// if err := provider startConfigCenter((* providerConfig).BaseConfig); err != nil { // return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) // } -// config.providerConfig.fresh() +// provider fresh() // } // return nil //} + +///////////////////////////////////// provider config api +// ProviderConfigOpt is the +type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig + +// NewEmptyProviderConfig returns ProviderConfig with default ApplicationConfig +func NewEmptyProviderConfig() *ProviderConfig { + newProviderConfig := &ProviderConfig{ + Services: make(map[string]*ServiceConfig), + Registry: make([]string, 8), + } + return newProviderConfig +} + +// NewProviderConfig returns ProviderConfig with given @opts +func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { + newConfig := NewEmptyProviderConfig() + for _, v := range opts { + v(newConfig) + } + return newConfig +} + +// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig +func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { + return func(config *ProviderConfig) *ProviderConfig { + config.Services[serviceName] = serviceConfig + return config + } +} + +// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig +func WithProviderRegistry(registryKey ...string) ProviderConfigOpt { + return func(config *ProviderConfig) *ProviderConfig { + config.Registry = append(config.Registry, registryKey...) + return config + } +} diff --git a/config/reference_config.go b/config/reference_config.go index 6cc2e40625..0e911b1e5d 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -18,9 +18,20 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "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/proxy" + "dubbo.apache.org/dubbo-go/v3/config/generic" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" + "fmt" + "github.com/creasty/defaults" + gxstrings "github.com/dubbogo/gost/strings" + "net/url" + "strconv" + "time" ) // ReferenceConfig is the configuration of service consumer @@ -30,262 +41,341 @@ type ReferenceConfig struct { InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` URL string `yaml:"url" json:"url,omitempty" property:"url"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` - Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` - Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` - Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` - ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` - Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` - Async bool `yaml:"async" json:"async,omitempty" property:"async"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` + Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` + Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Version string `yaml:"version" json:"version,omitempty" property:"version"` + Serialization string `yaml:"serialization" json:"serialization" property:"serialization"` + ProvidedBy string `yaml:"provided_by" json:"provided_by,omitempty" property:"provided_by"` + Methods []*MethodConfig `yaml:"methods" json:"methods,omitempty" property:"methods"` + Async bool `yaml:"async" json:"async,omitempty" property:"async"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` invoker protocol.Invoker urls []*common.URL Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` Sticky bool `yaml:"sticky" json:"sticky,omitempty" property:"sticky"` RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` + + rootConfig *RootConfig +} + +// nolint +func (c *ReferenceConfig) Prefix() string { + return constant.ReferenceConfigPrefix + c.InterfaceName + "." +} + +// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function +func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + type rf ReferenceConfig + raw := rf{} // Put your defaults here + if err := unmarshal(&raw); err != nil { + return err + } + + *c = ReferenceConfig(raw) + return defaults.Set(c) +} + +func (c *ReferenceConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) } -//// nolint -//func (c *ReferenceConfig) Prefix() string { -// return constant.ReferenceConfigPrefix + c.InterfaceName + "." -//} -// -//// NewReferenceConfig The only way to get a new ReferenceConfig -//func NewReferenceConfig(id string) *ReferenceConfig { -// return &ReferenceConfig{id: id} -//} -// -//// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function -//func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { -// type rf ReferenceConfig -// raw := rf{} // Put your defaults here -// if err := unmarshal(&raw); err != nil { -// return err -// } -// -// *c = ReferenceConfig(raw) -// return defaults.Set(c) -//} +func (c *ReferenceConfig) Validate(rootConfig *RootConfig) { + c.rootConfig = rootConfig + // todo set default application +} // Refer ... -//func (c *ReferenceConfig) Refer(_ interface{}) { -// cfgURL := common.NewURLWithOptions( -// common.WithPath(c.InterfaceName), -// common.WithProtocol(c.Protocol), -// common.WithParams(c.getURLMap()), -// common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), -// ) -// if c.ForceTag { -// cfgURL.AddParam(constant.ForceUseTag, "true") -// } -// c.postProcessConfig(cfgURL) -// if c.URL != "" { -// // 1. user specified URL, could be peer-to-peer address, or register center's address. -// urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*") -// for _, urlStr := range urlStrings { -// serviceURL, err := common.NewURL(urlStr) -// if err != nil { -// panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) -// } -// if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { -// serviceURL.SubURL = cfgURL -// c.urls = append(c.urls, serviceURL) -// } else { -// if serviceURL.Path == "" { -// serviceURL.Path = "/" + c.InterfaceName -// } -// // merge url need to do -// newURL := common.MergeURL(serviceURL, cfgURL) -// c.urls = append(c.urls, newURL) -// } -// } -// } else { -// // 2. assemble SubURL from register center's configuration mode -// c.urls = registry.loadRegistries(c.Registry, config.consumerConfig.Registries, common.CONSUMER) -// -// // set url to regURLs -// for _, regURL := range c.urls { -// regURL.SubURL = cfgURL -// } -// } -// -// if len(c.urls) == 1 { -// c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) -// // c.URL != "" is direct call -// if c.URL != "" { -// //filter -// c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY) -// -// // cluster -// invokers := make([]protocol.Invoker, 0, len(c.urls)) -// invokers = append(invokers, c.invoker) -// // TODO(decouple from directory, config should not depend on directory module) -// var hitClu string -// // not a registry url, must be direct invoke. -// hitClu = constant.FAILOVER_CLUSTER_NAME -// if len(invokers) > 0 { -// u := invokers[0].GetURL() -// if nil != &u { -// hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) -// } -// } -// -// cluster := extension.GetCluster(hitClu) -// // If 'zone-aware' policy select, the invoker wrap sequence would be: -// // ZoneAwareClusterInvoker(StaticDirectory) -> -// // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker -// c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) -// } -// } else { -// invokers := make([]protocol.Invoker, 0, len(c.urls)) -// var regURL *common.URL -// for _, u := range c.urls { -// invoker := extension.GetProtocol(u.Protocol).Refer(u) -// // c.URL != "" is direct call -// if c.URL != "" { -// //filter -// invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) -// } -// invokers = append(invokers, invoker) -// if u.Protocol == constant.REGISTRY_PROTOCOL { -// regURL = u -// } -// } -// -// // TODO(decouple from directory, config should not depend on directory module) -// var hitClu string -// if regURL != nil { -// // for multi-subscription scenario, use 'zone-aware' policy by default -// hitClu = constant.ZONEAWARE_CLUSTER_NAME -// } else { -// // not a registry url, must be direct invoke. -// hitClu = constant.FAILOVER_CLUSTER_NAME -// if len(invokers) > 0 { -// u := invokers[0].GetURL() -// if nil != &u { -// hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) -// } -// } -// } -// -// cluster := extension.GetCluster(hitClu) -// // If 'zone-aware' policy select, the invoker wrap sequence would be: -// // ZoneAwareClusterInvoker(StaticDirectory) -> -// // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker -// c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) -// } -// // publish consumer metadata -// publishConsumerDefinition(cfgURL) -// // create proxy -// if c.Async { -// callback := instance.GetCallback(c.id) -// c.pxy = extension.GetProxyFactory(config.consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) -// } else { -// c.pxy = extension.GetProxyFactory(config.consumerConfig.ProxyFactory).GetProxy(c.invoker, cfgURL) -// } -//} -// -//// Implement -//// @v is service provider implemented RPCService -//func (c *ReferenceConfig) Implement(v common.RPCService) { -// c.pxy.Implement(v) -//} -// -//// GetRPCService gets RPCService from proxy -//func (c *ReferenceConfig) GetRPCService() common.RPCService { -// return c.pxy.Get() -//} -// -//// GetProxy gets proxy -//func (c *ReferenceConfig) GetProxy() *proxy.Proxy { -// return c.pxy -//} -// -//func (c *ReferenceConfig) getURLMap() url.Values { -// urlMap := url.Values{} -// // first set user params -// for k, v := range c.Params { -// urlMap.Set(k, v) -// } -// urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) -// urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) -// urlMap.Set(constant.CLUSTER_KEY, c.Cluster) -// urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) -// urlMap.Set(constant.RETRIES_KEY, c.Retries) -// urlMap.Set(constant.GROUP_KEY, c.Group) -// urlMap.Set(constant.VERSION_KEY, c.Version) -// urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(c.Generic)) -// urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) -// urlMap.Set(constant.PROVIDED_BY, c.ProvidedBy) -// urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) -// -// urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) -// urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) -// -// if len(c.RequestTimeout) != 0 { -// urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout) -// } -// // getty invoke async or sync -// urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) -// urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) -// -// // applicationConfig info -// urlMap.Set(constant.APPLICATION_KEY, config.consumerConfig.ApplicationConfig.Name) -// urlMap.Set(constant.ORGANIZATION_KEY, config.consumerConfig.ApplicationConfig.Organization) -// urlMap.Set(constant.NAME_KEY, config.consumerConfig.ApplicationConfig.Name) -// urlMap.Set(constant.MODULE_KEY, config.consumerConfig.ApplicationConfig.Module) -// urlMap.Set(constant.APP_VERSION_KEY, config.consumerConfig.ApplicationConfig.Version) -// urlMap.Set(constant.OWNER_KEY, config.consumerConfig.ApplicationConfig.Owner) -// urlMap.Set(constant.ENVIRONMENT_KEY, config.consumerConfig.ApplicationConfig.Environment) -// -// // filter -// defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS -// if c.Generic { -// defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter -// } -// urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) -// -// for _, v := range c.Methods { -// urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) -// urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) -// urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky)) -// if len(v.RequestTimeout) != 0 { -// urlMap.Set("methods."+v.Name+"."+constant.TIMEOUT_KEY, v.RequestTimeout) -// } -// } -// -// return urlMap -//} -// -//// GenericLoad ... -//func (c *ReferenceConfig) GenericLoad(id string) { -// genericService := generic.NewGenericService(c.id) -// instance.SetConsumerService(genericService) -// c.id = id -// c.Refer(genericService) -// c.Implement(genericService) -//} -// -//// GetInvoker get invoker from ReferenceConfig -//func (c *ReferenceConfig) GetInvoker() protocol.Invoker { -// return c.invoker -//} -// -//func publishConsumerDefinition(url *common.URL) { -// if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { -// remoteMetadataService.PublishServiceDefinition(url) -// } -//} -// -//// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. -//func (c *ReferenceConfig) postProcessConfig(url *common.URL) { -// for _, p := range extension.GetConfigPostProcessors() { -// p.PostProcessReferenceConfig(url) -// } -//} +func (c *ReferenceConfig) Refer(_ interface{}) { + cfgURL := common.NewURLWithOptions( + common.WithPath(c.InterfaceName), + common.WithProtocol(c.Protocol), + common.WithParams(c.getURLMap()), + common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), + ) + if c.ForceTag { + cfgURL.AddParam(constant.ForceUseTag, "true") + } + c.postProcessConfig(cfgURL) + if c.URL != "" { + // 1. user specified URL, could be peer-to-peer address, or register center's address. + urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*") + for _, urlStr := range urlStrings { + serviceURL, err := common.NewURL(urlStr) + if err != nil { + panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) + } + if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { + serviceURL.SubURL = cfgURL + c.urls = append(c.urls, serviceURL) + } else { + if serviceURL.Path == "" { + serviceURL.Path = "/" + c.InterfaceName + } + // merge url need to do + newURL := common.MergeURL(serviceURL, cfgURL) + c.urls = append(c.urls, newURL) + } + } + } else { + // 2. assemble SubURL from register center's configuration mode + c.urls = loadRegistries(c.Registry, c.rootConfig.Registries, common.CONSUMER) + + // set url to regURLs + for _, regURL := range c.urls { + regURL.SubURL = cfgURL + } + } + + if len(c.urls) == 1 { + c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) + // c.URL != "" is direct call + if c.URL != "" { + //filter + c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY) + + // cluster + invokers := make([]protocol.Invoker, 0, len(c.urls)) + invokers = append(invokers, c.invoker) + // TODO(decouple from directory, config should not depend on directory module) + var hitClu string + // not a registry url, must be direct invoke. + hitClu = constant.FAILOVER_CLUSTER_NAME + if len(invokers) > 0 { + u := invokers[0].GetURL() + if nil != &u { + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) + } + } + + cluster := extension.GetCluster(hitClu) + // If 'zone-aware' policy select, the invoker wrap sequence would be: + // ZoneAwareClusterInvoker(StaticDirectory) -> + // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker + c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + } + } else { + invokers := make([]protocol.Invoker, 0, len(c.urls)) + var regURL *common.URL + for _, u := range c.urls { + invoker := extension.GetProtocol(u.Protocol).Refer(u) + // c.URL != "" is direct call + if c.URL != "" { + //filter + invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) + } + invokers = append(invokers, invoker) + if u.Protocol == constant.REGISTRY_PROTOCOL { + regURL = u + } + } + + // TODO(decouple from directory, config should not depend on directory module) + var hitClu string + if regURL != nil { + // for multi-subscription scenario, use 'zone-aware' policy by default + hitClu = constant.ZONEAWARE_CLUSTER_NAME + } else { + // not a registry url, must be direct invoke. + hitClu = constant.FAILOVER_CLUSTER_NAME + if len(invokers) > 0 { + u := invokers[0].GetURL() + if nil != &u { + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) + } + } + } + + cluster := extension.GetCluster(hitClu) + // If 'zone-aware' policy select, the invoker wrap sequence would be: + // ZoneAwareClusterInvoker(StaticDirectory) -> + // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker + c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + } + // publish consumer metadata + publishConsumerDefinition(cfgURL) + // create proxy + if c.Async { + callback := GetCallback(c.id) + c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) + } else { + c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetProxy(c.invoker, cfgURL) + } +} + +// Implement +// @v is service provider implemented RPCService +func (c *ReferenceConfig) Implement(v common.RPCService) { + c.pxy.Implement(v) +} + +// GetRPCService gets RPCService from proxy +func (c *ReferenceConfig) GetRPCService() common.RPCService { + return c.pxy.Get() +} + +// GetProxy gets proxy +func (c *ReferenceConfig) GetProxy() *proxy.Proxy { + return c.pxy +} + +func (c *ReferenceConfig) getURLMap() url.Values { + urlMap := url.Values{} + // first set user params + for k, v := range c.Params { + urlMap.Set(k, v) + } + urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) + urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) + urlMap.Set(constant.CLUSTER_KEY, c.Cluster) + urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) + urlMap.Set(constant.RETRIES_KEY, c.Retries) + urlMap.Set(constant.GROUP_KEY, c.Group) + urlMap.Set(constant.VERSION_KEY, c.Version) + urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(c.Generic)) + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) + urlMap.Set(constant.PROVIDED_BY, c.ProvidedBy) + urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) + + urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) + urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) + + if len(c.RequestTimeout) != 0 { + urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout) + } + // getty invoke async or sync + urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) + urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) + + // applicationConfig info + urlMap.Set(constant.APPLICATION_KEY, c.rootConfig.Application.Name) + urlMap.Set(constant.ORGANIZATION_KEY, c.rootConfig.Application.Organization) + urlMap.Set(constant.NAME_KEY, c.rootConfig.Application.Name) + urlMap.Set(constant.MODULE_KEY, c.rootConfig.Application.Module) + urlMap.Set(constant.APP_VERSION_KEY, c.rootConfig.Application.Version) + urlMap.Set(constant.OWNER_KEY, c.rootConfig.Application.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, c.rootConfig.Application.Environment) + + // filter + defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS + if c.Generic { + defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter + } + //urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) + + for _, v := range c.Methods { + urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) + urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) + urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky)) + if len(v.RequestTimeout) != 0 { + urlMap.Set("methods."+v.Name+"."+constant.TIMEOUT_KEY, v.RequestTimeout) + } + } + + return urlMap +} + +// GenericLoad ... +func (c *ReferenceConfig) GenericLoad(id string) { + genericService := generic.NewGenericService(c.id) + SetConsumerService(genericService) + c.id = id + c.Refer(genericService) + c.Implement(genericService) +} + +// GetInvoker get invoker from ReferenceConfig +func (c *ReferenceConfig) GetInvoker() protocol.Invoker { + return c.invoker +} + +func publishConsumerDefinition(url *common.URL) { + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { + remoteMetadataService.PublishServiceDefinition(url) + } +} + +// postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. +func (c *ReferenceConfig) postProcessConfig(url *common.URL) { + for _, p := range extension.GetConfigPostProcessors() { + p.PostProcessReferenceConfig(url) + } +} + +//////////////////////////////////// reference config api + +// ReferenceConfigOpt is consumer's reference config +type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig + +// NewReferenceConfig The only way to get a new ReferenceConfig +func NewReferenceConfigWithID(id string) *ReferenceConfig { + return &ReferenceConfig{id: id} +} + +// NewEmptyReferenceConfig returns empty ReferenceConfig +func NewEmptyReferenceConfig() *ReferenceConfig { + newReferenceConfig := NewReferenceConfigWithID("") + newReferenceConfig.Methods = make([]*MethodConfig, 0, 8) + newReferenceConfig.Params = make(map[string]string, 8) + return newReferenceConfig +} + +// NewReferenceConfig returns ReferenceConfig with given @opts +func NewReferenceConfig(opts ...ReferenceConfigOpt) *ReferenceConfig { + newReferenceConfig := NewEmptyReferenceConfig() + for _, v := range opts { + v(newReferenceConfig) + } + return newReferenceConfig +} + +// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry +func WithReferenceRegistry(registry ...string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Registry = registry + return config + } +} + +// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol +func WithReferenceProtocol(protocol string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Protocol = protocol + return config + } +} + +// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName +func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.InterfaceName = interfaceName + return config + } +} + +// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster +func WithReferenceCluster(cluster string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Cluster = cluster + return config + } +} + +// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb +func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Methods = append(config.Methods, &MethodConfig{ + Name: methodName, + Retries: retries, + LoadBalance: lb, + }) + return config + } +} diff --git a/config/registry_config.go b/config/registry_config.go index 0ea910b217..9b01aec870 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -54,15 +54,15 @@ type RegistryConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*RegistryConfig { - for _, reg := range registries { - defaults.MustSet(reg) - reg.translateRegistryAddress() - if err := verify(reg); err != nil { - panic(err) - } - } - return registries +func (c *RegistryConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + c.translateRegistryAddress() + return verify(c) +} + +func (c *RegistryConfig) Validate() { + // todo set default application } // UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function @@ -79,54 +79,6 @@ func (RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix } -func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { - var urls []*common.URL - //trSlice := strings.Split(targetRegistries, ",") - - for k, registryConf := range registries { - target := false - - // if user not config targetRegistries, default load all - // Notice: in func "func Split(s, sep string) []string" comment: - // if s does not contain sep and sep is not empty, SplitAfter returns - // a slice of length 1 whose only element is s. So we have to add the - // condition when targetRegistries string is not set (it will be "" when not set) - if len(registryIds) == 0 || (len(registryIds) == 1 && registryIds[0] == "") { - target = true - } else { - // else if user config targetRegistries - for _, tr := range registryIds { - if tr == k { - target = true - break - } - } - } - - if target { - addresses := strings.Split(registryConf.Address, ",") - address := addresses[0] - address = registryConf.translateRegistryAddress() - url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, - common.WithParams(registryConf.getUrlMap(roleType)), - common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), - common.WithUsername(registryConf.Username), - common.WithPassword(registryConf.Password), - common.WithLocation(registryConf.Address), - ) - - if err != nil { - logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) - panic(err) - } else { - urls = append(urls, url) - } - } - } - - return urls -} - func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { urlMap := url.Values{} urlMap.Set(constant.GROUP_KEY, c.Group) diff --git a/config/root_config.go b/config/root_config.go index 916cb1cef0..e86f6b9f02 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -2,26 +2,8 @@ package config import ( "bytes" - "strings" -) - -import ( - "github.com/go-playground/validator/v10" - "github.com/pkg/errors" -) - -import ( "dubbo.apache.org/dubbo-go/v3/common/constant" -) - -var ( - applicationConfig *ApplicationConfig - - consumerConfig *ConsumerConfig - - providerConfig *ProviderConfig - - registriesConfig map[string]*RegistryConfig + "github.com/creasty/defaults" ) // RootConfig is the root config @@ -29,7 +11,7 @@ type RootConfig struct { ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` // since 1.5.0 version - //Remotes map[string]*config.RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` @@ -46,6 +28,9 @@ type RootConfig struct { // provider config Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` + // consumer config + Consumer *ConsumerConfig `yaml:"consumer" json:"consumer" property:"consumer"` + // prefix string fatherConfig interface{} EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` @@ -56,72 +41,127 @@ type RootConfig struct { CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` } +func init() { + rootConfig = NewRootConfig() +} + +func SetRootConfig(r RootConfig) { + rootConfig = &r +} + +func NewRootConfig() *RootConfig { + return &RootConfig{ + ConfigCenter: &CenterConfig{}, + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReportConfig: &MetadataReportConfig{}, + Application: &ApplicationConfig{}, + Registries: make(map[string]*RegistryConfig), + Protocols: make(map[string]*ProtocolConfig), + Provider: NewProviderConfig(), + Consumer: NewConsumerConfig(), + MetricConfig: &MetricConfig{}, + } +} + // Prefix dubbo func (RootConfig) Prefix() string { return constant.DUBBO } -func verify(s interface{}) error { +func (rc *RootConfig) CheckConfig() error { + defaults.MustSet(rc) + + if err := rc.Application.CheckConfig(); err != nil { + return err + } - if err := validate.Struct(s); err != nil { - errs := err.(validator.ValidationErrors) - var slice []string - for _, msg := range errs { - slice = append(slice, msg.Error()) + for k, _ := range rc.Registries { + if err := rc.Registries[k].CheckConfig(); err != nil { + return err } - return errors.New(strings.Join(slice, ",")) } - return nil -} -// removeDuplicateElement remove duplicate element -func removeDuplicateElement(items []string) []string { - result := make([]string, 0, len(items)) - temp := map[string]struct{}{} - for _, item := range items { - if _, ok := temp[item]; !ok && item != "" { - temp[item] = struct{}{} - result = append(result, item) + for k, _ := range rc.Protocols { + if err := rc.Protocols[k].CheckConfig(); err != nil { + return err } } - return result + + if err := rc.ConfigCenter.CheckConfig(); err != nil { + return err + } + + if err := rc.MetadataReportConfig.CheckConfig(); err != nil { + return err + } + + if err := rc.Provider.CheckConfig(); err != nil { + return err + } + + if err := rc.Consumer.CheckConfig(); err != nil { + return err + } + + return verify(rootConfig) } -// translateRegistryIds string "nacos,zk" => ["nacos","zk"] -func translateRegistryIds(registryIds []string) []string { - ids := make([]string, 0) - for _, id := range registryIds { - ids = append(ids, strings.Split(id, ",")...) +func (rc *RootConfig) Validate() { + // 2. validate config + rc.Application.Validate() + + for k, _ := range rc.Registries { + rc.Registries[k].Validate() } - return removeDuplicateElement(ids) + + for k, _ := range rc.Protocols { + rc.Protocols[k].Validate() + } + + for k, _ := range rc.Registries { + rc.Registries[k].Validate() + } + + rc.ConfigCenter.Validate() + rc.MetadataReportConfig.Validate() + rc.Provider.Validate(rc) + rc.Consumer.Validate(rc) } -func (rc *RootConfig) Init() { - rc.Application = getApplicationConfig(rc.Application) - rc.Protocols = getProtocolsConfig(rc.Protocols) - rc.Registries = getRegistriesConfig(rc.Registries) - rc.ConfigCenter = getConfigCenterConfig(rc.ConfigCenter) +//GetApplicationConfig get applicationConfig config +func GetApplicationConfig() *ApplicationConfig { + if err := check(); err != nil { + return NewApplicationConfig() + } + if rootConfig.Application != nil { + return rootConfig.Application + } + return NewApplicationConfig() } -// GetApplicationConfig get applicationConfig config -//func GetApplicationConfig() (*ApplicationConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// if applicationConfig != nil { -// return applicationConfig, nil -// } -// applicationConfig = getApplicationConfig(rootConfig.Application) -// if err := defaults.Set(applicationConfig); err != nil { -// return nil, err -// } -// -// if err := verify(applicationConfig); err != nil { -// return nil, err -// } -// -// return applicationConfig, nil -//} +func GetRootConfig() *RootConfig { + return rootConfig +} + +func GetProviderConfig() *ProviderConfig { + if err := check(); err != nil { + return NewProviderConfig() + } + if rootConfig.Provider != nil { + return rootConfig.Provider + } + return NewProviderConfig() +} + +func GetConsumerConfig() *ConsumerConfig { + if err := check(); err != nil { + return NewConsumerConfig() + } + if rootConfig.Consumer != nil { + return rootConfig.Consumer + } + return NewConsumerConfig() +} // GetConfigCenterConfig get config center config //func GetConfigCenterConfig() (*CenterConfig, error) { @@ -205,11 +245,11 @@ func (rc *RootConfig) Init() { // return provider, nil //} -// getRegistryIds get registry keys -func getRegistryIds() []string { - ids := make([]string, 0) - for key := range rootConfig.Registries { - ids = append(ids, key) - } - return removeDuplicateElement(ids) -} +//// getRegistryIds get registry keys +//func getRegistryIds() []string { +// ids := make([]string, 0) +// for key := range rootConfig.Registries { +// ids = append(ids, key) +// } +// return removeDuplicateElement(ids) +//} diff --git a/config/service_config.go b/config/service_config.go index add72400ce..16dc30b0dd 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -83,6 +83,8 @@ type ServiceConfig struct { exportersLock sync.Mutex exporters []protocol.Exporter + + rootConfig *RootConfig } // Prefix returns dubbo.service.${InterfaceName}. @@ -105,14 +107,18 @@ func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } -// NewServiceConfig The only way to get a new ServiceConfig -func NewServiceConfig(id string) *ServiceConfig { - return &ServiceConfig{ - id: id, - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, - } +func (c *ServiceConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *ServiceConfig) Validate(rootConfig *RootConfig) { + c.rootConfig = rootConfig + c.exported = atomic.NewBool(false) + c.unexported = atomic.NewBool(false) + c.export = true + // todo set default application } //getRegistryServices get registry services @@ -194,9 +200,9 @@ func (c *ServiceConfig) Export() error { return nil } - regUrls := loadRegistries(c.Registry, registriesConfig, common.PROVIDER) + regUrls := loadRegistries(c.Registry, c.rootConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() - protocolConfigs := loadProtocol(c.Protocol, c.Protocols) + protocolConfigs := loadProtocol(c.Protocol, c.rootConfig.Protocols) if len(protocolConfigs) == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.Interface, c.Protocol) return nil @@ -204,7 +210,7 @@ func (c *ServiceConfig) Export() error { ports := getRandomPort(protocolConfigs) nextPort := ports.Front() - proxyFactory := extension.GetProxyFactory(providerConfig.ProxyFactory) + proxyFactory := extension.GetProxyFactory(c.rootConfig.Provider.ProxyFactory) for _, proto := range protocolConfigs { // registry the service reflect methods, err := common.ServiceMap.Register(c.Interface, proto.Name, c.Group, c.Version, c.rpcService) @@ -280,6 +286,67 @@ func (c *ServiceConfig) Export() error { return nil } +//loadProtocol filter protocols by ids +func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { + returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) + for _, v := range protocolIds { + for k, protocol := range protocols { + if v == k { + returnProtocols = append(returnProtocols, protocol) + } + } + } + return returnProtocols +} + +func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { + var urls []*common.URL + //trSlice := strings.Split(targetRegistries, ",") + + for k, registryConf := range registries { + target := false + + // if user not config targetRegistries, default load all + // Notice: in func "func Split(s, sep string) []string" comment: + // if s does not contain sep and sep is not empty, SplitAfter returns + // a slice of length 1 whose only element is s. So we have to add the + // condition when targetRegistries string is not set (it will be "" when not set) + if len(registryIds) == 0 || (len(registryIds) == 1 && registryIds[0] == "") { + target = true + } else { + // else if user config targetRegistries + for _, tr := range registryIds { + if tr == k { + target = true + break + } + } + } + + if target { + addresses := strings.Split(registryConf.Address, ",") + address := addresses[0] + address = registryConf.translateRegistryAddress() + url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, + common.WithParams(registryConf.getUrlMap(roleType)), + common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), + common.WithUsername(registryConf.Username), + common.WithPassword(registryConf.Password), + common.WithLocation(registryConf.Address), + ) + + if err != nil { + logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) + panic(err) + } else { + urls = append(urls, url) + } + } + } + + return urls +} + // Unexport will call unexport of all exporters service config exported func (c *ServiceConfig) Unexport() { if !c.exported.Load() { @@ -328,16 +395,16 @@ func (c *ServiceConfig) getUrlMap() url.Values { // todo: move urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) // application config info - urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) - urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) - urlMap.Set(constant.NAME_KEY, applicationConfig.Name) - urlMap.Set(constant.MODULE_KEY, applicationConfig.Module) - urlMap.Set(constant.APP_VERSION_KEY, applicationConfig.Version) - urlMap.Set(constant.OWNER_KEY, applicationConfig.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) + //urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) + //urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) + //urlMap.Set(constant.NAME_KEY, applicationConfig.Name) + //urlMap.Set(constant.MODULE_KEY, applicationConfig.Module) + //urlMap.Set(constant.APP_VERSION_KEY, applicationConfig.Version) + //urlMap.Set(constant.OWNER_KEY, applicationConfig.Owner) + //urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) // filter - urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) + urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(c.rootConfig.Provider.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) // filter special config urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) @@ -401,3 +468,94 @@ func (c *ServiceConfig) postProcessConfig(url *common.URL) { p.PostProcessServiceConfig(url) } } + +// NewServiceConfig The only way to get a new ServiceConfig +func NewServiceConfig(id string) *ServiceConfig { + return &ServiceConfig{ + id: id, + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + } +} + +// ServiceConfigOpt is the option to init ServiceConfig +type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig + +// NewDefaultServiceConfig returns default ServiceConfig +func NewDefaultServiceConfig() *ServiceConfig { + newServiceConfig := NewServiceConfig("") + newServiceConfig.Params = make(map[string]string) + newServiceConfig.Methods = make([]*MethodConfig, 0, 8) + return newServiceConfig +} + +// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared +// NewServiceConfigByAPI returns ServiceConfig with given @opts +func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig { + defaultServiceConfig := NewDefaultServiceConfig() + for _, v := range opts { + v(defaultServiceConfig) + } + return defaultServiceConfig +} + +// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry +func WithServiceRegistry(registry string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Registry = append(config.Registry, registry) + return config + } +} + +// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol +func WithServiceProtocol(protocol string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Protocol = append(config.Protocol, protocol) + return config + } +} + +// WithServiceInterface returns ServiceConfigOpt with given @interfaceName +func WithServiceInterface(interfaceName string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Interface = interfaceName + return config + } +} + +// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb +func WithServiceLoadBalance(lb string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Loadbalance = lb + return config + } +} + +// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time +func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Warmup = warmUp + return config + } +} + +// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster +func WithServiceCluster(cluster string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Cluster = cluster + return config + } +} + +// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb +func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Methods = append(config.Methods, &MethodConfig{ + Name: name, + Retries: retries, + LoadBalance: lb, + }) + return config + } +} diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index fc8c64163d..02cc5475d7 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -18,7 +18,6 @@ package apollo import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/base" "fmt" "net/http" "net/http/httptest" @@ -185,7 +184,7 @@ func TestGetConfigItem(t *testing.T) { } func initMockApollo(t *testing.T) *apolloConfiguration { - c := &base.Config{ConfigCenterConfig: &config.CenterConfig{ + c := &config.RootConfig{ConfigCenter: &config.CenterConfig{ Protocol: "apollo", Address: "106.12.25.204:8080", AppID: "testApplication_yang", @@ -194,7 +193,7 @@ func initMockApollo(t *testing.T) *apolloConfiguration { }} apollo := initApollo() apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo") - url, err := common.NewURL(apolloUrl, common.WithParams(c.ConfigCenterConfig.GetUrlMap())) + url, err := common.NewURL(apolloUrl, common.WithParams(c.ConfigCenter.GetUrlMap())) assert.NoError(t, err) configuration, err := newApolloConfiguration(url) assert.NoError(t, err) diff --git a/go.mod b/go.mod index 4c8378182c..1fa906227c 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 - github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 @@ -36,8 +35,6 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.9.0 github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.7.1 // indirect github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 diff --git a/go.sum b/go.sum index b3fa53949e..5411fce5c6 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,6 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDH github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-getty v1.4.4 h1:pthYQaCXyjHJ6/SjVwKkX5NhdAqSpUrRL1Z9GowrLdE= -github.com/apache/dubbo-getty v1.4.4/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= @@ -130,7 +128,6 @@ 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.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -209,7 +206,6 @@ github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8c github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA= github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= @@ -227,8 +223,6 @@ github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5 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/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9 h1:wqckanyE9qc/XnvnybC6SHOb8Nyd62QXAZOzA8twFig= -github.com/goinggo/mapstructure v0.0.0-20140717182941-194205d9b4a9/go.mod h1:64ikIrMv84B+raz7akXOqbF7cK3/OQQ/6cClY10oy7A= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -458,7 +452,6 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -506,7 +499,6 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 562ca7002c..d6b4ebe7cf 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -49,7 +49,7 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { serviceConfig := config.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) - serviceConfig.Protocol = constant.DEFAULT_PROTOCOL + serviceConfig.Protocol = []string{constant.DEFAULT_PROTOCOL} if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") } @@ -59,8 +59,8 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { Port: url.SubURL.Port, }, } - serviceConfig.Registry = "N/A" - serviceConfig.InterfaceName = constant.METADATA_SERVICE_NAME + serviceConfig.Registry = []string{"N/A"} + serviceConfig.Interface = constant.METADATA_SERVICE_NAME // identify this is a golang server serviceConfig.Params = map[string]string{} diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 8e7a35290b..f94aa12624 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -19,8 +19,6 @@ package configurable import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" ) @@ -80,49 +78,22 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &config.ProviderConfig{ - - BaseConfig: base.Config{ - ApplicationConfig: &config.ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "1.0.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &config.RegistryConfig{ - Address: "mock://127.0.0.1:2181", - Username: "user1", - Password: "pwd1", + providerConfig := &config.ProviderConfig{} + providerConfig.Services["MockService"].InitExported() + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{ + Organization: "dubbo_org", + Name: "dubbo", + Module: "module", + Version: "1.0.0", + Owner: "dubbo", + Environment: "test", }, - Registries: map[string]*config.RegistryConfig{}, - - Services: map[string]*config.ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*config.MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, + Registries: map[string]*config.RegistryConfig{ + "mock": { + Address: "mock://127.0.0.1:2181", + Username: "user1", + Password: "pwd1", }, }, Protocols: map[string]*config.ProtocolConfig{ @@ -132,7 +103,33 @@ func mockInitProviderWithSingleRegistry() { Port: "20000", }, }, - } - providerConfig.Services["MockService"].InitExported() - provider.SetProviderConfig(*providerConfig) + + Provider: &config.ProviderConfig{ + Services: map[string]*config.ServiceConfig{ + "MockService": { + Interface: "com.MockService", + Protocol: []string{"mock"}, + Cluster: "failover", + Loadbalance: "random", + Retries: "3", + Group: "huadong_idc", + Version: "1.0.0", + Methods: []*config.MethodConfig{ + { + Name: "GetUser", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, + { + Name: "GetUser1", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, + }, + }, + }, + }, + }) } diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index d23d62cfd9..5761aca16d 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -19,7 +19,6 @@ package internal import ( "context" - "dubbo.apache.org/dubbo-go/v3/config/provider" "log" ) @@ -57,7 +56,7 @@ func InitDubboServer() { config.WithServiceCluster("failover"), )), ) - provider.SetProviderConfig(*providerConfig) // set to providerConfig ptr + config.SetProviderConfig(*providerConfig) // set to providerConfig ptr config.SetProviderService(&Server{ GreeterProviderBase: &GreeterProviderBase{}, diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 66208c828a..84d812dfe2 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -39,8 +39,8 @@ import ( var clientConf *ClientConfig func init() { - // load clientconfig from consumer_config - consumerConfig := config.GetConsumerConfig() + // load rootConfig from runtime + rootConfig := config.GetRootConfig() clientConfig := GetClientConfig() clientConf = &clientConfig @@ -56,7 +56,7 @@ func init() { } }() - if consumerConfig.ApplicationConfig == nil { + if rootConfig.Application == nil { return } protocolConf := config.GetConsumerConfig().ProtocolConf diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 8ac4c8c0fe..d5ac9ff374 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -19,8 +19,6 @@ package grpc import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" ) @@ -36,37 +34,37 @@ import ( ) func doInitProvider() { - providerConfig := config.ProviderConfig{ - BaseConfig: base.Config{ - ApplicationConfig: &config.ApplicationConfig{ - Organization: "dubbo_org", - Name: "BDTService", - Module: "module", - Version: "0.0.1", - Owner: "dubbo", - Environment: "test", - }, + rootConfig := config.RootConfig{ + Application: &config.ApplicationConfig{ + Organization: "dubbo_org", + Name: "BDTService", + Module: "module", + Version: "0.0.1", + Owner: "dubbo", + Environment: "test", }, - Services: map[string]*config.ServiceConfig{ - "GrpcGreeterImpl": { - InterfaceName: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", - Protocol: "grpc", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Methods: []*config.MethodConfig{ - { - Name: "SayHello", - Retries: "2", - LoadBalance: "random", - Weight: 200, + Provider: &config.ProviderConfig{ + Services: map[string]*config.ServiceConfig{ + "GrpcGreeterImpl": { + Interface: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", + Protocol: []string{"grpc"}, + Registry: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, + Cluster: "failover", + Loadbalance: "random", + Retries: "3", + Methods: []*config.MethodConfig{ + { + Name: "SayHello", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, }, }, }, }, } - provider.SetProviderConfig(providerConfig) + config.SetRootConfig(rootConfig) } func TestGrpcProtocolExport(t *testing.T) { diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index e068999447..e077cd7cad 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -144,7 +144,7 @@ func registerService(providerServices map[string]*config.ServiceConfig, server * panic("illegal service type registered") } - serviceKey := common.ServiceKey(providerService.InterfaceName, providerService.Group, providerService.Version) + serviceKey := common.ServiceKey(providerService.Interface, providerService.Group, providerService.Version) exporter, _ := grpcProtocol.ExporterMap().Load(serviceKey) if exporter == nil { panic(fmt.Sprintf("no exporter found for servicekey: %v", serviceKey)) diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 78c0988811..365e6363ac 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -19,7 +19,6 @@ package jsonrpc import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/consumer" "fmt" "strings" "testing" @@ -79,7 +78,7 @@ func TestJsonrpcProtocolRefer(t *testing.T) { ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } - consumer.SetConsumerConfig(con) + config.SetConsumerConfig(con) invoker := proto.Refer(url) // make sure url diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index c3bbd8d87b..e666fbc3c7 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -20,7 +20,6 @@ package rest import ( "context" "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" ) @@ -69,7 +68,7 @@ func TestRestInvokerInvoke(t *testing.T) { _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) con := config.ProviderConfig{} - provider.SetProviderConfig(con) + config.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index b9f945149d..c28f9c54ae 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -20,8 +20,6 @@ package rest import ( "context" "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/consumer" - "dubbo.apache.org/dubbo-go/v3/config/provider" "errors" "fmt" "strings" @@ -49,7 +47,7 @@ func TestRestProtocolRefer(t *testing.T) { ConnectTimeout: 5 * time.Second, RequestTimeout: 5 * time.Second, } - consumer.SetConsumerConfig(con) + config.SetConsumerConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ Client: "resty", @@ -77,7 +75,7 @@ func TestRestProtocolExport(t *testing.T) { _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) assert.NoError(t, err) con := config.ProviderConfig{} - provider.SetProviderConfig(con) + config.SetProviderConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 17ec5649e5..5b42cc964f 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -486,10 +486,7 @@ type consumerConfigurationListener struct { func newConsumerConfigurationListener(dir *RegistryDirectory) *consumerConfigurationListener { listener := &consumerConfigurationListener{directory: dir} - application, err := config.GetApplicationConfig() - if err != nil { - panic(err) - } + application := config.GetApplicationConfig() listener.InitWith( application.Name+constant.CONFIGURATORS_SUFFIX, listener, diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 01cf2b59c7..e74125302d 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -19,8 +19,6 @@ package directory import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/consumer" "strconv" "testing" "time" @@ -42,10 +40,8 @@ import ( ) func init() { - consumer.SetConsumerConfig(config.ConsumerConfig{ - BaseConfig: base.Config{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }, + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, }) } diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index c90633d165..416d2af701 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -295,12 +295,12 @@ func newEtcdV3ServiceDiscovery(name string) (registry.ServiceDiscovery, error) { initLock.Lock() defer initLock.Unlock() - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the etcd service instance because the config is invalid") } - remoteConfig, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/etcdv3/service_discovery_test.go b/registry/etcdv3/service_discovery_test.go index 704297f95a..ba82330c14 100644 --- a/registry/etcdv3/service_discovery_test.go +++ b/registry/etcdv3/service_discovery_test.go @@ -34,12 +34,12 @@ import ( var testName = "test" func setUp() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "etcdv3", RemoteRef: testName, } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: "localhost:2379", TimeoutStr: "10s", } @@ -52,18 +52,18 @@ func Test_newEtcdV3ServiceDiscovery(t *testing.T) { // warn: log configure file name is nil assert.NotNil(t, err) - sdc := &config.ServiceConfig{ + sdc := &config.ServiceDiscoveryConfig{ Protocol: "etcdv3", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newEtcdV3ServiceDiscovery(name) // RemoteConfig not found assert.NotNil(t, err) - config.GetBaseConfig().Remotes["mock"] = &config.RemoteConfig{ + config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ Address: "localhost:2379", TimeoutStr: "10s", } diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index b6c7a319ec..562fece8ca 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -56,7 +56,7 @@ type fileSystemServiceDiscovery struct { } func newFileSystemServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || sdc.Protocol != constant.FILE_KEY { return nil, perrors.New("could not init the instance because the config is invalid") } diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index e1c8d3047c..39e70a010f 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -87,7 +87,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "file", } } diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 174bf0bc82..e801521b72 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -321,12 +321,12 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { return instance, nil } - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the instance because the config is invalid") } - rc, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + rc, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 381f4679ce..ff769cab11 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -49,18 +49,18 @@ func Test_newNacosServiceDiscovery(t *testing.T) { // the ShutdownConfig not found assert.NotNil(t, err) - sdc := &config.ServiceConfig{ + sdc := &config.ServiceDiscoveryConfig{ Protocol: "nacos", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newNacosServiceDiscovery(name) // RemoteConfig not found assert.NotNil(t, err) - config.GetBaseConfig().Remotes["mock"] = &config.RemoteConfig{ + config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ Address: "console.nacos.io:80", TimeoutStr: "10s", } @@ -178,12 +178,12 @@ func TestNacosServiceDiscovery_Destroy(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "nacos", RemoteRef: testName, } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: "console.nacos.io:80", TimeoutStr: "10s", } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 25204e6bb7..686a7913f2 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -254,8 +254,9 @@ func registerServiceMap(invoker protocol.Invoker) error { return perrors.New(s) } - _, err := common.ServiceMap.Register(serviceConfig.InterfaceName, - serviceConfig.Protocol, serviceConfig.Group, + _, err := common.ServiceMap.Register(serviceConfig.Interface, + // FIXME + serviceConfig.Protocol[0], serviceConfig.Group, serviceConfig.Version, rpcService) if err != nil { s := "reExport can not re register ServiceMap. Error message is " + err.Error() @@ -456,7 +457,7 @@ func newProviderConfigurationListener(overrideListeners *sync.Map) *providerConf listener := &providerConfigurationListener{} listener.overrideListeners = overrideListeners listener.InitWith( - config.GetProviderConfig().ApplicationConfig.Name+constant.CONFIGURATORS_SUFFIX, + config.GetApplicationConfig().Name+constant.CONFIGURATORS_SUFFIX, listener, extension.GetDefaultConfiguratorFunc(), ) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 13e47c19f1..03d3f4db15 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -19,9 +19,6 @@ package protocol import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config/base" - "dubbo.apache.org/dubbo-go/v3/config/consumer" - "dubbo.apache.org/dubbo-go/v3/config/provider" "testing" "time" ) @@ -46,9 +43,9 @@ import ( ) func init() { - provider.SetProviderConfig(config.ProviderConfig{BaseConfig: base.Config{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }}) + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, + }) } func referNormal(t *testing.T, regProtocol *registryProtocol) { @@ -71,10 +68,9 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { } func TestRefer(t *testing.T) { - consumer.SetConsumerConfig( - config.ConsumerConfig{BaseConfig: base.Config{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }}) + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, + }) regProtocol := newRegistryProtocol() referNormal(t, regProtocol) } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 1feb8f1555..1f3fcc29ed 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -126,7 +126,7 @@ func (s *serviceDiscoveryRegistry) UnSubscribe(url *common.URL, listener registr func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { sdcName := url.GetParam(constant.SERVICE_DISCOVERY_KEY, "") - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(sdcName) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[sdcName] if !ok { return nil, perrors.Errorf("The service discovery with name: %s is not found", sdcName) } diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index 580f9aaa4e..a265ad50fc 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -63,7 +63,7 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { }) extension.SetAndInitGlobalDispatcher("mock") - config.GetBaseConfig().ServiceDiscoveries["mock"] = &config.ServiceConfig{ + config.GetRootConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ Protocol: "mock", } registryURL, _ := common.NewURL("service-discovery://localhost:12345", diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index b2a966d3ba..93534675af 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -89,11 +89,11 @@ func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error return instance, nil } - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the instance because the config is invalid") } - remoteConfig, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index 3042bf1dff..7520457ac6 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -53,12 +53,12 @@ func prepareData(t *testing.T) *zk.TestCluster { address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) //address := "127.0.0.1:2181" - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "zookeeper", RemoteRef: "test", } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: address, TimeoutStr: "10s", } @@ -73,11 +73,11 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) { // err: could not init the instance because the config is invalid assert.NotNil(t, err) - sdc := &config.ServiceConfig{ + sdc := &config.ServiceDiscoveryConfig{ Protocol: "zookeeper", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newZookeeperServiceDiscovery(name) // RemoteConfig not found From bb43b9f34f6bcec74973d3ca7149190f5ac3fd64 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 19:10:47 +0800 Subject: [PATCH 023/148] =?UTF-8?q?up:=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application_config.go | 4 ++-- config/config_loader_test.go | 4 ++++ config/service_config.go | 4 ++-- config/testdata/config/app/application.yaml | 24 +++++++++++++++---- .../testdata/config/service/hello_service.go | 8 ++----- .../testdata/config/service/order_service.go | 8 ++----- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 55981a4749..741c44f86d 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -24,7 +24,7 @@ import ( // ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer type ApplicationConfig struct { - Organization string `default:"dubbo.io" yaml:"organization" json:"organization,omitempty" property:"organization"` + Organization string `default:"dubbo-go" yaml:"organization" json:"organization,omitempty" property:"organization"` Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"` Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"` Version string `default:"0.0.1" yaml:"version" json:"version,omitempty" property:"version"` @@ -40,7 +40,7 @@ func NewApplicationConfig() *ApplicationConfig { // Prefix dubbo.applicationConfig func (ApplicationConfig) Prefix() string { - return constant.DUBBO + ".applicationConfig" + return constant.DUBBO + ".application" } func (a *ApplicationConfig) CheckConfig() error { diff --git a/config/config_loader_test.go b/config/config_loader_test.go index a3fade14b8..d973757a70 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -141,6 +141,10 @@ func TestGetProviderConfig(t *testing.T) { }) } +func TestRootConfig(t *testing.T) { + Load(WithPath("./testdata/config/app/application.yaml")) +} + // //func TestLoadWithSingleReg(t *testing.T) { // reference.doInitConsumerWithSingleRegistry() diff --git a/config/service_config.go b/config/service_config.go index 16dc30b0dd..ebc723f159 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -290,9 +290,9 @@ func (c *ServiceConfig) Export() error { func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) for _, v := range protocolIds { - for k, protocol := range protocols { + for k, config := range protocols { if v == k { - returnProtocols = append(returnProtocols, protocol) + returnProtocols = append(returnProtocols, config) } } } diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml index 9c7e6c873f..f083988823 100644 --- a/config/testdata/config/app/application.yaml +++ b/config/testdata/config/app/application.yaml @@ -1,6 +1,20 @@ dubbo: - application: - name: dubbo-go - module: local - version: 1.0.0 - owner: zhaoyunxing \ No newline at end of file + registries: + nacos: + timeout: 3s + address: zookeeper://127.0.0.1:2182 + protocols: + dubbo: + name: dubbo + port: 20000 + consumer: + references: + helloService: + protocol: dubbo + interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java + provider: + register: true + services: + helloService: + protocol: dubbo + interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java \ No newline at end of file diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go index ff0726c998..a4dff89bca 100644 --- a/config/testdata/config/service/hello_service.go +++ b/config/testdata/config/service/hello_service.go @@ -9,10 +9,6 @@ type HelloService struct { Say func(ctx context.Context, req []interface{}) error } -func (HelloService) Name() string { - return "helloService" -} - func (HelloService) Reference() string { - return "org.github.dubbo.HelloService" -} + return "helloService" +} \ No newline at end of file diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go index 07a256b0e0..8c03c794ae 100644 --- a/config/testdata/config/service/order_service.go +++ b/config/testdata/config/service/order_service.go @@ -9,10 +9,6 @@ type OrderService struct { GetOrders func(ctx context.Context, req []interface{}) error } -func (OrderService) Name() string { - return "orderService" -} - func (OrderService) Reference() string { - return "org.github.dubbo.OrderService" -} + return "orderService" +} \ No newline at end of file From 48c615d0c5f5b83ab06a01e42aebc878dd28ebab Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 19:49:10 +0800 Subject: [PATCH 024/148] =?UTF-8?q?add:=E4=BF=AE=E6=94=B9=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_loader.go | 1 + config/consumer_config.go | 36 ++++++++++++++++-------------------- config/root_config.go | 2 +- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 8ce1455a41..850693cedb 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -70,6 +70,7 @@ func Load(opts ...LoaderConfOption) { panic(err) } rootConfig.Validate() + // root config init finish // todo why this line diff --git a/config/consumer_config.go b/config/consumer_config.go index 163f9469d3..794e25a010 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -38,24 +38,20 @@ const ( // ConsumerConfig is Consumer default configuration type ConsumerConfig struct { - //root.RootConfig `yaml:",inline" property:"base"` - //center.ConsumerConfig `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // client - Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` - ConnectTimeout time.Duration - + ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` + // support string Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` - //Registries map[string]*RegistryConfig `default:"{}" yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` - Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` - RequestTimeout time.Duration - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Check *bool `yaml:"check" json:"check,omitempty" property:"check"` + RequestTimeout string `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"` + ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` + Check bool `default:"true" yaml:"check" json:"check,omitempty" property:"check"` - References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` + // ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol-conf,omitempty" property:"protocol-conf"` + // FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` @@ -123,8 +119,8 @@ func (c *ConsumerConfig) Load() { checkok := true for _, refconfig := range c.References { if (refconfig.Check != nil && *refconfig.Check) || - (refconfig.Check == nil && c.Check != nil && *c.Check) || - (refconfig.Check == nil && c.Check == nil) { // default to true + (refconfig.Check == nil && c.Check) || + (refconfig.Check == nil) { // default to true if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { checkok = false @@ -223,13 +219,13 @@ type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig // NewEmptyConsumerConfig returns default ConsumerConfig // with connection timeout = 3s, request timeout = 3s func NewEmptyConsumerConfig() *ConsumerConfig { - check := true + newConsumerConfig := &ConsumerConfig{ //Registries: make(map[string]*RegistryConfig, 8), References: make(map[string]*ReferenceConfig, 8), - ConnectTimeout: 3 * time.Second, - RequestTimeout: 3 * time.Second, - Check: &check, + ConnectTimeout: "3s", + RequestTimeout: "3s", + Check: true, } return newConsumerConfig } @@ -278,7 +274,7 @@ func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { // WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { return func(config *ConsumerConfig) *ConsumerConfig { - *config.Check = check + config.Check = check return config } } diff --git a/config/root_config.go b/config/root_config.go index e86f6b9f02..5b1928fba2 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -15,7 +15,7 @@ type RootConfig struct { ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` - MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` + MetadataReportConfig *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` // Application applicationConfig config Application *ApplicationConfig `validate:"required" yaml:"application" json:"application,omitempty" property:"application"` From e291fc1396783b9fa345821be5104627a0e83a76 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sat, 31 Jul 2021 23:09:36 +0800 Subject: [PATCH 025/148] add config --- config/application_config.go | 11 +++++ config/config_center_config.go | 28 ++++++----- config/config_loader.go | 20 ++++---- config/consumer_config.go | 4 +- config/logger_config.go | 4 ++ config/network_config.go | 4 ++ config/protocol_config.go | 18 +++++++ config/registry_config.go | 14 ++++++ config/root_config.go | 55 ++++++++++++++++++++- config/router_config.go | 3 ++ config/testdata/config/app/application.yaml | 1 + 11 files changed, 137 insertions(+), 25 deletions(-) create mode 100644 config/logger_config.go create mode 100644 config/network_config.go diff --git a/config/application_config.go b/config/application_config.go index 741c44f86d..170fc27ed5 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -34,6 +34,17 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` } +func getApplicationConfig(ac *ApplicationConfig) *ApplicationConfig { + if ac == nil { + ac = new(ApplicationConfig) + } + defaults.MustSet(ac) + if err := verify(ac); err != nil { + panic(err) + } + return ac +} + func NewApplicationConfig() *ApplicationConfig { return &ApplicationConfig{} } diff --git a/config/config_center_config.go b/config/config_center_config.go index d3c1976569..ebfd2ebcfa 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -44,18 +44,23 @@ import ( // // CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type CenterConfig struct { - Protocol string `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"` + Protocol string `yaml:"protocol" json:"protocol,omitempty"` + Address string `yaml:"address" json:"address,omitempty"` + // Deprecated + 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"` + // Deprecated + LogDir string `yaml:"log-dir" json:"log-dir,omitempty"` + // Deprecated + ConfigFile string `default:"dubbo.properties" yaml:"config-file" json:"config-file,omitempty"` + Namespace string `default:"dubbo" yaml:"namespace" json:"namespace,omitempty"` + // Deprecated 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"` - Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"` + // Deprecated + AppID string `default:"dubbo" yaml:"app-id" json:"app-id,omitempty"` + Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"` // Deprecated RemoteRef string `required:"false" yaml:"remote-ref" json:"remote-ref,omitempty"` Params map[string]string `yaml:"params" json:"parameters,omitempty"` @@ -165,6 +170,7 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) error { logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) return errors.WithStack(err) } + //yaml.Unmarshal([]byte(conten),rootConfig) //var appGroup string //var appContent string //if config2.providerConfig != nil && config2.providerConfig.ApplicationConfig != nil && diff --git a/config/config_loader.go b/config/config_loader.go index 850693cedb..016881e50e 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -57,26 +57,26 @@ func Load(opts ...LoaderConfOption) { conf := NewLoaderConf(opts...) // init config - rootConfig = NewRootConfig() + rootConfig = new(RootConfig) viper := getKoanf(conf) if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { panic(err) } - if rootConfig.ConfigCenter != nil { - //监听远程配置刷新本地指定配置 - } - if err := rootConfig.CheckConfig(); err != nil { - panic(err) - } - rootConfig.Validate() + + rootConfig.Init() + + //if err := rootConfig.CheckConfig(); err != nil { + // panic(err) + //} + //rootConfig.Validate() // root config init finish // todo why this line //extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) - rootConfig.Provider.Load() - rootConfig.Consumer.Load() + // rootConfig.Provider.Load() + // rootConfig.Consumer.Load() } func check() error { diff --git a/config/consumer_config.go b/config/consumer_config.go index 794e25a010..b34c06f282 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -256,7 +256,7 @@ func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig } // WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout -func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { +func WithConsumerConnTimeout(timeout string) ConsumerConfigOpt { return func(config *ConsumerConfig) *ConsumerConfig { config.ConnectTimeout = timeout return config @@ -264,7 +264,7 @@ func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { } // WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout -func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { +func WithConsumerRequestTimeout(timeout string) ConsumerConfigOpt { return func(config *ConsumerConfig) *ConsumerConfig { config.RequestTimeout = timeout return config diff --git a/config/logger_config.go b/config/logger_config.go new file mode 100644 index 0000000000..b013388ec4 --- /dev/null +++ b/config/logger_config.go @@ -0,0 +1,4 @@ +package config + +type LoggerConfig struct { +} diff --git a/config/network_config.go b/config/network_config.go new file mode 100644 index 0000000000..bb11f5a452 --- /dev/null +++ b/config/network_config.go @@ -0,0 +1,4 @@ +package config + +type NetworkConfig struct { +} diff --git a/config/protocol_config.go b/config/protocol_config.go index cddfdd746c..f0fa3fbe1d 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -18,6 +18,7 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" "github.com/creasty/defaults" ) @@ -28,6 +29,23 @@ type ProtocolConfig struct { Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } +func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*ProtocolConfig { + if len(protocols) <= 0 { + protocol := new(ProtocolConfig) + protocols = make(map[string]*ProtocolConfig, 1) + protocols[constant.DUBBO] = protocol + return protocols + } + for _, protocol := range protocols { + //protocol.CheckConfig() + //defaults.MustSet(protocol) + if err := protocol.CheckConfig(); err != nil { + panic(err) + } + } + return protocols +} + func (p *ProtocolConfig) CheckConfig() error { // todo check defaults.MustSet(p) diff --git a/config/registry_config.go b/config/registry_config.go index 9b01aec870..6df28f22cf 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -61,6 +61,20 @@ func (c *RegistryConfig) CheckConfig() error { return verify(c) } +func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*RegistryConfig { + if len(registries) <= 0 { + panic("registries mast set") + } + for _, registry := range registries { + defaults.MustSet(registry) + registry.translateRegistryAddress() + if err := verify(registry); err != nil { + panic(err) + } + } + return registries +} + func (c *RegistryConfig) Validate() { // todo set default application } diff --git a/config/root_config.go b/config/root_config.go index 5b1928fba2..c8aec6b15e 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -31,10 +31,20 @@ type RootConfig struct { // consumer config Consumer *ConsumerConfig `yaml:"consumer" json:"consumer" property:"consumer"` + MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty" property:"metrics"` + + // Logger log + Logger *LoggerConfig `yaml:"logger" json:"logger,omitempty" property:"logger"` + + // Shutdown config + Shutdown *ShutdownConfig `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` + + Network *NetworkConfig `yaml:"network" json:"network,omitempty" property:"network"` + + Router *RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` // prefix string fatherConfig interface{} - EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` - MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` + EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` fileStream *bytes.Buffer // cache file used to store the current used configurations. @@ -63,11 +73,52 @@ func NewRootConfig() *RootConfig { } } +type rootConfOption interface { + apply(vc *RootConfig) +} + +type rootConfFunc func(*RootConfig) + +func (fn rootConfFunc) apply(vc *RootConfig) { + fn(vc) +} + // Prefix dubbo func (RootConfig) Prefix() string { return constant.DUBBO } +func (rc *RootConfig) Init(opts ...rootConfOption) { + if rc.ConfigCenter != nil { + //监听远程配置刷新本地指定配置 + // yaml + // 监听文件变化 + } + for _, opt := range opts { + opt.apply(rc) + } + rc.Application = getApplicationConfig(rc.Application) + rc.Protocols = getProtocolsConfig(rc.Protocols) + rc.Registries = getRegistriesConfig(rc.Registries) + + rc.Provider.Load() + rc.Consumer.Load() +} + +//log rout me + +func WithApplication(ac *ApplicationConfig) rootConfFunc { + return rootConfFunc(func(conf *RootConfig) { + conf.Application = ac + }) +} + +func WithProtocols(protocols map[string]*ProtocolConfig) rootConfFunc { + return rootConfFunc(func(conf *RootConfig) { + conf.Protocols = protocols + }) +} + func (rc *RootConfig) CheckConfig() error { defaults.MustSet(rc) diff --git a/config/router_config.go b/config/router_config.go index fd3a838a43..2ef0a77b1c 100644 --- a/config/router_config.go +++ b/config/router_config.go @@ -22,6 +22,9 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/yaml" ) +type RouterConfig struct { + +} // LocalRouterRules defines the local router config structure type LocalRouterRules struct { RouterRules []interface{} `yaml:"routerRules"` diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml index f083988823..2dcb875165 100644 --- a/config/testdata/config/app/application.yaml +++ b/config/testdata/config/app/application.yaml @@ -14,6 +14,7 @@ dubbo: interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java provider: register: true + registry: nacos services: helloService: protocol: dubbo From cf25e75c2246aacfad6d40395872bfc1307f24de Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 00:14:39 +0800 Subject: [PATCH 026/148] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application_config.go | 31 ++-- config/config_loader.go | 27 +-- config/config_loader_test.go | 25 --- config/consumer_config.go | 10 +- config/logger_config.go | 22 +++ config/protocol_config.go | 27 ++- config/protocol_config_test.go | 51 ++++++ config/provider_config.go | 8 + config/registry_config.go | 45 ++--- config/root_config.go | 170 ++++++++++-------- .../testdata/config/protocol/application.yaml | 6 +- 11 files changed, 231 insertions(+), 191 deletions(-) create mode 100644 config/protocol_config_test.go diff --git a/config/application_config.go b/config/application_config.go index 170fc27ed5..6392c26af1 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -34,26 +34,31 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` } -func getApplicationConfig(ac *ApplicationConfig) *ApplicationConfig { - if ac == nil { - ac = new(ApplicationConfig) +// Prefix dubbo.applicationConfig +func (ApplicationConfig) Prefix() string { + return constant.DUBBO + ".application" +} + +func initApplicationConfig(rc *RootConfig) error { + application := rc.Application + if application == nil { + application = new(ApplicationConfig) } - defaults.MustSet(ac) - if err := verify(ac); err != nil { - panic(err) + defaults.MustSet(application) + if err := application.check(); err != nil { + return err } - return ac + rc.Application = application + return nil +} +func (ac *ApplicationConfig) check() error { + defaults.MustSet(ac) + return verify(ac) } - func NewApplicationConfig() *ApplicationConfig { return &ApplicationConfig{} } -// Prefix dubbo.applicationConfig -func (ApplicationConfig) Prefix() string { - return constant.DUBBO + ".application" -} - func (a *ApplicationConfig) CheckConfig() error { // todo check defaults.MustSet(a) diff --git a/config/config_loader.go b/config/config_loader.go index 016881e50e..074560dd61 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -50,33 +50,18 @@ var ( maxWait = 3 ) -func Load(opts ...LoaderConfOption) { - // pares CommandLine - //parseCommandLine() +func Load(opts ...LoaderConfOption) error { // conf conf := NewLoaderConf(opts...) - // init config rootConfig = new(RootConfig) viper := getKoanf(conf) - - if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { - panic(err) + if err := viper.UnmarshalWithConf(rootConfig.Prefix(), + rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { + return err } - rootConfig.Init() - - //if err := rootConfig.CheckConfig(); err != nil { - // panic(err) - //} - //rootConfig.Validate() - - // root config init finish - - // todo why this line - //extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) - // rootConfig.Provider.Load() - // rootConfig.Consumer.Load() + return rootConfig.InitConfig() } func check() error { @@ -466,7 +451,7 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // } //} // -//// Load Dubbo Init +//// Load Dubbo InitConfig //func Load() { // options := DefaultInit() // LoadWithOptions(options...) diff --git a/config/config_loader_test.go b/config/config_loader_test.go index d973757a70..51200e4f30 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -101,31 +101,6 @@ func TestGetRegistriesConfig(t *testing.T) { }) } -func TestGetProtocolsConfig(t *testing.T) { - - //t.Run("empty protocols", func(t *testing.T) { - // Load(WithPath("./testdata/config/protocol/empty_application.yaml")) - // - // protocols := rootConfig.Protocols - // assert.NotNil(t, protocols) - // // default - // assert.Equal(t, "dubbo", protocols["default"].Name) - // assert.Equal(t, "127.0.0.1", protocols["default"].Ip) - // assert.Equal(t, 0, protocols["default"].Port) - //}) - - t.Run("protocols", func(t *testing.T) { - Load(WithPath("./testdata/config/protocol/application.yaml")) - - protocols := rootConfig.Protocols - assert.NotNil(t, protocols) - // default - assert.Equal(t, "dubbo", protocols["dubbo"].Name) - assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) - assert.Equal(t, string("20000"), protocols["dubbo"].Port) - }) -} - func TestGetProviderConfig(t *testing.T) { // empty registry t.Run("empty registry", func(t *testing.T) { diff --git a/config/consumer_config.go b/config/consumer_config.go index b34c06f282..ba503045a1 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -38,7 +38,6 @@ const ( // ConsumerConfig is Consumer default configuration type ConsumerConfig struct { - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // client ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` @@ -63,13 +62,8 @@ func (ConsumerConfig) Prefix() string { return constant.ConsumerConfigPrefix } -// UnmarshalYAML unmarshal the ConsumerConfig by @unmarshal function -func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ConsumerConfig - return unmarshal((*plain)(c)) +func initConsumerConfig(rc *RootConfig) error { + return nil } func (c *ConsumerConfig) CheckConfig() error { diff --git a/config/logger_config.go b/config/logger_config.go index b013388ec4..a5d5f7462d 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -1,4 +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 type LoggerConfig struct { } + +func initLoggerConfig(rc *RootConfig) error { + + return nil +} diff --git a/config/protocol_config.go b/config/protocol_config.go index f0fa3fbe1d..1ade142bb1 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -24,35 +24,30 @@ import ( // ProtocolConfig is protocol configuration type ProtocolConfig struct { - Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` + Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` + Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` } -func getProtocolsConfig(protocols map[string]*ProtocolConfig) map[string]*ProtocolConfig { +func initProtocolsConfig(rc *RootConfig) error { + protocols := rc.Protocols if len(protocols) <= 0 { protocol := new(ProtocolConfig) protocols = make(map[string]*ProtocolConfig, 1) protocols[constant.DUBBO] = protocol - return protocols + rc.Protocols = protocols + return protocol.check() } for _, protocol := range protocols { - //protocol.CheckConfig() - //defaults.MustSet(protocol) - if err := protocol.CheckConfig(); err != nil { - panic(err) + if err := protocol.check(); err != nil { + return err } } - return protocols + rc.Protocols = protocols + return nil } -func (p *ProtocolConfig) CheckConfig() error { - // todo check +func (p *ProtocolConfig) check() error { defaults.MustSet(p) return verify(p) } - -func (p *ProtocolConfig) Validate() { - - // todo set default application -} diff --git a/config/protocol_config_test.go b/config/protocol_config_test.go new file mode 100644 index 0000000000..a0c835c0fa --- /dev/null +++ b/config/protocol_config_test.go @@ -0,0 +1,51 @@ +/* + * 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 + +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +func TestGetProtocolsConfig(t *testing.T) { + + t.Run("empty use default", func(t *testing.T) { + err := Load(WithPath("./testdata/config/protocol/empty_application.yaml")) + assert.Nil(t, err) + protocols := rootConfig.Protocols + assert.NotNil(t, protocols) + // default + assert.Equal(t, "dubbo", protocols["dubbo"].Name) + assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) + assert.Equal(t, string("2000"), protocols["dubbo"].Port) + }) + + t.Run("use config", func(t *testing.T) { + err := Load(WithPath("./testdata/config/protocol/application.yaml")) + assert.Nil(t, err) + protocols := rootConfig.Protocols + assert.NotNil(t, protocols) + // default + assert.Equal(t, "dubbo", protocols["dubbo"].Name) + assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) + assert.Equal(t, string("2000"), protocols["dubbo"].Port) + }) +} diff --git a/config/provider_config.go b/config/provider_config.go index ea9a518479..7778d84bb1 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -53,6 +53,14 @@ func (c *ProviderConfig) CheckConfig() error { return verify(c) } +func initProviderConfig(rc *RootConfig) error { + provider := rc.Provider + if provider == nil { + provider = new(ProviderConfig) + } + return nil +} + func (c *ProviderConfig) Validate(r *RootConfig) { ids := make([]string, 0) for key := range r.Registries { diff --git a/config/registry_config.go b/config/registry_config.go index 6df28f22cf..1205c914d1 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -18,6 +18,7 @@ package config import ( + "github.com/pkg/errors" "net/url" "strconv" "strings" @@ -54,43 +55,31 @@ type RegistryConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -func (c *RegistryConfig) CheckConfig() error { - // todo check - defaults.MustSet(c) +// Prefix dubbo.registriesConfig +func (RegistryConfig) Prefix() string { + return constant.RegistryConfigPrefix +} + +func (c *RegistryConfig) check() error { + if err := defaults.Set(c); err != nil { + return err + } c.translateRegistryAddress() return verify(c) } -func getRegistriesConfig(registries map[string]*RegistryConfig) map[string]*RegistryConfig { +func initRegistriesConfig(rc *RootConfig) error { + registries := rc.Registries if len(registries) <= 0 { - panic("registries mast set") + return errors.New("dubbo.registries must set") } for _, registry := range registries { - defaults.MustSet(registry) - registry.translateRegistryAddress() - if err := verify(registry); err != nil { - panic(err) + if err := registry.check(); err != nil { + return err } } - return registries -} - -func (c *RegistryConfig) Validate() { - // todo set default application -} - -// UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function -func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain RegistryConfig - return unmarshal((*plain)(c)) -} - -// Prefix dubbo.registriesConfig -func (RegistryConfig) Prefix() string { - return constant.RegistryConfigPrefix + rc.Registries = registries + return nil } func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { diff --git a/config/root_config.go b/config/root_config.go index c8aec6b15e..63e0d0ac55 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -3,27 +3,26 @@ package config import ( "bytes" "dubbo.apache.org/dubbo-go/v3/common/constant" - "github.com/creasty/defaults" ) // RootConfig is the root config type RootConfig struct { - ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` - - // since 1.5.0 version - Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - - ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` - - MetadataReportConfig *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` - // Application applicationConfig config Application *ApplicationConfig `validate:"required" yaml:"application" json:"application,omitempty" property:"application"` + Protocols map[string]*ProtocolConfig `validate:"required" yaml:"protocols" json:"protocols" property:"protocols"` + // Registries registry config Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` - Protocols map[string]*ProtocolConfig `validate:"required" yaml:"protocols" json:"protocols" property:"protocols"` + // since 1.5.0 version + // Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + + ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` + + ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` + + MetadataReportConfig *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` // provider config Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` @@ -88,96 +87,117 @@ func (RootConfig) Prefix() string { return constant.DUBBO } -func (rc *RootConfig) Init(opts ...rootConfOption) { +func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { + for _, opt := range opts { + opt.apply(rc) + } + // 这个里面不能panic if rc.ConfigCenter != nil { //监听远程配置刷新本地指定配置 // yaml // 监听文件变化 } - for _, opt := range opts { - opt.apply(rc) - } - rc.Application = getApplicationConfig(rc.Application) - rc.Protocols = getProtocolsConfig(rc.Protocols) - rc.Registries = getRegistriesConfig(rc.Registries) - - rc.Provider.Load() - rc.Consumer.Load() -} - -//log rout me - -func WithApplication(ac *ApplicationConfig) rootConfFunc { - return rootConfFunc(func(conf *RootConfig) { - conf.Application = ac - }) -} -func WithProtocols(protocols map[string]*ProtocolConfig) rootConfFunc { - return rootConfFunc(func(conf *RootConfig) { - conf.Protocols = protocols - }) -} - -func (rc *RootConfig) CheckConfig() error { - defaults.MustSet(rc) - - if err := rc.Application.CheckConfig(); err != nil { + if err := initApplicationConfig(rc); err != nil { return err } - - for k, _ := range rc.Registries { - if err := rc.Registries[k].CheckConfig(); err != nil { - return err - } - } - - for k, _ := range rc.Protocols { - if err := rc.Protocols[k].CheckConfig(); err != nil { - return err - } + if err := initProtocolsConfig(rc); err != nil { + return err } - if err := rc.ConfigCenter.CheckConfig(); err != nil { + if err := initRegistriesConfig(rc); err != nil { return err } - if err := rc.MetadataReportConfig.CheckConfig(); err != nil { + if err := initLoggerConfig(rc); err != nil { return err } - if err := rc.Provider.CheckConfig(); err != nil { + if err := initProviderConfig(rc); err != nil { return err } - if err := rc.Consumer.CheckConfig(); err != nil { + if err := initConsumerConfig(rc); err != nil { return err } - return verify(rootConfig) -} + rc.Provider.Load() + rc.Consumer.Load() -func (rc *RootConfig) Validate() { - // 2. validate config - rc.Application.Validate() + return nil +} - for k, _ := range rc.Registries { - rc.Registries[k].Validate() - } +func WithApplication(ac *ApplicationConfig) rootConfFunc { + return rootConfFunc(func(conf *RootConfig) { + conf.Application = ac + }) +} - for k, _ := range rc.Protocols { - rc.Protocols[k].Validate() - } +func WithProtocols(protocols map[string]*ProtocolConfig) rootConfFunc { + return rootConfFunc(func(conf *RootConfig) { + conf.Protocols = protocols + }) +} - for k, _ := range rc.Registries { - rc.Registries[k].Validate() - } +//func (rc *RootConfig) CheckConfig() error { +// defaults.MustSet(rc) +// +// if err := rc.Application.CheckConfig(); err != nil { +// return err +// } +// +// for k, _ := range rc.Registries { +// if err := rc.Registries[k].CheckConfig(); err != nil { +// return err +// } +// } +// +// for k, _ := range rc.Protocols { +// if err := rc.Protocols[k].CheckConfig(); err != nil { +// return err +// } +// } +// +// if err := rc.ConfigCenter.CheckConfig(); err != nil { +// return err +// } +// +// if err := rc.MetadataReportConfig.CheckConfig(); err != nil { +// return err +// } +// +// if err := rc.Provider.CheckConfig(); err != nil { +// return err +// } +// +// if err := rc.Consumer.CheckConfig(); err != nil { +// return err +// } +// +// return verify(rootConfig) +//} - rc.ConfigCenter.Validate() - rc.MetadataReportConfig.Validate() - rc.Provider.Validate(rc) - rc.Consumer.Validate(rc) -} +//func (rc *RootConfig) Validate() { +// // 2. validate config +// rc.Application.Validate() +// +// for k, _ := range rc.Registries { +// rc.Registries[k].Validate() +// } +// +// for k, _ := range rc.Protocols { +// rc.Protocols[k].Validate() +// } +// +// for k, _ := range rc.Registries { +// rc.Registries[k].Validate() +// } +// +// rc.ConfigCenter.Validate() +// rc.MetadataReportConfig.Validate() +// rc.Provider.Validate(rc) +// rc.Consumer.Validate(rc) +//} //GetApplicationConfig get applicationConfig config func GetApplicationConfig() *ApplicationConfig { @@ -242,7 +262,7 @@ func GetConsumerConfig() *ConsumerConfig { // if registriesConfig != nil { // return registriesConfig, nil // } -// registriesConfig = getRegistriesConfig(rootConfig.Registries) +// registriesConfig = initRegistriesConfig(rootConfig.Registries) // for _, reg := range registriesConfig { // if err := defaults.Set(reg); err != nil { // return nil, err diff --git a/config/testdata/config/protocol/application.yaml b/config/testdata/config/protocol/application.yaml index 0288dac8c4..bc0aecba71 100644 --- a/config/testdata/config/protocol/application.yaml +++ b/config/testdata/config/protocol/application.yaml @@ -1,6 +1,2 @@ dubbo: - protocols: - dubbo: - name: dubbo - ip: 127.0.0.1 - port: 20000 \ No newline at end of file + protocols: \ No newline at end of file From d93df442cb9b97598f3e473a90504ea8bed0e45e Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 00:22:13 +0800 Subject: [PATCH 027/148] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/metadata_report_config.go | 10 +--------- config/metric_config.go | 4 ++++ config/network_config.go | 4 ++++ config/root_config.go | 20 ++++++++++++++++---- config/router_config.go | 6 +++++- config/service_discovery_config.go | 4 ++++ 6 files changed, 34 insertions(+), 14 deletions(-) diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 6b59e210d7..fb752be4b5 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -37,15 +37,7 @@ type MetadataReportConfig struct { Group string `yaml:"group" json:"group,omitempty"` } -// UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function -func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return perrors.WithStack(err) - } - type plain MetadataReportConfig - if err := unmarshal((*plain)(c)); err != nil { - return perrors.WithStack(err) - } +func initMetadataReportConfig(rc *RootConfig) error { return nil } diff --git a/config/metric_config.go b/config/metric_config.go index 9af1691dad..e6d0a5a171 100644 --- a/config/metric_config.go +++ b/config/metric_config.go @@ -25,6 +25,10 @@ type MetricConfig struct { HistogramBucket []float64 `yaml:"histogram_bucket" json:"histogram_bucket,omitempty"` } +func initMetricConfig(rc *RootConfig) error { + return nil +} + // find the histogram bucket // if it's empty, the default value will be return func (mc *MetricConfig) GetHistogramBucket() []float64 { diff --git a/config/network_config.go b/config/network_config.go index bb11f5a452..e5a2bc7980 100644 --- a/config/network_config.go +++ b/config/network_config.go @@ -2,3 +2,7 @@ package config type NetworkConfig struct { } + +func initNetworkConfig(rc *RootConfig) error { + return nil +} diff --git a/config/root_config.go b/config/root_config.go index 63e0d0ac55..1aace91633 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -104,19 +104,31 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { if err := initProtocolsConfig(rc); err != nil { return err } - if err := initRegistriesConfig(rc); err != nil { return err } - if err := initLoggerConfig(rc); err != nil { return err } - + if err := initServiceDiscoveryConfig(rc); err != nil { + return err + } + if err := initMetadataReportConfig(rc); err != nil { + return err + } + if err := initMetricConfig(rc); err != nil { + return err + } + if err := initNetworkConfig(rc); err != nil { + return err + } + if err := initRouterConfig(rc); err != nil { + return err + } + // provider、consumer must last init if err := initProviderConfig(rc); err != nil { return err } - if err := initConsumerConfig(rc); err != nil { return err } diff --git a/config/router_config.go b/config/router_config.go index 2ef0a77b1c..6acf8d4c37 100644 --- a/config/router_config.go +++ b/config/router_config.go @@ -23,8 +23,12 @@ import ( ) type RouterConfig struct { - } + +func initRouterConfig(rc *RootConfig) error { + return nil +} + // LocalRouterRules defines the local router config structure type LocalRouterRules struct { RouterRules []interface{} `yaml:"routerRules"` diff --git a/config/service_discovery_config.go b/config/service_discovery_config.go index b08a16aa9a..c902f958fc 100644 --- a/config/service_discovery_config.go +++ b/config/service_discovery_config.go @@ -34,3 +34,7 @@ type ServiceDiscoveryConfig struct { func (ServiceDiscoveryConfig) Prefix() string { return constant.ServiceDiscPrefix } + +func initServiceDiscoveryConfig(rc *RootConfig) error { + return nil +} From ddca0226481cde69b12206c1518f346c55dfc7dc Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 00:59:20 +0800 Subject: [PATCH 028/148] =?UTF-8?q?up:=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application_config.go | 19 +++++-------------- config/config_loader.go | 2 +- config/provider_config.go | 1 + config/registry_config.go | 2 +- config/root_config.go | 32 ++++++++++++-------------------- remoting/getty/getty_client.go | 13 +++++++------ 6 files changed, 27 insertions(+), 42 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 6392c26af1..c68492cf65 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -40,6 +40,10 @@ func (ApplicationConfig) Prefix() string { } func initApplicationConfig(rc *RootConfig) error { + // ignore refresh action + if rc.refresh { + return nil + } application := rc.Application if application == nil { application = new(ApplicationConfig) @@ -51,21 +55,8 @@ func initApplicationConfig(rc *RootConfig) error { rc.Application = application return nil } + func (ac *ApplicationConfig) check() error { defaults.MustSet(ac) return verify(ac) } -func NewApplicationConfig() *ApplicationConfig { - return &ApplicationConfig{} -} - -func (a *ApplicationConfig) CheckConfig() error { - // todo check - defaults.MustSet(a) - return verify(a) -} - -func (a *ApplicationConfig) Validate() { - defaults.MustSet(a) - // todo set default application -} diff --git a/config/config_loader.go b/config/config_loader.go index 074560dd61..bee96cae43 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -60,7 +60,7 @@ func Load(opts ...LoaderConfOption) error { rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err } - + rootConfig.refresh = false return rootConfig.InitConfig() } diff --git a/config/provider_config.go b/config/provider_config.go index 7778d84bb1..e64bf54aaa 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -58,6 +58,7 @@ func initProviderConfig(rc *RootConfig) error { if provider == nil { provider = new(ProviderConfig) } + rc.Provider = provider return nil } diff --git a/config/registry_config.go b/config/registry_config.go index 1205c914d1..05aa5d1233 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -18,7 +18,6 @@ package config import ( - "github.com/pkg/errors" "net/url" "strconv" "strings" @@ -26,6 +25,7 @@ import ( import ( "github.com/creasty/defaults" + "github.com/pkg/errors" ) import ( diff --git a/config/root_config.go b/config/root_config.go index 1aace91633..60b78a7213 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -15,8 +15,8 @@ type RootConfig struct { // Registries registry config Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` - // since 1.5.0 version - // Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + // Deprecated since 1.5.0 version + Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` @@ -38,9 +38,11 @@ type RootConfig struct { // Shutdown config Shutdown *ShutdownConfig `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` - Network *NetworkConfig `yaml:"network" json:"network,omitempty" property:"network"` + Network map[interface{}]interface{} `yaml:"network" json:"network,omitempty" property:"network"` Router *RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` + // is refresh action + refresh bool // prefix string fatherConfig interface{} EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` @@ -76,9 +78,9 @@ type rootConfOption interface { apply(vc *RootConfig) } -type rootConfFunc func(*RootConfig) +type RootConfFunc func(*RootConfig) -func (fn rootConfFunc) apply(vc *RootConfig) { +func (fn RootConfFunc) apply(vc *RootConfig) { fn(vc) } @@ -92,12 +94,11 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { opt.apply(rc) } // 这个里面不能panic - if rc.ConfigCenter != nil { + if rc.ConfigCenter != nil && !rc.refresh { //监听远程配置刷新本地指定配置 // yaml // 监听文件变化 } - if err := initApplicationConfig(rc); err != nil { return err } @@ -139,14 +140,14 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { return nil } -func WithApplication(ac *ApplicationConfig) rootConfFunc { - return rootConfFunc(func(conf *RootConfig) { +func WithApplication(ac *ApplicationConfig) RootConfFunc { + return RootConfFunc(func(conf *RootConfig) { conf.Application = ac }) } -func WithProtocols(protocols map[string]*ProtocolConfig) rootConfFunc { - return rootConfFunc(func(conf *RootConfig) { +func WithProtocols(protocols map[string]*ProtocolConfig) RootConfFunc { + return RootConfFunc(func(conf *RootConfig) { conf.Protocols = protocols }) } @@ -212,15 +213,6 @@ func WithProtocols(protocols map[string]*ProtocolConfig) rootConfFunc { //} //GetApplicationConfig get applicationConfig config -func GetApplicationConfig() *ApplicationConfig { - if err := check(); err != nil { - return NewApplicationConfig() - } - if rootConfig.Application != nil { - return rootConfig.Application - } - return NewApplicationConfig() -} func GetRootConfig() *RootConfig { return rootConfig diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 7ca3a35789..b8f2150a28 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -56,16 +56,17 @@ func initClient(protocol string) { // load clientconfig from consumer_config // default use dubbo - consumerConfig := config.GetConsumerConfig() - if consumerConfig.ApplicationConfig == nil { - return - } - protocolConf := config.GetConsumerConfig().ProtocolConf + //consumerConfig := config.GetConsumerConfig() + //if consumerConfig.ApplicationConfig == nil { + // return + //} + protocolConf := config.GetRootConfig().Network defaultClientConfig := GetDefaultClientConfig() if protocolConf == nil { logger.Info("protocol_conf default use dubbo config") } else { - dubboConf := protocolConf.(map[interface{}]interface{})[protocol] + //dubboConf := protocolConf.(map[interface{}]interface{})[protocol] + dubboConf := protocolConf[protocol] if dubboConf == nil { logger.Warnf("dubboConf is nil") return From 1ecc7eb34a933879e97ede50b73282dc553e2717 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sun, 1 Aug 2021 12:27:34 +0800 Subject: [PATCH 029/148] Config refactor (#1358) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * config file enhance * set Koanf * add:registry config * add:config center config * up:default config name * up:调整结构 * up:set config * add validate * add check genre * 修改配置目录 * add registry config * add protocol * add provider config * add comments * up:service config * 修改解析tag * registries: * 配置中心配置 * 添加registry * fix: make new config struct runnable Co-authored-by: zhaoyunxing92 <2385585770@qq.com> --- cluster/router/chain/chain.go | 2 +- .../judger/attachment_match_judger_test.go | 2 +- .../v3router/judger/bool_match_judger.go | 4 +- .../v3router/judger/bool_match_judger_test.go | 5 +- .../judger/double_match_judger_test.go | 5 +- .../judger/double_range_match_judger_test.go | 5 +- .../judger/list_double_match_judger_test.go | 5 +- .../judger/list_string_match_judger_test.go | 5 +- .../judger/method_match_judger_test.go | 2 +- .../v3router/judger/string_match_judger.go | 5 +- .../judger/string_match_judger_test.go | 5 +- .../v3router/k8s_api/listener_handler_impl.go | 2 +- cluster/router/v3router/router_chain.go | 2 +- cluster/router/v3router/router_chain_test.go | 2 +- cluster/router/v3router/uniform_rule.go | 2 +- common/constant/key.go | 28 +- common/rpc_service.go | 5 +- config/application_config.go | 45 +- config/base_config.go | 312 ----- config/base_config_test.go | 303 ----- config/config_api.go | 1091 ++++++++-------- config/config_api_test.go | 283 ++-- config/config_center_config.go | 207 +-- config/config_center_config_test.go | 75 -- config/config_loader.go | 910 +++++++------ config/config_loader_options.go | 322 +++-- config/config_loader_options_test.go | 61 + config/config_loader_test.go | 1153 +++++++++-------- config/config_utils.go | 42 + config/consumer_config.go | 275 +++- config/{ => generic}/generic_service.go | 2 +- config/graceful_shutdown.go | 241 ++-- config/graceful_shutdown_config.go | 6 +- config/graceful_shutdown_test.go | 184 +-- config/metadata_report_config.go | 94 +- config/metadata_report_config_test.go | 52 - config/metric_config_test.go | 8 +- config/protocol_config.go | 32 +- config/provider_config.go | 168 ++- config/provider_config_test.go | 64 +- config/reference_config.go | 136 +- config/reference_config_test.go | 777 +++++------ config/registry_config.go | 100 +- config/registry_config_test.go | 38 +- config/root_config.go | 255 ++++ config/service.go | 5 + config/service_config.go | 262 +++- config/service_config_test.go | 215 --- config/service_discovery_config.go | 2 +- config/testdata/application.yaml | 35 + config/testdata/config/app/application.yaml | 6 + .../config/center/conf-application.yaml | 13 + .../testdata/config/protocol/application.yaml | 6 + .../config/protocol/empty_application.yaml | 2 + .../testdata/config/provider/application.yaml | 12 + .../provider/empty_registry_application.yaml | 8 + .../config/provider/registry_application.yaml | 10 + .../testdata/config/registry/application.yaml | 10 + .../config/registry/empty_application.yaml | 2 + .../testdata/config/service/hello_service.go | 18 + .../testdata/config/service/order_service.go | 18 + config_center/apollo/impl.go | 2 +- config_center/apollo/impl_test.go | 6 +- filter/hystrix/filter.go | 6 +- go.mod | 2 + go.sum | 38 +- .../mapping/dynamic/service_name_mapping.go | 2 +- .../dynamic/service_name_mapping_test.go | 2 +- .../mapping/memory/service_name_mapping.go | 2 +- .../service/exporter/configurable/exporter.go | 8 +- .../exporter/configurable/exporter_test.go | 91 +- metadata/service/local/service.go | 2 +- protocol/dubbo3/common_test.go | 2 +- protocol/dubbo3/dubbo3_protocol.go | 2 +- protocol/dubbo3/internal/client.go | 5 +- protocol/grpc/client.go | 6 +- protocol/grpc/grpc_protocol_test.go | 52 +- protocol/grpc/internal/helloworld/client.go | 5 +- protocol/grpc/internal/routeguide/client.go | 5 +- protocol/grpc/server.go | 2 +- protocol/jsonrpc/jsonrpc_protocol_test.go | 2 +- .../rest/config/reader/rest_config_reader.go | 10 +- protocol/rest/rest_invoker_test.go | 2 +- protocol/rest/rest_protocol_test.go | 2 +- registry/directory/directory.go | 5 +- registry/directory/directory_test.go | 8 +- registry/etcdv3/service_discovery.go | 4 +- registry/etcdv3/service_discovery_test.go | 8 +- ...vent_publishing_service_deiscovery_test.go | 2 +- .../event/service_config_exported_event.go | 2 +- registry/file/service_discovery.go | 2 +- registry/file/service_discovery_test.go | 2 +- registry/nacos/service_discovery.go | 4 +- registry/nacos/service_discovery_test.go | 10 +- registry/protocol/protocol.go | 7 +- registry/protocol/protocol_test.go | 15 +- .../service_discovery_registry.go | 2 +- .../service_discovery_registry_test.go | 3 +- registry/zookeeper/service_discovery.go | 4 +- registry/zookeeper/service_discovery_test.go | 8 +- remoting/getty/config.go | 5 +- remoting/getty/getty_client.go | 2 +- samples | 1 - test/integrate/dubbo/go-client/client.go | 2 +- test/integrate/dubbo/go-client/user.go | 2 +- test/integrate/dubbo/go-server/server.go | 2 +- test/integrate/dubbo/go-server/user.go | 2 +- 107 files changed, 4277 insertions(+), 4027 deletions(-) delete mode 100644 config/base_config.go delete mode 100644 config/base_config_test.go delete mode 100644 config/config_center_config_test.go create mode 100644 config/config_loader_options_test.go rename config/{ => generic}/generic_service.go (98%) delete mode 100644 config/metadata_report_config_test.go create mode 100644 config/root_config.go delete mode 100644 config/service_config_test.go create mode 100644 config/testdata/application.yaml create mode 100644 config/testdata/config/app/application.yaml create mode 100644 config/testdata/config/center/conf-application.yaml create mode 100644 config/testdata/config/protocol/application.yaml create mode 100644 config/testdata/config/protocol/empty_application.yaml create mode 100644 config/testdata/config/provider/application.yaml create mode 100644 config/testdata/config/provider/empty_registry_application.yaml create mode 100644 config/testdata/config/provider/registry_application.yaml create mode 100644 config/testdata/config/registry/application.yaml create mode 100644 config/testdata/config/registry/empty_application.yaml create mode 100644 config/testdata/config/service/hello_service.go create mode 100644 config/testdata/config/service/order_service.go delete mode 160000 samples diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 616909ab1e..81839f75d5 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -122,7 +122,7 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) { 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") + logger.Warnf("virtual Service ProtocolConfig 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) if r == nil || err != nil { diff --git a/cluster/router/v3router/judger/attachment_match_judger_test.go b/cluster/router/v3router/judger/attachment_match_judger_test.go index 26a8d5ed59..eabc312f35 100644 --- a/cluster/router/v3router/judger/attachment_match_judger_test.go +++ b/cluster/router/v3router/judger/attachment_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,7 +27,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/cluster/router/v3router/judger/bool_match_judger.go b/cluster/router/v3router/judger/bool_match_judger.go index 4dcf2003a4..5c4bb46e77 100644 --- a/cluster/router/v3router/judger/bool_match_judger.go +++ b/cluster/router/v3router/judger/bool_match_judger.go @@ -17,7 +17,9 @@ package judger -import "dubbo.apache.org/dubbo-go/v3/config" +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) // nolint type BoolMatchJudger struct { diff --git a/cluster/router/v3router/judger/bool_match_judger_test.go b/cluster/router/v3router/judger/bool_match_judger_test.go index a86651e400..fb7fc2086a 100644 --- a/cluster/router/v3router/judger/bool_match_judger_test.go +++ b/cluster/router/v3router/judger/bool_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestBoolMatchJudger(t *testing.T) { assert.True(t, newBoolMatchJudger(&config.BoolMatch{ Exact: true, diff --git a/cluster/router/v3router/judger/double_match_judger_test.go b/cluster/router/v3router/judger/double_match_judger_test.go index a2ba18b255..f15f604614 100644 --- a/cluster/router/v3router/judger/double_match_judger_test.go +++ b/cluster/router/v3router/judger/double_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestDoubleMatchJudger(t *testing.T) { assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ Exact: 3.14159, diff --git a/cluster/router/v3router/judger/double_range_match_judger_test.go b/cluster/router/v3router/judger/double_range_match_judger_test.go index 9487e404c7..e8c6b6fd38 100644 --- a/cluster/router/v3router/judger/double_range_match_judger_test.go +++ b/cluster/router/v3router/judger/double_range_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestDoubleRangeMatchJudger(t *testing.T) { assert.True(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ Start: 1.0, diff --git a/cluster/router/v3router/judger/list_double_match_judger_test.go b/cluster/router/v3router/judger/list_double_match_judger_test.go index bc84c7801f..696be6bef8 100644 --- a/cluster/router/v3router/judger/list_double_match_judger_test.go +++ b/cluster/router/v3router/judger/list_double_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestListDoubleMatchJudger_Judge(t *testing.T) { assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ Oneof: []*config.DoubleMatch{ diff --git a/cluster/router/v3router/judger/list_string_match_judger_test.go b/cluster/router/v3router/judger/list_string_match_judger_test.go index 1816b9503f..169ee57f2b 100644 --- a/cluster/router/v3router/judger/list_string_match_judger_test.go +++ b/cluster/router/v3router/judger/list_string_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ 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"}}, diff --git a/cluster/router/v3router/judger/method_match_judger_test.go b/cluster/router/v3router/judger/method_match_judger_test.go index 71e90aacb5..d0f5023075 100644 --- a/cluster/router/v3router/judger/method_match_judger_test.go +++ b/cluster/router/v3router/judger/method_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -27,7 +28,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/cluster/router/v3router/judger/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go index fae5278fb2..a502cc3b91 100644 --- a/cluster/router/v3router/judger/string_match_judger.go +++ b/cluster/router/v3router/judger/string_match_judger.go @@ -18,14 +18,11 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "regexp" "strings" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - // nolint type StringMatchJudger struct { config.StringMatch diff --git a/cluster/router/v3router/judger/string_match_judger_test.go b/cluster/router/v3router/judger/string_match_judger_test.go index 968eda96f7..c9da665bc6 100644 --- a/cluster/router/v3router/judger/string_match_judger_test.go +++ b/cluster/router/v3router/judger/string_match_judger_test.go @@ -18,6 +18,7 @@ package judger import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -25,10 +26,6 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func TestNewStringMatchJudger(t *testing.T) { assert.True(t, NewStringMatchJudger(&config.StringMatch{ Exact: "abc", diff --git a/cluster/router/v3router/k8s_api/listener_handler_impl.go b/cluster/router/v3router/k8s_api/listener_handler_impl.go index 64a8cf3f83..e6f660c50f 100644 --- a/cluster/router/v3router/k8s_api/listener_handler_impl.go +++ b/cluster/router/v3router/k8s_api/listener_handler_impl.go @@ -18,6 +18,7 @@ package k8s_api import ( + "dubbo.apache.org/dubbo-go/v3/config" metav "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -27,7 +28,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_crd" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index ce8269493d..b677d8f05c 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -18,6 +18,7 @@ package v3router import ( + "dubbo.apache.org/dubbo-go/v3/config" "encoding/json" "io" "strings" @@ -32,7 +33,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_api" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index 9e12da1eb3..e1af5328a5 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -18,6 +18,7 @@ package v3router import ( + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "testing" ) @@ -28,7 +29,6 @@ import ( 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" ) diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go index 3b552b89f0..ef4b16ca36 100644 --- a/cluster/router/v3router/uniform_rule.go +++ b/cluster/router/v3router/uniform_rule.go @@ -18,6 +18,7 @@ package v3router import ( + "dubbo.apache.org/dubbo-go/v3/config" "math/rand" "time" ) @@ -30,7 +31,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/judger" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/common/constant/key.go b/common/constant/key.go index 4d258bb05d..b1ec48ec73 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -53,6 +53,7 @@ const ( SSL_ENABLED_KEY = "ssl-enabled" // PARAMS_TYPE_Key key used in pass through invoker factory, to define param type PARAMS_TYPE_Key = "parameter-type-names" + DEFAULT_Key = "default" ) const ( @@ -169,19 +170,20 @@ const ( ) const ( - RegistryConfigPrefix = "dubbo.registries." - SingleRegistryConfigPrefix = "dubbo.registry." - ReferenceConfigPrefix = "dubbo.reference." - ServiceConfigPrefix = "dubbo.service." - ConfigBasePrefix = "dubbo.base." - RemotePrefix = "dubbo.remote." - ServiceDiscPrefix = "dubbo.service-discovery." - ProtocolConfigPrefix = "dubbo.protocols." - ProviderConfigPrefix = "dubbo.provider." - ConsumerConfigPrefix = "dubbo.consumer." - ShutdownConfigPrefix = "dubbo.shutdown." - MetadataReportPrefix = "dubbo.metadata-report." - RouterConfigPrefix = "dubbo.router." + RegistryConfigPrefix = "dubbo.registries" + ConfigCenterPrefix = "dubbo.config-center" + SingleRegistryConfigPrefix = "dubbo.registry" + ReferenceConfigPrefix = "dubbo.reference" + ServiceConfigPrefix = "dubbo.service" + ConfigBasePrefix = "dubbo.base" + RemotePrefix = "dubbo.remote" + ServiceDiscPrefix = "dubbo.service-discovery" + ProtocolConfigPrefix = "dubbo.protocols" + ProviderConfigPrefix = "dubbo.provider" + ConsumerConfigPrefix = "dubbo.consumer" + ShutdownConfigPrefix = "dubbo.shutdown" + MetadataReportPrefix = "dubbo.metadata-report" + RouterConfigPrefix = "dubbo.router" ) const ( diff --git a/common/rpc_service.go b/common/rpc_service.go index 57c8f1c4ea..1bca7d9a58 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -37,8 +37,9 @@ import ( // RPCService // rpc service interface type RPCService interface { - // Reference: - // rpc service id or reference id + //// Name rpc service id + //Name() string + // Reference rpc service reference Reference() string } diff --git a/config/application_config.go b/config/application_config.go index 1b4291dc3f..55981a4749 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -17,36 +17,39 @@ package config -import ( - "github.com/creasty/defaults" -) - import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" ) -// ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer +// ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer type ApplicationConfig struct { - Organization string `yaml:"organization" json:"organization,omitempty" property:"organization"` - Name string `yaml:"name" json:"name,omitempty" property:"name"` - Module string `yaml:"module" json:"module,omitempty" property:"module"` - Version string `yaml:"version" json:"version,omitempty" property:"version"` - Owner string `yaml:"owner" json:"owner,omitempty" property:"owner"` - Environment string `yaml:"environment" json:"environment,omitempty" property:"environment"` + Organization string `default:"dubbo.io" yaml:"organization" json:"organization,omitempty" property:"organization"` + Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"` + Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"` + Version string `default:"0.0.1" yaml:"version" json:"version,omitempty" property:"version"` + Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"` + Environment string `default:"dev" yaml:"environment" json:"environment,omitempty" property:"environment"` // the metadata type. remote or local MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` } -// nolint -func (*ApplicationConfig) Prefix() string { - return constant.DUBBO + ".application." +func NewApplicationConfig() *ApplicationConfig { + return &ApplicationConfig{} +} + +// Prefix dubbo.applicationConfig +func (ApplicationConfig) Prefix() string { + return constant.DUBBO + ".applicationConfig" +} + +func (a *ApplicationConfig) CheckConfig() error { + // todo check + defaults.MustSet(a) + return verify(a) } -// UnmarshalYAML unmarshals the ApplicationConfig by @unmarshal function -func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ApplicationConfig - return unmarshal((*plain)(c)) +func (a *ApplicationConfig) Validate() { + defaults.MustSet(a) + // todo set default application } diff --git a/config/base_config.go b/config/base_config.go deleted file mode 100644 index 0259549149..0000000000 --- a/config/base_config.go +++ /dev/null @@ -1,312 +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 config - -import ( - "bytes" - "reflect" - "strconv" - "strings" -) - -import ( - perrors "github.com/pkg/errors" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/yaml" -) - -// BaseConfig is the common configuration for provider and consumer -type BaseConfig struct { - ConfigCenterConfig *ConfigCenterConfig `yaml:"config_center" json:"config_center,omitempty"` - - // since 1.5.0 version - Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service_discovery" json:"service_discovery,omitempty" property:"service_discovery"` - MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` - - // application config - ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` - - // prefix string - fatherConfig interface{} - EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` - MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` - fileStream *bytes.Buffer - - // cache file used to store the current used configurations. - CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` -} - -func (c *BaseConfig) Prefix() string { - return constant.ConfigBasePrefix -} - -func BaseInit(confBaseFile string) error { - if confBaseFile == "" { - return perrors.Errorf("application configure(base) file name is nil") - } - baseConfig = &BaseConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confBaseFile, baseConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - } - baseConfig.fileStream = bytes.NewBuffer(fileStream) - return nil -} - -// nolint -func (c *BaseConfig) GetServiceDiscoveries(name string) (config *ServiceDiscoveryConfig, ok bool) { - config, ok = c.ServiceDiscoveries[name] - return -} - -// GetRemoteConfig will return the remote's config with the name if found -func (c *BaseConfig) GetRemoteConfig(name string) (config *RemoteConfig, ok bool) { - config, ok = c.Remotes[name] - return -} - -func getKeyPrefix(val reflect.Value) []string { - var prefix string - configPrefixMethod := "Prefix" - if val.CanAddr() { - prefix = val.Addr().MethodByName(configPrefixMethod).Call(nil)[0].String() - } else { - prefix = val.MethodByName(configPrefixMethod).Call(nil)[0].String() - } - - return strings.Split(prefix, "|") -} - -func getPtrElement(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Ptr { - v = v.Elem() - if v.Kind() == reflect.Ptr { - return getPtrElement(v) - } - } - return v -} - -func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryConfiguration) { - for i := 0; i < val.NumField(); i++ { - if key := val.Type().Field(i).Tag.Get("property"); key != "-" && key != "" { - f := val.Field(i) - if f.IsValid() { - setBaseValue := func(f reflect.Value) { - var ( - ok bool - value string - idStr string - ) - - prefixes := getKeyPrefix(val) - - if id.Kind() == reflect.String { - idStr = id.Interface().(string) - } - - for _, pfx := range prefixes { - - if len(pfx) > 0 { - if len(idStr) > 0 { - ok, value = config.GetProperty(pfx + idStr + "." + key) - } - if len(value) == 0 || !ok { - ok, value = config.GetProperty(pfx + key) - } - - } else { - ok, value = config.GetProperty(key) - } - - if ok { - break - } - - } - if ok { - errMsg := func(structName string, fieldName string, errorDetails error) { - logger.Errorf("Dynamic change the configuration in struct {%v} field {%v} error ,error message is {%v}", - structName, fieldName, errorDetails) - } - switch f.Kind() { - case reflect.Int64: - x, err := strconv.Atoi(value) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } else { - if !f.OverflowInt(int64(x)) { - f.SetInt(int64(x)) - } else { - errMsg(val.Type().Name(), val.Type().Field(i).Name, perrors.Errorf("the int64 value {%v} from config center is overflow", int64(x))) - } - } - case reflect.String: - f.SetString(value) - case reflect.Bool: - x, err := strconv.ParseBool(value) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } - f.SetBool(x) - case reflect.Float64: - x, err := strconv.ParseFloat(value, 64) - if err != nil { - errMsg(val.Type().Name(), val.Type().Field(i).Name, err) - } else { - if !f.OverflowFloat(x) { - f.SetFloat(x) - } else { - errMsg(val.Type().Name(), val.Type().Field(i).Name, perrors.Errorf("the float64 value {%v} from config center is overflow", x)) - } - } - default: - logger.Warnf("The kind of field {%v} is not supported ", f.Kind().String()) - } - - } - } - - if f.Kind() == reflect.Ptr { - f = getPtrElement(f) - if f.Kind() == reflect.Struct { - setFieldValue(f, reflect.Value{}, config) - } else { - setBaseValue(f) - } - } - - if f.Kind() == reflect.Struct { - setFieldValue(f, reflect.Value{}, config) - } - if f.Kind() == reflect.Slice { - for i := 0; i < f.Len(); i++ { - e := f.Index(i) - if e.Kind() == reflect.Ptr { - e = getPtrElement(e) - if e.Kind() == reflect.Struct { - setFieldValue(e, reflect.Value{}, config) - } else { - setBaseValue(e) - } - } - - } - } - if f.Kind() == reflect.Map { - - if f.Type().Elem().Kind() == reflect.Ptr { - // initiate config - s := reflect.New(f.Type().Elem().Elem()) - prefix := s.MethodByName("Prefix").Call(nil)[0].String() - for _, pfx := range strings.Split(prefix, "|") { - m := config.GetSubProperty(pfx) - for k := range m { - f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem())) - } - } - - } - - for _, k := range f.MapKeys() { - v := f.MapIndex(k) - switch v.Kind() { - case reflect.Ptr: - v = getPtrElement(v) - if v.Kind() == reflect.Struct { - setFieldValue(v, k, config) - } else { - setBaseValue(v) - } - case reflect.Int64, reflect.String, reflect.Bool, reflect.Float64: - setBaseValue(v) - default: - logger.Warnf("The kind of field {%v} is not supported ", v.Kind().String()) - } - } - } - setBaseValue(f) - } - } - } -} - -func (c *BaseConfig) fresh() { - configList := config.GetEnvInstance().Configuration() - for element := configList.Back(); element != nil; element = element.Prev() { - cfg := element.Value.(*config.InmemoryConfiguration) - c.freshInternalConfig(cfg) - } -} - -func (c *BaseConfig) freshInternalConfig(config *config.InmemoryConfiguration) { - // reflect to init struct - tp := reflect.ValueOf(c.fatherConfig).Elem().Type() - initializeStruct(tp, reflect.ValueOf(c.fatherConfig).Elem()) - - val := reflect.Indirect(reflect.ValueOf(c.fatherConfig)) - setFieldValue(val, reflect.Value{}, config) -} - -// SetFatherConfig sets father config by @fatherConfig -func (c *BaseConfig) SetFatherConfig(fatherConfig interface{}) { - c.fatherConfig = fatherConfig -} - -func initializeStruct(t reflect.Type, v reflect.Value) { - if v.Kind() != reflect.Struct { - return - } - for i := 0; i < v.NumField(); i++ { - f := v.Field(i) - ft := t.Field(i) - - if ft.Tag.Get("property") == "" { - continue - } - switch ft.Type.Kind() { - case reflect.Map: - if f.IsNil() { - f.Set(reflect.MakeMap(ft.Type)) - } - case reflect.Slice: - if f.IsNil() { - f.Set(reflect.MakeSlice(ft.Type, 0, 0)) - } - case reflect.Chan: - if f.IsNil() { - f.Set(reflect.MakeChan(ft.Type, 0)) - } - case reflect.Struct: - initializeStruct(ft.Type, f) - case reflect.Ptr: - if f.IsNil() { - fv := reflect.New(ft.Type.Elem()) - initializeStruct(ft.Type.Elem(), fv.Elem()) - f.Set(fv) - } - default: - } - } -} diff --git a/config/base_config_test.go b/config/base_config_test.go deleted file mode 100644 index 7d5fa5534b..0000000000 --- a/config/base_config_test.go +++ /dev/null @@ -1,303 +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 config - -import ( - "reflect" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" -) - -func getMockMap() map[string]string { - baseMockMap := map[string]string{ - "dubbo.registries.shanghai_reg1.protocol": "mock100", - "dubbo.reference.com.MockService.MockService.retries": "10", - "dubbo.com.MockService.MockService.GetUser.retries": "10", - "dubbo.consumer.check": "false", - "dubbo.application.name": "dubbo", - } - return baseMockMap -} - -var baseAppConfig = &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", -} - -var baseRegistries = map[string]*RegistryConfig{ - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, -} - -var baseMockRef = map[string]*ReferenceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, -} - -func TestRefresh(t *testing.T) { - c := &BaseConfig{} - c.fileStream = nil - mockMap := getMockMap() - mockMap["dubbo.shutdown.timeout"] = "12s" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - ShutdownConfig: &ShutdownConfig{ - Timeout: "12s", - StepTimeout: "2s", - RejectRequestHandler: "mock", - RejectRequest: false, - RequestsFinished: false, - }, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{false}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestAppExternalRefresh(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - mockMap["dubbo.reference.com.MockService.retries"] = "5" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - mockMap["dubbo.consumer.check"] = "true" - config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{true}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestAppExternalWithoutIDRefresh(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - delete(mockMap, "dubbo.reference.com.MockService.MockService.retries") - mockMap["dubbo.reference.com.MockService.retries"] = "10" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - mockMap["dubbo.consumer.check"] = "true" - config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap) - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{true}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestRefreshSingleRegistry(t *testing.T) { - c := &BaseConfig{} - mockMap := map[string]string{} - mockMap["dubbo.registry.address"] = "mock100://127.0.0.1:2181" - mockMap["dubbo.reference.com.MockService.MockService.retries"] = "10" - mockMap["dubbo.com.MockService.MockService.GetUser.retries"] = "10" - mockMap["dubbo.consumer.check"] = "false" - mockMap["dubbo.application.name"] = "dubbo" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ConsumerConfig{ - Check: &[]bool{true}[0], - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: map[string]*RegistryConfig{}, - Registry: &RegistryConfig{}, - References: baseMockRef, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100://127.0.0.1:2181", father.Registry.Address) - assert.Equal(t, "10", father.References["MockService"].Retries) - - assert.Equal(t, "10", father.References["MockService"].Methods[0].Retries) - assert.Equal(t, &[]bool{false}[0], father.Check) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) -} - -func TestRefreshProvider(t *testing.T) { - c := &BaseConfig{} - mockMap := getMockMap() - delete(mockMap, "dubbo.reference.com.MockService.MockService.retries") - mockMap["dubbo.service.com.MockService.MockService.retries"] = "10" - mockMap["dubbo.protocols.jsonrpc1.name"] = "jsonrpc" - mockMap["dubbo.protocols.jsonrpc1.ip"] = "127.0.0.1" - mockMap["dubbo.protocols.jsonrpc1.port"] = "20001" - - config.GetEnvInstance().UpdateExternalConfigMap(mockMap) - config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{}) - - father := &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: baseAppConfig, - }, - Registries: baseRegistries, - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - InterfaceId: "MockService", - InterfaceName: "com.MockService", - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, - }, - } - - c.SetFatherConfig(father) - c.fresh() - assert.Equal(t, "mock100", father.Registries["shanghai_reg1"].Protocol) - assert.Equal(t, "10", father.Services["MockService"].Retries) - - assert.Equal(t, "10", father.Services["MockService"].Methods[0].Retries) - assert.Equal(t, "dubbo", father.ApplicationConfig.Name) - assert.Equal(t, "20001", father.Protocols["jsonrpc1"].Port) -} - -func TestInitializeStruct(t *testing.T) { - testConsumerConfig := &ConsumerConfig{} - tp := reflect.TypeOf(ConsumerConfig{}) - v := reflect.New(tp) - initializeStruct(tp, v.Elem()) - t.Logf("testConsumerConfig type:%s", reflect.ValueOf(testConsumerConfig).Elem().Type().String()) - reflect.ValueOf(testConsumerConfig).Elem().Set(v.Elem()) - - assert.Condition(t, func() (success bool) { - return testConsumerConfig.Registry != nil - }) - assert.Condition(t, func() (success bool) { - return testConsumerConfig.Registries != nil - }) - assert.Condition(t, func() (success bool) { - return testConsumerConfig.References != nil - }) -} diff --git a/config/config_api.go b/config/config_api.go index fc9ebdb6e1..ebcabd4ab0 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -1,545 +1,556 @@ /* - * 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. +* 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 -import ( - "time" -) - -//////////////////////////////////// default registry config -const ( - // defaultZKAddr is the default registry address of zookeeper - defaultZKAddr = "127.0.0.1:2181" - - // defaultNacosAddr is the default registry address of nacos - defaultNacosAddr = "127.0.0.1:8848" - - // defaultRegistryTimeout is the default registry timeout - defaultRegistryTimeout = "3s" -) - -// NewDefaultRegistryConfig New default registry config -// the input @protocol can only be: -// "zookeeper" with default addr "127.0.0.1:2181" -// "nacos" with default addr "127.0.0.1:8848" -func NewDefaultRegistryConfig(protocol string) *RegistryConfig { - switch protocol { - case "zookeeper": - return &RegistryConfig{ - Protocol: protocol, - Address: defaultZKAddr, - TimeoutStr: defaultRegistryTimeout, - } - case "nacos": - return &RegistryConfig{ - Protocol: protocol, - Address: defaultNacosAddr, - TimeoutStr: defaultRegistryTimeout, - } - default: - return &RegistryConfig{ - Protocol: protocol, - } - } -} - -///////////////////////////////////// registry config api -type RegistryConfigOpt func(config *RegistryConfig) *RegistryConfig - -// NewRegistryConfig creates New RegistryConfig with @opts -func NewRegistryConfig(opts ...RegistryConfigOpt) *RegistryConfig { - newRegistryConfig := NewDefaultRegistryConfig("") - for _, v := range opts { - newRegistryConfig = v(newRegistryConfig) - } - return newRegistryConfig -} - -// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name -func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Protocol = regProtocol - return config - } -} - -// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address -func WithRegistryAddress(addr string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Address = addr - return config - } -} - -// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config -func WithRegistryTimeOut(timeout string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.TimeoutStr = timeout - return config - } -} - -// WithRegistryGroup returns RegistryConfigOpt with given @group registry group -func WithRegistryGroup(group string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Group = group - return config - } -} - -// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl -func WithRegistryTTL(ttl string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.TTL = ttl - return config - } -} - -// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName -func WithRegistryUserName(userName string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Username = userName - return config - } -} - -// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password -func WithRegistryPassword(psw string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Password = psw - return config - } -} - -// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag -func WithRegistrySimplified(simplified bool) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Simplified = simplified - return config - } -} - -// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag -func WithRegistryPreferred(preferred bool) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Preferred = preferred - return config - } -} - -// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag -func WithRegistryWeight(weight int64) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Weight = weight - return config - } -} - -// WithRegistryParams returns RegistryConfigOpt with given registry @params -func WithRegistryParams(params map[string]string) RegistryConfigOpt { - return func(config *RegistryConfig) *RegistryConfig { - config.Params = params - return config - } -} - -///////////////////////////////////// consumer config api -// ConsumerConfigOpt is the options to init ConsumerConfig -type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig - -// NewDefaultConsumerConfig returns default ConsumerConfig -// with connection timeout = 3s, request timeout = 3s -func NewDefaultConsumerConfig() *ConsumerConfig { - check := true - newConsumerConfig := &ConsumerConfig{ - BaseConfig: BaseConfig{}, - Registries: make(map[string]*RegistryConfig, 8), - References: make(map[string]*ReferenceConfig, 8), - ConnectTimeout: 3 * time.Second, - RequestTimeout: 3 * time.Second, - Check: &check, - } - return newConsumerConfig -} - -// NewConsumerConfig returns ConsumerConfig with @opts -func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { - newConfig := NewDefaultConsumerConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig -func WithConsumerAppConfig(appConfig *ApplicationConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ApplicationConfig = appConfig - return config - } -} - -// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig -func WithConsumerRegistryConfig(registryKey string, regConfig *RegistryConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.Registries[registryKey] = regConfig - return config - } -} - -// WithConsumerReferenceConfig returns ConsumerConfigOpt with -func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.References[referenceKey] = refConfig - return config - } -} - -// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout -func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ConnectTimeout = timeout - return config - } -} - -// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout -func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.RequestTimeout = timeout - return config - } -} - -// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig -func WithConsumerConfigCenterConfig(configCenterConfig *ConfigCenterConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ConfigCenterConfig = configCenterConfig - return config - } -} - -// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag -func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - *config.Check = check - return config - } -} - -//////////////////////////////////// reference config api -// ReferenceConfigOpt is consumer's reference config -type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig - -// NewDefaultReferenceConfig returns empty ReferenceConfig -func NewDefaultReferenceConfig() *ReferenceConfig { - newReferenceConfig := NewReferenceConfig("") - newReferenceConfig.Methods = make([]*MethodConfig, 0, 8) - newReferenceConfig.Params = make(map[string]string, 8) - return newReferenceConfig -} - -// NewReferenceConfigByAPI returns ReferenceConfig with given @opts -func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *ReferenceConfig { - newReferenceConfig := NewDefaultReferenceConfig() - for _, v := range opts { - v(newReferenceConfig) - } - return newReferenceConfig -} - -// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry -func WithReferenceRegistry(registry string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Registry = registry - return config - } -} - -// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol -func WithReferenceProtocol(protocol string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Protocol = protocol - return config - } -} - -// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName -func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.InterfaceName = interfaceName - return config - } -} - -// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster -func WithReferenceCluster(cluster string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Cluster = cluster - return config - } -} - -// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb -func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: methodName, - Retries: retries, - LoadBalance: lb, - }) - return config - } -} - -///////////////////////////////////// provider config api -// ProviderConfigOpt is the -type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig - -// NewDefaultProviderConfig returns ProviderConfig with default ApplicationConfig -func NewDefaultProviderConfig() *ProviderConfig { - newConsumerConfig := &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Name: "dubbo", - Module: "module", - Organization: "dubbo_org", - Owner: "dubbo", - }, - }, - Services: make(map[string]*ServiceConfig), - Registries: make(map[string]*RegistryConfig, 8), - Protocols: make(map[string]*ProtocolConfig, 8), - } - return newConsumerConfig -} - -// NewProviderConfig returns ProviderConfig with given @opts -func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { - newConfig := NewDefaultProviderConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -// WithProviderRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig -func WithProviderRegistryConfig(regConfig *RegistryConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Registries[regConfig.Protocol] = regConfig - return config - } -} - -// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig -func WithProviderAppConfig(appConfig *ApplicationConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.ApplicationConfig = appConfig - return config - } -} - -// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Services[serviceName] = serviceConfig - return config - } -} - -// WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port -func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Protocols[protocolKey] = &ProtocolConfig{ - Name: protocol, - Port: port, - } - return config - } -} - -// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig -func WithProviderRegistry(registryKey string, registryConfig *RegistryConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Registries[registryKey] = registryConfig - return config - } -} - -/////////////////////////////////////// service config api -// ServiceConfigOpt is the option to init ServiceConfig -type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig - -// NewDefaultServiceConfig returns default ServiceConfig -func NewDefaultServiceConfig() *ServiceConfig { - newServiceConfig := NewServiceConfig("") - newServiceConfig.Params = make(map[string]string) - newServiceConfig.Methods = make([]*MethodConfig, 0, 8) - return newServiceConfig -} - -// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared -// NewServiceConfigByAPI returns ServiceConfig with given @opts -func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig { - defaultServiceConfig := NewDefaultServiceConfig() - for _, v := range opts { - v(defaultServiceConfig) - } - return defaultServiceConfig -} - -// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry -func WithServiceRegistry(registry string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Registry = registry - return config - } -} - -// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol -func WithServiceProtocol(protocol string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Protocol = protocol - return config - } -} - -// WithServiceInterface returns ServiceConfigOpt with given @interfaceName -func WithServiceInterface(interfaceName string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.InterfaceName = interfaceName - return config - } -} - -// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb -func WithServiceLoadBalance(lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Loadbalance = lb - return config - } -} - -// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time -func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Warmup = warmUp - return config - } -} - -// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster -func WithServiceCluster(cluster string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Cluster = cluster - return config - } -} - -// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb -func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: name, - Retries: retries, - LoadBalance: lb, - }) - return config - } -} - -///////////////////////////////////////// Application config api -// ApplicationConfigOpt is option to init ApplicationConfig -type ApplicationConfigOpt func(config *ApplicationConfig) *ApplicationConfig - -// NewDefaultApplicationConfig returns ApplicationConfig with default -// name: dubbo.io -// module: sample -// organization: dubbo.io -// owner: dubbogo -// version: 0.0.1 -// environment dev -func NewDefaultApplicationConfig() *ApplicationConfig { - newAppConfig := &ApplicationConfig{ - Name: "dubbo.io", - Module: "sample", - Organization: "dubbo.io", - Owner: "dubbogo", - Version: "0.0.1", - Environment: "dev", - } - return newAppConfig -} - -// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared -// NewApplicationConfig returns ApplicationConfig with default application config -func NewApplicationConfig(opts ...ApplicationConfigOpt) *ApplicationConfig { - defaultServiceConfig := NewDefaultApplicationConfig() - for _, v := range opts { - v(defaultServiceConfig) - } - return defaultServiceConfig -} - -// WithAppName returns ApplicationConfigOpt with given @name -func WithAppName(name string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Name = name - return config - } -} - -// WithAppModule returns ApplicationConfigOpt with given @module -func WithAppModule(module string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Module = module - return config - } -} - -// WithAppOrganization returns ApplicationConfigOpt wight given organization @org -func WithAppOrganization(org string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Organization = org - return config - } -} - -// WithAppOwner returns ApplicationConfigOpt with given @owner -func WithAppOwner(owner string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Owner = owner - return config - } -} - -// WithAppVersion returns ApplicationConfigOpt with given version @version -func WithAppVersion(version string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Version = version - return config - } -} - -// WithAppEnvironment returns ApplicationConfigOpt with given environment @env -func WithAppEnvironment(env string) ApplicationConfigOpt { - return func(config *ApplicationConfig) *ApplicationConfig { - config.Environment = env - return config - } -} +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" +// "dubbo.apache.org/dubbo-go/v3/config/center" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "dubbo.apache.org/dubbo-go/v3/config/method" +// "dubbo.apache.org/dubbo-go/v3/config/protocol" +// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "dubbo.apache.org/dubbo-go/v3/config/reference" +// "dubbo.apache.org/dubbo-go/v3/config/registry" +// "dubbo.apache.org/dubbo-go/v3/config/service" +// "google.golang.org/grpc/balancer/base" +// "time" +//) +// +////////////////////////////////////// default registry config +//const ( +// // defaultZKAddr is the default registry address of zookeeper +// defaultZKAddr = "127.0.0.1:2181" +// +// // defaultNacosAddr is the default registry address of nacos +// defaultNacosAddr = "127.0.0.1:8848" +// +// // defaultRegistryTimeout is the default registry timeout +// defaultRegistryTimeout = "3s" +//) +// +//// NewDefaultRegistryConfig New default registry config +//// the input @protocol can only be: +//// "zookeeper" with default addr "127.0.0.1:2181" +//// "nacos" with default addr "127.0.0.1:8848" +//func NewDefaultRegistryConfig(protocol string) *registry.RegistryConfig { +// switch protocol { +// case "zookeeper": +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// Address: defaultZKAddr, +// TimeoutStr: defaultRegistryTimeout, +// } +// case "nacos": +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// Address: defaultNacosAddr, +// TimeoutStr: defaultRegistryTimeout, +// } +// default: +// return ®istry.RegistryConfig{ +// Protocol: protocol, +// } +// } +//} +// +/////////////////////////////////////// registry config api +//type RegistryConfigOpt func(config *registry.RegistryConfig) *registry.RegistryConfig +// +//// NewRegistryConfig creates New RegistryConfig with @opts +//func NewRegistryConfig(opts ...RegistryConfigOpt) *registry.RegistryConfig { +// newRegistryConfig := NewDefaultRegistryConfig("") +// for _, v := range opts { +// newRegistryConfig = v(newRegistryConfig) +// } +// return newRegistryConfig +//} +// +//// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name +//func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Protocol = regProtocol +// return config +// } +//} +// +//// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address +//func WithRegistryAddress(addr string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Address = addr +// return config +// } +//} +// +//// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config +//func WithRegistryTimeOut(timeout string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.TimeoutStr = timeout +// return config +// } +//} +// +//// WithRegistryGroup returns RegistryConfigOpt with given @group registry group +//func WithRegistryGroup(group string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Group = group +// return config +// } +//} +// +//// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl +//func WithRegistryTTL(ttl string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.TTL = ttl +// return config +// } +//} +// +//// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName +//func WithRegistryUserName(userName string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Username = userName +// return config +// } +//} +// +//// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password +//func WithRegistryPassword(psw string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Password = psw +// return config +// } +//} +// +//// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag +//func WithRegistrySimplified(simplified bool) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Simplified = simplified +// return config +// } +//} +// +//// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag +//func WithRegistryPreferred(preferred bool) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Preferred = preferred +// return config +// } +//} +// +//// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag +//func WithRegistryWeight(weight int64) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Weight = weight +// return config +// } +//} +// +//// WithRegistryParams returns RegistryConfigOpt with given registry @params +//func WithRegistryParams(params map[string]string) RegistryConfigOpt { +// return func(config *registry.RegistryConfig) *registry.RegistryConfig { +// config.Params = params +// return config +// } +//} +// +/////////////////////////////////////// consumer config api +//// ConsumerConfigOpt is the options to init ShutdownConfig +//type ConsumerConfigOpt func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig +// +//// NewDefaultConsumerConfig returns default ShutdownConfig +//// with connection timeout = 3s, request timeout = 3s +//func NewDefaultConsumerConfig() *consumer.ShutdownConfig { +// check := true +// newConsumerConfig := &consumer.ShutdownConfig{ +// BaseConfig: base.ShutdownConfig{}, +// Registries: make(map[string]*registry.RegistryConfig, 8), +// References: make(map[string]*reference.ReferenceConfig, 8), +// ConnectTimeout: 3 * time.Second, +// RequestTimeout: 3 * time.Second, +// Check: &check, +// } +// return newConsumerConfig +//} +// +//// NewConsumerConfig returns ShutdownConfig with @opts +//func NewConsumerConfig(opts ...ConsumerConfigOpt) *consumer.ShutdownConfig { +// newConfig := NewDefaultConsumerConfig() +// for _, v := range opts { +// v(newConfig) +// } +// return newConfig +//} +// +//// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig +//func WithConsumerAppConfig(appConfig *applicationConfig.ShutdownConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.ApplicationConfig = appConfig +// return config +// } +//} +// +//// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig +//func WithConsumerRegistryConfig(registryKey string, regConfig *registry.RegistryConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.Registries[registryKey] = regConfig +// return config +// } +//} +// +//// WithConsumerReferenceConfig returns ConsumerConfigOpt with +//func WithConsumerReferenceConfig(referenceKey string, refConfig *reference.ReferenceConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.References[referenceKey] = refConfig +// return config +// } +//} +// +//// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout +//func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.ConnectTimeout = timeout +// return config +// } +//} +// +//// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout +//func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.RequestTimeout = timeout +// return config +// } +//} +// +//// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig +//func WithConsumerConfigCenterConfig(configCenterConfig *center.ShutdownConfig) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// config.ConfigCenterConfig = configCenterConfig +// return config +// } +//} +// +//// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag +//func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { +// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { +// *config.Check = check +// return config +// } +//} +// +////////////////////////////////////// reference config api +//// ReferenceConfigOpt is consumer's reference config +//type ReferenceConfigOpt func(config *reference.ReferenceConfig) *reference.ReferenceConfig +// +//// NewDefaultReferenceConfig returns empty ReferenceConfig +//func NewDefaultReferenceConfig() *reference.ReferenceConfig { +// newReferenceConfig := reference.NewReferenceConfig("") +// newReferenceConfig.Methods = make([]*method.MethodConfig, 0, 8) +// newReferenceConfig.Params = make(map[string]string, 8) +// return newReferenceConfig +//} +// +//// NewReferenceConfigByAPI returns ReferenceConfig with given @opts +//func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *reference.ReferenceConfig { +// newReferenceConfig := NewDefaultReferenceConfig() +// for _, v := range opts { +// v(newReferenceConfig) +// } +// return newReferenceConfig +//} +// +//// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry +//func WithReferenceRegistry(registry string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Registry = registry +// return config +// } +//} +// +//// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol +//func WithReferenceProtocol(protocol string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Protocol = protocol +// return config +// } +//} +// +//// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName +//func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.InterfaceName = interfaceName +// return config +// } +//} +// +//// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster +//func WithReferenceCluster(cluster string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Cluster = cluster +// return config +// } +//} +// +//// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb +//func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { +// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { +// config.Methods = append(config.Methods, &method.MethodConfig{ +// Name: methodName, +// Retries: retries, +// LoadBalance: lb, +// }) +// return config +// } +//} +// +/////////////////////////////////////// provider config api +//// ProviderConfigOpt is the +//type ProviderConfigOpt func(config *provider.ProviderConfig) *provider.ProviderConfig +// +//// NewDefaultProviderConfig returns ProviderConfig with default ShutdownConfig +//func NewDefaultProviderConfig() *provider.ProviderConfig { +// newConsumerConfig := &provider.ProviderConfig{ +// BaseConfig: base.ShutdownConfig{ +// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ +// Name: "dubbo", +// Module: "module", +// Organization: "dubbo_org", +// Owner: "dubbo", +// }, +// }, +// Services: make(map[string]*service.ShutdownConfig), +// Registries: make(map[string]*registry.RegistryConfig, 8), +// Protocols: make(map[string]*protocol.ProtocolConfig, 8), +// } +// return newConsumerConfig +//} +// +//// NewProviderConfig returns ProviderConfig with given @opts +//func NewProviderConfig(opts ...ProviderConfigOpt) *provider.ProviderConfig { +// newConfig := NewDefaultProviderConfig() +// for _, v := range opts { +// v(newConfig) +// } +// return newConfig +//} +// +//// WithProviderRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig +//func WithProviderRegistryConfig(regConfig *registry.RegistryConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Registries[regConfig.Protocol] = regConfig +// return config +// } +//} +// +//// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig +//func WithProviderAppConfig(appConfig *applicationConfig.ShutdownConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.ApplicationConfig = appConfig +// return config +// } +//} +// +//// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig +//func WithProviderServices(serviceName string, serviceConfig *service.ShutdownConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Services[serviceName] = serviceConfig +// return config +// } +//} +// +//// WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port +//func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Protocols[protocolKey] = &protocol.ProtocolConfig{ +// Name: protocol, +// Port: port, +// } +// return config +// } +//} +// +//// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig +//func WithProviderRegistry(registryKey string, registryConfig *registry.RegistryConfig) ProviderConfigOpt { +// return func(config *provider.ProviderConfig) *provider.ProviderConfig { +// config.Registries[registryKey] = registryConfig +// return config +// } +//} +// +///////////////////////////////////////// service config api +//// ServiceConfigOpt is the option to init ShutdownConfig +//type ServiceConfigOpt func(config *service.ShutdownConfig) *service.ShutdownConfig +// +//// NewDefaultServiceConfig returns default ShutdownConfig +//func NewDefaultServiceConfig() *service.ShutdownConfig { +// newServiceConfig := service.NewServiceConfig("") +// newServiceConfig.Params = make(map[string]string) +// newServiceConfig.Methods = make([]*method.MethodConfig, 0, 8) +// return newServiceConfig +//} +// +//// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared +//// NewServiceConfigByAPI returns ShutdownConfig with given @opts +//func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *service.ShutdownConfig { +// defaultServiceConfig := NewDefaultServiceConfig() +// for _, v := range opts { +// v(defaultServiceConfig) +// } +// return defaultServiceConfig +//} +// +//// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry +//func WithServiceRegistry(registry string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Registry = registry +// return config +// } +//} +// +//// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol +//func WithServiceProtocol(protocol string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Protocol = protocol +// return config +// } +//} +// +//// WithServiceInterface returns ServiceConfigOpt with given @interfaceName +//func WithServiceInterface(interfaceName string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.InterfaceName = interfaceName +// return config +// } +//} +// +//// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb +//func WithServiceLoadBalance(lb string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Loadbalance = lb +// return config +// } +//} +// +//// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time +//func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Warmup = warmUp +// return config +// } +//} +// +//// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster +//func WithServiceCluster(cluster string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Cluster = cluster +// return config +// } +//} +// +//// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb +//func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { +// return func(config *service.ShutdownConfig) *service.ShutdownConfig { +// config.Methods = append(config.Methods, &method.MethodConfig{ +// Name: name, +// Retries: retries, +// LoadBalance: lb, +// }) +// return config +// } +//} +// +/////////////////////////////////////////// Application config api +//// ApplicationConfigOpt is option to init ShutdownConfig +//type ApplicationConfigOpt func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig +// +//// NewDefaultApplicationConfig returns ShutdownConfig with default +//// name: dubbo.io +//// module: sample +//// organization: dubbo.io +//// owner: dubbogo +//// version: 0.0.1 +//// environment dev +//func NewDefaultApplicationConfig() *applicationConfig.ShutdownConfig { +// newAppConfig := &applicationConfig.ShutdownConfig{ +// Name: "dubbo.io", +// Module: "sample", +// Organization: "dubbo.io", +// Owner: "dubbogo", +// Version: "0.0.1", +// Environment: "dev", +// } +// return newAppConfig +//} +// +//// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared +//// NewApplicationConfig returns ShutdownConfig with default applicationConfig config +//func NewApplicationConfig(opts ...ApplicationConfigOpt) *applicationConfig.ShutdownConfig { +// defaultServiceConfig := NewDefaultApplicationConfig() +// for _, v := range opts { +// v(defaultServiceConfig) +// } +// return defaultServiceConfig +//} +// +//// WithAppName returns ApplicationConfigOpt with given @name +//func WithAppName(name string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Name = name +// return config +// } +//} +// +//// WithAppModule returns ApplicationConfigOpt with given @module +//func WithAppModule(module string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Module = module +// return config +// } +//} +// +//// WithAppOrganization returns ApplicationConfigOpt wight given organization @org +//func WithAppOrganization(org string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Organization = org +// return config +// } +//} +// +//// WithAppOwner returns ApplicationConfigOpt with given @owner +//func WithAppOwner(owner string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Owner = owner +// return config +// } +//} +// +//// WithAppVersion returns ApplicationConfigOpt with given version @version +//func WithAppVersion(version string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Version = version +// return config +// } +//} +// +//// WithAppEnvironment returns ApplicationConfigOpt with given environment @env +//func WithAppEnvironment(env string) ApplicationConfigOpt { +// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { +// config.Environment = env +// return config +// } +//} diff --git a/config/config_api_test.go b/config/config_api_test.go index aa70a60cf7..65899edbad 100644 --- a/config/config_api_test.go +++ b/config/config_api_test.go @@ -17,149 +17,140 @@ package config -import ( - "strconv" - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestNewDefaultServiceConfig(t *testing.T) { - serviceConfig := NewServiceConfigByAPI( - WithServiceCluster("test-cluster"), - WithServiceInterface("test-interface"), - WithServiceLoadBalance("test-loadbalance"), - WithServiceMethod("test-method1", "test-retries1", "test-lb1"), - WithServiceMethod("test-method2", "test-retries2", "test-lb2"), - WithServiceMethod("test-method3", "test-retries3", "test-lb3"), - WithServiceProtocol("test-protocol"), - WithServiceRegistry("test-registry"), - WithServiceWarmUpTime("test-warmup"), - ) - assert.Equal(t, serviceConfig.Cluster, "test-cluster") - assert.Equal(t, serviceConfig.InterfaceName, "test-interface") - assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance") - for i, v := range serviceConfig.Methods { - backFix := strconv.Itoa(i + 1) - assert.Equal(t, v.Name, "test-method"+backFix) - assert.Equal(t, v.Retries, "test-retries"+backFix) - assert.Equal(t, v.LoadBalance, "test-lb"+backFix) - } - assert.Equal(t, serviceConfig.Protocol, "test-protocol") - assert.Equal(t, serviceConfig.Registry, "test-registry") - assert.Equal(t, serviceConfig.Warmup, "test-warmup") -} - -func TestNewReferenceConfigByAPI(t *testing.T) { - refConfig := NewReferenceConfigByAPI( - WithReferenceCluster("test-cluster"), - WithReferenceInterface("test-interface"), - WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), - WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), - WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), - WithReferenceProtocol("test-protocol"), - WithReferenceRegistry("test-registry"), - ) - assert.Equal(t, refConfig.Cluster, "test-cluster") - assert.Equal(t, refConfig.InterfaceName, "test-interface") - for i, v := range refConfig.Methods { - backFix := strconv.Itoa(i + 1) - assert.Equal(t, v.Name, "test-method"+backFix) - assert.Equal(t, v.Retries, "test-retries"+backFix) - assert.Equal(t, v.LoadBalance, "test-lb"+backFix) - } - assert.Equal(t, refConfig.Protocol, "test-protocol") - assert.Equal(t, refConfig.Registry, "test-registry") -} - -func TestNewRegistryConfig(t *testing.T) { - regConfig := NewRegistryConfig( - WithRegistryTimeOut("test-timeout"), - WithRegistryProtocol("test-protocol"), - WithRegistryGroup("test-group"), - WithRegistryAddress("test-address"), - WithRegistrySimplified(true), - WithRegistryUserName("test-username"), - WithRegistryPassword("test-password"), - ) - assert.Equal(t, regConfig.TimeoutStr, "test-timeout") - assert.Equal(t, regConfig.Protocol, "test-protocol") - assert.Equal(t, regConfig.Group, "test-group") - assert.Equal(t, regConfig.Address, "test-address") - assert.Equal(t, regConfig.Simplified, true) - assert.Equal(t, regConfig.Username, "test-username") - assert.Equal(t, regConfig.Password, "test-password") -} - -func TestNewConsumerConfig(t *testing.T) { - referConfig := NewReferenceConfigByAPI( - WithReferenceCluster("test-cluster"), - WithReferenceInterface("test-interface"), - WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), - WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), - WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), - WithReferenceProtocol("test-protocol"), - WithReferenceRegistry("test-registry"), - ) - defaultZKRegistry := NewDefaultRegistryConfig("zookeeper") - assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr) - assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper") - assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout) - - testConsumerConfig := NewConsumerConfig( - WithConsumerConfigCheck(true), - WithConsumerConnTimeout(time.Minute), - WithConsumerRequestTimeout(time.Hour), - WithConsumerReferenceConfig("UserProvider", referConfig), - WithConsumerRegistryConfig("demoZK", defaultZKRegistry), - ) - - assert.Equal(t, *testConsumerConfig.Check, true) - assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute) - assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour) - assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry) - assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig) -} - -// TestNewProviderConfig test NewProviderConfig api -func TestNewProviderConfig(t *testing.T) { - serviceConfig := NewServiceConfigByAPI( - WithServiceCluster("test-cluster"), - WithServiceInterface("test-interface"), - WithServiceLoadBalance("test-loadbalance"), - WithServiceMethod("test-method1", "test-retries1", "test-lb1"), - WithServiceMethod("test-method2", "test-retries2", "test-lb2"), - WithServiceMethod("test-method3", "test-retries3", "test-lb3"), - WithServiceProtocol("test-protocol"), - WithServiceRegistry("test-registry"), - WithServiceWarmUpTime("test-warmup"), - ) - - defaultNacosRegistry := NewDefaultRegistryConfig("nacos") - assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr) - assert.Equal(t, defaultNacosRegistry.Protocol, "nacos") - assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout) - - testProviderConfig := NewProviderConfig( - WithProviderServices("UserProvider", serviceConfig), - WithProviderProtocol("dubbo", "dubbo", "20000"), - WithProviderRegistry("demoNacos", defaultNacosRegistry), - ) - - assert.NotNil(t, testProviderConfig.Services) - for k, v := range testProviderConfig.Services { - assert.Equal(t, k, "UserProvider") - assert.Equal(t, v, serviceConfig) - } - assert.NotNil(t, testProviderConfig.Registries) - - if registry, ok := testProviderConfig.Registries["demoNacos"]; ok { - assert.Equal(t, registry, defaultNacosRegistry) - } - assert.NotNil(t, testProviderConfig.Protocols) - assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo") - assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000") -} +// +//func TestNewDefaultServiceConfig(t *testing.T) { +// serviceConfig := NewServiceConfigByAPI( +// WithServiceCluster("test-cluster"), +// WithServiceInterface("test-interface"), +// WithServiceLoadBalance("test-loadbalance"), +// WithServiceMethod("test-method1", "test-retries1", "test-lb1"), +// WithServiceMethod("test-method2", "test-retries2", "test-lb2"), +// WithServiceMethod("test-method3", "test-retries3", "test-lb3"), +// WithServiceProtocol("test-protocol"), +// WithServiceRegistry("test-registry"), +// WithServiceWarmUpTime("test-warmup"), +// ) +// assert.Equal(t, serviceConfig.Cluster, "test-cluster") +// assert.Equal(t, serviceConfig.InterfaceName, "test-interface") +// assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance") +// for i, v := range serviceConfig.Methods { +// backFix := strconv.Itoa(i + 1) +// assert.Equal(t, v.Name, "test-method"+backFix) +// assert.Equal(t, v.Retries, "test-retries"+backFix) +// assert.Equal(t, v.LoadBalance, "test-lb"+backFix) +// } +// assert.Equal(t, serviceConfig.Protocol, "test-protocol") +// assert.Equal(t, serviceConfig.Registry, "test-registry") +// assert.Equal(t, serviceConfig.Warmup, "test-warmup") +//} +// +//func TestNewReferenceConfigByAPI(t *testing.T) { +// refConfig := NewReferenceConfigByAPI( +// WithReferenceCluster("test-cluster"), +// WithReferenceInterface("test-interface"), +// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), +// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), +// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), +// WithReferenceProtocol("test-protocol"), +// WithReferenceRegistry("test-registry"), +// ) +// assert.Equal(t, refConfig.Cluster, "test-cluster") +// assert.Equal(t, refConfig.InterfaceName, "test-interface") +// for i, v := range refConfig.Methods { +// backFix := strconv.Itoa(i + 1) +// assert.Equal(t, v.Name, "test-method"+backFix) +// assert.Equal(t, v.Retries, "test-retries"+backFix) +// assert.Equal(t, v.LoadBalance, "test-lb"+backFix) +// } +// assert.Equal(t, refConfig.Protocol, "test-protocol") +// assert.Equal(t, refConfig.Registry, "test-registry") +//} +// +//func TestNewRegistryConfig(t *testing.T) { +// regConfig := NewRegistryConfig( +// WithRegistryTimeOut("test-timeout"), +// WithRegistryProtocol("test-protocol"), +// WithRegistryGroup("test-group"), +// WithRegistryAddress("test-address"), +// WithRegistrySimplified(true), +// WithRegistryUserName("test-username"), +// WithRegistryPassword("test-password"), +// ) +// assert.Equal(t, regConfig.TimeoutStr, "test-timeout") +// assert.Equal(t, regConfig.Protocol, "test-protocol") +// assert.Equal(t, regConfig.Group, "test-group") +// assert.Equal(t, regConfig.Address, "test-address") +// assert.Equal(t, regConfig.Simplified, true) +// assert.Equal(t, regConfig.Username, "test-username") +// assert.Equal(t, regConfig.Password, "test-password") +//} +// +//func TestNewConsumerConfig(t *testing.T) { +// referConfig := NewReferenceConfigByAPI( +// WithReferenceCluster("test-cluster"), +// WithReferenceInterface("test-interface"), +// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"), +// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"), +// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"), +// WithReferenceProtocol("test-protocol"), +// WithReferenceRegistry("test-registry"), +// ) +// defaultZKRegistry := NewDefaultRegistryConfig("zookeeper") +// assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr) +// assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper") +// assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout) +// +// testConsumerConfig := NewConsumerConfig( +// WithConsumerConfigCheck(true), +// WithConsumerConnTimeout(time.Minute), +// WithConsumerRequestTimeout(time.Hour), +// WithConsumerReferenceConfig("UserProvider", referConfig), +// WithConsumerRegistryConfig("demoZK", defaultZKRegistry), +// ) +// +// assert.Equal(t, *testConsumerConfig.Check, true) +// assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute) +// assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour) +// assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry) +// assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig) +//} +// +//// TestNewProviderConfig test NewProviderConfig api +//func TestNewProviderConfig(t *testing.T) { +// serviceConfig := NewServiceConfigByAPI( +// WithServiceCluster("test-cluster"), +// WithServiceInterface("test-interface"), +// WithServiceLoadBalance("test-loadbalance"), +// WithServiceMethod("test-method1", "test-retries1", "test-lb1"), +// WithServiceMethod("test-method2", "test-retries2", "test-lb2"), +// WithServiceMethod("test-method3", "test-retries3", "test-lb3"), +// WithServiceProtocol("test-protocol"), +// WithServiceRegistry("test-registry"), +// WithServiceWarmUpTime("test-warmup"), +// ) +// +// defaultNacosRegistry := NewDefaultRegistryConfig("nacos") +// assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr) +// assert.Equal(t, defaultNacosRegistry.Protocol, "nacos") +// assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout) +// +// testProviderConfig := NewProviderConfig( +// WithProviderServices("UserProvider", serviceConfig), +// WithProviderProtocol("dubbo", "dubbo", "20000"), +// WithProviderRegistry("demoNacos", defaultNacosRegistry), +// ) +// +// assert.NotNil(t, testProviderConfig.Services) +// for k, v := range testProviderConfig.Services { +// assert.Equal(t, k, "UserProvider") +// assert.Equal(t, v, serviceConfig) +// } +// assert.NotNil(t, testProviderConfig.Registries) +// +// if registry, ok := testProviderConfig.Registries["demoNacos"]; ok { +// assert.Equal(t, registry, defaultNacosRegistry) +// } +// assert.NotNil(t, testProviderConfig.Protocols) +// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo") +// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000") +//} diff --git a/config/config_center_config.go b/config/config_center_config.go index 360818c8d3..d3c1976569 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -19,58 +19,70 @@ package config import ( "net/url" - "reflect" + "strings" ) import ( "github.com/creasty/defaults" - perrors "github.com/pkg/errors" + "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/config" + conf "dubbo.apache.org/dubbo-go/v3/common/config" "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/config_center" ) -// ConfigCenterConfig is configuration for config center +// CenterConfig is configuration for config center // // ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group, // those configs are already built-in in many professional third-party configuration centers. // In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups. // -// 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"` - Params map[string]string `yaml:"params" json:"parameters,omitempty"` +// CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo +type CenterConfig struct { + Protocol string `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"` + Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"` + // Deprecated + 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 -func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *CenterConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + c.translateConfigAddress() + return verify(c) +} + +func (c *CenterConfig) Validate() { + // todo set default application +} + +// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function +func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err } - type plain ConfigCenterConfig + type plain CenterConfig return unmarshal((*plain)(c)) } // GetUrlMap gets url map from ConfigCenterConfig -func (c *ConfigCenterConfig) GetUrlMap() url.Values { +func (c *CenterConfig) GetUrlMap() url.Values { urlMap := url.Values{} urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace) urlMap.Set(constant.CONFIG_GROUP_KEY, c.Group) @@ -79,7 +91,7 @@ func (c *ConfigCenterConfig) GetUrlMap() url.Values { 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) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, c.Timeout) for key, val := range c.Params { urlMap.Set(key, val) @@ -87,94 +99,107 @@ func (c *ConfigCenterConfig) GetUrlMap() url.Values { return urlMap } -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) { - 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())) - } - rc, ok := baseConfig.GetRemoteConfig(remoteRef) - if !ok { - return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) - } - // set protocol if remote not set - if len(rc.Protocol) <= 0 { - rc.Protocol = baseConfig.ConfigCenterConfig.Protocol +//translateConfigAddress translate config address +// eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos +func (c *CenterConfig) translateConfigAddress() string { + if strings.Contains(c.Address, "://") { + translatedUrl, err := url.Parse(c.Address) + if err != nil { + logger.Errorf("The config address:%s is invalid, error: %#v", c.Address, err) + panic(err) + } + c.Protocol = translatedUrl.Scheme + c.Address = strings.Replace(c.Address, translatedUrl.Scheme+"://", "", -1) } - newURL, err := rc.ToURL() - return newURL, err + return c.Address +} + +// toURL will compatible with baseConfig.ShutdownConfig.Address and baseConfig.ShutdownConfig.RemoteRef before 1.6.0 +// After 1.6.0 will not compatible, only baseConfig.ShutdownConfig.RemoteRef +func (c *CenterConfig) toURL() (*common.URL, error) { + //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())) + //} + //rc, ok := baseConfig.GetRemoteConfig(remoteRef) + //if !ok { + // return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) + //} + //// set protocol if remote not set + //if len(rc.Protocol) <= 0 { + // rc.Protocol = baseConfig.ConfigCenterConfig.Protocol + //} + return common.NewURL(c.Address, + common.WithProtocol(c.Protocol), + common.WithParams(c.GetUrlMap())) } // startConfigCenter will start the config center. // it will prepare the environment -func (b *configCenter) startConfigCenter(baseConfig BaseConfig) error { - newUrl, err := b.toURL(baseConfig) +func (c *CenterConfig) startConfigCenter() error { + newUrl, err := c.toURL() if err != nil { return err } - if err = b.prepareEnvironment(baseConfig, newUrl); err != nil { - return perrors.WithMessagef(err, "start config center error!") + if err = c.prepareEnvironment(newUrl); err != nil { + return errors.WithMessagef(err, "start config center error!") } // c.fresh() return nil } -func (b *configCenter) prepareEnvironment(baseConfig BaseConfig, configCenterUrl *common.URL) error { +func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) error { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { logger.Errorf("Get dynamic configuration error , error message is %v", err) - return perrors.WithStack(err) + return errors.WithStack(err) } - envInstance := config.GetEnvInstance() + envInstance := conf.GetEnvInstance() envInstance.SetDynamicConfiguration(dynamicConfig) - content, err := dynamicConfig.GetProperties(baseConfig.ConfigCenterConfig.ConfigFile, - config_center.WithGroup(baseConfig.ConfigCenterConfig.Group)) + _, err = dynamicConfig.GetProperties(c.ConfigFile, config_center.WithGroup(c.Group)) if err != nil { logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) - return perrors.WithStack(err) - } - var appGroup string - var appContent string - if providerConfig != nil && providerConfig.ApplicationConfig != nil && - reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ProviderConfig" { - appGroup = providerConfig.ApplicationConfig.Name - } else if consumerConfig != nil && consumerConfig.ApplicationConfig != nil && - reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ConsumerConfig" { - appGroup = consumerConfig.ApplicationConfig.Name - } - - if len(appGroup) != 0 { - configFile := baseConfig.ConfigCenterConfig.AppConfigFile - if len(configFile) == 0 { - configFile = baseConfig.ConfigCenterConfig.ConfigFile - } - appContent, err = dynamicConfig.GetProperties(configFile, config_center.WithGroup(appGroup)) - if err != nil { - return perrors.WithStack(err) - } - } - // global config file - mapContent, err := dynamicConfig.Parser().Parse(content) - if err != nil { - return perrors.WithStack(err) - } - envInstance.UpdateExternalConfigMap(mapContent) - - // appGroup config file - if len(appContent) != 0 { - appMapContent, err := dynamicConfig.Parser().Parse(appContent) - if err != nil { - return perrors.WithStack(err) - } - envInstance.UpdateAppExternalConfigMap(appMapContent) + return errors.WithStack(err) } + //var appGroup string + //var appContent string + //if config2.providerConfig != nil && config2.providerConfig.ApplicationConfig != nil && + // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ProviderConfig" { + // appGroup = config2.providerConfig.ApplicationConfig.Name + //} else if config2.consumerConfig != nil && config2.consumerConfig.ApplicationConfig != nil && + // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ConsumerConfig" { + // appGroup = config2.consumerConfig.ApplicationConfig.Name + //} + // + //if len(appGroup) != 0 { + // configFile := baseConfig.ConfigCenterConfig.AppConfigFile + // if len(configFile) == 0 { + // configFile = baseConfig.ConfigCenterConfig.ConfigFile + // } + // appContent, err = dynamicConfig.GetProperties(configFile, config_center.WithGroup(appGroup)) + // if err != nil { + // return perrors.WithStack(err) + // } + //} + //// global config file + //mapContent, err := dynamicConfig.Parser().Parse(content) + //if err != nil { + // return perrors.WithStack(err) + //} + //envInstance.UpdateExternalConfigMap(mapContent) + // + //// appGroup config file + //if len(appContent) != 0 { + // appMapContent, err := dynamicConfig.Parser().Parse(appContent) + // if err != nil { + // return perrors.WithStack(err) + // } + // envInstance.UpdateAppExternalConfigMap(appMapContent) + //} return nil } diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go deleted file mode 100644 index ec11947e4d..0000000000 --- a/config/config_center_config_test.go +++ /dev/null @@ -1,75 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/config" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config_center" -) - -func TestStartConfigCenter(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - baseConfig := &BaseConfig{ConfigCenterConfig: &ConfigCenterConfig{ - Protocol: "mock", - Address: "172.0.0.1", - Group: "dubbo", - ConfigFile: "mockDubbo.properties", - }} - - c := &configCenter{} - err := c.startConfigCenter(*baseConfig) - assert.NoError(t, err) - b, v := config.GetEnvInstance().Configuration().Back().Value.(*config.InmemoryConfiguration).GetProperty("dubbo.application.organization") - assert.True(t, b) - assert.Equal(t, "ikurento.com", v) -} - -func TestStartConfigCenterWithRemoteRef(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - m := make(map[string]*RemoteConfig) - m["mock"] = &RemoteConfig{Protocol: "mock", 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.NoError(t, err) - b, v := config.GetEnvInstance().Configuration().Back().Value.(*config.InmemoryConfiguration).GetProperty("dubbo.application.organization") - assert.True(t, b) - assert.Equal(t, "ikurento.com", v) -} diff --git a/config/config_loader.go b/config/config_loader.go index 48af47e6aa..634eb22a29 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,401 +18,489 @@ package config import ( - "flag" + "dubbo.apache.org/dubbo-go/v3/common" + "errors" "fmt" - "io/ioutil" - "os" - "reflect" - "strconv" - "sync" - "time" ) - import ( - hessian "github.com/apache/dubbo-go-hessian2" - perrors "github.com/pkg/errors" + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/json" + "github.com/knadh/koanf/parsers/toml" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/file" ) import ( - "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/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/common/yaml" - "dubbo.apache.org/dubbo-go/v3/registry" ) var ( - consumerConfig *ConsumerConfig - providerConfig *ProviderConfig - // baseConfig = providerConfig.BaseConfig or consumerConfig - baseConfig *BaseConfig - sslEnabled = false - - // configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. - // it should be used combine with double-check to avoid the race condition - configAccessMutex sync.Mutex - - maxWait = 3 - confRouterFile string - confBaseFile string - uniformVirtualServiceConfigPath string - uniformDestRuleConfigPath string + rootConfig *RootConfig + + //consumerConfig *consumer.ShutdownConfig + //providerConfig *provider.ProviderConfig + //// baseConfig = providerConfig.BaseConfig or consumerConfig + //baseConfig *root.ShutdownConfig + //sslEnabled = false + // + //// configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. + //// it should be used combine with double-check to avoid the race condition + //configAccessMutex sync.Mutex + // + maxWait = 3 ) -// loaded consumer & provider config from xxx.yml, and log config from xxx.xml -// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo -func DefaultInit() []LoaderInitOption { - var ( - confConFile string - confProFile string - ) - - fs := flag.NewFlagSet("config", flag.ContinueOnError) - fs.StringVar(&confConFile, "conConf", os.Getenv(constant.CONF_CONSUMER_FILE_PATH), "default client config path") - fs.StringVar(&confProFile, "proConf", os.Getenv(constant.CONF_PROVIDER_FILE_PATH), "default server config path") - fs.StringVar(&confRouterFile, "rouConf", os.Getenv(constant.CONF_ROUTER_FILE_PATH), "default router config path") - fs.StringVar(&uniformVirtualServiceConfigPath, "vsConf", os.Getenv(constant.CONF_VIRTUAL_SERVICE_FILE_PATH), "default virtual service of uniform router config path") - fs.StringVar(&uniformDestRuleConfigPath, "drConf", os.Getenv(constant.CONF_DEST_RULE_FILE_PATH), "default destination rule of uniform router config path") - fs.Parse(os.Args[1:]) - for len(fs.Args()) != 0 { - fs.Parse(fs.Args()[1:]) - } - // If user did not set the environment variables or flags, - // we provide default value - if confConFile == "" { - confConFile = constant.DEFAULT_CONSUMER_CONF_FILE_PATH +func Load(opts ...LoaderConfOption) { + // pares CommandLine + //parseCommandLine() + // conf + conf := NewLoaderConf(opts...) + for _, opt := range opts { + opt.apply(conf) } - if confProFile == "" { - confProFile = constant.DEFAULT_PROVIDER_CONF_FILE_PATH - } - if confRouterFile == "" { - confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH - } - return []LoaderInitOption{RouterInitOption(confRouterFile), BaseInitOption(""), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} -} -// setDefaultValue set default value for providerConfig or consumerConfig if it is null -func setDefaultValue(target interface{}) { - registryConfig := &RegistryConfig{ - Protocol: constant.DEFAULT_REGISTRY_ZK_PROTOCOL, - TimeoutStr: constant.DEFAULT_REGISTRY_ZK_TIMEOUT, - Address: constant.DEFAULT_REGISTRY_ZK_ADDRESS, - } - switch target.(type) { - case *ProviderConfig: - p := target.(*ProviderConfig) - if len(p.Registries) == 0 && p.Registry == nil { - p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig - } - if len(p.Protocols) == 0 { - p.Protocols[constant.DEFAULT_PROTOCOL] = &ProtocolConfig{ - Name: constant.DEFAULT_PROTOCOL, - Port: strconv.Itoa(constant.DEFAULT_PORT), - } - } - if p.ApplicationConfig == nil { - p.ApplicationConfig = NewDefaultApplicationConfig() - } - default: - c := target.(*ConsumerConfig) - if len(c.Registries) == 0 && c.Registry == nil { - c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig - } - if c.ApplicationConfig == nil { - c.ApplicationConfig = NewDefaultApplicationConfig() - } - } -} + // init config + rootConfig = NewRootConfig() + viper := getKoanf(conf) -func checkRegistries(registries map[string]*RegistryConfig, singleRegistry *RegistryConfig) { - if len(registries) == 0 && singleRegistry != nil { - registries[constant.DEFAULT_KEY] = singleRegistry - } -} - -func checkApplicationName(config *ApplicationConfig) { - if config == nil || len(config.Name) == 0 { - errMsg := "application config must not be nil, pls check your configuration" - logger.Errorf(errMsg) - panic(errMsg) - } -} - -func loadConsumerConfig() { - if consumerConfig == nil { - logger.Warnf("consumerConfig is nil!") - return - } - // init other consumer config - conConfigType := consumerConfig.ConfigType - for key, value := range extension.GetDefaultConfigReader() { - if conConfigType != nil { - if v, ok := conConfigType[key]; ok { - value = v - } - } - if err := extension.GetConfigReaders(value).ReadConsumerConfig(consumerConfig.fileStream); err != nil { - logger.Errorf("ReadConsumerConfig error: %#v for %s", perrors.WithStack(err), value) - } - } - - checkApplicationName(consumerConfig.ApplicationConfig) - if err := configCenterRefreshConsumer(); err != nil { - logger.Errorf("[consumer config center refresh] %#v", err) - } - - // start the metadata report if config set - if err := startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { - logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) - return + if err := viper.UnmarshalWithConf(rootConfig.Prefix(), &rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { + panic(err) } - - checkRegistries(consumerConfig.Registries, consumerConfig.Registry) - for key, ref := range consumerConfig.References { - if ref.Generic { - genericService := NewGenericService(key) - SetConsumerService(genericService) - } - rpcService := GetConsumerService(key) - if rpcService == nil { - logger.Warnf("%s does not exist!", key) - continue - } - ref.id = key - ref.Refer(rpcService) - ref.Implement(rpcService) + if rootConfig.ConfigCenter != nil { + //监听远程配置刷新本地指定配置 } - - // Write current configuration to cache file. - if consumerConfig.CacheFile != "" { - if data, err := yaml.MarshalYML(consumerConfig); err != nil { - logger.Errorf("Marshal consumer config err: %s", err.Error()) - } else { - if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0666); err != nil { - logger.Errorf("Write consumer config cache file err: %s", err.Error()) - } - } + if err := rootConfig.CheckConfig(); err != nil { + panic(err) } + rootConfig.Validate() + // root config init finish - // wait for invoker is available, if wait over default 3s, then panic - var count int - for { - checkok := true - for _, refconfig := range consumerConfig.References { - if (refconfig.Check != nil && *refconfig.Check) || - (refconfig.Check == nil && consumerConfig.Check != nil && *consumerConfig.Check) || - (refconfig.Check == nil && consumerConfig.Check == nil) { // default to true - - if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { - checkok = false - count++ - if count > maxWait { - errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) - logger.Error(errMsg) - panic(errMsg) - } - time.Sleep(time.Second * 1) - break - } - if refconfig.invoker == nil { - logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) - } - } - } - if checkok { - break - } - } + // todo why this line + //extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) + rootConfig.Provider.Load() + rootConfig.Consumer.Load() } -func loadProviderConfig() { - if providerConfig == nil { - logger.Warnf("providerConfig is nil!") - return - } - - // init other provider config - proConfigType := providerConfig.ConfigType - for key, value := range extension.GetDefaultConfigReader() { - if proConfigType != nil { - if v, ok := proConfigType[key]; ok { - value = v - } - } - if err := extension.GetConfigReaders(value).ReadProviderConfig(providerConfig.fileStream); err != nil { - logger.Errorf("ReadProviderConfig error: %#v for %s", perrors.WithStack(err), value) - } - } - - checkApplicationName(providerConfig.ApplicationConfig) - if err := configCenterRefreshProvider(); err != nil { - logger.Errorf("[provider config center refresh] %#v", err) +func check() error { + if rootConfig == nil { + return errors.New("execute the config.Load() method first") } - - // start the metadata report if config set - if err := startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { - logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) - return - } - - checkRegistries(providerConfig.Registries, providerConfig.Registry) - - // Write the current configuration to cache file. - if providerConfig.CacheFile != "" { - if data, err := yaml.MarshalYML(providerConfig); err != nil { - logger.Errorf("Marshal provider config err: %s", err.Error()) - } else { - if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0666); err != nil { - logger.Errorf("Write provider config cache file err: %s", err.Error()) - } - } - } - - for key, svs := range providerConfig.Services { - rpcService := GetProviderService(key) - if rpcService == nil { - logger.Warnf("%s does not exist!", key) - continue - } - svs.id = key - svs.Implement(rpcService) - svs.Protocols = providerConfig.Protocols - if err := svs.Export(); err != nil { - panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) - } - } - registerServiceInstance() + return nil } -// registerServiceInstance register service instance -func registerServiceInstance() { - url := selectMetadataServiceExportedURL() - if url == nil { - return - } - instance, err := createInstance(url) - if err != nil { - panic(err) - } - p := extension.GetProtocol(constant.REGISTRY_KEY) - var rp registry.RegistryFactory - var ok bool - if rp, ok = p.(registry.RegistryFactory); !ok { - panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") - } - rs := rp.GetRegistries() - for _, r := range rs { - var sdr registry.ServiceDiscoveryHolder - if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { - continue - } - err := sdr.GetServiceDiscovery().Register(instance) - if err != nil { - panic(err) - } - } - // todo publish metadata to remote - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { - remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) - } -} +//parseCommandLine parse command line +//func parseCommandLine() { +// flag.String("delim", ".", "config file delim") +// flag.String("name", "conf_application.yaml", "config file name") +// flag.String("genre", "yaml", "config file type") +// flag.String("path", "./conf", "config file path default") +// +// pflag.CommandLine.AddGoFlagSet(flag.CommandLine) +// pflag.Parse() +// +// if err := viper.BindPFlags(pflag.CommandLine); err != nil { +// panic(err) +// } +//} + +func getKoanf(conf *loaderConf) *koanf.Koanf { + var ( + k *koanf.Koanf + err error + ) -// nolint -func createInstance(url *common.URL) (registry.ServiceInstance, error) { - appConfig := GetApplicationConfig() - port, err := strconv.ParseInt(url.Port, 10, 32) - if err != nil { - return nil, perrors.WithMessage(err, "invalid port: "+url.Port) - } + k = koanf.New(conf.delim) - host := url.Ip - if len(host) == 0 { - host = common.GetLocalIp() + switch conf.genre { + case "yaml", "yml": + err = k.Load(file.Provider(conf.path), yaml.Parser()) + case "json": + err = k.Load(file.Provider(conf.path), json.Parser()) + case "toml": + err = k.Load(file.Provider(conf.path), toml.Parser()) + default: + err = errors.New(fmt.Sprintf("Unsupported %s file type", conf.genre)) } - // usually we will add more metadata - metadata := make(map[string]string, 8) - metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType - - return ®istry.DefaultServiceInstance{ - ServiceName: appConfig.Name, - Host: host, - Port: int(port), - ID: host + constant.KEY_SEPARATOR + url.Port, - Enable: true, - Healthy: true, - Metadata: metadata, - }, nil -} - -// selectMetadataServiceExportedURL get already be exported url -func selectMetadataServiceExportedURL() *common.URL { - var selectedUrl *common.URL - metaDataService, err := extension.GetLocalMetadataService("") - if err != nil { - logger.Warn(err) - return nil - } - urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) if err != nil { panic(err) } - if len(urlList) == 0 { - return nil - } - for _, url := range urlList { - selectedUrl = url - // rest first - if url.Protocol == "rest" { - break - } - } - return selectedUrl -} - -func initRouter() { - if uniformDestRuleConfigPath != "" && uniformVirtualServiceConfigPath != "" { - if err := RouterInit(uniformVirtualServiceConfigPath, uniformDestRuleConfigPath); err != nil { - logger.Warnf("[routerConfig init] %#v", err) - } - } -} - -// Load Dubbo Init -func Load() { - options := DefaultInit() - LoadWithOptions(options...) -} - -func LoadWithOptions(options ...LoaderInitOption) { - // register metadata info and service info - hessian.RegisterPOJO(&common.MetadataInfo{}) - hessian.RegisterPOJO(&common.ServiceInfo{}) - hessian.RegisterPOJO(&common.URL{}) - - for _, option := range options { - option.init() - } - for _, option := range options { - option.apply() - } - // init router - initRouter() - - // init the shutdown callback - GracefulShutdownInit() + return k } +// +//func GetConfigCenterConfig() (*center.ConfigCenterConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// if configCenterConfig != nil { +// return configCenterConfig, nil +// } +// conf := center.GetConfigCenterConfig(rootConfig.ConfigCenter, rootConfig.Koanf) +// +// if err := conf.SetDefault(); err != nil { +// return nil, err +// } +// conf.TranslateConfigAddress() +// if err := conf.Validate(rootConfig.Validate); err != nil { +// return nil, err +// } +// configCenterConfig = conf +// return conf, nil +//} +// +//// loaded consumer & provider config from xxx.yml, and log config from xxx.xml +//// Namely: dubbo.consumer.xml & dubbo.provider.xml in java dubbo +//func DefaultInit() []LoaderInitOption { +// var ( +// confConFile string +// confProFile string +// ) +// +// fs := flag.NewFlagSet("config", flag.ContinueOnError) +// fs.StringVar(&confConFile, "conConf", os.Getenv(constant.CONF_CONSUMER_FILE_PATH), "default client config path") +// fs.StringVar(&confProFile, "proConf", os.Getenv(constant.CONF_PROVIDER_FILE_PATH), "default server config path") +// fs.StringVar(&confRouterFile, "rouConf", os.Getenv(constant.CONF_ROUTER_FILE_PATH), "default router config path") +// fs.StringVar(&uniformVirtualServiceConfigPath, "vsConf", os.Getenv(constant.CONF_VIRTUAL_SERVICE_FILE_PATH), "default virtual service of uniform router config path") +// fs.StringVar(&uniformDestRuleConfigPath, "drConf", os.Getenv(constant.CONF_DEST_RULE_FILE_PATH), "default destination rule of uniform router config path") +// fs.Parse(os.Args[1:]) +// for len(fs.Args()) != 0 { +// fs.Parse(fs.Args()[1:]) +// } +// // If user did not set the environment variables or flags, +// // we provide default value +// if confConFile == "" { +// confConFile = constant.DEFAULT_CONSUMER_CONF_FILE_PATH +// } +// if confProFile == "" { +// confProFile = constant.DEFAULT_PROVIDER_CONF_FILE_PATH +// } +// if confRouterFile == "" { +// confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH +// } +// return []LoaderInitOption{RouterInitOption(confRouterFile), BaseInitOption(""), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} +//} +// +//// setDefaultValue set default value for providerConfig or consumerConfig if it is null +//func setDefaultValue(target interface{}) { +// registryConfig := ®istry2.RegistryConfig{ +// Protocol: constant.DEFAULT_REGISTRY_ZK_PROTOCOL, +// TimeoutStr: constant.DEFAULT_REGISTRY_ZK_TIMEOUT, +// Address: constant.DEFAULT_REGISTRY_ZK_ADDRESS, +// } +// switch target.(type) { +// case *provider.ProviderConfig: +// p := target.(*provider.ProviderConfig) +// if len(p.Registries) == 0 && p.Registry == nil { +// p.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig +// } +// if len(p.Protocols) == 0 { +// p.Protocols[constant.DEFAULT_PROTOCOL] = &protocol.ProtocolConfig{ +// Name: constant.DEFAULT_PROTOCOL, +// Port: strconv.Itoa(constant.DEFAULT_PORT), +// } +// } +// if p.ApplicationConfig == nil { +// p.ApplicationConfig = NewDefaultApplicationConfig() +// } +// default: +// c := target.(*consumer.ShutdownConfig) +// if len(c.Registries) == 0 && c.Registry == nil { +// c.Registries[constant.DEFAULT_REGISTRY_ZK_ID] = registryConfig +// } +// if c.ApplicationConfig == nil { +// c.ApplicationConfig = NewDefaultApplicationConfig() +// } +// } +//} +// +//func checkRegistries(registriesConfig map[string]*registry2.RegistryConfig, singleRegistry *registry2.RegistryConfig) { +// if len(registriesConfig) == 0 && singleRegistry != nil { +// registriesConfig[constant.DEFAULT_KEY] = singleRegistry +// } +//} +// +//func checkApplicationName(config *applicationConfig.ShutdownConfig) { +// if config == nil || len(config.Name) == 0 { +// errMsg := "applicationConfig config must not be nil, pls check your configuration" +// logger.Errorf(errMsg) +// panic(errMsg) +// } +//} +// +//func loadConsumerConfig() { +// if consumerConfig == nil { +// logger.Warnf("consumerConfig is nil!") +// return +// } +// // init other consumer config +// conConfigType := consumerConfig.ConfigType +// for key, value := range extension.GetDefaultConfigReader() { +// if conConfigType != nil { +// if v, ok := conConfigType[key]; ok { +// value = v +// } +// } +// if err := extension.GetConfigReaders(value).ReadConsumerConfig(consumerConfig.fileStream); err != nil { +// logger.Errorf("ReadConsumerConfig error: %#v for %s", perrors.WithStack(err), value) +// } +// } +// +// checkApplicationName(consumerConfig.ApplicationConfig) +// if err := consumer.configCenterRefreshConsumer(); err != nil { +// logger.Errorf("[consumer config center refresh] %#v", err) +// } +// +// // start the metadata report if config set +// if err := report.startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { +// logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) +// return +// } +// +// checkRegistries(consumerConfig.Registries, consumerConfig.Registry) +// for key, ref := range consumerConfig.References { +// if ref.Generic { +// genericService := generic.NewGenericService(key) +// instance.SetConsumerService(genericService) +// } +// rpcService := instance.GetConsumerService(key) +// if rpcService == nil { +// logger.Warnf("%s does not exist!", key) +// continue +// } +// ref.id = key +// ref.Refer(rpcService) +// ref.Implement(rpcService) +// } +// +// // Write current configuration to cache file. +// if consumerConfig.CacheFile != "" { +// if data, err := yaml.MarshalYML(consumerConfig); err != nil { +// logger.Errorf("Marshal consumer config err: %s", err.Error()) +// } else { +// if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0666); err != nil { +// logger.Errorf("Write consumer config cache file err: %s", err.Error()) +// } +// } +// } +// +// // wait for invoker is available, if wait over default 3s, then panic +// var count int +// for { +// checkok := true +// for _, refconfig := range consumerConfig.References { +// if (refconfig.Check != nil && *refconfig.Check) || +// (refconfig.Check == nil && consumerConfig.Check != nil && *consumerConfig.Check) || +// (refconfig.Check == nil && consumerConfig.Check == nil) { // default to true +// +// if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { +// checkok = false +// count++ +// if count > maxWait { +// errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) +// logger.Error(errMsg) +// panic(errMsg) +// } +// time.Sleep(time.Second * 1) +// break +// } +// if refconfig.invoker == nil { +// logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) +// } +// } +// } +// if checkok { +// break +// } +// } +//} +// +//func loadProviderConfig() { +// if providerConfig == nil { +// logger.Warnf("providerConfig is nil!") +// return +// } +// +// // init other provider config +// proConfigType := providerConfig.ConfigType +// for key, value := range extension.GetDefaultConfigReader() { +// if proConfigType != nil { +// if v, ok := proConfigType[key]; ok { +// value = v +// } +// } +// if err := extension.GetConfigReaders(value).ReadProviderConfig(providerConfig.fileStream); err != nil { +// logger.Errorf("ReadProviderConfig error: %#v for %s", perrors.WithStack(err), value) +// } +// } +// +// checkApplicationName(providerConfig.ApplicationConfig) +// if err := provider.configCenterRefreshProvider(); err != nil { +// logger.Errorf("[provider config center refresh] %#v", err) +// } +// +// // start the metadata report if config set +// if err := report.startMetadataReport(GetApplicationConfig().MetadataType, GetBaseConfig().MetadataReportConfig); err != nil { +// logger.Errorf("Provider starts metadata report error, and the error is {%#v}", err) +// return +// } +// +// checkRegistries(providerConfig.Registries, providerConfig.Registry) +// +// // Write the current configuration to cache file. +// if providerConfig.CacheFile != "" { +// if data, err := yaml.MarshalYML(providerConfig); err != nil { +// logger.Errorf("Marshal provider config err: %s", err.Error()) +// } else { +// if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0666); err != nil { +// logger.Errorf("Write provider config cache file err: %s", err.Error()) +// } +// } +// } +// +// for key, svs := range providerConfig.Services { +// rpcService := instance.GetProviderService(key) +// if rpcService == nil { +// logger.Warnf("%s does not exist!", key) +// continue +// } +// svs.id = key +// svs.Implement(rpcService) +// svs.Protocols = providerConfig.Protocols +// if err := svs.Export(); err != nil { +// panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) +// } +// } +// registerServiceInstance() +//} +// +//// registerServiceInstance register service instance +//func registerServiceInstance() { +// url := selectMetadataServiceExportedURL() +// if url == nil { +// return +// } +// instance, err := createInstance(url) +// if err != nil { +// panic(err) +// } +// p := extension.GetProtocol(constant.REGISTRY_KEY) +// var rp registry.RegistryFactory +// var ok bool +// if rp, ok = p.(registry.RegistryFactory); !ok { +// panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") +// } +// rs := rp.GetRegistries() +// for _, r := range rs { +// var sdr registry.ServiceDiscoveryHolder +// if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { +// continue +// } +// err := sdr.GetServiceDiscovery().Register(instance) +// if err != nil { +// panic(err) +// } +// } +// // todo publish metadata to remote +// if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { +// remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) +// } +//} +// +//// nolint +//func createInstance(url *common.URL) (registry.ServiceInstance, error) { +// appConfig := GetApplicationConfig() +// port, err := strconv.ParseInt(url.Port, 10, 32) +// if err != nil { +// return nil, perrors.WithMessage(err, "invalid port: "+url.Port) +// } +// +// host := url.Ip +// if len(host) == 0 { +// host = common.GetLocalIp() +// } +// +// // usually we will add more metadata +// metadata := make(map[string]string, 8) +// metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType +// +// return ®istry.DefaultServiceInstance{ +// ServiceName: appConfig.Name, +// Host: host, +// Port: int(port), +// ID: host + constant.KEY_SEPARATOR + url.Port, +// Enable: true, +// Healthy: true, +// Metadata: metadata, +// }, nil +//} +// +//// selectMetadataServiceExportedURL get already be exported url +//func selectMetadataServiceExportedURL() *common.URL { +// var selectedUrl *common.URL +// metaDataService, err := extension.GetLocalMetadataService("") +// if err != nil { +// logger.Warn(err) +// return nil +// } +// urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) +// if err != nil { +// panic(err) +// } +// if len(urlList) == 0 { +// return nil +// } +// for _, url := range urlList { +// selectedUrl = url +// // rest first +// if url.Protocol == "rest" { +// break +// } +// } +// return selectedUrl +//} +// +//func initRouter() { +// if uniformDestRuleConfigPath != "" && uniformVirtualServiceConfigPath != "" { +// if err := router.RouterInit(uniformVirtualServiceConfigPath, uniformDestRuleConfigPath); err != nil { +// logger.Warnf("[routerConfig init] %#v", err) +// } +// } +//} +// +//// Load Dubbo Init +//func Load() { +// options := DefaultInit() +// LoadWithOptions(options...) +//} +// +//func LoadWithOptions(options ...LoaderInitOption) { +// // register metadata info and service info +// hessian.RegisterPOJO(&common.MetadataInfo{}) +// hessian.RegisterPOJO(&common.ServiceInfo{}) +// hessian.RegisterPOJO(&common.URL{}) +// +// for _, option := range options { +// option.init() +// } +// for _, option := range options { +// option.apply() +// } +// // init router +// initRouter() +// +// // init the shutdown callback +// shutdown.GracefulShutdownInit() +//} +// // GetRPCService get rpc service for consumer func GetRPCService(name string) common.RPCService { - return consumerConfig.References[name].GetRPCService() + return rootConfig.Consumer.References[name].GetRPCService() } // RPCService create rpc service for consumer func RPCService(service common.RPCService) { - consumerConfig.References[service.Reference()].Implement(service) + rootConfig.Consumer.References[service.Reference()].Implement(service) } // GetMetricConfig find the MetricConfig @@ -421,83 +509,71 @@ func RPCService(service common.RPCService) { // In general, it will be locked 0 or 1 time. // So you don't need to worry about the race condition func GetMetricConfig() *MetricConfig { - if GetBaseConfig().MetricConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if GetBaseConfig().MetricConfig == nil { - GetBaseConfig().MetricConfig = &MetricConfig{} - } - } - return GetBaseConfig().MetricConfig + // todo + //if GetBaseConfig().MetricConfig == nil { + // configAccessMutex.Lock() + // defer configAccessMutex.Unlock() + // if GetBaseConfig().MetricConfig == nil { + // GetBaseConfig().MetricConfig = &metric.MetricConfig{} + // } + //} + //return GetBaseConfig().MetricConfig + return rootConfig.MetricConfig } -// GetApplicationConfig find the application config +// GetApplicationConfig find the applicationConfig config // if not, we will create one // Usually applicationConfig will be initialized when system start // we use double-check to reduce race condition // In general, it will be locked 0 or 1 time. // So you don't need to worry about the race condition -func GetApplicationConfig() *ApplicationConfig { - if GetBaseConfig().ApplicationConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if GetBaseConfig().ApplicationConfig == nil { - GetBaseConfig().ApplicationConfig = &ApplicationConfig{} - } - } - return GetBaseConfig().ApplicationConfig -} +//func GetApplicationConfig() *ShutdownConfig { +// // todo +// //if GetBaseConfig().ApplicationConfig == nil { +// // configAccessMutex.Lock() +// // defer configAccessMutex.Unlock() +// // if GetBaseConfig().ApplicationConfig == nil { +// // GetBaseConfig().ApplicationConfig = &applicationConfig.ShutdownConfig{} +// // } +// //} +// //return GetBaseConfig().ApplicationConfig +// return rootConfig. +//} // GetProviderConfig find the provider config // if not found, create new one -func GetProviderConfig() ProviderConfig { - if providerConfig == nil { - if providerConfig == nil { - return ProviderConfig{} - } - } - return *providerConfig -} +//func GetProviderConfig() provider.ProviderConfig { +// if providerConfig == nil { +// if providerConfig == nil { +// return provider.ProviderConfig{} +// } +// } +// return *providerConfig +//} // GetConsumerConfig find the consumer config // if not found, create new one // we use double-check to reduce race condition // In general, it will be locked 0 or 1 time. // So you don't need to worry about the race condition -func GetConsumerConfig() ConsumerConfig { - if consumerConfig == nil { - if consumerConfig == nil { - return ConsumerConfig{} - } - } - return *consumerConfig -} - -func GetBaseConfig() *BaseConfig { - if baseConfig == nil { - configAccessMutex.Lock() - defer configAccessMutex.Unlock() - if baseConfig == nil { - baseConfig = &BaseConfig{ - MetricConfig: &MetricConfig{}, - ConfigCenterConfig: &ConfigCenterConfig{}, - Remotes: make(map[string]*RemoteConfig), - ApplicationConfig: &ApplicationConfig{}, - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - } - } - } - return baseConfig -} - -func GetSslEnabled() bool { - return sslEnabled -} - -func SetSslEnabled(enabled bool) { - sslEnabled = enabled -} +//func GetConsumerConfig() consumer.ShutdownConfig { +// if consumerConfig == nil { +// if consumerConfig == nil { +// return consumer.ShutdownConfig{} +// } +// } +// return *consumerConfig +//} + +//func GetSslEnabled() bool { +// return sslEnabled +//} +// +//func SetSslEnabled(enabled bool) { +// sslEnabled = enabled +//} func IsProvider() bool { - return providerConfig != nil + // FixME + return rootConfig.Provider != nil } diff --git a/config/config_loader_options.go b/config/config_loader_options.go index bc8aff1a17..685447ad07 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -1,138 +1,252 @@ /* - * 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. +* 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 import ( - "log" + "fmt" + "os" + "path/filepath" + "runtime" + "sort" + "strings" ) - import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" + "github.com/pkg/errors" ) -type LoaderInitOption interface { - init() - apply() +type loaderConf struct { + // loaderConf file type default yaml + genre string + // loaderConf file path default ./conf + path string + // loaderConf file delim default . + delim string } -type optionFunc struct { - initFunc func() - applyFunc func() -} +func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { + conf := &loaderConf{ + genre: "yaml", + path: "./conf/application.yaml", + delim: ".", + } -func (f *optionFunc) init() { - f.initFunc() + for _, opt := range opts { + opt.apply(conf) + } + return conf } -func (f *optionFunc) apply() { - f.applyFunc() +type LoaderConfOption interface { + apply(vc *loaderConf) } -func ConsumerInitOption(confConFile string) LoaderInitOption { - return consumerInitOption(confConFile, false) -} +type loaderConfigFunc func(*loaderConf) -func ConsumerMustInitOption(confConFile string) LoaderInitOption { - return consumerInitOption(confConFile, true) +func (fn loaderConfigFunc) apply(vc *loaderConf) { + fn(vc) } -func consumerInitOption(confConFile string, must bool) LoaderInitOption { - return &optionFunc{ - func() { - if consumerConfig != nil && !must { - return - } - if errCon := ConsumerInit(confConFile); errCon != nil { - log.Printf("[consumerInit] %#v", errCon) - consumerConfig = nil - } else if confBaseFile == "" { - // Check if there are some important key fields missing, - // if so, we set a default value for it - setDefaultValue(consumerConfig) - // Even though baseConfig has been initialized, we override it - // because we think read from config file is correct config - baseConfig = &consumerConfig.BaseConfig - } - }, - func() { - loadConsumerConfig() - }, - } +// WithGenre set loaderConf Genre +func WithGenre(genre string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { + g := strings.ToLower(genre) + if err := checkGenre(g); err != nil { + panic(err) + } + conf.genre = g + }) } -func ProviderInitOption(confProFile string) LoaderInitOption { - return providerInitOption(confProFile, false) +// WithPath set loaderConf path +func WithPath(path string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { + conf.path = absolutePath(path) + }) } -func ProviderMustInitOption(confProFile string) LoaderInitOption { - return providerInitOption(confProFile, true) +func WithDelim(delim string) LoaderConfOption { + return loaderConfigFunc(func(conf *loaderConf) { + conf.delim = delim + }) } -func providerInitOption(confProFile string, must bool) LoaderInitOption { - return &optionFunc{ - func() { - if providerConfig != nil && !must { - return - } - if errPro := ProviderInit(confProFile); errPro != nil { - log.Printf("[providerInit] %#v", errPro) - providerConfig = nil - } else if confBaseFile == "" { - // Check if there are some important key fields missing, - // if so, we set a default value for it - setDefaultValue(providerConfig) - // Even though baseConfig has been initialized, we override it - // because we think read from config file is correct config - baseConfig = &providerConfig.BaseConfig - } - }, - func() { - loadProviderConfig() - }, +// absolutePath get absolut path +func absolutePath(inPath string) string { + + if inPath == "$HOME" || strings.HasPrefix(inPath, "$HOME"+string(os.PathSeparator)) { + inPath = userHomeDir() + inPath[5:] } + + if filepath.IsAbs(inPath) { + return filepath.Clean(inPath) + } + + p, err := filepath.Abs(inPath) + if err == nil { + return filepath.Clean(p) + } + + return "" } -func RouterInitOption(crf string) LoaderInitOption { - return &optionFunc{ - func() { - confRouterFile = crf - }, - func() { - initRouter() - }, +//userHomeDir get gopath +func userHomeDir() string { + if runtime.GOOS == "windows" { + home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") + if home == "" { + home = os.Getenv("USERPROFILE") + } + return home } + return os.Getenv("HOME") } -func BaseInitOption(cbf string) LoaderInitOption { - return &optionFunc{ - func() { - if cbf == "" { - return - } - confBaseFile = cbf - if err := BaseInit(cbf); err != nil { - log.Printf("[BaseInit] %#v", err) - baseConfig = nil - } - }, - func() { - // init the global event dispatcher - extension.SetAndInitGlobalDispatcher(GetBaseConfig().EventDispatcherType) - }, +// checkGenre check Genre +func checkGenre(genre string) error { + genres := []string{"json", "toml", "yaml", "yml"} + sort.Strings(genres) + idx := sort.SearchStrings(genres, genre) + if genres[idx] != genre { + return errors.New(fmt.Sprintf("no support %s", genre)) } + return nil } + +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/loaderConf/base" +// "dubbo.apache.org/dubbo-go/v3/loaderConf/consumer" +// "dubbo.apache.org/dubbo-go/v3/loaderConf/provider" +// "log" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common/extension" +//) +// +//type LoaderInitOption interface { +// init() +// apply() +//} +// +//type loaderConfigFunc struct { +// initFunc func() +// applyFunc func() +//} +// +//func (f *loaderConfigFunc) init() { +// f.initFunc() +//} +// +//func (f *loaderConfigFunc) apply() { +// f.applyFunc() +//} +// +//func ConsumerInitOption(confConFile string) LoaderInitOption { +// return consumerInitOption(confConFile, false) +//} +// +//func ConsumerMustInitOption(confConFile string) LoaderInitOption { +// return consumerInitOption(confConFile, true) +//} +// +//func consumerInitOption(confConFile string, must bool) LoaderInitOption { +// return &loaderConfigFunc{ +// func() { +// if consumerConfig != nil && !must { +// return +// } +// if errCon := consumer.ConsumerInit(confConFile); errCon != nil { +// log.Printf("[consumerInit] %#v", errCon) +// consumerConfig = nil +// } else if confBaseFile == "" { +// // Check if there are some important key fields missing, +// // if so, we set a default value for it +// setDefaultValue(consumerConfig) +// // Even though baseConfig has been initialized, we override it +// // because we think read from loaderConf file is correct loaderConf +// baseConfig = &consumerConfig.BaseConfig +// } +// }, +// func() { +// loadConsumerConfig() +// }, +// } +//} +// +//func ProviderInitOption(confProFile string) LoaderInitOption { +// return providerInitOption(confProFile, false) +//} +// +//func ProviderMustInitOption(confProFile string) LoaderInitOption { +// return providerInitOption(confProFile, true) +//} +// +//func providerInitOption(confProFile string, must bool) LoaderInitOption { +// return &loaderConfigFunc{ +// func() { +// if providerConfig != nil && !must { +// return +// } +// if errPro := provider.ProviderInit(confProFile); errPro != nil { +// log.Printf("[providerInit] %#v", errPro) +// providerConfig = nil +// } else if confBaseFile == "" { +// // Check if there are some important key fields missing, +// // if so, we set a default value for it +// setDefaultValue(providerConfig) +// // Even though baseConfig has been initialized, we override it +// // because we think read from loaderConf file is correct loaderConf +// baseConfig = &providerConfig.BaseConfig +// } +// }, +// func() { +// loadProviderConfig() +// }, +// } +//} +// +//func RouterInitOption(crf string) LoaderInitOption { +// return &loaderConfigFunc{ +// func() { +// confRouterFile = crf +// }, +// func() { +// initRouter() +// }, +// } +//} +// +//func BaseInitOption(cbf string) LoaderInitOption { +// return &loaderConfigFunc{ +// func() { +// if cbf == "" { +// return +// } +// confBaseFile = cbf +// if err := base.BaseInit(cbf); err != nil { +// log.Printf("[BaseInit] %#v", err) +// baseConfig = nil +// } +// }, +// func() { +// // init the global event dispatcher +// extension.SetAndInitGlobalDispatcher(GetBaseConfig().EventDispatcherType) +// }, +// } +//} diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go new file mode 100644 index 0000000000..000489823e --- /dev/null +++ b/config/config_loader_options_test.go @@ -0,0 +1,61 @@ +/* +* 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 + +import ( + "testing" +) + +import "github.com/stretchr/testify/assert" + +func TestCheckGenre(t *testing.T) { + + err := checkGenre("abc") + assert.NotNil(t, err) + + err = checkGenre("json") + assert.Nil(t, err) +} + +func TestNewLoaderConf(t *testing.T) { + conf := NewLoaderConf() + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} + +func TestWithDelim(t *testing.T) { + conf := NewLoaderConf(WithDelim(":")) + assert.Equal(t, ":", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} + +func TestWithPath(t *testing.T) { + conf := NewLoaderConf(WithPath("./conf/app.yaml")) + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "yaml", conf.genre) + assert.Equal(t, absolutePath("./conf/app.yaml"), conf.path) +} + +func TestWithGenre(t *testing.T) { + conf := NewLoaderConf(WithGenre("json")) + assert.Equal(t, ".", conf.delim) + assert.Equal(t, "json", conf.genre) + assert.Equal(t, "./conf/application.yaml", conf.path) +} diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 737b6f641d..a3fade14b8 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,605 +18,624 @@ package config import ( - "context" - "path/filepath" - "sort" - "sync" + "dubbo.apache.org/dubbo-go/v3/common/constant" "testing" ) -import ( - "github.com/Workiva/go-datastructures/slice/skip" - gxset "github.com/dubbogo/gost/container/set" - gxpage "github.com/dubbogo/gost/hash/page" - "github.com/stretchr/testify/assert" - "go.uber.org/atomic" -) +import "github.com/stretchr/testify/assert" -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/config" - "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/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" -) +import "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" + +func init() { + SetProviderService(new(service.OrderService)) + SetProviderService(new(service.HelloService)) +} const ( - mockConsumerConfigPath = "./testdata/consumer_config.yml" - mockProviderConfigPath = "./testdata/provider_config.yml" + configPath = "./testdata/application.yaml" ) -func TestConfigLoader(t *testing.T) { - conPath, err := filepath.Abs(mockConsumerConfigPath) - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) - - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) - - err = ConsumerInit(conPath) - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - assert.Equal(t, "soa.com.ikurento.user.UserProvider", GetConsumerConfig().References["UserProvider"].Params["serviceid"]) -} - func TestLoad(t *testing.T) { - extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} + Load(WithPath(configPath)) + + t.Run("application", func(t *testing.T) { + application := rootConfig.Application + + assert.Equal(t, application.Organization, "dubbo.io") + assert.Equal(t, application.Name, "dubbo-go") + assert.Equal(t, application.Module, "local") + assert.Equal(t, application.Version, "1.0.0") + assert.Equal(t, application.Owner, "zhaoyunxing") + assert.Equal(t, application.Environment, "dev") + assert.Equal(t, application.MetadataType, "local") }) - doInitConsumer() - doInitProvider() + t.Run("registries", func(t *testing.T) { + registries := rootConfig.Registries - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) - - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - GetApplicationConfig().MetadataType = "mock" - var mm *mockMetadataService - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil + assert.Equal(t, 2, len(registries)) + //address= nacos://127.0.0.1:8848 Translate Registry Address + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "10s", registries["zk"].Timeout) }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - err := common.ServiceMap.UnRegister("com.MockService", "mock", - common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - assert.Nil(t, err) - consumerConfig = nil - providerConfig = nil -} -func TestLoadWithSingleReg(t *testing.T) { - doInitConsumerWithSingleRegistry() - mockInitProviderWithSingleRegistry() + //config-center + t.Run("config-center", func(t *testing.T) { + conf := rootConfig.ConfigCenter - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) - - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - var mm *mockMetadataService - GetApplicationConfig().MetadataType = "mock" - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil + assert.Equal(t, "nacos", conf.Protocol) }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - consumerConfig = nil - providerConfig = nil } -func TestWithNoRegLoad(t *testing.T) { - doInitConsumer() - doInitProvider() - providerConfig.Services["MockService"].Registry = "" - consumerConfig.References["MockService"].Registry = "" - ms := &MockService{} - SetConsumerService(ms) - SetProviderService(ms) +//TestLoadConfigCenter test key config_center、config-center 、configCenter +func TestLoadConfigCenter(t *testing.T) { - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) - var mm *mockMetadataService - GetApplicationConfig().MetadataType = "mock" - extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { - if mm == nil { - mm = &mockMetadataService{ - exportedServiceURLs: new(sync.Map), - lock: new(sync.RWMutex), - } - } - return mm, nil + t.Run("config-center", func(t *testing.T) { + Load(WithPath("./testdata/config/center/conf-application.yaml")) + conf := rootConfig.ConfigCenter + assert.Equal(t, "nacos", conf.Protocol) + assert.Equal(t, "10s", conf.Timeout) + assert.Equal(t, "./logs", conf.LogDir) }) - Load() - - assert.Equal(t, ms, GetRPCService(ms.Reference())) - ms2 := &struct { - MockService - }{} - RPCService(ms2) - assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) - - conServices = map[string]common.RPCService{} - proServices = map[string]common.RPCService{} - err := common.ServiceMap.UnRegister("com.MockService", "mock", - common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - assert.Nil(t, err) - common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) - consumerConfig = nil - providerConfig = nil } -func TestSetDefaultValue(t *testing.T) { - proConfig := &ProviderConfig{Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig)} - assert.Nil(t, proConfig.ApplicationConfig) - setDefaultValue(proConfig) - assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181") - assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s") - assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper") - assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo") - assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") - assert.NotNil(t, proConfig.ApplicationConfig) - - conConfig := &ConsumerConfig{Registries: make(map[string]*RegistryConfig)} - assert.Nil(t, conConfig.ApplicationConfig) - setDefaultValue(conConfig) - assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") - assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s") - assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper") - assert.NotNil(t, conConfig.ApplicationConfig) - -} -func TestConfigLoaderWithConfigCenter(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{} - }) - - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) +func TestGetRegistriesConfig(t *testing.T) { - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) + t.Run("registry", func(t *testing.T) { + Load(WithPath("./testdata/config/registry/application.yaml")) - err = ConsumerInit(conPath) - assert.NoError(t, err) - err = configCenterRefreshConsumer() - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - err = configCenterRefreshProvider() - assert.NoError(t, err) + registries := rootConfig.Registries - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - - assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) - assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address) -} - -func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) { - consumerConfig = nil - providerConfig = nil - config.NewEnvInstance() - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { - return &config_center.MockDynamicConfigurationFactory{Content: ` - dubbo.consumer.request_timeout=5s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registry.address=mock://127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover - dubbo.protocols.jsonrpc1.name=jsonrpc - dubbo.protocols.jsonrpc1.ip=127.0.0.1 - dubbo.protocols.jsonrpc1.port=20001 -`} + assert.Equal(t, 2, len(registries)) + // nacos + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "5s", registries["nacos"].Timeout) + assert.Equal(t, "127.0.0.1:8848", registries["nacos"].Address) + assert.Equal(t, "dev", registries["nacos"].Group) + // zk + assert.Equal(t, "zookeeper", registries["zk"].Protocol) + assert.Equal(t, "10s", registries["zk"].Timeout) + assert.Equal(t, "127.0.0.1:2181", registries["zk"].Address) + assert.Equal(t, "test", registries["zk"].Group) }) - - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - proPath, err := filepath.Abs(mockProviderConfigPath) - assert.NoError(t, err) - - assert.Nil(t, consumerConfig) - assert.Equal(t, ConsumerConfig{}, GetConsumerConfig()) - assert.Nil(t, providerConfig) - assert.Equal(t, ProviderConfig{}, GetProviderConfig()) - - err = ConsumerInit(conPath) - assert.NoError(t, err) - checkApplicationName(consumerConfig.ApplicationConfig) - err = configCenterRefreshConsumer() - checkRegistries(consumerConfig.Registries, consumerConfig.Registry) - assert.NoError(t, err) - err = ProviderInit(proPath) - assert.NoError(t, err) - checkApplicationName(providerConfig.ApplicationConfig) - err = configCenterRefreshProvider() - checkRegistries(providerConfig.Registries, providerConfig.Registry) - assert.NoError(t, err) - - assert.NotNil(t, consumerConfig) - assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig()) - assert.NotNil(t, providerConfig) - assert.NotEqual(t, ProviderConfig{}, GetProviderConfig()) - - assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) - assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address) -} - -func TestGetBaseConfig(t *testing.T) { - bc := GetBaseConfig() - assert.NotNil(t, bc) - _, found := bc.GetRemoteConfig("mock") - assert.False(t, found) -} - -// mockInitProviderWithSingleRegistry will init a mocked providerConfig -func mockInitProviderWithSingleRegistry() { - providerConfig = &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "1.0.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &RegistryConfig{ - Address: "mock://127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - Registries: map[string]*RegistryConfig{}, - - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - }, - Protocols: map[string]*ProtocolConfig{ - "mock": { - Name: "mock", - Ip: "127.0.0.1", - Port: "20000", - }, - }, - } -} - -type mockMetadataService struct { - exportedServiceURLs *sync.Map - lock *sync.RWMutex -} - -func (m *mockMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { - panic("implement me") -} - -func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { - panic("implement me") -} - -func (m *mockMetadataService) Reference() string { - panic("implement me") -} - -func (m *mockMetadataService) ServiceName() (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) ExportURL(url *common.URL) (bool, error) { - return m.addURL(m.exportedServiceURLs, url), nil -} - -func (m *mockMetadataService) UnexportURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { - return nil -} - -func (m *mockMetadataService) MethodMapper() map[string]string { - panic("implement me") } -func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) Version() (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) addURL(targetMap *sync.Map, url *common.URL) bool { - var ( - urlSet interface{} - loaded bool - ) - logger.Debug(url.ServiceKey()) - if urlSet, loaded = targetMap.LoadOrStore(url.ServiceKey(), skip.New(uint64(0))); loaded { - m.lock.RLock() - wantedUrl := urlSet.(*skip.SkipList).Get(url) - if len(wantedUrl) > 0 && wantedUrl[0] != nil { - m.lock.RUnlock() - return false - } - m.lock.RUnlock() - } - m.lock.Lock() - // double chk - wantedUrl := urlSet.(*skip.SkipList).Get(url) - if len(wantedUrl) > 0 && wantedUrl[0] != nil { - m.lock.Unlock() - return false - } - urlSet.(*skip.SkipList).Insert(url) - m.lock.Unlock() - return true -} - -func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { - // using skip list to dedup and sorting - var res []*common.URL - services.Range(func(key, value interface{}) bool { - urls := value.(*skip.SkipList) - for i := uint64(0); i < urls.Len(); i++ { - url := urls.ByPosition(i).(*common.URL) - if url.GetParam(constant.INTERFACE_KEY, url.Path) != constant.METADATA_SERVICE_NAME { - res = append(res, url) - } - } - return true +func TestGetProtocolsConfig(t *testing.T) { + + //t.Run("empty protocols", func(t *testing.T) { + // Load(WithPath("./testdata/config/protocol/empty_application.yaml")) + // + // protocols := rootConfig.Protocols + // assert.NotNil(t, protocols) + // // default + // assert.Equal(t, "dubbo", protocols["default"].Name) + // assert.Equal(t, "127.0.0.1", protocols["default"].Ip) + // assert.Equal(t, 0, protocols["default"].Port) + //}) + + t.Run("protocols", func(t *testing.T) { + Load(WithPath("./testdata/config/protocol/application.yaml")) + + protocols := rootConfig.Protocols + assert.NotNil(t, protocols) + // default + assert.Equal(t, "dubbo", protocols["dubbo"].Name) + assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) + assert.Equal(t, string("20000"), protocols["dubbo"].Port) }) - sort.Sort(common.URLSlice(res)) - return res -} - -type mockServiceDiscoveryRegistry struct{} - -func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) IsAvailable() bool { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Destroy() { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Register(*common.URL) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) UnRegister(*common.URL) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) Subscribe(*common.URL, registry.NotifyListener) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error { - panic("implement me") -} - -func (mr *mockServiceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery { - return &mockServiceDiscovery{} -} - -type mockServiceDiscovery struct{} - -func (m *mockServiceDiscovery) String() string { - panic("implement me") -} - -func (m *mockServiceDiscovery) Destroy() error { - panic("implement me") } -func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { - return nil -} - -func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetDefaultPageSize() int { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { - panic("implement me") -} - -func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { - if len(urls) == 0 { - return []interface{}{} - } - - res := make([]interface{}, 0, len(urls)) - for _, u := range urls { - res = append(res, u.String()) - } - return res -} - -type mockGracefulShutdownFilter struct{} - -func (f *mockGracefulShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - panic("implement me") -} +func TestGetProviderConfig(t *testing.T) { + // empty registry + t.Run("empty registry", func(t *testing.T) { + Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) + provider := rootConfig.Provider + assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) + }) -func (f *mockGracefulShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - panic("implement me") + t.Run("root registry", func(t *testing.T) { + Load(WithPath("./testdata/config/provider/registry_application.yaml")) + provider := rootConfig.Provider + assert.NotNil(t, provider) + }) } -func (f *mockGracefulShutdownFilter) Set(name string, config interface{}) { - return -} +// +//func TestLoadWithSingleReg(t *testing.T) { +// reference.doInitConsumerWithSingleRegistry() +// mockInitProviderWithSingleRegistry() +// +// ms := &MockService{} +// instance.SetConsumerService(ms) +// instance.SetProviderService(ms) +// +// extension.SetProtocol("registry", reference.GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) +// var mm *mockMetadataService +// GetApplicationConfig().MetadataType = "mock" +// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { +// if mm == nil { +// mm = &mockMetadataService{ +// exportedServiceURLs: new(sync.Map), +// lock: new(sync.RWMutex), +// } +// } +// return mm, nil +// }) +// Load() +// +// assert.Equal(t, ms, GetRPCService(ms.Reference())) +// ms2 := &struct { +// MockService +// }{} +// RPCService(ms2) +// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) +// +// service2.conServices = map[string]common.RPCService{} +// service2.proServices = map[string]common.RPCService{} +// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// consumerConfig = nil +// providerConfig = nil +//} +// +//func TestWithNoRegLoad(t *testing.T) { +// reference.doInitConsumer() +// service2.doInitProvider() +// providerConfig.Services["MockService"].Registry = "" +// consumerConfig.References["MockService"].Registry = "" +// ms := &MockService{} +// instance.SetConsumerService(ms) +// instance.SetProviderService(ms) +// +// extension.SetProtocol("registry", reference.GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) +// var mm *mockMetadataService +// GetApplicationConfig().MetadataType = "mock" +// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { +// if mm == nil { +// mm = &mockMetadataService{ +// exportedServiceURLs: new(sync.Map), +// lock: new(sync.RWMutex), +// } +// } +// return mm, nil +// }) +// Load() +// +// assert.Equal(t, ms, GetRPCService(ms.Reference())) +// ms2 := &struct { +// MockService +// }{} +// RPCService(ms2) +// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) +// +// service2.conServices = map[string]common.RPCService{} +// service2.proServices = map[string]common.RPCService{} +// err := common.ServiceMap.UnRegister("com.MockService", "mock", +// common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// assert.Nil(t, err) +// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) +// consumerConfig = nil +// providerConfig = nil +//} +// +//func TestSetDefaultValue(t *testing.T) { +// proConfig := &provider.ProviderConfig{Registries: make(map[string]*registry2.RegistryConfig), Protocols: make(map[string]*protocol2.ProtocolConfig)} +// assert.Nil(t, proConfig.ApplicationConfig) +// setDefaultValue(proConfig) +// assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181") +// assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s") +// assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper") +// assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo") +// assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") +// assert.NotNil(t, proConfig.ApplicationConfig) +// +// conConfig := &consumer.ShutdownConfig{Registries: make(map[string]*registry2.RegistryConfig)} +// assert.Nil(t, conConfig.ApplicationConfig) +// setDefaultValue(conConfig) +// assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") +// assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s") +// assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper") +// assert.NotNil(t, conConfig.ApplicationConfig) +// +//} +//func TestConfigLoaderWithConfigCenter(t *testing.T) { +// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { +// return &config_center.MockDynamicConfigurationFactory{} +// }) +// +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// proPath, err := filepath.Abs(mockProviderConfigPath) +// assert.NoError(t, err) +// +// assert.Nil(t, consumerConfig) +// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) +// assert.Nil(t, providerConfig) +// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// err = consumer.ConsumerInit(conPath) +// assert.NoError(t, err) +// err = consumer.configCenterRefreshConsumer() +// assert.NoError(t, err) +// err = provider.ProviderInit(proPath) +// assert.NoError(t, err) +// err = provider.configCenterRefreshProvider() +// assert.NoError(t, err) +// +// assert.NotNil(t, consumerConfig) +// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) +// assert.NotNil(t, providerConfig) +// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) +// assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address) +//} +// +//func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) { +// consumerConfig = nil +// providerConfig = nil +// config.NewEnvInstance() +// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { +// return &config_center.MockDynamicConfigurationFactory{Content: ` +// dubbo.consumer.request_timeout=5s +// dubbo.consumer.connect_timeout=5s +// dubbo.applicationConfig.organization=ikurento.com +// dubbo.applicationConfig.name=BDTService +// dubbo.applicationConfig.module=dubbogo user-info server +// dubbo.applicationConfig.version=0.0.1 +// dubbo.applicationConfig.owner=ZX +// dubbo.applicationConfig.environment=dev +// dubbo.registry.address=mock://127.0.0.1:2182 +// dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo +// dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider +// dubbo.service.com.ikurento.user.UserProvider.loadbalance=random +// dubbo.service.com.ikurento.user.UserProvider.warmup=100 +// dubbo.service.com.ikurento.user.UserProvider.cluster=failover +// dubbo.protocols.jsonrpc1.name=jsonrpc +// dubbo.protocols.jsonrpc1.ip=127.0.0.1 +// dubbo.protocols.jsonrpc1.port=20001 +//`} +// }) +// +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// proPath, err := filepath.Abs(mockProviderConfigPath) +// assert.NoError(t, err) +// +// assert.Nil(t, consumerConfig) +// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) +// assert.Nil(t, providerConfig) +// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// err = consumer.ConsumerInit(conPath) +// assert.NoError(t, err) +// checkApplicationName(consumerConfig.ApplicationConfig) +// err = consumer.configCenterRefreshConsumer() +// checkRegistries(consumerConfig.Registries, consumerConfig.Registry) +// assert.NoError(t, err) +// err = provider.ProviderInit(proPath) +// assert.NoError(t, err) +// checkApplicationName(providerConfig.ApplicationConfig) +// err = provider.configCenterRefreshProvider() +// checkRegistries(providerConfig.Registries, providerConfig.Registry) +// assert.NoError(t, err) +// +// assert.NotNil(t, consumerConfig) +// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) +// assert.NotNil(t, providerConfig) +// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) +// +// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) +// assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address) +//} +// +//func TestGetBaseConfig(t *testing.T) { +// bc := GetBaseConfig() +// assert.NotNil(t, bc) +// _, found := bc.GetRemoteConfig("mock") +// assert.False(t, found) +//} +// +//// mockInitProviderWithSingleRegistry will init a mocked providerConfig +//func mockInitProviderWithSingleRegistry() { +// providerConfig = &provider.ProviderConfig{ +// BaseConfig: base.ShutdownConfig{ +// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "1.0.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registry: ®istry2.RegistryConfig{ +// Address: "mock://127.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// Registries: map[string]*registry2.RegistryConfig{}, +// +// Services: map[string]*service2.ShutdownConfig{ +// "MockService": { +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// Weight: 200, +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// Weight: 200, +// }, +// }, +// exported: new(atomic.Bool), +// }, +// }, +// Protocols: map[string]*protocol2.ProtocolConfig{ +// "mock": { +// Name: "mock", +// Ip: "127.0.0.1", +// Port: "20000", +// }, +// }, +// } +//} +// +//type mockMetadataService struct { +// exportedServiceURLs *sync.Map +// lock *sync.RWMutex +//} +// +//func (m *mockMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Reference() string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ServiceName() (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ExportURL(url *common.URL) (bool, error) { +// return m.addURL(m.exportedServiceURLs, url), nil +//} +// +//func (m *mockMetadataService) UnexportURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { +// return nil +//} +// +//func (m *mockMetadataService) MethodMapper() map[string]string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Version() (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) addURL(targetMap *sync.Map, url *common.URL) bool { +// var ( +// urlSet interface{} +// loaded bool +// ) +// logger.Debug(url.ServiceKey()) +// if urlSet, loaded = targetMap.LoadOrStore(url.ServiceKey(), skip.New(uint64(0))); loaded { +// m.lock.RLock() +// wantedUrl := urlSet.(*skip.SkipList).Get(url) +// if len(wantedUrl) > 0 && wantedUrl[0] != nil { +// m.lock.RUnlock() +// return false +// } +// m.lock.RUnlock() +// } +// m.lock.Lock() +// // double chk +// wantedUrl := urlSet.(*skip.SkipList).Get(url) +// if len(wantedUrl) > 0 && wantedUrl[0] != nil { +// m.lock.Unlock() +// return false +// } +// urlSet.(*skip.SkipList).Insert(url) +// m.lock.Unlock() +// return true +//} +// +//func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { +// // using skip list to dedup and sorting +// var res []*common.URL +// services.Range(func(key, value interface{}) bool { +// urls := value.(*skip.SkipList) +// for i := uint64(0); i < urls.Len(); i++ { +// url := urls.ByPosition(i).(*common.URL) +// if url.GetParam(constant.INTERFACE_KEY, url.Path) != constant.METADATA_SERVICE_NAME { +// res = append(res, url) +// } +// } +// return true +// }) +// sort.Sort(common.URLSlice(res)) +// return res +//} +// +//type mockServiceDiscoveryRegistry struct{} +// +//func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) IsAvailable() bool { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Destroy() { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Register(*common.URL) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) UnRegister(*common.URL) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) Subscribe(*common.URL, registry.NotifyListener) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error { +// panic("implement me") +//} +// +//func (mr *mockServiceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery { +// return &mockServiceDiscovery{} +//} +// +//type mockServiceDiscovery struct{} +// +//func (m *mockServiceDiscovery) String() string { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Destroy() error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { +// return nil +//} +// +//func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetDefaultPageSize() int { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { +// panic("implement me") +//} +// +//func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { +// if len(urls) == 0 { +// return []interface{}{} +// } +// +// res := make([]interface{}, 0, len(urls)) +// for _, u := range urls { +// res = append(res, u.String()) +// } +// 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_utils.go b/config/config_utils.go index 5464502065..868567f6d1 100644 --- a/config/config_utils.go +++ b/config/config_utils.go @@ -19,6 +19,8 @@ package config import ( "fmt" + "github.com/go-playground/validator/v10" + "github.com/pkg/errors" "regexp" "strings" ) @@ -27,6 +29,12 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) +var validate *validator.Validate + +func init() { + validate = validator.New() +} + func mergeValue(str1, str2, def string) string { if str1 == "" && str2 == "" { return def @@ -63,3 +71,37 @@ func removeMinus(strArr []string) string { normalStr = reg.ReplaceAllString(strings.Trim(normalStr, ","), ",") return normalStr } + +// removeDuplicateElement remove duplicate element +func removeDuplicateElement(items []string) []string { + result := make([]string, 0, len(items)) + temp := map[string]struct{}{} + for _, item := range items { + if _, ok := temp[item]; !ok && item != "" { + temp[item] = struct{}{} + result = append(result, item) + } + } + return result +} + +// translateRegistryIds string "nacos,zk" => ["nacos","zk"] +func translateRegistryIds(registryIds []string) []string { + ids := make([]string, 0) + for _, id := range registryIds { + ids = append(ids, strings.Split(id, ",")...) + } + return removeDuplicateElement(ids) +} + +func verify(s interface{}) error { + if err := validate.Struct(s); err != nil { + errs := err.(validator.ValidationErrors) + var slice []string + for _, msg := range errs { + slice = append(slice, msg.Error()) + } + return errors.New(strings.Join(slice, ",")) + } + return nil +} diff --git a/config/consumer_config.go b/config/consumer_config.go index e3c0e0adf9..163f9469d3 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -18,19 +18,18 @@ package config import ( - "bytes" + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config/generic" + "fmt" "time" ) import ( "github.com/creasty/defaults" - perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/yaml" ) const ( @@ -39,29 +38,36 @@ const ( // ConsumerConfig is Consumer default configuration type ConsumerConfig struct { - BaseConfig `yaml:",inline" property:"base"` - configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + //root.RootConfig `yaml:",inline" property:"base"` + //center.ConsumerConfig `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // client Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` ConnectTimeout time.Duration - Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + //Registries map[string]*RegistryConfig `default:"{}" yaml:"registriesConfig" json:"registriesConfig" property:"registriesConfig"` Request_Timeout string `yaml:"request_timeout" default:"5s" json:"request_timeout,omitempty" property:"request_timeout"` RequestTimeout time.Duration ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"` - References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + + rootConfig *RootConfig } -// UnmarshalYAML unmarshals the ConsumerConfig by @unmarshal function +// Prefix dubbo.consumer +func (ConsumerConfig) Prefix() string { + return constant.ConsumerConfigPrefix +} + +// UnmarshalYAML unmarshal the ConsumerConfig by @unmarshal function func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err @@ -70,74 +76,209 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// nolint -func (*ConsumerConfig) Prefix() string { - return constant.ConsumerConfigPrefix +func (c *ConsumerConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) } -// SetConsumerConfig sets consumerConfig by @c -func SetConsumerConfig(c ConsumerConfig) { - consumerConfig = &c +func (c *ConsumerConfig) Validate(rootConfig *RootConfig) { + for k, _ := range c.References { + c.References[k].Validate(rootConfig) + } + c.rootConfig = rootConfig + // todo set default application } -// ConsumerInit loads config file to init consumer config -func ConsumerInit(confConFile string) error { - if confConFile == "" { - return perrors.Errorf("application configure(consumer) file name is nil") - } - consumerConfig = &ConsumerConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - } - consumerConfig.fileStream = bytes.NewBuffer(fileStream) - // set method interfaceId & interfaceName - for k, v := range consumerConfig.References { - // set id for reference - for _, n := range consumerConfig.References[k].Methods { - n.InterfaceName = v.InterfaceName - n.InterfaceId = k - } - } - if consumerConfig.Request_Timeout != "" { - if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) +func (c *ConsumerConfig) Load() { + for key, ref := range c.References { + if ref.Generic { + genericService := generic.NewGenericService(key) + SetConsumerService(genericService) } - if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) { - return perrors.WithMessagef(err, "request_timeout %s should be less than %s", - consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan)) + rpcService := GetConsumerService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue } + ref.id = key + ref.Refer(rpcService) + ref.Implement(rpcService) } - if consumerConfig.Connect_Timeout != "" { - if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) + + // todo Write current configuration to cache file. + //if c.CacheFile != "" { + // if data, err := yaml.MarshalYML(c); err != nil { + // logger.Errorf("Marshal consumer config err: %s", err.Error()) + // } else { + // if err := ioutil.WriteFile(c.CacheFile, data, 0666); err != nil { + // logger.Errorf("Write consumer config cache file err: %s", err.Error()) + // } + // } + //} + + // wait for invoker is available, if wait over default 3s, then panic + var count int + for { + checkok := true + for _, refconfig := range c.References { + if (refconfig.Check != nil && *refconfig.Check) || + (refconfig.Check == nil && c.Check != nil && *c.Check) || + (refconfig.Check == nil && c.Check == nil) { // default to true + + if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { + checkok = false + count++ + if count > maxWait { + errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) + logger.Error(errMsg) + panic(errMsg) + } + time.Sleep(time.Second * 1) + break + } + if refconfig.invoker == nil { + logger.Warnf("The interface %s invoker not exist, may you should check your interface config.", refconfig.InterfaceName) + } + } + } + if checkok { + break } } - logger.Debugf("consumer config{%#v}\n", consumerConfig) +} + +// SetConsumerConfig sets consumerConfig by @c +func SetConsumerConfig(c ConsumerConfig) { + rootConfig.Consumer = &c +} + +// ConsumerInit loads config file to init consumer config +func ConsumerInit(confConFile string) error { + //if confConFile == "" { + // return perrors.Errorf("applicationConfig configure(consumer) file name is nil") + //} + //consumerConfig = &ShutdownConfig{} + //fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) + //if err != nil { + // return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) + //} + //consumerConfig.fileStream = bytes.NewBuffer(fileStream) + //// set method interfaceId & interfaceName + //for k, v := range consumerConfig.References { + // // set id for reference + // for _, n := range consumerConfig.References[k].Methods { + // n.InterfaceName = v.InterfaceName + // n.InterfaceId = k + // } + //} + //if consumerConfig.Request_Timeout != "" { + // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) + // } + // if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) { + // return perrors.WithMessagef(err, "request_timeout %s should be less than %s", + // consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan)) + // } + //} + //if consumerConfig.Connect_Timeout != "" { + // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) + // } + //} + // + //logger.Debugf("consumer config{%#v}\n", consumerConfig) return nil } func configCenterRefreshConsumer() error { - // fresh it - var err error - if consumerConfig.Request_Timeout != "" { - if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) - } + //// fresh it + //var err error + //if consumerConfig.Request_Timeout != "" { + // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) + // } + //} + //if consumerConfig.Connect_Timeout != "" { + // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { + // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) + // } + //} + //if consumerConfig.ConfigCenterConfig != nil { + // consumerConfig.SetFatherConfig(consumerConfig) + // if err = consumerConfig.startConfigCenter((*consumerConfig).BaseConfig); err != nil { + // return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) + // } + // consumerConfig.fresh() + //} + return nil +} + +///////////////////////////////////// consumer config api +// ConsumerConfigOpt is the options to init ConsumerConfig +type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig + +// NewEmptyConsumerConfig returns default ConsumerConfig +// with connection timeout = 3s, request timeout = 3s +func NewEmptyConsumerConfig() *ConsumerConfig { + check := true + newConsumerConfig := &ConsumerConfig{ + //Registries: make(map[string]*RegistryConfig, 8), + References: make(map[string]*ReferenceConfig, 8), + ConnectTimeout: 3 * time.Second, + RequestTimeout: 3 * time.Second, + Check: &check, } - if consumerConfig.Connect_Timeout != "" { - if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) - } + return newConsumerConfig +} + +// NewConsumerConfig returns ConsumerConfig with @opts +func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { + newConfig := NewEmptyConsumerConfig() + for _, v := range opts { + v(newConfig) } - if consumerConfig.ConfigCenterConfig != nil { - consumerConfig.SetFatherConfig(consumerConfig) - if err = consumerConfig.startConfigCenter((*consumerConfig).BaseConfig); err != nil { - return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) - } - consumerConfig.fresh() + return newConfig +} + +// WithRootConfig returns ConsumerConfigOpt with given @rootConfig +func WithRootConfig(rootConfig *RootConfig) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.rootConfig = rootConfig + return config + } +} + +// WithConsumerReferenceConfig returns ConsumerConfigOpt with +func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.References[referenceKey] = refConfig + return config + } +} + +// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout +func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.ConnectTimeout = timeout + return config + } +} + +// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout +func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + config.RequestTimeout = timeout + return config + } +} + +// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag +func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { + return func(config *ConsumerConfig) *ConsumerConfig { + *config.Check = check + return config } - return nil } diff --git a/config/generic_service.go b/config/generic/generic_service.go similarity index 98% rename from config/generic_service.go rename to config/generic/generic_service.go index a3332afe04..34f2f7d359 100644 --- a/config/generic_service.go +++ b/config/generic/generic_service.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package config +package generic import "context" diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index 6d2b71687c..d37ad82733 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -18,9 +18,6 @@ package config import ( - "os" - "os/signal" - "runtime/debug" "time" ) @@ -54,61 +51,61 @@ import ( const defaultShutDownTime = time.Second * 60 // nolint -func GracefulShutdownInit() { - signals := make(chan os.Signal, 1) - - signal.Notify(signals, ShutdownSignals...) - - // retrieve ShutdownConfig for gracefulShutdownFilter - if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(Setter); ok && GetConsumerConfig().ShutdownConfig != nil { - filter.Set(GracefulShutdownFilterShutdownConfig, GetConsumerConfig().ShutdownConfig) - } - if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(Setter); ok && GetProviderConfig().ShutdownConfig != nil { - filter.Set(GracefulShutdownFilterShutdownConfig, GetProviderConfig().ShutdownConfig) - } - - go func() { - select { - case sig := <-signals: - logger.Infof("get signal %s, application will shutdown.", sig) - // gracefulShutdownOnce.Do(func() { - time.AfterFunc(totalTimeout(), func() { - logger.Warn("Shutdown gracefully timeout, application will shutdown immediately. ") - os.Exit(0) - }) - BeforeShutdown() - // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior - for _, dumpSignal := range DumpHeapShutdownSignals { - if sig == dumpSignal { - debug.WriteHeapDump(os.Stdout.Fd()) - } - } - os.Exit(0) - } - }() -} +//func GracefulShutdownInit() { +// signals := make(chan os.Signal, 1) +// +// signal.Notify(signals, ShutdownSignals...) +// +// // retrieve ShutdownConfig for gracefulShutdownFilter +// if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(config.Setter); ok && config.GetConsumerConfig().ShutdownConfig != nil { +// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetConsumerConfig().ShutdownConfig) +// } +// if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(config.Setter); ok && config.GetProviderConfig().ShutdownConfig != nil { +// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetProviderConfig().ShutdownConfig) +// } +// +// go func() { +// select { +// case sig := <-signals: +// logger.Infof("get signal %s, applicationConfig will shutdown.", sig) +// // gracefulShutdownOnce.Do(func() { +// time.AfterFunc(totalTimeout(), func() { +// logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ") +// os.Exit(0) +// }) +// BeforeShutdown() +// // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior +// for _, dumpSignal := range DumpHeapShutdownSignals { +// if sig == dumpSignal { +// debug.WriteHeapDump(os.Stdout.Fd()) +// } +// } +// os.Exit(0) +// } +// }() +//} // BeforeShutdown provides processing flow before shutdown func BeforeShutdown() { destroyAllRegistries() // waiting for a short time so that the clients have enough time to get the notification that server shutdowns // The value of configuration depends on how long the clients will get notification. - waitAndAcceptNewRequests() + //waitAndAcceptNewRequests() // reject the new request, but keeping waiting for accepting requests - waitForReceivingRequests() + //waitForReceivingRequests() // we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc - consumerProtocols := getConsumerProtocols() + //consumerProtocols := getConsumerProtocols() - // If this application is not the provider, it will do nothing - destroyProviderProtocols(consumerProtocols) + // If this applicationConfig is not the provider, it will do nothing + //destroyProviderProtocols(consumerProtocols) // reject sending the new request, and waiting for response of sending requests - waitForSendingRequests() + //waitForSendingRequests() - // If this application is not the consumer, it will do nothing - destroyConsumerProtocols(consumerProtocols) + // If this applicationConfig is not the consumer, it will do nothing + //destroyConsumerProtocols(consumerProtocols) logger.Info("Graceful shutdown --- Execute the custom callbacks.") customCallbacks := extension.GetAllCustomShutdownCallbacks() @@ -118,7 +115,7 @@ func BeforeShutdown() { } func destroyAllRegistries() { - logger.Info("Graceful shutdown --- Destroy all registries. ") + logger.Info("Graceful shutdown --- Destroy all registriesConfig. ") registryProtocol := extension.GetProtocol(constant.REGISTRY_KEY) registryProtocol.Destroy() } @@ -132,59 +129,59 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { // destroyProviderProtocols destroys the provider's protocol. // if the protocol is consumer's protocol too, we will keep it -func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { - logger.Info("Graceful shutdown --- Destroy provider's protocols. ") - - if providerConfig == nil || providerConfig.Protocols == nil { - return - } - - for _, protocol := range providerConfig.Protocols { - - // the protocol is the consumer's protocol too, we can not destroy it. - if consumerProtocols.Contains(protocol.Name) { - continue - } - extension.GetProtocol(protocol.Name).Destroy() - } -} - -func waitAndAcceptNewRequests() { - logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") - if providerConfig == nil || providerConfig.ShutdownConfig == nil { - return - } - - timeout := providerConfig.ShutdownConfig.GetStepTimeout() - - // ignore this step - if timeout < 0 { - return - } - time.Sleep(timeout) -} +//func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { +// logger.Info("Graceful shutdown --- Destroy provider's protocols. ") +// +// if config.providerConfig == nil || config.providerConfig.Protocols == nil { +// return +// } +// +// for _, protocol := range config.providerConfig.Protocols { +// +// // the protocol is the consumer's protocol too, we can not destroy it. +// if consumerProtocols.Contains(protocol.Name) { +// continue +// } +// extension.GetProtocol(protocol.Name).Destroy() +// } +//} + +//func waitAndAcceptNewRequests() { +// logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") +// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { +// return +// } +// +// timeout := config.providerConfig.ShutdownConfig.GetStepTimeout() +// +// // ignore this step +// if timeout < 0 { +// return +// } +// time.Sleep(timeout) +//} // for provider. It will wait for processing receiving requests -func waitForReceivingRequests() { - logger.Info("Graceful shutdown --- Keep waiting until accepting requests finish or timeout. ") - if providerConfig == nil || providerConfig.ShutdownConfig == nil { - // ignore this step - return - } - providerConfig.ShutdownConfig.RejectRequest = true - waitingProcessedTimeout(providerConfig.ShutdownConfig) -} +//func waitForReceivingRequests() { +// logger.Info("Graceful shutdown --- Keep waiting until accepting requests finish or timeout. ") +// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { +// // ignore this step +// return +// } +// config.providerConfig.ShutdownConfig.RejectRequest = true +// waitingProcessedTimeout(config.providerConfig.ShutdownConfig) +//} // for consumer. It will wait for the response of sending requests -func waitForSendingRequests() { - logger.Info("Graceful shutdown --- Keep waiting until sending requests getting response or timeout ") - if consumerConfig == nil || consumerConfig.ShutdownConfig == nil { - // ignore this step - return - } - consumerConfig.ShutdownConfig.RejectRequest = true - waitingProcessedTimeout(consumerConfig.ShutdownConfig) -} +//func waitForSendingRequests() { +// logger.Info("Graceful shutdown --- Keep waiting until sending requests getting response or timeout ") +// if config.consumerConfig == nil || config.consumerConfig.ShutdownConfig == nil { +// // ignore this step +// return +// } +// config.consumerConfig.ShutdownConfig.RejectRequest = true +// waitingProcessedTimeout(config.consumerConfig.ShutdownConfig) +//} func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { timeout := shutdownConfig.GetStepTimeout() @@ -199,33 +196,33 @@ func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { } } -func totalTimeout() time.Duration { - providerShutdown := defaultShutDownTime - if providerConfig != nil && providerConfig.ShutdownConfig != nil { - providerShutdown = providerConfig.ShutdownConfig.GetTimeout() - } - - var consumerShutdown time.Duration - if consumerConfig != nil && consumerConfig.ShutdownConfig != nil { - consumerShutdown = consumerConfig.ShutdownConfig.GetTimeout() - } - - timeout := providerShutdown - if consumerShutdown > providerShutdown { - timeout = consumerShutdown - } - return timeout -} +//func totalTimeout() time.Duration { +// providerShutdown := defaultShutDownTime +// if config.providerConfig != nil && config.providerConfig.ShutdownConfig != nil { +// providerShutdown = config.providerConfig.ShutdownConfig.GetTimeout() +// } +// +// var consumerShutdown time.Duration +// if config.consumerConfig != nil && config.consumerConfig.ShutdownConfig != nil { +// consumerShutdown = config.consumerConfig.ShutdownConfig.GetTimeout() +// } +// +// timeout := providerShutdown +// if consumerShutdown > providerShutdown { +// timeout = consumerShutdown +// } +// return timeout +//} // we can not get the protocols from consumerConfig because some protocol don't have configuration, like jsonrpc. -func getConsumerProtocols() *gxset.HashSet { - result := gxset.NewSet() - if consumerConfig == nil || consumerConfig.References == nil { - return result - } - - for _, reference := range consumerConfig.References { - result.Add(reference.Protocol) - } - return result -} +//func getConsumerProtocols() *gxset.HashSet { +// result := gxset.NewSet() +// if config.consumerConfig == nil || config.consumerConfig.References == nil { +// return result +// } +// +// for _, reference := range config.consumerConfig.References { +// result.Add(reference.Protocol) +// } +// return result +//} diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index fd0bfb41a8..76720a31d2 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -35,7 +35,7 @@ const ( type ShutdownConfig struct { /* * Total timeout. Even though we don't release all resources, - * the application will shutdown if the costing time is over this configuration. The unit is ms. + * the applicationConfig will shutdown if the costing time is over this configuration. The unit is ms. * default value is 60 * 1000 ms = 1 minutes * In general, it should be bigger than 3 * StepTimeout. */ @@ -48,7 +48,7 @@ type ShutdownConfig struct { * maybe (10 + 2*3) * 1000ms is a good choice. */ StepTimeout string `default:"10s" yaml:"step_timeout" json:"step.timeout,omitempty" property:"step.timeout"` - // when we try to shutdown the application, we will reject the new requests. In most cases, you don't need to configure this. + // when we try to shutdown the applicationConfig, we will reject the new requests. In most cases, you don't need to configure this. RejectRequestHandler string `yaml:"reject_handler" json:"reject_handler,omitempty" property:"reject_handler"` // true -> new request will be rejected. RejectRequest bool @@ -57,7 +57,7 @@ type ShutdownConfig struct { RequestsFinished bool } -// nolint +// Prefix dubbo.shutdown func (config *ShutdownConfig) Prefix() string { return constant.ShutdownConfigPrefix } diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go index c30f6eabb6..825ba7e27f 100644 --- a/config/graceful_shutdown_test.go +++ b/config/graceful_shutdown_test.go @@ -17,92 +17,98 @@ package config -import ( - "testing" -) - -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.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { - return &mockGracefulShutdownFilter{} - }) - GracefulShutdownInit() -} - -func TestBeforeShutdown(t *testing.T) { - extension.SetProtocol("registry", func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - extension.SetProtocol(constant.DUBBO, func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - - extension.SetProtocol("mock", func() protocol.Protocol { - return &mockRegistryProtocol{} - }) - - consumerReferences := map[string]*ReferenceConfig{} - consumerReferences[constant.DUBBO] = &ReferenceConfig{ - Protocol: constant.DUBBO, - } - - // without configuration - consumerConfig = nil - providerConfig = nil - BeforeShutdown() - - consumerConfig = &ConsumerConfig{ - References: consumerReferences, - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "1s", - }, - } - - providerProtocols := map[string]*ProtocolConfig{} - providerProtocols[constant.DUBBO] = &ProtocolConfig{ - Name: constant.DUBBO, - } - - providerProtocols["mock"] = &ProtocolConfig{ - Name: "mock", - } - - providerConfig = &ProviderConfig{ - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "1s", - }, - Protocols: providerProtocols, - } - // test destroy protocol - BeforeShutdown() - - providerConfig = &ProviderConfig{ - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "-1s", - }, - Protocols: providerProtocols, - } - - consumerConfig = &ConsumerConfig{ - References: consumerReferences, - ShutdownConfig: &ShutdownConfig{ - Timeout: "1", - StepTimeout: "-1s", - }, - } - - // test ignore steps - BeforeShutdown() -} +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// protocol2 "dubbo.apache.org/dubbo-go/v3/config/protocol" +// "dubbo.apache.org/dubbo-go/v3/config/provider" +// "dubbo.apache.org/dubbo-go/v3/config/reference" +// "testing" +//) +// +//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.GracefulShutdownConsumerFilterKey, func() filter.Filter { +// return &config.mockGracefulShutdownFilter{} +// }) +// extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { +// return &config.mockGracefulShutdownFilter{} +// }) +// GracefulShutdownInit() +//} +// +//func TestBeforeShutdown(t *testing.T) { +// extension.SetProtocol("registry", func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// extension.SetProtocol(constant.DUBBO, func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// +// extension.SetProtocol("mock", func() protocol.Protocol { +// return &config.mockRegistryProtocol{} +// }) +// +// consumerReferences := map[string]*reference.ReferenceConfig{} +// consumerReferences[constant.DUBBO] = &reference.ReferenceConfig{ +// Protocol: constant.DUBBO, +// } +// +// // without configuration +// config.consumerConfig = nil +// config.providerConfig = nil +// BeforeShutdown() +// +// config.consumerConfig = &consumer.ShutdownConfig{ +// References: consumerReferences, +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "1s", +// }, +// } +// +// providerProtocols := map[string]*protocol2.ProtocolConfig{} +// providerProtocols[constant.DUBBO] = &protocol2.ProtocolConfig{ +// Name: constant.DUBBO, +// } +// +// providerProtocols["mock"] = &protocol2.ProtocolConfig{ +// Name: "mock", +// } +// +// config.providerConfig = &provider.ProviderConfig{ +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "1s", +// }, +// Protocols: providerProtocols, +// } +// // test destroy protocol +// BeforeShutdown() +// +// config.providerConfig = &provider.ProviderConfig{ +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "-1s", +// }, +// Protocols: providerProtocols, +// } +// +// config.consumerConfig = &consumer.ShutdownConfig{ +// References: consumerReferences, +// ShutdownConfig: &ShutdownConfig{ +// Timeout: "1", +// StepTimeout: "-1s", +// }, +// } +// +// // test ignore steps +// BeforeShutdown() +//} diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 050339af7c..6b59e210d7 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -17,10 +17,6 @@ package config -import ( - "net/url" -) - import ( "github.com/creasty/defaults" perrors "github.com/pkg/errors" @@ -28,21 +24,17 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/config/instance" ) -// MethodConfig is method level configuration +// MetadataReportConfig is app level configuration type MetadataReportConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - RemoteRef string `required:"true" yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` -} - -// nolint -func (c *MetadataReportConfig) Prefix() string { - return constant.MetadataReportPrefix + Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` + Address string `required:"true" yaml:"address" json:"address"` + Username string `yaml:"username" json:"username,omitempty"` + Password string `yaml:"password" json:"password,omitempty"` + Timeout string `yaml:"timeout" json:"timeout,omitempty"` + Group string `yaml:"group" json:"group,omitempty"` } // UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function @@ -57,34 +49,45 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) return nil } -// nolint -func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { - urlMap := make(url.Values) - - if c.Params != nil { - for k, v := range c.Params { - urlMap.Set(k, v) - } - } +func (c *MetadataReportConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} - rc, ok := GetBaseConfig().GetRemoteConfig(c.RemoteRef) +func (c *MetadataReportConfig) Validate() { - if !ok { - return nil, perrors.New("Could not find out the remote ref config, name: " + c.RemoteRef) - } + // todo set default application +} - res, err := common.NewURL(rc.Address, - common.WithParams(urlMap), - common.WithUsername(rc.Username), - common.WithPassword(rc.Password), - common.WithLocation(rc.Address), - common.WithProtocol(c.Protocol), - ) - if err != nil || len(res.Protocol) == 0 { - return nil, perrors.New("Invalid MetadataReportConfig.") - } - res.SetParam("metadata", res.Protocol) - return res, nil +// nolint +func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { + //urlMap := make(url.Values) + + //if c.Params != nil { + // for k, v := range c.Params { + // urlMap.Set(k, v) + // } + //} + // + //rc, ok := config.GetBaseConfig().GetRemoteConfig(c.RemoteRef) + // + //if !ok { + // return nil, perrors.New("Could not find out the remote ref config, name: " + c.RemoteRef) + //} + // + //res, err := common.NewURL(rc.Address, + // common.WithParams(urlMap), + // common.WithUsername(rc.Username), + // common.WithPassword(rc.Password), + // common.WithLocation(rc.Address), + // common.WithProtocol(c.Protocol), + //) + //if err != nil || len(res.Protocol) == 0 { + // return nil, perrors.New("Invalid MetadataReportConfig.") + //} + //res.SetParam("metadata", res.Protocol) + return nil, nil } func (c *MetadataReportConfig) IsValid() bool { @@ -92,14 +95,15 @@ func (c *MetadataReportConfig) IsValid() bool { } // StartMetadataReport: The entry of metadata report start -func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { +func (c *MetadataReportConfig) StartMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { if metadataReportConfig == nil || !metadataReportConfig.IsValid() { return nil } - - if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.RemoteRef) == 0 { - return perrors.New("MetadataConfig remote ref can not be empty.") - } + // todo + // + //if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.RemoteRef) == 0 { + // return perrors.New("MetadataConfig remote ref can not be empty.") + //} if tmpUrl, err := metadataReportConfig.ToUrl(); err == nil { instance.GetMetadataReportInstance(tmpUrl) diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go deleted file mode 100644 index 46b7f83b3b..0000000000 --- a/config/metadata_report_config_test.go +++ /dev/null @@ -1,52 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestMetadataReportConfig_ToUrl(t *testing.T) { - GetBaseConfig().Remotes["mock"] = &RemoteConfig{ - Address: "127.0.0.1:2181", - Username: "test", - Password: "test", - TimeoutStr: "3s", - } - metadataReportConfig := MetadataReportConfig{ - Protocol: "mock", - RemoteRef: "mock", - Params: map[string]string{ - "k": "v", - }, - } - url, err := metadataReportConfig.ToUrl() - assert.NoError(t, err) - assert.Equal(t, "mock", url.Protocol) - assert.Equal(t, "127.0.0.1:2181", url.Location) - assert.Equal(t, "127.0.0.1", url.Ip) - assert.Equal(t, "2181", url.Port) - assert.Equal(t, "test", url.Username) - assert.Equal(t, "test", url.Password) - assert.Equal(t, "v", url.GetParam("k", "")) - assert.Equal(t, "mock", url.GetParam("metadata", "")) -} diff --git a/config/metric_config_test.go b/config/metric_config_test.go index fe9d2493f3..2bcdd6d4a7 100644 --- a/config/metric_config_test.go +++ b/config/metric_config_test.go @@ -21,11 +21,7 @@ import ( "testing" ) -import ( - "github.com/stretchr/testify/assert" -) - func TestGetMetricConfig(t *testing.T) { - empty := GetMetricConfig() - assert.NotNil(t, empty) + //empty := GetMetricConfig() + //assert.NotNil(t, empty) } diff --git a/config/protocol_config.go b/config/protocol_config.go index 92e93f11bc..cddfdd746c 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -18,33 +18,23 @@ package config import ( - "strings" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" ) // ProtocolConfig is protocol configuration type ProtocolConfig struct { - Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"` - Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` + Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` + Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` + Port string `default:"0" yaml:"port" json:"port,omitempty" property:"port"` } -// nolint -func (c *ProtocolConfig) Prefix() string { - return constant.ProtocolConfigPrefix +func (p *ProtocolConfig) CheckConfig() error { + // todo check + defaults.MustSet(p) + return verify(p) } -func loadProtocol(protocolsIds string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { - returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) - for _, v := range strings.Split(protocolsIds, ",") { - for k, protocol := range protocols { - if v == k { - returnProtocols = append(returnProtocols, protocol) - } - } - } - return returnProtocols +func (p *ProtocolConfig) Validate() { + + // todo set default application } diff --git a/config/provider_config.go b/config/provider_config.go index 8f1b562477..ea9a518479 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -18,34 +18,51 @@ package config import ( - "bytes" -) - -import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "fmt" "github.com/creasty/defaults" - perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/yaml" ) // ProviderConfig is the default configuration of service provider type ProviderConfig struct { - BaseConfig `yaml:",inline" property:"base"` - configCenter `yaml:"-"` - Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` - Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + //base.ShutdownConfig `yaml:",inline" property:"base"` + //center.configCenter `yaml:"-"` + Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` + // Register whether registration is required + Register bool `yaml:"register" json:"register" property:"register"` + // Registry registry ids + Registry []string `yaml:"registry" json:"registry" property:"registry"` + // Services services + Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` + + ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` +} + +func (c *ProviderConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} - Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` - Registries map[string]*RegistryConfig `default:"{}" yaml:"registries" json:"registries" property:"registries"` +func (c *ProviderConfig) Validate(r *RootConfig) { + ids := make([]string, 0) + for key := range r.Registries { + ids = append(ids, key) + } + c.Registry = removeDuplicateElement(ids) + for k, _ := range c.Services { + c.Services[k].Validate(r) + } + // todo set default application } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function @@ -57,48 +74,113 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// nolint -func (*ProviderConfig) Prefix() string { +// Prefix dubbo.provider +func (c *ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } +func (c *ProviderConfig) Load() { + // todo Write the current configuration to cache file. + //if c.CacheFile != "" { + // if data, err := yaml.MarshalYML(providerConfig); err != nil { + // logger.Errorf("Marshal provider config err: %s", err.Error()) + // } else { + // if err := ioutil.WriteFile(provider CacheFile, data, 0666); err != nil { + // logger.Errorf("Write provider config cache file err: %s", err.Error()) + // } + // } + //} + + for key, svs := range c.Services { + rpcService := GetProviderService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue + } + svs.id = key + svs.Implement(rpcService) + if err := svs.Export(); err != nil { + panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) + } + } +} + // SetProviderConfig sets provider config by @p func SetProviderConfig(p ProviderConfig) { - providerConfig = &p + rootConfig.Provider = &p } -// ProviderInit loads config file to init provider config -func ProviderInit(confProFile string) error { - if len(confProFile) == 0 { - return perrors.Errorf("application configure(provider) file name is nil") - } - providerConfig = &ProviderConfig{} - fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) - if err != nil { - return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) +// +//// ProviderInit loads config file to init provider config +//func ProviderInit(confProFile string) error { +// if len(confProFile) == 0 { +// return perrors.Errorf("applicationConfig configure(provider) file name is nil") +// } +// providerConfig = &ProviderConfig{} +// fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) +// if err != nil { +// return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) +// } +// +// provider fileStream = bytes.NewBuffer(fileStream) +// // set method interfaceId & interfaceName +// for k, v := range provider Services { +// // set id for reference +// for _, n := range provider Services[k].Methods { +// n.InterfaceName = v.InterfaceName +// n.InterfaceId = k +// } +// } +// +// return nil +//} +// +//func configCenterRefreshProvider() error { +// // fresh it +// if provider ConfigCenterConfig != nil { +// provider fatherConfig = providerConfig +// if err := provider startConfigCenter((* providerConfig).BaseConfig); err != nil { +// return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) +// } +// provider fresh() +// } +// return nil +//} + +///////////////////////////////////// provider config api +// ProviderConfigOpt is the +type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig + +// NewEmptyProviderConfig returns ProviderConfig with default ApplicationConfig +func NewEmptyProviderConfig() *ProviderConfig { + newProviderConfig := &ProviderConfig{ + Services: make(map[string]*ServiceConfig), + Registry: make([]string, 8), } + return newProviderConfig +} - providerConfig.fileStream = bytes.NewBuffer(fileStream) - // set method interfaceId & interfaceName - for k, v := range providerConfig.Services { - // set id for reference - for _, n := range providerConfig.Services[k].Methods { - n.InterfaceName = v.InterfaceName - n.InterfaceId = k - } +// NewProviderConfig returns ProviderConfig with given @opts +func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { + newConfig := NewEmptyProviderConfig() + for _, v := range opts { + v(newConfig) } + return newConfig +} - return nil +// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig +func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { + return func(config *ProviderConfig) *ProviderConfig { + config.Services[serviceName] = serviceConfig + return config + } } -func configCenterRefreshProvider() error { - // fresh it - if providerConfig.ConfigCenterConfig != nil { - providerConfig.fatherConfig = providerConfig - if err := providerConfig.startConfigCenter((*providerConfig).BaseConfig); err != nil { - return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) - } - providerConfig.fresh() +// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig +func WithProviderRegistry(registryKey ...string) ProviderConfigOpt { + return func(config *ProviderConfig) *ProviderConfig { + config.Registry = append(config.Registry, registryKey...) + return config } - return nil } diff --git a/config/provider_config_test.go b/config/provider_config_test.go index e8a9c1f7a7..4427b0d9d3 100644 --- a/config/provider_config_test.go +++ b/config/provider_config_test.go @@ -17,34 +17,36 @@ package config -import ( - "path/filepath" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestConsumerInit(t *testing.T) { - conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") - assert.NoError(t, err) - assert.NoError(t, ConsumerInit(conPath)) - assert.Equal(t, "default", consumerConfig.ProxyFactory) - assert.Equal(t, "dubbo.properties", consumerConfig.ConfigCenterConfig.ConfigFile) - assert.Equal(t, "100ms", consumerConfig.Connect_Timeout) -} - -func TestConsumerInitWithDefaultProtocol(t *testing.T) { - conPath, err := filepath.Abs("./testdata/consumer_config_withoutProtocol.yml") - assert.NoError(t, err) - assert.NoError(t, ConsumerInit(conPath)) - assert.Equal(t, "dubbo", consumerConfig.References["UserProvider"].Protocol) -} - -func TestProviderInitWithDefaultProtocol(t *testing.T) { - conPath, err := filepath.Abs("./testdata/provider_config_withoutProtocol.yml") - assert.NoError(t, err) - assert.NoError(t, ProviderInit(conPath)) - assert.Equal(t, "dubbo", providerConfig.Services["UserProvider"].Protocol) -} +//import ( +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "path/filepath" +// "testing" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//func TestConsumerInit(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") +// assert.NoError(t, err) +// assert.NoError(t, consumer.ConsumerInit(conPath)) +// assert.Equal(t, "default", config.consumerConfig.ProxyFactory) +// assert.Equal(t, "dubbo.properties", config.consumerConfig.ConfigCenterConfig.ConfigFile) +// assert.Equal(t, "100ms", config.consumerConfig.Connect_Timeout) +//} +// +//func TestConsumerInitWithDefaultProtocol(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/consumer_config_withoutProtocol.yml") +// assert.NoError(t, err) +// assert.NoError(t, consumer.ConsumerInit(conPath)) +// assert.Equal(t, "dubbo", config.consumerConfig.References["UserProvider"].Protocol) +//} +// +//func TestProviderInitWithDefaultProtocol(t *testing.T) { +// conPath, err := filepath.Abs("./testdata/provider_config_withoutProtocol.yml") +// assert.NoError(t, err) +// assert.NoError(t, ProviderInit(conPath)) +// assert.Equal(t, "dubbo", config.providerConfig.Services["UserProvider"].Protocol) +//} diff --git a/config/reference_config.go b/config/reference_config.go index ff5f6b6ab9..0e911b1e5d 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -17,26 +17,21 @@ package config -import ( - "fmt" - "net/url" - "strconv" - "time" -) - -import ( - "github.com/creasty/defaults" - gxstrings "github.com/dubbogo/gost/strings" -) - import ( "dubbo.apache.org/dubbo-go/v3/cluster/directory" "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/proxy" + "dubbo.apache.org/dubbo-go/v3/config/generic" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" + "fmt" + "github.com/creasty/defaults" + gxstrings "github.com/dubbogo/gost/strings" + "net/url" + "strconv" + "time" ) // ReferenceConfig is the configuration of service consumer @@ -48,7 +43,7 @@ type ReferenceConfig struct { URL string `yaml:"url" json:"url,omitempty" property:"url"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` @@ -65,6 +60,8 @@ type ReferenceConfig struct { Sticky bool `yaml:"sticky" json:"sticky,omitempty" property:"sticky"` RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` + + rootConfig *RootConfig } // nolint @@ -72,11 +69,6 @@ func (c *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + c.InterfaceName + "." } -// NewReferenceConfig The only way to get a new ReferenceConfig -func NewReferenceConfig(id string) *ReferenceConfig { - return &ReferenceConfig{id: id} -} - // UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type rf ReferenceConfig @@ -89,6 +81,17 @@ func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return defaults.Set(c) } +func (c *ReferenceConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *ReferenceConfig) Validate(rootConfig *RootConfig) { + c.rootConfig = rootConfig + // todo set default application +} + // Refer ... func (c *ReferenceConfig) Refer(_ interface{}) { cfgURL := common.NewURLWithOptions( @@ -123,7 +126,7 @@ func (c *ReferenceConfig) Refer(_ interface{}) { } } else { // 2. assemble SubURL from register center's configuration mode - c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER) + c.urls = loadRegistries(c.Registry, c.rootConfig.Registries, common.CONSUMER) // set url to regURLs for _, regURL := range c.urls { @@ -201,9 +204,9 @@ func (c *ReferenceConfig) Refer(_ interface{}) { // create proxy if c.Async { callback := GetCallback(c.id) - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) + c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) } else { - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetProxy(c.invoker, cfgURL) + c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetProxy(c.invoker, cfgURL) } } @@ -251,21 +254,21 @@ func (c *ReferenceConfig) getURLMap() url.Values { urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) - // application info - urlMap.Set(constant.APPLICATION_KEY, consumerConfig.ApplicationConfig.Name) - urlMap.Set(constant.ORGANIZATION_KEY, consumerConfig.ApplicationConfig.Organization) - urlMap.Set(constant.NAME_KEY, consumerConfig.ApplicationConfig.Name) - urlMap.Set(constant.MODULE_KEY, consumerConfig.ApplicationConfig.Module) - urlMap.Set(constant.APP_VERSION_KEY, consumerConfig.ApplicationConfig.Version) - urlMap.Set(constant.OWNER_KEY, consumerConfig.ApplicationConfig.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, consumerConfig.ApplicationConfig.Environment) + // applicationConfig info + urlMap.Set(constant.APPLICATION_KEY, c.rootConfig.Application.Name) + urlMap.Set(constant.ORGANIZATION_KEY, c.rootConfig.Application.Organization) + urlMap.Set(constant.NAME_KEY, c.rootConfig.Application.Name) + urlMap.Set(constant.MODULE_KEY, c.rootConfig.Application.Module) + urlMap.Set(constant.APP_VERSION_KEY, c.rootConfig.Application.Version) + urlMap.Set(constant.OWNER_KEY, c.rootConfig.Application.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, c.rootConfig.Application.Environment) // filter defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS if c.Generic { defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter } - urlMap.Set(constant.REFERENCE_FILTER_KEY, mergeValue(consumerConfig.Filter, c.Filter, defaultReferenceFilter)) + //urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) for _, v := range c.Methods { urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) @@ -281,7 +284,7 @@ func (c *ReferenceConfig) getURLMap() url.Values { // GenericLoad ... func (c *ReferenceConfig) GenericLoad(id string) { - genericService := NewGenericService(c.id) + genericService := generic.NewGenericService(c.id) SetConsumerService(genericService) c.id = id c.Refer(genericService) @@ -305,3 +308,74 @@ func (c *ReferenceConfig) postProcessConfig(url *common.URL) { p.PostProcessReferenceConfig(url) } } + +//////////////////////////////////// reference config api + +// ReferenceConfigOpt is consumer's reference config +type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig + +// NewReferenceConfig The only way to get a new ReferenceConfig +func NewReferenceConfigWithID(id string) *ReferenceConfig { + return &ReferenceConfig{id: id} +} + +// NewEmptyReferenceConfig returns empty ReferenceConfig +func NewEmptyReferenceConfig() *ReferenceConfig { + newReferenceConfig := NewReferenceConfigWithID("") + newReferenceConfig.Methods = make([]*MethodConfig, 0, 8) + newReferenceConfig.Params = make(map[string]string, 8) + return newReferenceConfig +} + +// NewReferenceConfig returns ReferenceConfig with given @opts +func NewReferenceConfig(opts ...ReferenceConfigOpt) *ReferenceConfig { + newReferenceConfig := NewEmptyReferenceConfig() + for _, v := range opts { + v(newReferenceConfig) + } + return newReferenceConfig +} + +// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry +func WithReferenceRegistry(registry ...string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Registry = registry + return config + } +} + +// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol +func WithReferenceProtocol(protocol string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Protocol = protocol + return config + } +} + +// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName +func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.InterfaceName = interfaceName + return config + } +} + +// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster +func WithReferenceCluster(cluster string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Cluster = cluster + return config + } +} + +// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb +func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { + return func(config *ReferenceConfig) *ReferenceConfig { + config.Methods = append(config.Methods, &MethodConfig{ + Name: methodName, + Retries: retries, + LoadBalance: lb, + }) + return config + } +} diff --git a/config/reference_config_test.go b/config/reference_config_test.go index fc76f1dbce..84585876b0 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -17,388 +17,395 @@ package config -import ( - "context" - "sync" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - "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/filter" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -var regProtocol protocol.Protocol - -func doInitConsumer() { - consumerConfig = &ConsumerConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registries: map[string]*RegistryConfig{ - "shanghai_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, - }, - - References: map[string]*ReferenceConfig{ - "MockService": { - id: "MockProvider", - Params: map[string]string{ - "serviceid": "soa.mock", - "forks": "5", - }, - Sticky: false, - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Sticky: true, - }, - }, - }, - }, - } -} - -var mockProvider = new(MockProvider) - -type MockProvider struct{} - -func (m *MockProvider) Reference() string { - return "MockProvider" -} - -func (m *MockProvider) CallBack(res common.CallbackResponse) { - // CallBack is a mock function. to implement the interface -} - -func doInitConsumerAsync() { - doInitConsumer() - SetConsumerService(mockProvider) - for _, v := range consumerConfig.References { - v.Async = true - } -} - -func doInitConsumerWithSingleRegistry() { - consumerConfig = &ConsumerConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &RegistryConfig{ - Address: "mock://27.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - Registries: map[string]*RegistryConfig{}, - - References: map[string]*ReferenceConfig{ - "MockService": { - Params: map[string]string{ - "serviceid": "soa.mock", - "forks": "5", - }, - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - }, - }, - }, - }, - } -} - -func TestReferMultiReg(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestRefer(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.Equal(t, "soa.mock", reference.Params["serviceid"]) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferAsync(t *testing.T) { - doInitConsumerAsync() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.Equal(t, "soa.mock", reference.Params["serviceid"]) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - assert.NotNil(t, reference.pxy.GetCallback()) - } - consumerConfig = nil -} - -func TestReferP2P(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferMultiP2P(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestReferMultiP2PWithReg(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - assert.NotNil(t, reference.invoker) - assert.NotNil(t, reference.pxy) - } - consumerConfig = nil -} - -func TestImplement(t *testing.T) { - doInitConsumer() - extension.SetProtocol("registry", GetProtocol) - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) - for _, reference := range consumerConfig.References { - reference.Refer(nil) - reference.Implement(&MockService{}) - assert.NotNil(t, reference.GetRPCService()) - - } - consumerConfig = nil -} - -func TestForking(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - for _, reference := range consumerConfig.References { - reference.Refer(nil) - forks := int(reference.invoker.GetURL().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) - assert.Equal(t, 5, forks) - assert.NotNil(t, reference.pxy) - assert.NotNil(t, reference.Cluster) - } - consumerConfig = nil -} - -func TestSticky(t *testing.T) { - doInitConsumer() - extension.SetProtocol("dubbo", GetProtocol) - extension.SetProtocol("registry", GetProtocol) - mockFilter() - m := consumerConfig.References["MockService"] - m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" - - reference := consumerConfig.References["MockService"] - reference.Refer(nil) - referenceSticky := reference.invoker.GetURL().GetParam(constant.STICKY_KEY, "false") - assert.Equal(t, "false", referenceSticky) - - method0StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false") - assert.Equal(t, "false", method0StickKey) - method1StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false") - assert.Equal(t, "true", method1StickKey) -} - -func GetProtocol() protocol.Protocol { - if regProtocol != nil { - return regProtocol - } - return newRegistryProtocol() -} - -func newRegistryProtocol() protocol.Protocol { - return &mockRegistryProtocol{} -} - -type mockRegistryProtocol struct { -} - -func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { - return protocol.NewBaseInvoker(url) -} - -func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - registryURL := getRegistryURL(invoker) - if registryURL.Protocol == "service-discovery" { - metaDataService, err := extension.GetLocalMetadataService("") - if err != nil { - panic(err) - } - ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone()) - if err != nil { - panic(err) - } - if !ok { - panic("The URL has been registry!") - } - } - return protocol.NewBaseExporter("test", invoker, &sync.Map{}) -} - -func (*mockRegistryProtocol) Destroy() { - // Destroy is a mock function -} - -func getRegistryURL(invoker protocol.Invoker) *common.URL { - // here add * for return a new url - url := invoker.GetURL() - // if the protocol == registry ,set protocol the registry value in url.params - if url.Protocol == constant.REGISTRY_PROTOCOL { - protocol := url.GetParam(constant.REGISTRY_KEY, "") - url.Protocol = protocol - } - return url -} - -func (p *mockRegistryProtocol) GetRegistries() []registry.Registry { - return []registry.Registry{&mockServiceDiscoveryRegistry{}} -} - -func mockFilter() { - consumerFiler := &mockShutdownFilter{} - extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { - return consumerFiler - }) -} - -type mockShutdownFilter struct { -} - -// Invoke adds the requests count and block the new requests if application is closing -func (gf *mockShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - return invoker.Invoke(ctx, invocation) -} - -// OnResponse reduces the number of active processes then return the process result -func (gf *mockShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - return result -} +//import ( +// "context" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" +// "dubbo.apache.org/dubbo-go/v3/config/base" +// "dubbo.apache.org/dubbo-go/v3/config/consumer" +// "dubbo.apache.org/dubbo-go/v3/config/instance" +// "dubbo.apache.org/dubbo-go/v3/config/method" +// registry2 "dubbo.apache.org/dubbo-go/v3/config/registry" +// "sync" +// "testing" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" +// "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/filter" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/registry" +//) +// +//var regProtocol protocol.Protocol +// +//func doInitConsumer() { +// config.consumerConfig = &consumer.Config{ +// BaseConfig: base.Config{ +// applicationConfig.Config: &applicationConfig.Config{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "2.6.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registries: map[string]*registry2.RegistryConfig{ +// "shanghai_reg1": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "shanghai_idc", +// Address: "127.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "shanghai_reg2": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "shanghai_idc", +// Address: "127.0.0.2:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "hangzhou_reg1": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "hangzhou_idc", +// Address: "127.0.0.3:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// "hangzhou_reg2": { +// Protocol: "mock", +// TimeoutStr: "2s", +// Group: "hangzhou_idc", +// Address: "127.0.0.4:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// }, +// +// References: map[string]*ReferenceConfig{ +// "MockService": { +// id: "MockProvider", +// Params: map[string]string{ +// "serviceid": "soa.mock", +// "forks": "5", +// }, +// Sticky: false, +// Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2", +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// Sticky: true, +// }, +// }, +// }, +// }, +// } +//} +// +//var mockProvider = new(MockProvider) +// +//type MockProvider struct{} +// +//func (m *MockProvider) Reference() string { +// return "MockProvider" +//} +// +//func (m *MockProvider) CallBack(res common.CallbackResponse) { +// // CallBack is a mock function. to implement the interface +//} +// +//func doInitConsumerAsync() { +// doInitConsumer() +// instance.SetConsumerService(mockProvider) +// for _, v := range config.consumerConfig.References { +// v.Async = true +// } +//} +// +//func doInitConsumerWithSingleRegistry() { +// config.consumerConfig = &consumer.Config{ +// BaseConfig: base.Config{ +// applicationConfig.Config: &applicationConfig.Config{ +// Organization: "dubbo_org", +// Name: "dubbo", +// Module: "module", +// Version: "2.6.0", +// Owner: "dubbo", +// Environment: "test", +// }, +// }, +// +// Registry: ®istry2.RegistryConfig{ +// Address: "mock://27.0.0.1:2181", +// Username: "user1", +// Password: "pwd1", +// }, +// Registries: map[string]*registry2.RegistryConfig{}, +// +// References: map[string]*ReferenceConfig{ +// "MockService": { +// Params: map[string]string{ +// "serviceid": "soa.mock", +// "forks": "5", +// }, +// InterfaceName: "com.MockService", +// Protocol: "mock", +// Cluster: "failover", +// Loadbalance: "random", +// Retries: "3", +// Group: "huadong_idc", +// Version: "1.0.0", +// Methods: []*method.MethodConfig{ +// { +// Name: "GetUser", +// Retries: "2", +// LoadBalance: "random", +// }, +// { +// Name: "GetUser1", +// Retries: "2", +// LoadBalance: "random", +// }, +// }, +// }, +// }, +// } +//} +// +//func TestReferMultiReg(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestRefer(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.Equal(t, "soa.mock", reference.Params["serviceid"]) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferAsync(t *testing.T) { +// doInitConsumerAsync() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.Equal(t, "soa.mock", reference.Params["serviceid"]) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// assert.NotNil(t, reference.pxy.GetCallback()) +// } +// config.consumerConfig = nil +//} +// +//func TestReferP2P(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferMultiP2P(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestReferMultiP2PWithReg(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// assert.NotNil(t, reference.invoker) +// assert.NotNil(t, reference.pxy) +// } +// config.consumerConfig = nil +//} +// +//func TestImplement(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("registry", GetProtocol) +// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// reference.Implement(&config.MockService{}) +// assert.NotNil(t, reference.GetRPCService()) +// +// } +// config.consumerConfig = nil +//} +// +//func TestForking(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// for _, reference := range config.consumerConfig.References { +// reference.Refer(nil) +// forks := int(reference.invoker.GetURL().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) +// assert.Equal(t, 5, forks) +// assert.NotNil(t, reference.pxy) +// assert.NotNil(t, reference.Cluster) +// } +// config.consumerConfig = nil +//} +// +//func TestSticky(t *testing.T) { +// doInitConsumer() +// extension.SetProtocol("dubbo", GetProtocol) +// extension.SetProtocol("registry", GetProtocol) +// mockFilter() +// m := config.consumerConfig.References["MockService"] +// m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" +// +// reference := config.consumerConfig.References["MockService"] +// reference.Refer(nil) +// referenceSticky := reference.invoker.GetURL().GetParam(constant.STICKY_KEY, "false") +// assert.Equal(t, "false", referenceSticky) +// +// method0StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false") +// assert.Equal(t, "false", method0StickKey) +// method1StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false") +// assert.Equal(t, "true", method1StickKey) +//} +// +//func GetProtocol() protocol.Protocol { +// if regProtocol != nil { +// return regProtocol +// } +// return newRegistryProtocol() +//} +// +//func newRegistryProtocol() protocol.Protocol { +// return &mockRegistryProtocol{} +//} +// +//type mockRegistryProtocol struct { +//} +// +//func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { +// return protocol.NewBaseInvoker(url) +//} +// +//func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { +// registryURL := getRegistryURL(invoker) +// if registryURL.Protocol == "service-discovery" { +// metaDataService, err := extension.GetLocalMetadataService("") +// if err != nil { +// panic(err) +// } +// ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone()) +// if err != nil { +// panic(err) +// } +// if !ok { +// panic("The URL has been registry!") +// } +// } +// return protocol.NewBaseExporter("test", invoker, &sync.Map{}) +//} +// +//func (*mockRegistryProtocol) Destroy() { +// // Destroy is a mock function +//} +// +//func getRegistryURL(invoker protocol.Invoker) *common.URL { +// // here add * for return a new url +// url := invoker.GetURL() +// // if the protocol == registry ,set protocol the registry value in url.params +// if url.Protocol == constant.REGISTRY_PROTOCOL { +// protocol := url.GetParam(constant.REGISTRY_KEY, "") +// url.Protocol = protocol +// } +// return url +//} +// +//func (p *mockRegistryProtocol) GetRegistries() []registry.Registry { +// return []registry.Registry{&config.mockServiceDiscoveryRegistry{}} +//} +// +//func mockFilter() { +// consumerFiler := &mockShutdownFilter{} +// extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { +// return consumerFiler +// }) +//} +// +//type mockShutdownFilter struct { +//} +// +//// Invoke adds the requests count and block the new requests if applicationConfig is closing +//func (gf *mockShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +// return invoker.Invoke(ctx, invocation) +//} +// +//// OnResponse reduces the number of active processes then return the process result +//func (gf *mockShutdownFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +// return result +//} diff --git a/config/registry_config.go b/config/registry_config.go index 92d92a666d..9b01aec870 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -35,26 +35,37 @@ import ( // RegistryConfig is the configuration of the registry center type RegistryConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second - Group string `yaml:"group" json:"group,omitempty" property:"group"` - TTL string `yaml:"ttl" default:"10m" json:"ttl,omitempty" property:"ttl"` // unit: minute + Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second + Group string `yaml:"group" json:"group,omitempty" property:"group"` + TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry - Address string `yaml:"address" json:"address,omitempty" property:"address"` + Address string `validate:"required" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` Password string `yaml:"password" json:"password,omitempty" property:"password"` Simplified bool `yaml:"simplified" json:"simplified,omitempty" property:"simplified"` - // Always use this registry first if set to true, useful when subscribe to multiple registries + // Always use this registry first if set to true, useful when subscribe to multiple registriesConfig Preferred bool `yaml:"preferred" json:"preferred,omitempty" property:"preferred"` // The region where the registry belongs, usually used to isolate traffics Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"` - // Affects traffic distribution among registries, - // useful when subscribe to multiple registries Take effect only when no preferred registry is specified. + // Affects traffic distribution among registriesConfig, + // useful when subscribe to multiple registriesConfig Take effect only when no preferred registry is specified. Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -// UnmarshalYAML unmarshals the RegistryConfig by @unmarshal function +func (c *RegistryConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + c.translateRegistryAddress() + return verify(c) +} + +func (c *RegistryConfig) Validate() { + // todo set default application +} + +// UnmarshalYAML unmarshal the RegistryConfig by @unmarshal function func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err @@ -63,57 +74,9 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return unmarshal((*plain)(c)) } -// nolint -func (*RegistryConfig) Prefix() string { - return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix -} - -func loadRegistries(targetRegistries string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { - var urls []*common.URL - trSlice := strings.Split(targetRegistries, ",") - - for k, registryConf := range registries { - target := false - - // if user not config targetRegistries, default load all - // Notice: in func "func Split(s, sep string) []string" comment: - // if s does not contain sep and sep is not empty, SplitAfter returns - // a slice of length 1 whose only element is s. So we have to add the - // condition when targetRegistries string is not set (it will be "" when not set) - if len(trSlice) == 0 || (len(trSlice) == 1 && trSlice[0] == "") { - target = true - } else { - // else if user config targetRegistries - for _, tr := range trSlice { - if tr == k { - target = true - break - } - } - } - - if target { - addresses := strings.Split(registryConf.Address, ",") - address := addresses[0] - address = translateRegistryConf(address, registryConf) - url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, - common.WithParams(registryConf.getUrlMap(roleType)), - common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), - common.WithUsername(registryConf.Username), - common.WithPassword(registryConf.Password), - common.WithLocation(registryConf.Address), - ) - - if err != nil { - logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) - panic(err) - } else { - urls = append(urls, url) - } - } - } - - return urls +// Prefix dubbo.registriesConfig +func (RegistryConfig) Prefix() string { + return constant.RegistryConfigPrefix } func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { @@ -121,7 +84,7 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { urlMap.Set(constant.GROUP_KEY, c.Group) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) urlMap.Set(constant.REGISTRY_KEY, c.Protocol) - urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.TimeoutStr) + urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.Timeout) // multi registry invoker weight label for load balance urlMap.Set(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, strconv.FormatBool(true)) urlMap.Set(constant.REGISTRY_KEY+"."+constant.PREFERRED_KEY, strconv.FormatBool(c.Preferred)) @@ -134,16 +97,17 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { return urlMap } -func translateRegistryConf(address string, registryConf *RegistryConfig) string { - if strings.Contains(address, "://") { - translatedUrl, err := url.Parse(address) +//translateRegistryAddress translate registry address +// eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos +func (c *RegistryConfig) translateRegistryAddress() string { + if strings.Contains(c.Address, "://") { + translatedUrl, err := url.Parse(c.Address) if err != nil { logger.Errorf("The registry url is invalid, error: %#v", err) panic(err) } - address = translatedUrl.Host - registryConf.Protocol = translatedUrl.Scheme - registryConf.Address = strings.Replace(registryConf.Address, translatedUrl.Scheme+"://", "", -1) + c.Protocol = translatedUrl.Scheme + c.Address = strings.Replace(c.Address, translatedUrl.Scheme+"://", "", -1) } - return address + return c.Address } diff --git a/config/registry_config_test.go b/config/registry_config_test.go index 1ec85ca7d1..f1f4716d30 100644 --- a/config/registry_config_test.go +++ b/config/registry_config_test.go @@ -29,16 +29,16 @@ import ( ) func TestLoadRegistries(t *testing.T) { - target := "shanghai1" + target := []string{"shanghai1"} regs := map[string]*RegistryConfig{ "shanghai1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181,128.0.0.1:2181", - Username: "user1", - Password: "pwd1", + Protocol: "mock", + Timeout: "2s", + Group: "shanghai_idc", + Address: "127.0.0.2:2181,128.0.0.1:2181", + Username: "user1", + Password: "pwd1", }, } urls := loadRegistries(target, regs, common.CONSUMER) @@ -47,19 +47,29 @@ func TestLoadRegistries(t *testing.T) { } func TestLoadRegistries1(t *testing.T) { - target := "shanghai1" + target := []string{"shanghai1"} regs := map[string]*RegistryConfig{ "shanghai1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", + Protocol: "mock", + Timeout: "2s", + Group: "shanghai_idc", + Address: "127.0.0.2:2181", + Username: "user1", + Password: "pwd1", }, } urls := loadRegistries(target, regs, common.CONSUMER) t.Logf("loadRegistries() = urls:%v", urls) assert.Equal(t, "127.0.0.2:2181", urls[0].Location) } + +func TestTranslateRegistryAddress(t *testing.T) { + reg := new(RegistryConfig) + reg.Address = "nacos://127.0.0.1:8848" + + address := reg.translateRegistryAddress() + + assert.Equal(t, "nacos", reg.Protocol) + assert.Equal(t, "127.0.0.1:8848", address) +} diff --git a/config/root_config.go b/config/root_config.go new file mode 100644 index 0000000000..e86f6b9f02 --- /dev/null +++ b/config/root_config.go @@ -0,0 +1,255 @@ +package config + +import ( + "bytes" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" +) + +// RootConfig is the root config +type RootConfig struct { + ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` + + // since 1.5.0 version + Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + + ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` + + MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata-report,omitempty" property:"metadata-report"` + + // Application applicationConfig config + Application *ApplicationConfig `validate:"required" yaml:"application" json:"application,omitempty" property:"application"` + + // Registries registry config + Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` + + Protocols map[string]*ProtocolConfig `validate:"required" yaml:"protocols" json:"protocols" property:"protocols"` + + // provider config + Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` + + // consumer config + Consumer *ConsumerConfig `yaml:"consumer" json:"consumer" property:"consumer"` + + // prefix string + fatherConfig interface{} + EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` + MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` + fileStream *bytes.Buffer + + // cache file used to store the current used configurations. + CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` +} + +func init() { + rootConfig = NewRootConfig() +} + +func SetRootConfig(r RootConfig) { + rootConfig = &r +} + +func NewRootConfig() *RootConfig { + return &RootConfig{ + ConfigCenter: &CenterConfig{}, + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReportConfig: &MetadataReportConfig{}, + Application: &ApplicationConfig{}, + Registries: make(map[string]*RegistryConfig), + Protocols: make(map[string]*ProtocolConfig), + Provider: NewProviderConfig(), + Consumer: NewConsumerConfig(), + MetricConfig: &MetricConfig{}, + } +} + +// Prefix dubbo +func (RootConfig) Prefix() string { + return constant.DUBBO +} + +func (rc *RootConfig) CheckConfig() error { + defaults.MustSet(rc) + + if err := rc.Application.CheckConfig(); err != nil { + return err + } + + for k, _ := range rc.Registries { + if err := rc.Registries[k].CheckConfig(); err != nil { + return err + } + } + + for k, _ := range rc.Protocols { + if err := rc.Protocols[k].CheckConfig(); err != nil { + return err + } + } + + if err := rc.ConfigCenter.CheckConfig(); err != nil { + return err + } + + if err := rc.MetadataReportConfig.CheckConfig(); err != nil { + return err + } + + if err := rc.Provider.CheckConfig(); err != nil { + return err + } + + if err := rc.Consumer.CheckConfig(); err != nil { + return err + } + + return verify(rootConfig) +} + +func (rc *RootConfig) Validate() { + // 2. validate config + rc.Application.Validate() + + for k, _ := range rc.Registries { + rc.Registries[k].Validate() + } + + for k, _ := range rc.Protocols { + rc.Protocols[k].Validate() + } + + for k, _ := range rc.Registries { + rc.Registries[k].Validate() + } + + rc.ConfigCenter.Validate() + rc.MetadataReportConfig.Validate() + rc.Provider.Validate(rc) + rc.Consumer.Validate(rc) +} + +//GetApplicationConfig get applicationConfig config +func GetApplicationConfig() *ApplicationConfig { + if err := check(); err != nil { + return NewApplicationConfig() + } + if rootConfig.Application != nil { + return rootConfig.Application + } + return NewApplicationConfig() +} + +func GetRootConfig() *RootConfig { + return rootConfig +} + +func GetProviderConfig() *ProviderConfig { + if err := check(); err != nil { + return NewProviderConfig() + } + if rootConfig.Provider != nil { + return rootConfig.Provider + } + return NewProviderConfig() +} + +func GetConsumerConfig() *ConsumerConfig { + if err := check(); err != nil { + return NewConsumerConfig() + } + if rootConfig.Consumer != nil { + return rootConfig.Consumer + } + return NewConsumerConfig() +} + +// GetConfigCenterConfig get config center config +//func GetConfigCenterConfig() (*CenterConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// conf := rootConfig.ConfigCenter +// if conf == nil { +// return nil, errors.New("config center config is null") +// } +// if err := defaults.Set(conf); err != nil { +// return nil, err +// } +// conf.translateConfigAddress() +// if err := verify(conf); err != nil { +// return nil, err +// } +// return conf, nil +//} + +// GetRegistriesConfig get registry config default zookeeper registry +//func GetRegistriesConfig() (map[string]*RegistryConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// if registriesConfig != nil { +// return registriesConfig, nil +// } +// registriesConfig = getRegistriesConfig(rootConfig.Registries) +// for _, reg := range registriesConfig { +// if err := defaults.Set(reg); err != nil { +// return nil, err +// } +// reg.translateRegistryAddress() +// if err := verify(reg); err != nil { +// return nil, err +// } +// } +// +// return registriesConfig, nil +//} + +// GetProtocolsConfig get protocols config default dubbo protocol +//func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// protocols := getProtocolsConfig(rootConfig.Protocols) +// for _, protocol := range protocols { +// if err := defaults.Set(protocol); err != nil { +// return nil, err +// } +// if err := verify(protocol); err != nil { +// return nil, err +// } +// } +// return protocols, nil +//} + +// GetProviderConfig get provider config +//func GetProviderConfig() (*ProviderConfig, error) { +// if err := check(); err != nil { +// return nil, err +// } +// +// if providerConfig != nil { +// return providerConfig, nil +// } +// provider := getProviderConfig(rootConfig.Provider) +// if err := defaults.Set(provider); err != nil { +// return nil, err +// } +// if err := verify(provider); err != nil { +// return nil, err +// } +// +// provider.Services = getRegistryServices(common.PROVIDER, provider.Services, provider.Registry) +// providerConfig = provider +// return provider, nil +//} + +//// getRegistryIds get registry keys +//func getRegistryIds() []string { +// ids := make([]string, 0) +// for key := range rootConfig.Registries { +// ids = append(ids, key) +// } +// return removeDuplicateElement(ids) +//} diff --git a/config/service.go b/config/service.go index 12cc91e90b..3aa524d4ee 100644 --- a/config/service.go +++ b/config/service.go @@ -51,6 +51,11 @@ func GetAllProviderService() map[string]common.RPCService { return proServices } +// GetAllConsumerService gets all ConsumerService +func GetAllConsumerService() map[string]common.RPCService { + return conServices +} + // GetCallback gets CallbackResponse by @name func GetCallback(name string) func(response common.CallbackResponse) { service := GetConsumerService(name) diff --git a/config/service_config.go b/config/service_config.go index ebcac9a520..16dc30b0dd 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -19,6 +19,7 @@ package config import ( "container/list" + "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "fmt" "net/url" "strconv" @@ -40,16 +41,15 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" ) // ServiceConfig is the configuration of the service provider type ServiceConfig struct { id string Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol string `default:"dubbo" required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' - InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Protocol []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + Interface string `validate:"required" yaml:"interface" json:"interface,omitempty" property:"interface"` + Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Group string `yaml:"group" json:"group,omitempty" property:"group"` @@ -83,14 +83,16 @@ type ServiceConfig struct { exportersLock sync.Mutex exporters []protocol.Exporter + + rootConfig *RootConfig } -// Prefix returns dubbo.service.${interface}. +// Prefix returns dubbo.service.${InterfaceName}. func (c *ServiceConfig) Prefix() string { - return constant.ServiceConfigPrefix + c.InterfaceName + "." + return constant.ServiceConfigPrefix + c.id } -// UnmarshalYAML unmarshals the ServiceConfig by @unmarshal function +// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err @@ -105,14 +107,54 @@ func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } -// NewServiceConfig The only way to get a new ServiceConfig -func NewServiceConfig(id string) *ServiceConfig { - return &ServiceConfig{ - id: id, - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, +func (c *ServiceConfig) CheckConfig() error { + // todo check + defaults.MustSet(c) + return verify(c) +} + +func (c *ServiceConfig) Validate(rootConfig *RootConfig) { + c.rootConfig = rootConfig + c.exported = atomic.NewBool(false) + c.unexported = atomic.NewBool(false) + c.export = true + // todo set default application +} + +//getRegistryServices get registry services +func getRegistryServices(side int, services map[string]*ServiceConfig, registryIds []string) map[string]*ServiceConfig { + var ( + svc *ServiceConfig + exist bool + initService map[string]common.RPCService + registryServices map[string]*ServiceConfig + ) + if side == common.PROVIDER { + initService = proServices + } else if side == common.CONSUMER { + initService = conServices } + registryServices = make(map[string]*ServiceConfig, len(initService)) + for key := range initService { + //存在配置了使用用户的配置 + if svc, exist = services[key]; !exist { + svc = new(ServiceConfig) + } + defaults.MustSet(svc) + if len(svc.Registry) <= 0 { + svc.Registry = registryIds + } + svc.id = key + svc.export = true + svc.unexported = atomic.NewBool(false) + svc.exported = atomic.NewBool(false) + svc.Registry = translateRegistryIds(svc.Registry) + if err := verify(svc); err != nil { + return nil + } + registryServices[key] = svc + } + return registryServices } // InitExported will set exported as false atom bool @@ -149,32 +191,32 @@ func (c *ServiceConfig) Export() error { // TODO: delay export if c.unexported != nil && c.unexported.Load() { - err := perrors.Errorf("The service %v has already unexported!", c.InterfaceName) + err := perrors.Errorf("The service %v has already unexported!", c.Interface) logger.Errorf(err.Error()) return err } if c.unexported != nil && c.exported.Load() { - logger.Warnf("The service %v has already exported!", c.InterfaceName) + logger.Warnf("The service %v has already exported!", c.Interface) return nil } - regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) + regUrls := loadRegistries(c.Registry, c.rootConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() - protocolConfigs := loadProtocol(c.Protocol, c.Protocols) + protocolConfigs := loadProtocol(c.Protocol, c.rootConfig.Protocols) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.InterfaceName, c.Protocol) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.Interface, c.Protocol) return nil } ports := getRandomPort(protocolConfigs) nextPort := ports.Front() - proxyFactory := extension.GetProxyFactory(providerConfig.ProxyFactory) + proxyFactory := extension.GetProxyFactory(c.rootConfig.Provider.ProxyFactory) for _, proto := range protocolConfigs { // registry the service reflect - methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.Group, c.Version, c.rpcService) + methods, err := common.ServiceMap.Register(c.Interface, proto.Name, c.Group, c.Version, c.rpcService) if err != nil { formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", - c.InterfaceName, proto.Name, err.Error()) + c.Interface, proto.Name, err.Error()) logger.Errorf(formatErr.Error()) return formatErr } @@ -185,13 +227,13 @@ func (c *ServiceConfig) Export() error { nextPort = nextPort.Next() } ivkURL := common.NewURLWithOptions( - common.WithPath(c.InterfaceName), + common.WithPath(c.Interface), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), common.WithPort(port), common.WithParams(urlMap), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), - common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(GetSslEnabled())), + //common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), common.WithMethods(strings.Split(methods, ",")), common.WithToken(c.Token), ) @@ -244,6 +286,67 @@ func (c *ServiceConfig) Export() error { return nil } +//loadProtocol filter protocols by ids +func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) []*ProtocolConfig { + returnProtocols := make([]*ProtocolConfig, 0, len(protocols)) + for _, v := range protocolIds { + for k, protocol := range protocols { + if v == k { + returnProtocols = append(returnProtocols, protocol) + } + } + } + return returnProtocols +} + +func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { + var urls []*common.URL + //trSlice := strings.Split(targetRegistries, ",") + + for k, registryConf := range registries { + target := false + + // if user not config targetRegistries, default load all + // Notice: in func "func Split(s, sep string) []string" comment: + // if s does not contain sep and sep is not empty, SplitAfter returns + // a slice of length 1 whose only element is s. So we have to add the + // condition when targetRegistries string is not set (it will be "" when not set) + if len(registryIds) == 0 || (len(registryIds) == 1 && registryIds[0] == "") { + target = true + } else { + // else if user config targetRegistries + for _, tr := range registryIds { + if tr == k { + target = true + break + } + } + } + + if target { + addresses := strings.Split(registryConf.Address, ",") + address := addresses[0] + address = registryConf.translateRegistryAddress() + url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, + common.WithParams(registryConf.getUrlMap(roleType)), + common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), + common.WithUsername(registryConf.Username), + common.WithPassword(registryConf.Password), + common.WithLocation(registryConf.Address), + ) + + if err != nil { + logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) + panic(err) + } else { + urls = append(urls, url) + } + } + } + + return urls +} + // Unexport will call unexport of all exporters service config exported func (c *ServiceConfig) Unexport() { if !c.exported.Load() { @@ -277,7 +380,7 @@ func (c *ServiceConfig) getUrlMap() url.Values { for k, v := range c.Params { urlMap.Set(k, v) } - urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) + urlMap.Set(constant.INTERFACE_KEY, c.Interface) urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) urlMap.Set(constant.CLUSTER_KEY, c.Cluster) urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) @@ -291,17 +394,17 @@ func (c *ServiceConfig) getUrlMap() url.Values { urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(c.GrpcMaxMessageSize)) // todo: move urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) - // application info - urlMap.Set(constant.APPLICATION_KEY, providerConfig.ApplicationConfig.Name) - urlMap.Set(constant.ORGANIZATION_KEY, providerConfig.ApplicationConfig.Organization) - urlMap.Set(constant.NAME_KEY, providerConfig.ApplicationConfig.Name) - urlMap.Set(constant.MODULE_KEY, providerConfig.ApplicationConfig.Module) - urlMap.Set(constant.APP_VERSION_KEY, providerConfig.ApplicationConfig.Version) - urlMap.Set(constant.OWNER_KEY, providerConfig.ApplicationConfig.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, providerConfig.ApplicationConfig.Environment) + // application config info + //urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) + //urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) + //urlMap.Set(constant.NAME_KEY, applicationConfig.Name) + //urlMap.Set(constant.MODULE_KEY, applicationConfig.Module) + //urlMap.Set(constant.APP_VERSION_KEY, applicationConfig.Version) + //urlMap.Set(constant.OWNER_KEY, applicationConfig.Owner) + //urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) // filter - urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(providerConfig.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) + urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(c.rootConfig.Provider.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) // filter special config urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) @@ -365,3 +468,94 @@ func (c *ServiceConfig) postProcessConfig(url *common.URL) { p.PostProcessServiceConfig(url) } } + +// NewServiceConfig The only way to get a new ServiceConfig +func NewServiceConfig(id string) *ServiceConfig { + return &ServiceConfig{ + id: id, + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + } +} + +// ServiceConfigOpt is the option to init ServiceConfig +type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig + +// NewDefaultServiceConfig returns default ServiceConfig +func NewDefaultServiceConfig() *ServiceConfig { + newServiceConfig := NewServiceConfig("") + newServiceConfig.Params = make(map[string]string) + newServiceConfig.Methods = make([]*MethodConfig, 0, 8) + return newServiceConfig +} + +// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared +// NewServiceConfigByAPI returns ServiceConfig with given @opts +func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig { + defaultServiceConfig := NewDefaultServiceConfig() + for _, v := range opts { + v(defaultServiceConfig) + } + return defaultServiceConfig +} + +// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry +func WithServiceRegistry(registry string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Registry = append(config.Registry, registry) + return config + } +} + +// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol +func WithServiceProtocol(protocol string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Protocol = append(config.Protocol, protocol) + return config + } +} + +// WithServiceInterface returns ServiceConfigOpt with given @interfaceName +func WithServiceInterface(interfaceName string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Interface = interfaceName + return config + } +} + +// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb +func WithServiceLoadBalance(lb string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Loadbalance = lb + return config + } +} + +// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time +func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Warmup = warmUp + return config + } +} + +// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster +func WithServiceCluster(cluster string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Cluster = cluster + return config + } +} + +// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb +func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Methods = append(config.Methods, &MethodConfig{ + Name: name, + Retries: retries, + LoadBalance: lb, + }) + return config + } +} diff --git a/config/service_config_test.go b/config/service_config_test.go deleted file mode 100644 index 4c64c705b2..0000000000 --- a/config/service_config_test.go +++ /dev/null @@ -1,215 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" - "go.uber.org/atomic" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" -) - -func doInitProvider() { - providerConfig = &ProviderConfig{ - BaseConfig: BaseConfig{ - ApplicationConfig: &ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "2.6.0", - Owner: "dubbo", - Environment: "test", - }, - Remotes: map[string]*RemoteConfig{ - "test1": { - Address: "127.0.0.5:2181", - TimeoutStr: "5s", - Username: "user1", - Password: "pwd1", - Params: nil, - }, - }, - ServiceDiscoveries: map[string]*ServiceDiscoveryConfig{ - "mock_servicediscovery": { - Protocol: "mock", - RemoteRef: "test1", - }, - }, - MetadataReportConfig: &MetadataReportConfig{ - Protocol: "mock", - RemoteRef: "test1", - }, - }, - Services: map[string]*ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - "MockServiceNoRightProtocol": { - InterfaceName: "com.MockService", - Protocol: "mock1", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, - exported: new(atomic.Bool), - }, - }, - - Registries: map[string]*RegistryConfig{ - "shanghai_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.1:2181", - Username: "user1", - Password: "pwd1", - }, - "shanghai_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "shanghai_idc", - Address: "127.0.0.2:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg1": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.3:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_reg2": { - Protocol: "mock", - TimeoutStr: "2s", - Group: "hangzhou_idc", - Address: "127.0.0.4:2181", - Username: "user1", - Password: "pwd1", - }, - "hangzhou_service_discovery_reg": { - Protocol: "service-discovery", - Params: map[string]string{ - "service_discovery": "mock_servicediscovery", - "name_mapping": "in-memory", - "metadata": "default", - }, - }, - }, - - Protocols: map[string]*ProtocolConfig{ - "mock": { - Name: "mock", - Ip: "127.0.0.1", - Port: "20000", - }, - }, - } -} - -func TestExport(t *testing.T) { - doInitProvider() - extension.SetProtocol("registry", GetProtocol) - - for i := range providerConfig.Services { - service := providerConfig.Services[i] - service.Implement(&MockService{}) - service.Protocols = providerConfig.Protocols - err := service.Export() - assert.Nil(t, err) - } - providerConfig = nil -} - -func TestGetRandomPort(t *testing.T) { - protocolConfigs := make([]*ProtocolConfig, 0, 3) - - ip := common.GetLocalIp() - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - protocolConfigs = append(protocolConfigs, &ProtocolConfig{ - Ip: ip, - }) - // assert.NoError(t, err) - ports := getRandomPort(protocolConfigs) - - assert.Equal(t, ports.Len(), len(protocolConfigs)) - - front := ports.Front() - for { - if front == nil { - break - } - t.Logf("port:%v", front.Value) - front = front.Next() - } - - protocolConfigs = make([]*ProtocolConfig, 0, 3) - ports = getRandomPort(protocolConfigs) - assert.Equal(t, ports.Len(), len(protocolConfigs)) -} diff --git a/config/service_discovery_config.go b/config/service_discovery_config.go index 4362dd672b..b08a16aa9a 100644 --- a/config/service_discovery_config.go +++ b/config/service_discovery_config.go @@ -31,6 +31,6 @@ type ServiceDiscoveryConfig struct { RemoteRef string `yaml:"remote_ref" json:"remote_ref,omitempty" property:"remote_ref"` } -func (c *ServiceDiscoveryConfig) Prefix() string { +func (ServiceDiscoveryConfig) Prefix() string { return constant.ServiceDiscPrefix } diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml new file mode 100644 index 0000000000..f0876a125d --- /dev/null +++ b/config/testdata/application.yaml @@ -0,0 +1,35 @@ +dubbo: + application: + name: dubbo-go + module: local + version: 1.0.0 + owner: zhaoyunxing + config-center: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + log-dir: ./logs + protocols: + dubbo: + name: dubbo + ip: 127.0.0.1 + port: 20000 + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: dev + address: 127.0.0.1:2181 + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService + registry: nacos + provider: + register: true + services: \ No newline at end of file diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml new file mode 100644 index 0000000000..9c7e6c873f --- /dev/null +++ b/config/testdata/config/app/application.yaml @@ -0,0 +1,6 @@ +dubbo: + application: + name: dubbo-go + module: local + version: 1.0.0 + owner: zhaoyunxing \ No newline at end of file diff --git a/config/testdata/config/center/conf-application.yaml b/config/testdata/config/center/conf-application.yaml new file mode 100644 index 0000000000..bc0a93f0f1 --- /dev/null +++ b/config/testdata/config/center/conf-application.yaml @@ -0,0 +1,13 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + config-center: + address: nacos://127.0.0.1:8848 + cluster: dev + namespace: dubbo + log-dir: ./logs + config-file: dubbo.yaml + app-id: dubbo \ No newline at end of file diff --git a/config/testdata/config/protocol/application.yaml b/config/testdata/config/protocol/application.yaml new file mode 100644 index 0000000000..0288dac8c4 --- /dev/null +++ b/config/testdata/config/protocol/application.yaml @@ -0,0 +1,6 @@ +dubbo: + protocols: + dubbo: + name: dubbo + ip: 127.0.0.1 + port: 20000 \ No newline at end of file diff --git a/config/testdata/config/protocol/empty_application.yaml b/config/testdata/config/protocol/empty_application.yaml new file mode 100644 index 0000000000..bc0aecba71 --- /dev/null +++ b/config/testdata/config/protocol/empty_application.yaml @@ -0,0 +1,2 @@ +dubbo: + protocols: \ No newline at end of file diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml new file mode 100644 index 0000000000..45e7231273 --- /dev/null +++ b/config/testdata/config/provider/application.yaml @@ -0,0 +1,12 @@ +dubbo: + provider: + register: true + registry: + - nacos + - zk + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/provider/empty_registry_application.yaml b/config/testdata/config/provider/empty_registry_application.yaml new file mode 100644 index 0000000000..c171c86bda --- /dev/null +++ b/config/testdata/config/provider/empty_registry_application.yaml @@ -0,0 +1,8 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + provider: + register: true \ No newline at end of file diff --git a/config/testdata/config/provider/registry_application.yaml b/config/testdata/config/provider/registry_application.yaml new file mode 100644 index 0000000000..f5b04deb25 --- /dev/null +++ b/config/testdata/config/provider/registry_application.yaml @@ -0,0 +1,10 @@ +dubbo: + provider: + register: true + registry: nacos,zk + services: + helloService: + interface: org.dubbo.service.HelloService + registry: nacos,zk + orderService: + interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/registry/application.yaml b/config/testdata/config/registry/application.yaml new file mode 100644 index 0000000000..844353835a --- /dev/null +++ b/config/testdata/config/registry/application.yaml @@ -0,0 +1,10 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 \ No newline at end of file diff --git a/config/testdata/config/registry/empty_application.yaml b/config/testdata/config/registry/empty_application.yaml new file mode 100644 index 0000000000..9e7a20af2a --- /dev/null +++ b/config/testdata/config/registry/empty_application.yaml @@ -0,0 +1,2 @@ +dubbo: + registries: \ No newline at end of file diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go new file mode 100644 index 0000000000..ff0726c998 --- /dev/null +++ b/config/testdata/config/service/hello_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "context" +) + +type HelloService struct { + // say hello + Say func(ctx context.Context, req []interface{}) error +} + +func (HelloService) Name() string { + return "helloService" +} + +func (HelloService) Reference() string { + return "org.github.dubbo.HelloService" +} diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go new file mode 100644 index 0000000000..07a256b0e0 --- /dev/null +++ b/config/testdata/config/service/order_service.go @@ -0,0 +1,18 @@ +package service + +import ( + "context" +) + +type OrderService struct { + // GetOrders + GetOrders func(ctx context.Context, req []interface{}) error +} + +func (OrderService) Name() string { + return "orderService" +} + +func (OrderService) Reference() string { + return "org.github.dubbo.OrderService" +} diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 8a0a28d63f..95c754e84f 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -132,7 +132,7 @@ func (c *apolloConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (string, error) { /** - * when group is not null, we are getting startup configs(config file) from Config Center, for example: + * when group is not null, we are getting startup configs(config file) from ShutdownConfig Center, for example: * key=dubbo.propertie */ tmpConfig := agollo.GetConfig(key) diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 3392868223..02cc5475d7 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -17,6 +17,7 @@ package apollo import ( + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "net/http" "net/http/httptest" @@ -33,7 +34,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/parser" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -184,7 +184,7 @@ func TestGetConfigItem(t *testing.T) { } func initMockApollo(t *testing.T) *apolloConfiguration { - c := &config.BaseConfig{ConfigCenterConfig: &config.ConfigCenterConfig{ + c := &config.RootConfig{ConfigCenter: &config.CenterConfig{ Protocol: "apollo", Address: "106.12.25.204:8080", AppID: "testApplication_yang", @@ -193,7 +193,7 @@ func initMockApollo(t *testing.T) *apolloConfiguration { }} apollo := initApollo() apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo") - url, err := common.NewURL(apolloUrl, common.WithParams(c.ConfigCenterConfig.GetUrlMap())) + url, err := common.NewURL(apolloUrl, common.WithParams(c.ConfigCenter.GetUrlMap())) assert.NoError(t, err) configuration, err := newApolloConfiguration(url) assert.NoError(t, err) diff --git a/filter/hystrix/filter.go b/filter/hystrix/filter.go index 8dbdae918b..39e06707d4 100644 --- a/filter/hystrix/filter.go +++ b/filter/hystrix/filter.go @@ -199,7 +199,7 @@ func newFilterConsumer() filter.Filter { // When first called, load the config in consumerConfigOnce.Do(func() { if err := initConfigConsumer(); err != nil { - logger.Warnf("[Hystrix Filter]Config load failed for consumer, error is: %v , will use default", err) + logger.Warnf("[Hystrix Filter]ShutdownConfig load failed for consumer, error is: %v , will use default", err) } }) return &Filter{COrP: true} @@ -209,7 +209,7 @@ func newFilterConsumer() filter.Filter { func newFilterProvider() filter.Filter { providerConfigOnce.Do(func() { if err := initConfigProvider(); err != nil { - logger.Warnf("[Hystrix Filter]Config load failed for provider, error is: %v , will use default", err) + logger.Warnf("[Hystrix Filter]ShutdownConfig load failed for provider, error is: %v , will use default", err) } }) return &Filter{COrP: false} @@ -300,7 +300,7 @@ type CommandConfigWithError struct { Error []string `yaml:"error_whitelist"` } -//Config: +//ShutdownConfig: //- Timeout: how long to wait for command to complete, in milliseconds //- MaxConcurrentRequests: how many commands of the same type can run at the same time //- RequestVolumeThreshold: the minimum number of requests needed before a circuit can be tripped due to health diff --git a/go.mod b/go.mod index c1861c222d..1fa906227c 100644 --- a/go.mod +++ b/go.mod @@ -18,12 +18,14 @@ require ( github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 + github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 + github.com/knadh/koanf v1.1.1 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd diff --git a/go.sum b/go.sum index 120647fc08..5411fce5c6 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,6 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDH github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-getty v1.4.4 h1:pthYQaCXyjHJ6/SjVwKkX5NhdAqSpUrRL1Z9GowrLdE= -github.com/apache/dubbo-getty v1.4.4/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= @@ -130,7 +128,6 @@ 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.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -191,6 +188,7 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -202,6 +200,14 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= +github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= @@ -306,6 +312,7 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= +github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= @@ -313,7 +320,9 @@ github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -332,9 +341,12 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= +github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 h1:e1ok06zGrWJW91rzRroyl5nRNqraaBe4d5hiKcVZuHM= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= @@ -347,6 +359,8 @@ github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXT github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= @@ -372,6 +386,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= +github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -382,6 +398,8 @@ 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= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4= @@ -411,6 +429,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -423,6 +443,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -430,7 +452,6 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -478,8 +499,9 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= @@ -534,6 +556,7 @@ github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULU github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -780,6 +803,7 @@ golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7w 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= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -793,6 +817,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -854,6 +879,7 @@ google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -901,6 +927,7 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -917,6 +944,7 @@ gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= diff --git a/metadata/mapping/dynamic/service_name_mapping.go b/metadata/mapping/dynamic/service_name_mapping.go index b81423df36..e1dbb7dcfe 100644 --- a/metadata/mapping/dynamic/service_name_mapping.go +++ b/metadata/mapping/dynamic/service_name_mapping.go @@ -18,6 +18,7 @@ package dynamic import ( + "dubbo.apache.org/dubbo-go/v3/config" "strconv" "sync" "time" @@ -33,7 +34,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/mapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go index 1f5940cbd1..75aa80b2b0 100644 --- a/metadata/mapping/dynamic/service_name_mapping_test.go +++ b/metadata/mapping/dynamic/service_name_mapping_test.go @@ -18,6 +18,7 @@ package dynamic import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -28,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" ) diff --git a/metadata/mapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go index cc104399bc..3175a50607 100644 --- a/metadata/mapping/memory/service_name_mapping.go +++ b/metadata/mapping/memory/service_name_mapping.go @@ -18,6 +18,7 @@ package memory import ( + "dubbo.apache.org/dubbo-go/v3/config" "sync" ) @@ -27,7 +28,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index f3f285806b..d6b4ebe7cf 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,6 +18,7 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config" "errors" "sync" ) @@ -26,7 +27,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" ) @@ -49,7 +49,7 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { serviceConfig := config.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) - serviceConfig.Protocol = constant.DEFAULT_PROTOCOL + serviceConfig.Protocol = []string{constant.DEFAULT_PROTOCOL} if url == nil || url.SubURL == nil { return errors.New("metadata server url is nil, pls check your configuration") } @@ -59,8 +59,8 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { Port: url.SubURL.Port, }, } - serviceConfig.Registry = "N/A" - serviceConfig.InterfaceName = constant.METADATA_SERVICE_NAME + serviceConfig.Registry = []string{"N/A"} + serviceConfig.Interface = constant.METADATA_SERVICE_NAME // identify this is a golang server serviceConfig.Params = map[string]string{} diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 3ae67500ff..f94aa12624 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -18,6 +18,7 @@ package configurable import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -28,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" @@ -78,49 +78,22 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &config.ProviderConfig{ - - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{ - Organization: "dubbo_org", - Name: "dubbo", - Module: "module", - Version: "1.0.0", - Owner: "dubbo", - Environment: "test", - }, - }, - - Registry: &config.RegistryConfig{ - Address: "mock://127.0.0.1:2181", - Username: "user1", - Password: "pwd1", + providerConfig := &config.ProviderConfig{} + providerConfig.Services["MockService"].InitExported() + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{ + Organization: "dubbo_org", + Name: "dubbo", + Module: "module", + Version: "1.0.0", + Owner: "dubbo", + Environment: "test", }, - Registries: map[string]*config.RegistryConfig{}, - - Services: map[string]*config.ServiceConfig{ - "MockService": { - InterfaceName: "com.MockService", - Protocol: "mock", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Group: "huadong_idc", - Version: "1.0.0", - Methods: []*config.MethodConfig{ - { - Name: "GetUser", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - { - Name: "GetUser1", - Retries: "2", - LoadBalance: "random", - Weight: 200, - }, - }, + Registries: map[string]*config.RegistryConfig{ + "mock": { + Address: "mock://127.0.0.1:2181", + Username: "user1", + Password: "pwd1", }, }, Protocols: map[string]*config.ProtocolConfig{ @@ -130,7 +103,33 @@ func mockInitProviderWithSingleRegistry() { Port: "20000", }, }, - } - providerConfig.Services["MockService"].InitExported() - config.SetProviderConfig(*providerConfig) + + Provider: &config.ProviderConfig{ + Services: map[string]*config.ServiceConfig{ + "MockService": { + Interface: "com.MockService", + Protocol: []string{"mock"}, + Cluster: "failover", + Loadbalance: "random", + Retries: "3", + Group: "huadong_idc", + Version: "1.0.0", + Methods: []*config.MethodConfig{ + { + Name: "GetUser", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, + { + Name: "GetUser1", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, + }, + }, + }, + }, + }) } diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go index 794d463aff..2d920952d9 100644 --- a/metadata/service/local/service.go +++ b/metadata/service/local/service.go @@ -17,6 +17,7 @@ package local import ( + "dubbo.apache.org/dubbo-go/v3/config" "sort" "sync" ) @@ -30,7 +31,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/service" ) diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go index f137e848f6..27150db7f1 100644 --- a/protocol/dubbo3/common_test.go +++ b/protocol/dubbo3/common_test.go @@ -19,6 +19,7 @@ package dubbo3 import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" ) @@ -27,7 +28,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index 25ca875478..df90c3b656 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -18,6 +18,7 @@ package dubbo3 import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "reflect" "sync" @@ -35,7 +36,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index 2b1d8e07d2..d85662c492 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -19,16 +19,13 @@ package internal import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" ) import ( "github.com/dubbogo/triple/pkg/triple" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { config.SetConsumerService(&GrpcGreeterImpl{}) } diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 66208c828a..84d812dfe2 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -39,8 +39,8 @@ import ( var clientConf *ClientConfig func init() { - // load clientconfig from consumer_config - consumerConfig := config.GetConsumerConfig() + // load rootConfig from runtime + rootConfig := config.GetRootConfig() clientConfig := GetClientConfig() clientConf = &clientConfig @@ -56,7 +56,7 @@ func init() { } }() - if consumerConfig.ApplicationConfig == nil { + if rootConfig.Application == nil { return } protocolConf := config.GetConsumerConfig().ProtocolConf diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 0570e470e0..d5ac9ff374 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -18,6 +18,7 @@ package grpc import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) @@ -28,43 +29,42 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal/helloworld" ) func doInitProvider() { - providerConfig := config.ProviderConfig{ - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{ - Organization: "dubbo_org", - Name: "BDTService", - Module: "module", - Version: "0.0.1", - Owner: "dubbo", - Environment: "test", - }, + rootConfig := config.RootConfig{ + Application: &config.ApplicationConfig{ + Organization: "dubbo_org", + Name: "BDTService", + Module: "module", + Version: "0.0.1", + Owner: "dubbo", + Environment: "test", }, - Services: map[string]*config.ServiceConfig{ - "GrpcGreeterImpl": { - InterfaceName: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", - Protocol: "grpc", - Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg", - Cluster: "failover", - Loadbalance: "random", - Retries: "3", - Methods: []*config.MethodConfig{ - { - Name: "SayHello", - Retries: "2", - LoadBalance: "random", - Weight: 200, + Provider: &config.ProviderConfig{ + Services: map[string]*config.ServiceConfig{ + "GrpcGreeterImpl": { + Interface: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", + Protocol: []string{"grpc"}, + Registry: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, + Cluster: "failover", + Loadbalance: "random", + Retries: "3", + Methods: []*config.MethodConfig{ + { + Name: "SayHello", + Retries: "2", + LoadBalance: "random", + Weight: 200, + }, }, }, }, }, } - config.SetProviderConfig(providerConfig) + config.SetRootConfig(rootConfig) } func TestGrpcProtocolExport(t *testing.T) { diff --git a/protocol/grpc/internal/helloworld/client.go b/protocol/grpc/internal/helloworld/client.go index ec45dd5861..3c6fc9cea2 100644 --- a/protocol/grpc/internal/helloworld/client.go +++ b/protocol/grpc/internal/helloworld/client.go @@ -19,16 +19,13 @@ package helloworld import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" ) import ( "google.golang.org/grpc" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { config.SetConsumerService(&GrpcGreeterImpl{}) } diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 5f79ef0399..9920115496 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -18,16 +18,13 @@ package routeguide import ( + "dubbo.apache.org/dubbo-go/v3/config" "io" "log" "math/rand" "time" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - func init() { config.SetConsumerService(&RouteGuideClientImpl{}) } diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index e068999447..e077cd7cad 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -144,7 +144,7 @@ func registerService(providerServices map[string]*config.ServiceConfig, server * panic("illegal service type registered") } - serviceKey := common.ServiceKey(providerService.InterfaceName, providerService.Group, providerService.Version) + serviceKey := common.ServiceKey(providerService.Interface, providerService.Group, providerService.Version) exporter, _ := grpcProtocol.ExporterMap().Load(serviceKey) if exporter == nil { panic(fmt.Sprintf("no exporter found for servicekey: %v", serviceKey)) diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 213cc40000..365e6363ac 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -18,6 +18,7 @@ package jsonrpc import ( + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "strings" "testing" @@ -30,7 +31,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go index d72821c69d..2c56c22f44 100644 --- a/protocol/rest/config/reader/rest_config_reader.go +++ b/protocol/rest/config/reader/rest_config_reader.go @@ -54,7 +54,7 @@ func (cr *RestConfigReader) ReadConsumerConfig(reader *bytes.Buffer) error { restConsumerConfig := &config.RestConsumerConfig{} err := yaml.Unmarshal(reader.Bytes(), restConsumerConfig) if err != nil { - return perrors.Errorf("[Rest Config] unmarshal Consumer error %#v", perrors.WithStack(err)) + return perrors.Errorf("[Rest ShutdownConfig] unmarshal Consumer error %#v", perrors.WithStack(err)) } restConsumerServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restConsumerConfig.RestServiceConfigsMap)) @@ -72,7 +72,7 @@ func (cr *RestConfigReader) ReadProviderConfig(reader *bytes.Buffer) error { restProviderConfig := &config.RestProviderConfig{} err := yaml.Unmarshal(reader.Bytes(), restProviderConfig) if err != nil { - return perrors.Errorf("[Rest Config] unmarshal Provider error %#v", perrors.WithStack(err)) + return perrors.Errorf("[Rest ShutdownConfig] unmarshal Provider error %#v", perrors.WithStack(err)) } restProviderServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restProviderConfig.RestServiceConfigsMap)) for key, rc := range restProviderConfig.RestServiceConfigsMap { @@ -116,7 +116,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.PathParamsMap) == 0 && len(methodConfig.PathParams) > 0 { paramsMap, err := parseParamsString2Map(methodConfig.PathParams) if err != nil { - logger.Warnf("[Rest Config] Path Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Path Param parse error:%v", err) } else { methodConfig.PathParamsMap = paramsMap } @@ -124,7 +124,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.QueryParamsMap) == 0 && len(methodConfig.QueryParams) > 0 { paramsMap, err := parseParamsString2Map(methodConfig.QueryParams) if err != nil { - logger.Warnf("[Rest Config] Argument Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Argument Param parse error:%v", err) } else { methodConfig.QueryParamsMap = paramsMap } @@ -132,7 +132,7 @@ func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMe if len(methodConfig.HeadersMap) == 0 && len(methodConfig.Headers) > 0 { headersMap, err := parseParamsString2Map(methodConfig.Headers) if err != nil { - logger.Warnf("[Rest Config] Argument Param parse error:%v", err) + logger.Warnf("[Rest ShutdownConfig] Argument Param parse error:%v", err) } else { methodConfig.HeadersMap = headersMap } diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index 4141b6e00a..e666fbc3c7 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -19,6 +19,7 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) @@ -31,7 +32,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 2ee6b63fd3..c28f9c54ae 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -19,6 +19,7 @@ package rest import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "errors" "fmt" "strings" @@ -34,7 +35,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" ) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 7974ad4be6..5b42cc964f 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -18,6 +18,7 @@ package directory import ( + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "net/url" "os" @@ -36,7 +37,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" _ "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" @@ -486,8 +486,9 @@ type consumerConfigurationListener struct { func newConsumerConfigurationListener(dir *RegistryDirectory) *consumerConfigurationListener { listener := &consumerConfigurationListener{directory: dir} + application := config.GetApplicationConfig() listener.InitWith( - config.GetConsumerConfig().ApplicationConfig.Name+constant.CONFIGURATORS_SUFFIX, + application.Name+constant.CONFIGURATORS_SUFFIX, listener, extension.GetDefaultConfiguratorFunc(), ) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 15a395e865..e74125302d 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,6 +18,7 @@ package directory import ( + "dubbo.apache.org/dubbo-go/v3/config" "strconv" "testing" "time" @@ -32,7 +33,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "dubbo.apache.org/dubbo-go/v3/registry" @@ -40,10 +40,8 @@ import ( ) func init() { - config.SetConsumerConfig(config.ConsumerConfig{ - BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }, + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, }) } diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index c90633d165..416d2af701 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -295,12 +295,12 @@ func newEtcdV3ServiceDiscovery(name string) (registry.ServiceDiscovery, error) { initLock.Lock() defer initLock.Unlock() - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the etcd service instance because the config is invalid") } - remoteConfig, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/etcdv3/service_discovery_test.go b/registry/etcdv3/service_discovery_test.go index a69db6d95b..ba82330c14 100644 --- a/registry/etcdv3/service_discovery_test.go +++ b/registry/etcdv3/service_discovery_test.go @@ -34,12 +34,12 @@ import ( var testName = "test" func setUp() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "etcdv3", RemoteRef: testName, } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: "localhost:2379", TimeoutStr: "10s", } @@ -56,14 +56,14 @@ func Test_newEtcdV3ServiceDiscovery(t *testing.T) { Protocol: "etcdv3", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newEtcdV3ServiceDiscovery(name) // RemoteConfig not found assert.NotNil(t, err) - config.GetBaseConfig().Remotes["mock"] = &config.RemoteConfig{ + config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ Address: "localhost:2379", TimeoutStr: "10s", } diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go index 13983b1188..51f472b83c 100644 --- a/registry/event/event_publishing_service_deiscovery_test.go +++ b/registry/event/event_publishing_service_deiscovery_test.go @@ -18,6 +18,7 @@ package event import ( + "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -33,7 +34,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" diff --git a/registry/event/service_config_exported_event.go b/registry/event/service_config_exported_event.go index af566e3b28..d40c0273d3 100644 --- a/registry/event/service_config_exported_event.go +++ b/registry/event/service_config_exported_event.go @@ -18,12 +18,12 @@ package event import ( + "dubbo.apache.org/dubbo-go/v3/config" "time" ) import ( "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/config" ) // ServiceConfigExportedEvent represents an service was exported diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index b6c7a319ec..562fece8ca 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -56,7 +56,7 @@ type fileSystemServiceDiscovery struct { } func newFileSystemServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || sdc.Protocol != constant.FILE_KEY { return nil, perrors.New("could not init the instance because the config is invalid") } diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index 2ca5915854..39e70a010f 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -87,7 +87,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "file", } } diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 174bf0bc82..e801521b72 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -321,12 +321,12 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { return instance, nil } - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the instance because the config is invalid") } - rc, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + rc, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 03b1b9cb8c..ff769cab11 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -46,21 +46,21 @@ func Test_newNacosServiceDiscovery(t *testing.T) { name := "nacos1" _, err := newNacosServiceDiscovery(name) - // the ServiceDiscoveryConfig not found + // the ShutdownConfig not found assert.NotNil(t, err) sdc := &config.ServiceDiscoveryConfig{ Protocol: "nacos", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newNacosServiceDiscovery(name) // RemoteConfig not found assert.NotNil(t, err) - config.GetBaseConfig().Remotes["mock"] = &config.RemoteConfig{ + config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ Address: "console.nacos.io:80", TimeoutStr: "10s", } @@ -178,12 +178,12 @@ func TestNacosServiceDiscovery_Destroy(t *testing.T) { } func prepareData() { - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "nacos", RemoteRef: testName, } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: "console.nacos.io:80", TimeoutStr: "10s", } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 25204e6bb7..686a7913f2 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -254,8 +254,9 @@ func registerServiceMap(invoker protocol.Invoker) error { return perrors.New(s) } - _, err := common.ServiceMap.Register(serviceConfig.InterfaceName, - serviceConfig.Protocol, serviceConfig.Group, + _, err := common.ServiceMap.Register(serviceConfig.Interface, + // FIXME + serviceConfig.Protocol[0], serviceConfig.Group, serviceConfig.Version, rpcService) if err != nil { s := "reExport can not re register ServiceMap. Error message is " + err.Error() @@ -456,7 +457,7 @@ func newProviderConfigurationListener(overrideListeners *sync.Map) *providerConf listener := &providerConfigurationListener{} listener.overrideListeners = overrideListeners listener.InitWith( - config.GetProviderConfig().ApplicationConfig.Name+constant.CONFIGURATORS_SUFFIX, + config.GetApplicationConfig().Name+constant.CONFIGURATORS_SUFFIX, listener, extension.GetDefaultConfiguratorFunc(), ) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 45d60b154d..03d3f4db15 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -18,6 +18,7 @@ package protocol import ( + "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) @@ -33,7 +34,6 @@ import ( common_cfg "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" @@ -43,9 +43,9 @@ import ( ) func init() { - config.SetProviderConfig(config.ProviderConfig{BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }}) + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, + }) } func referNormal(t *testing.T, regProtocol *registryProtocol) { @@ -68,10 +68,9 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { } func TestRefer(t *testing.T) { - config.SetConsumerConfig( - config.ConsumerConfig{BaseConfig: config.BaseConfig{ - ApplicationConfig: &config.ApplicationConfig{Name: "test-application"}, - }}) + config.SetRootConfig(config.RootConfig{ + Application: &config.ApplicationConfig{Name: "test-application"}, + }) regProtocol := newRegistryProtocol() referNormal(t, regProtocol) } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 1feb8f1555..1f3fcc29ed 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -126,7 +126,7 @@ func (s *serviceDiscoveryRegistry) UnSubscribe(url *common.URL, listener registr func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { sdcName := url.GetParam(constant.SERVICE_DISCOVERY_KEY, "") - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(sdcName) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[sdcName] if !ok { return nil, perrors.Errorf("The service discovery with name: %s is not found", sdcName) } diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index 8c926429b2..a265ad50fc 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -23,7 +23,6 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" - "github.com/dubbogo/gost/hash/page" "github.com/stretchr/testify/assert" ) @@ -64,7 +63,7 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { }) extension.SetAndInitGlobalDispatcher("mock") - config.GetBaseConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ + config.GetRootConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ Protocol: "mock", } registryURL, _ := common.NewURL("service-discovery://localhost:12345", diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index b2a966d3ba..93534675af 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -89,11 +89,11 @@ func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error return instance, nil } - sdc, ok := config.GetBaseConfig().GetServiceDiscoveries(name) + sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the instance because the config is invalid") } - remoteConfig, ok := config.GetBaseConfig().GetRemoteConfig(sdc.RemoteRef) + remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] if !ok { return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) } diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index 512031bd4b..7520457ac6 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -53,12 +53,12 @@ func prepareData(t *testing.T) *zk.TestCluster { address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) //address := "127.0.0.1:2181" - config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ + config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ Protocol: "zookeeper", RemoteRef: "test", } - config.GetBaseConfig().Remotes[testName] = &config.RemoteConfig{ + config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ Address: address, TimeoutStr: "10s", } @@ -69,7 +69,7 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) { name := "zookeeper1" _, err := newZookeeperServiceDiscovery(name) - // the ServiceDiscoveryConfig not found + // the ShutdownConfig not found // err: could not init the instance because the config is invalid assert.NotNil(t, err) @@ -77,7 +77,7 @@ func TestNewZookeeperServiceDiscovery(t *testing.T) { Protocol: "zookeeper", RemoteRef: "mock", } - config.GetBaseConfig().ServiceDiscoveries[name] = sdc + config.GetRootConfig().ServiceDiscoveries[name] = sdc _, err = newZookeeperServiceDiscovery(name) // RemoteConfig not found diff --git a/remoting/getty/config.go b/remoting/getty/config.go index bd56291b38..b1478da35b 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -18,6 +18,7 @@ package getty import ( + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -25,10 +26,6 @@ import ( perrors "github.com/pkg/errors" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - type ( // GettySessionParam is session configuration for getty GettySessionParam struct { diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index cbe8245eb3..7ca3a35789 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -89,7 +89,7 @@ func initClient(protocol string) { rand.Seed(time.Now().UnixNano()) } -// Config ClientConf +// ShutdownConfig ClientConf func SetClientConf(c ClientConfig) { clientConf = &c err := clientConf.CheckValidity() diff --git a/samples b/samples deleted file mode 160000 index ac38818cd1..0000000000 --- a/samples +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ac38818cd13ec2536fe59e51523a4fde3aee37da diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go index bcc3946616..2226f634de 100644 --- a/test/integrate/dubbo/go-client/client.go +++ b/test/integrate/dubbo/go-client/client.go @@ -19,6 +19,7 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) @@ -31,7 +32,6 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go index 4aa6a53512..75903f4370 100644 --- a/test/integrate/dubbo/go-client/user.go +++ b/test/integrate/dubbo/go-client/user.go @@ -19,11 +19,11 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "time" ) import ( - "dubbo.apache.org/dubbo-go/v3/config" hessian "github.com/apache/dubbo-go-hessian2" ) diff --git a/test/integrate/dubbo/go-server/server.go b/test/integrate/dubbo/go-server/server.go index b1c16704c8..06af91581a 100644 --- a/test/integrate/dubbo/go-server/server.go +++ b/test/integrate/dubbo/go-server/server.go @@ -18,6 +18,7 @@ package main import ( + "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -29,7 +30,6 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go index 1d7e36b86c..a87cae9758 100644 --- a/test/integrate/dubbo/go-server/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -19,13 +19,13 @@ package main import ( "context" + "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) import ( hessian "github.com/apache/dubbo-go-hessian2" - "dubbo.apache.org/dubbo-go/v3/config" ) func init() { From 94d6aa8f4fd0ab99d70637c44a508df83652321d Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 18:58:45 +0800 Subject: [PATCH 030/148] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/consumer_config.go | 2 +- protocol/dubbo/dubbo_invoker.go | 9 +++++---- protocol/dubbo/dubbo_protocol.go | 14 ++++++++++---- registry/directory/directory.go | 2 +- registry/protocol/protocol.go | 2 +- remoting/getty/getty_server.go | 10 +++++----- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index ba503045a1..91eb5c882b 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -50,7 +50,7 @@ type ConsumerConfig struct { References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` // ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol-conf,omitempty" property:"protocol-conf"` - // FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` + FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index b755592d49..f7222bce4e 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -58,16 +58,17 @@ type DubboInvoker struct { // NewDubboInvoker constructor func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient) *DubboInvoker { requestTimeout := config.GetConsumerConfig().RequestTimeout - - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) + // todo set timeout + timeout := 3 * time.Second + requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, requestTimeout) if t, err := time.ParseDuration(requestTimeoutStr); err == nil { - requestTimeout = t + timeout = t } di := &DubboInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), clientGuard: &sync.RWMutex{}, client: client, - timeout: requestTimeout, + timeout: timeout, } return di diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 050de8da23..808ca0b9e8 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -33,7 +33,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -195,11 +194,18 @@ func getExchangeClient(url *common.URL) *remoting.ExchangeClient { } return } + // new ExchangeClient + //exchangeClientTmp = remoting.NewExchangeClient(url, getty.NewClient(getty.Options{ + // ConnectTimeout: config.GetRootConfig().ConfigCenter.ConnectTimeout, + // RequestTimeout: config.GetConsumerConfig().RequestTimeout, + //}), config.GetConsumerConfig().ConnectTimeout, false) + + // todo set by config exchangeClientTmp = remoting.NewExchangeClient(url, getty.NewClient(getty.Options{ - ConnectTimeout: config.GetConsumerConfig().ConnectTimeout, - RequestTimeout: config.GetConsumerConfig().RequestTimeout, - }), config.GetConsumerConfig().ConnectTimeout, false) + ConnectTimeout: 3*time.Second, + RequestTimeout: 3*time.Second, + }), 3*time.Second, false) // input store if exchangeClientTmp != nil { exchangeClientMap.Store(url.Location, exchangeClientTmp) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 5b42cc964f..c6c0582af8 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -486,7 +486,7 @@ type consumerConfigurationListener struct { func newConsumerConfigurationListener(dir *RegistryDirectory) *consumerConfigurationListener { listener := &consumerConfigurationListener{directory: dir} - application := config.GetApplicationConfig() + application := config.GetRootConfig().Application listener.InitWith( application.Name+constant.CONFIGURATORS_SUFFIX, listener, diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 686a7913f2..3510e00684 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -457,7 +457,7 @@ func newProviderConfigurationListener(overrideListeners *sync.Map) *providerConf listener := &providerConfigurationListener{} listener.overrideListeners = overrideListeners listener.InitWith( - config.GetApplicationConfig().Name+constant.CONFIGURATORS_SUFFIX, + config.GetRootConfig().Application.Name+constant.CONFIGURATORS_SUFFIX, listener, extension.GetDefaultConfiguratorFunc(), ) diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index 9be3e055ad..6e2cf051fe 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -45,11 +45,11 @@ var srvConf *ServerConfig func initServer(protocol string) { // load clientconfig from provider_config // default use dubbo - providerConfig := config.GetProviderConfig() - if providerConfig.ApplicationConfig == nil { - return - } - protocolConf := providerConfig.ProtocolConf + //providerConfig := config.GetProviderConfig() + //if providerConfig.ApplicationConfig == nil { + // return + //} + protocolConf := config.GetRootConfig().Provider.ProtocolConf defaultServerConfig := GetDefaultServerConfig() if protocolConf == nil { logger.Info("protocol_conf default use dubbo config") From fadf717e70caaa3b08b28065e5ef942c9707afcd Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 19:21:29 +0800 Subject: [PATCH 031/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/consumer_config.go | 15 +++++++++++-- config/method_config.go | 45 +++++++++++++++++++++++++++++--------- config/provider_config.go | 25 +++++++++++++-------- config/reference_config.go | 33 +++++++++++++++++++++------- config/service_config.go | 37 ++++++++++++++++++++++--------- 5 files changed, 116 insertions(+), 39 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index 91eb5c882b..bca9992eb0 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -50,8 +50,8 @@ type ConsumerConfig struct { References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` // ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol-conf,omitempty" property:"protocol-conf"` - FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` - //ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` + // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` rootConfig *RootConfig @@ -63,6 +63,17 @@ func (ConsumerConfig) Prefix() string { } func initConsumerConfig(rc *RootConfig) error { + consumer := rc.Consumer + if consumer == nil { + consumer = new(ConsumerConfig) + } + if err := initReferenceConfig(consumer); err != nil { + return err + } + if err := defaults.Set(consumer); err != nil { + return err + } + rc.Consumer = consumer return nil } diff --git a/config/method_config.go b/config/method_config.go index e76cf7cdc4..729525a269 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -17,12 +17,9 @@ package config -import ( - "github.com/creasty/defaults" -) - import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "github.com/creasty/defaults" ) // MethodConfig defines method config @@ -51,11 +48,39 @@ func (c *MethodConfig) Prefix() string { return constant.DUBBO + "." + c.InterfaceName + "." + c.Name + "." } -// UnmarshalYAML unmarshals the MethodConfig by @unmarshal function -func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err +func initConsumerMethodConfig(rc *ReferenceConfig) error { + methods := rc.Methods + if methods == nil { + return nil + } + for _, method := range methods { + if err := defaults.Set(method); err != nil { + return err + } } - type plain MethodConfig - return unmarshal((*plain)(c)) + rc.Methods = methods + return nil } + +func initProviderMethodConfig(sc *ServiceConfig) error { + methods := sc.Methods + if methods == nil { + return nil + } + for _, method := range methods { + if err := defaults.Set(method); err != nil { + return err + } + } + sc.Methods = methods + return nil +} + +// UnmarshalYAML unmarshals the MethodConfig by @unmarshal function +//func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// if err := defaults.Set(c); err != nil { +// return err +// } +// type plain MethodConfig +// return unmarshal((*plain)(c)) +//} diff --git a/config/provider_config.go b/config/provider_config.go index e64bf54aaa..3541fae683 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -40,10 +40,10 @@ type ProviderConfig struct { Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` - Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` + // Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } @@ -58,6 +58,13 @@ func initProviderConfig(rc *RootConfig) error { if provider == nil { provider = new(ProviderConfig) } + + if err := initServiceConfig(provider); err != nil { + return err + } + if err := defaults.Set(provider); err != nil { + return err + } rc.Provider = provider return nil } @@ -75,13 +82,13 @@ func (c *ProviderConfig) Validate(r *RootConfig) { } // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err - } - type plain ProviderConfig - return unmarshal((*plain)(c)) -} +//func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// if err := defaults.Set(c); err != nil { +// return err +// } +// type plain ProviderConfig +// return unmarshal((*plain)(c)) +//} // Prefix dubbo.provider func (c *ProviderConfig) Prefix() string { diff --git a/config/reference_config.go b/config/reference_config.go index 0e911b1e5d..1ffb409eca 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -70,15 +70,32 @@ func (c *ReferenceConfig) Prefix() string { } // UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function -func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - type rf ReferenceConfig - raw := rf{} // Put your defaults here - if err := unmarshal(&raw); err != nil { - return err +//func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// type rf ReferenceConfig +// raw := rf{} // Put your defaults here +// if err := unmarshal(&raw); err != nil { +// return err +// } +// +// *c = ReferenceConfig(raw) +// return defaults.Set(c) +//} + +func initReferenceConfig(cc *ConsumerConfig) error { + references := cc.References + if references == nil { + references = make(map[string]*ReferenceConfig, 8) } - - *c = ReferenceConfig(raw) - return defaults.Set(c) + for _, reference := range references { + if err := defaults.Set(reference); err != nil { + return err + } + if err := initConsumerMethodConfig(reference); err != nil { + return err + } + } + cc.References = references + return nil } func (c *ReferenceConfig) CheckConfig() error { diff --git a/config/service_config.go b/config/service_config.go index ebc723f159..7395efebb5 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -92,21 +92,38 @@ func (c *ServiceConfig) Prefix() string { return constant.ServiceConfigPrefix + c.id } -// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function -func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { - return err +func initServiceConfig(rc *ProviderConfig) error { + services := rc.Services + if services == nil { + return nil } - type plain ServiceConfig - if err := unmarshal((*plain)(c)); err != nil { - return err + for _, service := range services { + if err := defaults.Set(service); err != nil { + return err + } + if err := initProviderMethodConfig(service); err != nil { + return err + } } - c.exported = atomic.NewBool(false) - c.unexported = atomic.NewBool(false) - c.export = true + rc.Services = services return nil } +// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function +//func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { +// if err := defaults.Set(c); err != nil { +// return err +// } +// type plain ServiceConfig +// if err := unmarshal((*plain)(c)); err != nil { +// return err +// } +// c.exported = atomic.NewBool(false) +// c.unexported = atomic.NewBool(false) +// c.export = true +// return nil +//} + func (c *ServiceConfig) CheckConfig() error { // todo check defaults.MustSet(c) From 40ae5052874a0e8984e8d3d6d84aa4e90e727713 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 19:50:15 +0800 Subject: [PATCH 032/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/method_config.go | 20 +++-- config/provider_config.go | 9 +- config/reference_config.go | 3 + config/service_config.go | 176 ++++++++++++++++++++----------------- 4 files changed, 117 insertions(+), 91 deletions(-) diff --git a/config/method_config.go b/config/method_config.go index 729525a269..45becadce5 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -40,12 +40,12 @@ type MethodConfig struct { } // nolint -func (c *MethodConfig) Prefix() string { - if len(c.InterfaceId) != 0 { - return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "." +func (mc *MethodConfig) Prefix() string { + if len(mc.InterfaceId) != 0 { + return constant.DUBBO + "." + mc.InterfaceName + "." + mc.InterfaceId + "." + mc.Name + "." } - return constant.DUBBO + "." + c.InterfaceName + "." + c.Name + "." + return constant.DUBBO + "." + mc.InterfaceName + "." + mc.Name + "." } func initConsumerMethodConfig(rc *ReferenceConfig) error { @@ -54,7 +54,7 @@ func initConsumerMethodConfig(rc *ReferenceConfig) error { return nil } for _, method := range methods { - if err := defaults.Set(method); err != nil { + if err := method.check(); err != nil { return err } } @@ -68,7 +68,7 @@ func initProviderMethodConfig(sc *ServiceConfig) error { return nil } for _, method := range methods { - if err := defaults.Set(method); err != nil { + if err := method.check(); err != nil { return err } } @@ -76,6 +76,14 @@ func initProviderMethodConfig(sc *ServiceConfig) error { return nil } +// check set default value and verify +func (mc *MethodConfig) check() error { + if err := defaults.Set(mc); err != nil { + return err + } + return verify(mc) +} + // UnmarshalYAML unmarshals the MethodConfig by @unmarshal function //func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { // if err := defaults.Set(c); err != nil { diff --git a/config/provider_config.go b/config/provider_config.go index 3541fae683..29b5b0df52 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -39,12 +39,12 @@ type ProviderConfig struct { // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` + ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` // Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } func (c *ProviderConfig) CheckConfig() error { @@ -65,6 +65,7 @@ func initProviderConfig(rc *RootConfig) error { if err := defaults.Set(provider); err != nil { return err } + provider.Registry = translateRegistryIds(provider.Registry) rc.Provider = provider return nil } diff --git a/config/reference_config.go b/config/reference_config.go index 1ffb409eca..43e1bccb6e 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -93,7 +93,10 @@ func initReferenceConfig(cc *ConsumerConfig) error { if err := initConsumerMethodConfig(reference); err != nil { return err } + // todo root config must ? + reference.rootConfig = GetRootConfig() } + cc.References = references return nil } diff --git a/config/service_config.go b/config/service_config.go index 7395efebb5..bfef0be59e 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -88,8 +88,8 @@ type ServiceConfig struct { } // Prefix returns dubbo.service.${InterfaceName}. -func (c *ServiceConfig) Prefix() string { - return constant.ServiceConfigPrefix + c.id +func (svc *ServiceConfig) Prefix() string { + return constant.ServiceConfigPrefix + svc.id } func initServiceConfig(rc *ProviderConfig) error { @@ -98,10 +98,11 @@ func initServiceConfig(rc *ProviderConfig) error { return nil } for _, service := range services { - if err := defaults.Set(service); err != nil { + + if err := initProviderMethodConfig(service); err != nil { return err } - if err := initProviderMethodConfig(service); err != nil { + if err := service.check(); err != nil { return err } } @@ -124,17 +125,30 @@ func initServiceConfig(rc *ProviderConfig) error { // return nil //} -func (c *ServiceConfig) CheckConfig() error { +func (svc *ServiceConfig) CheckConfig() error { // todo check - defaults.MustSet(c) - return verify(c) + defaults.MustSet(svc) + return verify(svc) +} + +func (svc *ServiceConfig) check() error { + if err := defaults.Set(svc); err != nil { + return err + } + // todo root config must ? + svc.rootConfig = rootConfig + svc.exported = atomic.NewBool(false) + svc.unexported = atomic.NewBool(false) + // svc.cacheProtocol = rootConfig.Protocols[0] + svc.export = true + return verify(svc) } -func (c *ServiceConfig) Validate(rootConfig *RootConfig) { - c.rootConfig = rootConfig - c.exported = atomic.NewBool(false) - c.unexported = atomic.NewBool(false) - c.export = true +func (svc *ServiceConfig) Validate(rootConfig *RootConfig) { + svc.rootConfig = rootConfig + svc.exported = atomic.NewBool(false) + svc.unexported = atomic.NewBool(false) + svc.export = true // todo set default application } @@ -175,13 +189,13 @@ func getRegistryServices(side int, services map[string]*ServiceConfig, registryI } // InitExported will set exported as false atom bool -func (c *ServiceConfig) InitExported() { - c.exported = atomic.NewBool(false) +func (svc *ServiceConfig) InitExported() { + svc.exported = atomic.NewBool(false) } // IsExport will return whether the service config is exported or not -func (c *ServiceConfig) IsExport() bool { - return c.exported.Load() +func (svc *ServiceConfig) IsExport() bool { + return svc.exported.Load() } // Get Random Port @@ -203,37 +217,37 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { } // Export exports the service -func (c *ServiceConfig) Export() error { +func (svc *ServiceConfig) Export() error { // TODO: config center start here // TODO: delay export - if c.unexported != nil && c.unexported.Load() { - err := perrors.Errorf("The service %v has already unexported!", c.Interface) + if svc.unexported != nil && svc.unexported.Load() { + err := perrors.Errorf("The service %v has already unexported!", svc.Interface) logger.Errorf(err.Error()) return err } - if c.unexported != nil && c.exported.Load() { - logger.Warnf("The service %v has already exported!", c.Interface) + if svc.unexported != nil && svc.exported.Load() { + logger.Warnf("The service %v has already exported!", svc.Interface) return nil } - regUrls := loadRegistries(c.Registry, c.rootConfig.Registries, common.PROVIDER) - urlMap := c.getUrlMap() - protocolConfigs := loadProtocol(c.Protocol, c.rootConfig.Protocols) + regUrls := loadRegistries(svc.Registry, svc.rootConfig.Registries, common.PROVIDER) + urlMap := svc.getUrlMap() + protocolConfigs := loadProtocol(svc.Protocol, svc.rootConfig.Protocols) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", c.Interface, c.Protocol) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", svc.Interface, svc.Protocol) return nil } ports := getRandomPort(protocolConfigs) nextPort := ports.Front() - proxyFactory := extension.GetProxyFactory(c.rootConfig.Provider.ProxyFactory) + proxyFactory := extension.GetProxyFactory(svc.rootConfig.Provider.ProxyFactory) for _, proto := range protocolConfigs { // registry the service reflect - methods, err := common.ServiceMap.Register(c.Interface, proto.Name, c.Group, c.Version, c.rpcService) + methods, err := common.ServiceMap.Register(svc.Interface, proto.Name, svc.Group, svc.Version, svc.rpcService) if err != nil { formatErr := perrors.Errorf("The service %v export the protocol %v error! Error message is %v.", - c.Interface, proto.Name, err.Error()) + svc.Interface, proto.Name, err.Error()) logger.Errorf(formatErr.Error()) return formatErr } @@ -244,43 +258,43 @@ func (c *ServiceConfig) Export() error { nextPort = nextPort.Next() } ivkURL := common.NewURLWithOptions( - common.WithPath(c.Interface), + common.WithPath(svc.Interface), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), common.WithPort(port), common.WithParams(urlMap), - common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), + common.WithParamsValue(constant.BEAN_NAME_KEY, svc.id), //common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), common.WithMethods(strings.Split(methods, ",")), - common.WithToken(c.Token), + common.WithToken(svc.Token), ) - if len(c.Tag) > 0 { - ivkURL.AddParam(constant.Tagkey, c.Tag) + if len(svc.Tag) > 0 { + ivkURL.AddParam(constant.Tagkey, svc.Tag) } // post process the URL to be exported - c.postProcessConfig(ivkURL) + svc.postProcessConfig(ivkURL) // config post processor may set "export" to false if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) { return nil } if len(regUrls) > 0 { - c.cacheMutex.Lock() - if c.cacheProtocol == nil { + svc.cacheMutex.Lock() + if svc.cacheProtocol == nil { logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL)) - c.cacheProtocol = extension.GetProtocol("registry") + svc.cacheProtocol = extension.GetProtocol("registry") } - c.cacheMutex.Unlock() + svc.cacheMutex.Unlock() for _, regUrl := range regUrls { regUrl.SubURL = ivkURL invoker := proxyFactory.GetInvoker(regUrl) - exporter := c.cacheProtocol.Export(invoker) + exporter := svc.cacheProtocol.Export(invoker) if exporter == nil { return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL)) } - c.exporters = append(c.exporters, exporter) + svc.exporters = append(svc.exporters, exporter) } } else { if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { @@ -295,11 +309,11 @@ func (c *ServiceConfig) Export() error { if exporter == nil { return perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error, url is {%v}", ivkURL)) } - c.exporters = append(c.exporters, exporter) + svc.exporters = append(svc.exporters, exporter) } publishServiceDefinition(ivkURL) } - c.exported.Store(true) + svc.exported.Store(true) return nil } @@ -365,52 +379,52 @@ func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, } // Unexport will call unexport of all exporters service config exported -func (c *ServiceConfig) Unexport() { - if !c.exported.Load() { +func (svc *ServiceConfig) Unexport() { + if !svc.exported.Load() { return } - if c.unexported.Load() { + if svc.unexported.Load() { return } func() { - c.exportersLock.Lock() - defer c.exportersLock.Unlock() - for _, exporter := range c.exporters { + svc.exportersLock.Lock() + defer svc.exportersLock.Unlock() + for _, exporter := range svc.exporters { exporter.Unexport() } - c.exporters = nil + svc.exporters = nil }() - c.exported.Store(false) - c.unexported.Store(true) + svc.exported.Store(false) + svc.unexported.Store(true) } // Implement only store the @s and return -func (c *ServiceConfig) Implement(s common.RPCService) { - c.rpcService = s +func (svc *ServiceConfig) Implement(s common.RPCService) { + svc.rpcService = s } -func (c *ServiceConfig) getUrlMap() url.Values { +func (svc *ServiceConfig) getUrlMap() url.Values { urlMap := url.Values{} // first set user params - for k, v := range c.Params { + for k, v := range svc.Params { urlMap.Set(k, v) } - urlMap.Set(constant.INTERFACE_KEY, c.Interface) + urlMap.Set(constant.INTERFACE_KEY, svc.Interface) urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) - urlMap.Set(constant.CLUSTER_KEY, c.Cluster) - urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) - urlMap.Set(constant.WARMUP_KEY, c.Warmup) - urlMap.Set(constant.RETRIES_KEY, c.Retries) - urlMap.Set(constant.GROUP_KEY, c.Group) - urlMap.Set(constant.VERSION_KEY, c.Version) + urlMap.Set(constant.CLUSTER_KEY, svc.Cluster) + urlMap.Set(constant.LOADBALANCE_KEY, svc.Loadbalance) + urlMap.Set(constant.WARMUP_KEY, svc.Warmup) + urlMap.Set(constant.RETRIES_KEY, svc.Retries) + urlMap.Set(constant.GROUP_KEY, svc.Group) + urlMap.Set(constant.VERSION_KEY, svc.Version) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) - urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(c.GrpcMaxMessageSize)) + urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(svc.GrpcMaxMessageSize)) // todo: move - urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) + urlMap.Set(constant.SERIALIZATION_KEY, svc.Serialization) // application config info //urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) //urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) @@ -421,29 +435,29 @@ func (c *ServiceConfig) getUrlMap() url.Values { //urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) // filter - urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(c.rootConfig.Provider.Filter, c.Filter, constant.DEFAULT_SERVICE_FILTERS)) + urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(svc.rootConfig.Provider.Filter, svc.Filter, constant.DEFAULT_SERVICE_FILTERS)) // filter special config - urlMap.Set(constant.AccessLogFilterKey, c.AccessLog) + urlMap.Set(constant.AccessLogFilterKey, svc.AccessLog) // tps limiter - urlMap.Set(constant.TPS_LIMIT_STRATEGY_KEY, c.TpsLimitStrategy) - urlMap.Set(constant.TPS_LIMIT_INTERVAL_KEY, c.TpsLimitInterval) - urlMap.Set(constant.TPS_LIMIT_RATE_KEY, c.TpsLimitRate) - urlMap.Set(constant.TPS_LIMITER_KEY, c.TpsLimiter) - urlMap.Set(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, c.TpsLimitRejectedHandler) + urlMap.Set(constant.TPS_LIMIT_STRATEGY_KEY, svc.TpsLimitStrategy) + urlMap.Set(constant.TPS_LIMIT_INTERVAL_KEY, svc.TpsLimitInterval) + urlMap.Set(constant.TPS_LIMIT_RATE_KEY, svc.TpsLimitRate) + urlMap.Set(constant.TPS_LIMITER_KEY, svc.TpsLimiter) + urlMap.Set(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, svc.TpsLimitRejectedHandler) // execute limit filter - urlMap.Set(constant.EXECUTE_LIMIT_KEY, c.ExecuteLimit) - urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, c.ExecuteLimitRejectedHandler) + urlMap.Set(constant.EXECUTE_LIMIT_KEY, svc.ExecuteLimit) + urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, svc.ExecuteLimitRejectedHandler) // auth filter - urlMap.Set(constant.SERVICE_AUTH_KEY, c.Auth) - urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, c.ParamSign) + urlMap.Set(constant.SERVICE_AUTH_KEY, svc.Auth) + urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, svc.ParamSign) // whether to export or not - urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(c.export)) + urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(svc.export)) - for _, v := range c.Methods { + for _, v := range svc.Methods { prefix := "methods." + v.Name + "." urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.LoadBalance) urlMap.Set(prefix+constant.RETRIES_KEY, v.Retries) @@ -461,10 +475,10 @@ func (c *ServiceConfig) getUrlMap() url.Values { } // GetExportedUrls will return the url in service config's exporter -func (c *ServiceConfig) GetExportedUrls() []*common.URL { - if c.exported.Load() { +func (svc *ServiceConfig) GetExportedUrls() []*common.URL { + if svc.exported.Load() { var urls []*common.URL - for _, exporter := range c.exporters { + for _, exporter := range svc.exporters { urls = append(urls, exporter.GetInvoker().GetURL()) } return urls @@ -480,7 +494,7 @@ func publishServiceDefinition(url *common.URL) { } // postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig. -func (c *ServiceConfig) postProcessConfig(url *common.URL) { +func (svc *ServiceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { p.PostProcessServiceConfig(url) } From 43386993a8dd13ab0830a2fb387c3f286b784cbb Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 20:59:38 +0800 Subject: [PATCH 033/148] =?UTF-8?q?fix:=E6=B3=A8=E5=86=8C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/reference_config.go | 162 +++++++++++++++++++------------------ registry/base_registry.go | 7 +- 2 files changed, 88 insertions(+), 81 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index 43e1bccb6e..2d4ec8ed64 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -65,8 +65,8 @@ type ReferenceConfig struct { } // nolint -func (c *ReferenceConfig) Prefix() string { - return constant.ReferenceConfigPrefix + c.InterfaceName + "." +func (rc *ReferenceConfig) Prefix() string { + return constant.ReferenceConfigPrefix + rc.InterfaceName + "." } // UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function @@ -87,46 +87,50 @@ func initReferenceConfig(cc *ConsumerConfig) error { references = make(map[string]*ReferenceConfig, 8) } for _, reference := range references { - if err := defaults.Set(reference); err != nil { + if err := initConsumerMethodConfig(reference); err != nil { return err } - if err := initConsumerMethodConfig(reference); err != nil { + if err := reference.check(); err != nil { return err } - // todo root config must ? - reference.rootConfig = GetRootConfig() } - cc.References = references return nil } -func (c *ReferenceConfig) CheckConfig() error { +func (rc *ReferenceConfig) check() error { + if err := defaults.Set(rc); err != nil { + return err + } + rc.rootConfig = rootConfig + return verify(rc) +} +func (rc *ReferenceConfig) CheckConfig() error { // todo check - defaults.MustSet(c) - return verify(c) + defaults.MustSet(rc) + return verify(rc) } -func (c *ReferenceConfig) Validate(rootConfig *RootConfig) { - c.rootConfig = rootConfig +func (rc *ReferenceConfig) Validate(rootConfig *RootConfig) { + rc.rootConfig = rootConfig // todo set default application } // Refer ... -func (c *ReferenceConfig) Refer(_ interface{}) { +func (rc *ReferenceConfig) Refer(_ interface{}) { cfgURL := common.NewURLWithOptions( - common.WithPath(c.InterfaceName), - common.WithProtocol(c.Protocol), - common.WithParams(c.getURLMap()), - common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), + common.WithPath(rc.InterfaceName), + common.WithProtocol(rc.Protocol), + common.WithParams(rc.getURLMap()), + common.WithParamsValue(constant.BEAN_NAME_KEY, rc.id), ) - if c.ForceTag { + if rc.ForceTag { cfgURL.AddParam(constant.ForceUseTag, "true") } - c.postProcessConfig(cfgURL) - if c.URL != "" { + rc.postProcessConfig(cfgURL) + if rc.URL != "" { // 1. user specified URL, could be peer-to-peer address, or register center's address. - urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*") + urlStrings := gxstrings.RegSplit(rc.URL, "\\s*[;]+\\s*") for _, urlStr := range urlStrings { serviceURL, err := common.NewURL(urlStr) if err != nil { @@ -134,36 +138,36 @@ func (c *ReferenceConfig) Refer(_ interface{}) { } if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { serviceURL.SubURL = cfgURL - c.urls = append(c.urls, serviceURL) + rc.urls = append(rc.urls, serviceURL) } else { if serviceURL.Path == "" { - serviceURL.Path = "/" + c.InterfaceName + serviceURL.Path = "/" + rc.InterfaceName } // merge url need to do newURL := common.MergeURL(serviceURL, cfgURL) - c.urls = append(c.urls, newURL) + rc.urls = append(rc.urls, newURL) } } } else { // 2. assemble SubURL from register center's configuration mode - c.urls = loadRegistries(c.Registry, c.rootConfig.Registries, common.CONSUMER) + rc.urls = loadRegistries(rc.Registry, rc.rootConfig.Registries, common.CONSUMER) // set url to regURLs - for _, regURL := range c.urls { + for _, regURL := range rc.urls { regURL.SubURL = cfgURL } } - if len(c.urls) == 1 { - c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) + if len(rc.urls) == 1 { + rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) // c.URL != "" is direct call - if c.URL != "" { + if rc.URL != "" { //filter - c.invoker = protocolwrapper.BuildInvokerChain(c.invoker, constant.REFERENCE_FILTER_KEY) + rc.invoker = protocolwrapper.BuildInvokerChain(rc.invoker, constant.REFERENCE_FILTER_KEY) // cluster - invokers := make([]protocol.Invoker, 0, len(c.urls)) - invokers = append(invokers, c.invoker) + invokers := make([]protocol.Invoker, 0, len(rc.urls)) + invokers = append(invokers, rc.invoker) // TODO(decouple from directory, config should not depend on directory module) var hitClu string // not a registry url, must be direct invoke. @@ -179,15 +183,15 @@ func (c *ReferenceConfig) Refer(_ interface{}) { // If 'zone-aware' policy select, the invoker wrap sequence would be: // ZoneAwareClusterInvoker(StaticDirectory) -> // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + rc.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) } } else { - invokers := make([]protocol.Invoker, 0, len(c.urls)) + invokers := make([]protocol.Invoker, 0, len(rc.urls)) var regURL *common.URL - for _, u := range c.urls { + for _, u := range rc.urls { invoker := extension.GetProtocol(u.Protocol).Refer(u) // c.URL != "" is direct call - if c.URL != "" { + if rc.URL != "" { //filter invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) } @@ -217,80 +221,80 @@ func (c *ReferenceConfig) Refer(_ interface{}) { // If 'zone-aware' policy select, the invoker wrap sequence would be: // ZoneAwareClusterInvoker(StaticDirectory) -> // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - c.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + rc.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) } // publish consumer metadata publishConsumerDefinition(cfgURL) // create proxy - if c.Async { - callback := GetCallback(c.id) - c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) + if rc.Async { + callback := GetCallback(rc.id) + rc.pxy = extension.GetProxyFactory(rc.rootConfig.Consumer.ProxyFactory).GetAsyncProxy(rc.invoker, callback, cfgURL) } else { - c.pxy = extension.GetProxyFactory(c.rootConfig.Consumer.ProxyFactory).GetProxy(c.invoker, cfgURL) + rc.pxy = extension.GetProxyFactory(rc.rootConfig.Consumer.ProxyFactory).GetProxy(rc.invoker, cfgURL) } } // Implement // @v is service provider implemented RPCService -func (c *ReferenceConfig) Implement(v common.RPCService) { - c.pxy.Implement(v) +func (rc *ReferenceConfig) Implement(v common.RPCService) { + rc.pxy.Implement(v) } // GetRPCService gets RPCService from proxy -func (c *ReferenceConfig) GetRPCService() common.RPCService { - return c.pxy.Get() +func (rc *ReferenceConfig) GetRPCService() common.RPCService { + return rc.pxy.Get() } // GetProxy gets proxy -func (c *ReferenceConfig) GetProxy() *proxy.Proxy { - return c.pxy +func (rc *ReferenceConfig) GetProxy() *proxy.Proxy { + return rc.pxy } -func (c *ReferenceConfig) getURLMap() url.Values { +func (rc *ReferenceConfig) getURLMap() url.Values { urlMap := url.Values{} // first set user params - for k, v := range c.Params { + for k, v := range rc.Params { urlMap.Set(k, v) } - urlMap.Set(constant.INTERFACE_KEY, c.InterfaceName) + urlMap.Set(constant.INTERFACE_KEY, rc.InterfaceName) urlMap.Set(constant.TIMESTAMP_KEY, strconv.FormatInt(time.Now().Unix(), 10)) - urlMap.Set(constant.CLUSTER_KEY, c.Cluster) - urlMap.Set(constant.LOADBALANCE_KEY, c.Loadbalance) - urlMap.Set(constant.RETRIES_KEY, c.Retries) - urlMap.Set(constant.GROUP_KEY, c.Group) - urlMap.Set(constant.VERSION_KEY, c.Version) - urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(c.Generic)) + urlMap.Set(constant.CLUSTER_KEY, rc.Cluster) + urlMap.Set(constant.LOADBALANCE_KEY, rc.Loadbalance) + urlMap.Set(constant.RETRIES_KEY, rc.Retries) + urlMap.Set(constant.GROUP_KEY, rc.Group) + urlMap.Set(constant.VERSION_KEY, rc.Version) + urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(rc.Generic)) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) - urlMap.Set(constant.PROVIDED_BY, c.ProvidedBy) - urlMap.Set(constant.SERIALIZATION_KEY, c.Serialization) + urlMap.Set(constant.PROVIDED_BY, rc.ProvidedBy) + urlMap.Set(constant.SERIALIZATION_KEY, rc.Serialization) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) - if len(c.RequestTimeout) != 0 { - urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout) + if len(rc.RequestTimeout) != 0 { + urlMap.Set(constant.TIMEOUT_KEY, rc.RequestTimeout) } // getty invoke async or sync - urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async)) - urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky)) + urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(rc.Async)) + urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(rc.Sticky)) // applicationConfig info - urlMap.Set(constant.APPLICATION_KEY, c.rootConfig.Application.Name) - urlMap.Set(constant.ORGANIZATION_KEY, c.rootConfig.Application.Organization) - urlMap.Set(constant.NAME_KEY, c.rootConfig.Application.Name) - urlMap.Set(constant.MODULE_KEY, c.rootConfig.Application.Module) - urlMap.Set(constant.APP_VERSION_KEY, c.rootConfig.Application.Version) - urlMap.Set(constant.OWNER_KEY, c.rootConfig.Application.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, c.rootConfig.Application.Environment) + urlMap.Set(constant.APPLICATION_KEY, rc.rootConfig.Application.Name) + urlMap.Set(constant.ORGANIZATION_KEY, rc.rootConfig.Application.Organization) + urlMap.Set(constant.NAME_KEY, rc.rootConfig.Application.Name) + urlMap.Set(constant.MODULE_KEY, rc.rootConfig.Application.Module) + urlMap.Set(constant.APP_VERSION_KEY, rc.rootConfig.Application.Version) + urlMap.Set(constant.OWNER_KEY, rc.rootConfig.Application.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, rc.rootConfig.Application.Environment) // filter defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS - if c.Generic { + if rc.Generic { defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter } //urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) - for _, v := range c.Methods { + for _, v := range rc.Methods { urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries) urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky)) @@ -303,17 +307,17 @@ func (c *ReferenceConfig) getURLMap() url.Values { } // GenericLoad ... -func (c *ReferenceConfig) GenericLoad(id string) { - genericService := generic.NewGenericService(c.id) +func (rc *ReferenceConfig) GenericLoad(id string) { + genericService := generic.NewGenericService(rc.id) SetConsumerService(genericService) - c.id = id - c.Refer(genericService) - c.Implement(genericService) + rc.id = id + rc.Refer(genericService) + rc.Implement(genericService) } // GetInvoker get invoker from ReferenceConfig -func (c *ReferenceConfig) GetInvoker() protocol.Invoker { - return c.invoker +func (rc *ReferenceConfig) GetInvoker() protocol.Invoker { + return rc.invoker } func publishConsumerDefinition(url *common.URL) { @@ -323,7 +327,7 @@ func publishConsumerDefinition(url *common.URL) { } // postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. -func (c *ReferenceConfig) postProcessConfig(url *common.URL) { +func (rc *ReferenceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { p.PostProcessReferenceConfig(url) } diff --git a/registry/base_registry.go b/registry/base_registry.go index dec27867f7..415a005354 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -143,7 +143,9 @@ func (r *BaseRegistry) Register(conf *common.URL) error { if portToRegistry := os.Getenv("DUBBO_PORT_TO_REGISTRY"); portToRegistry != "" { conf.Port = portToRegistry } - role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + // todo bug when provider、consumer simultaneous initialization + //role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + role, _ := strconv.Atoi(conf.GetParam(constant.ROLE_KEY, "")) // Check if the service has been registered r.cltLock.Lock() _, ok = r.services[conf.Key()] @@ -268,7 +270,8 @@ func (r *BaseRegistry) processURL(c *common.URL, f func(string, string) error, c params.Add("ip", localIP) // params.Add("timeout", fmt.Sprintf("%d", int64(r.Timeout)/1e6)) - role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) + role, _ := strconv.Atoi(c.GetParam(constant.ROLE_KEY, "")) + //role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) switch role { case common.PROVIDER: From f1e8378cd4fa9b1e5ba20e248539958626869879 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 21:54:37 +0800 Subject: [PATCH 034/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/consumer_config.go | 8 +++++++- config/provider_config.go | 7 ++++++- config/reference_config.go | 2 +- config/root_config.go | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index bca9992eb0..f1ec48b10c 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -46,7 +46,7 @@ type ConsumerConfig struct { RequestTimeout string `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"` ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` - Check bool `default:"true" yaml:"check" json:"check,omitempty" property:"check"` + Check bool `yaml:"check" json:"check,omitempty" property:"check"` References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` // ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol-conf,omitempty" property:"protocol-conf"` @@ -73,6 +73,12 @@ func initConsumerConfig(rc *RootConfig) error { if err := defaults.Set(consumer); err != nil { return err } + for { + if rc.Provider.ready.Load() { + consumer.Load() + break + } + } rc.Consumer = consumer return nil } diff --git a/config/provider_config.go b/config/provider_config.go index 29b5b0df52..1740e68fb5 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -21,6 +21,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" "fmt" "github.com/creasty/defaults" + "go.uber.org/atomic" ) import ( @@ -45,6 +46,8 @@ type ProviderConfig struct { FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + // 是否初始化完成 + ready *atomic.Bool } func (c *ProviderConfig) CheckConfig() error { @@ -66,6 +69,7 @@ func initProviderConfig(rc *RootConfig) error { return err } provider.Registry = translateRegistryIds(provider.Registry) + provider.Load() rc.Provider = provider return nil } @@ -107,7 +111,7 @@ func (c *ProviderConfig) Load() { // } // } //} - + c.ready = atomic.NewBool(false) for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { @@ -120,6 +124,7 @@ func (c *ProviderConfig) Load() { panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } + c.ready = atomic.NewBool(true) } // SetProviderConfig sets provider config by @p diff --git a/config/reference_config.go b/config/reference_config.go index 2d4ec8ed64..c6e1c24cd7 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -39,7 +39,7 @@ type ReferenceConfig struct { pxy *proxy.Proxy id string InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` - Check *bool `yaml:"check" json:"check,omitempty" property:"check"` + Check *bool `default:"false" yaml:"check" json:"check,omitempty" property:"check"` URL string `yaml:"url" json:"url,omitempty" property:"url"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` diff --git a/config/root_config.go b/config/root_config.go index 60b78a7213..1d3bbbc6c8 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -134,8 +134,8 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { return err } - rc.Provider.Load() - rc.Consumer.Load() + //rc.Provider.Load() + //rc.Consumer.Load() return nil } From 35ef293cf9d11445d6a7a1b2438828c798e39d2f Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 23:41:20 +0800 Subject: [PATCH 035/148] =?UTF-8?q?add:=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=A8=A1=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_center_config.go | 36 +++++++++++++++++++++------------- config/root_config.go | 8 ++++---- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/config/config_center_config.go b/config/config_center_config.go index ebfd2ebcfa..fd1a5b3104 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -18,6 +18,7 @@ package config import ( + "gopkg.in/yaml.v2" "net/url" "strings" ) @@ -46,6 +47,7 @@ import ( type CenterConfig struct { Protocol string `yaml:"protocol" json:"protocol,omitempty"` Address string `yaml:"address" json:"address,omitempty"` + DataId string `yaml:"data-id" json:"data-id,omitempty"` // Deprecated Cluster string `yaml:"cluster" json:"cluster,omitempty"` Group string `default:"dubbo" yaml:"group" json:"group,omitempty"` @@ -144,32 +146,40 @@ func (c *CenterConfig) toURL() (*common.URL, error) { // startConfigCenter will start the config center. // it will prepare the environment -func (c *CenterConfig) startConfigCenter() error { - newUrl, err := c.toURL() +func startConfigCenter(rc *RootConfig) error { + cc := rc.ConfigCenter + + newUrl, err := cc.toURL() if err != nil { return err } - if err = c.prepareEnvironment(newUrl); err != nil { + strConf, err := cc.prepareEnvironment(newUrl) + if err != nil { return errors.WithMessagef(err, "start config center error!") } - // c.fresh() - return nil + + if err = yaml.Unmarshal([]byte(strConf), rc); err != nil { + return err + } + rc.refresh = false + rc.ConfigCenter = nil + return rc.InitConfig() } -func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) error { +func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, error) { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { logger.Errorf("Get dynamic configuration error , error message is %v", err) - return errors.WithStack(err) + return "", errors.WithStack(err) } envInstance := conf.GetEnvInstance() envInstance.SetDynamicConfiguration(dynamicConfig) - _, err = dynamicConfig.GetProperties(c.ConfigFile, config_center.WithGroup(c.Group)) - if err != nil { - logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) - return errors.WithStack(err) - } + return dynamicConfig.GetProperties(c.DataId, config_center.WithGroup(c.Group)) + //if err != nil { + // logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) + // return errors.WithStack(err) + //} //yaml.Unmarshal([]byte(conten),rootConfig) //var appGroup string //var appContent string @@ -206,6 +216,4 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) error { // } // envInstance.UpdateAppExternalConfigMap(appMapContent) //} - - return nil } diff --git a/config/root_config.go b/config/root_config.go index 1d3bbbc6c8..923ca3e858 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -93,11 +93,11 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { for _, opt := range opts { opt.apply(rc) } - // 这个里面不能panic + // if rc.ConfigCenter != nil && !rc.refresh { - //监听远程配置刷新本地指定配置 - // yaml - // 监听文件变化 + if err := startConfigCenter(rc); err != nil { + return err + } } if err := initApplicationConfig(rc); err != nil { return err From 6c511dd0172e8b1393fd2dff6312bab25d757997 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 1 Aug 2021 23:46:43 +0800 Subject: [PATCH 036/148] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/root_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/root_config.go b/config/root_config.go index 923ca3e858..09cb3f41a7 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -89,11 +89,11 @@ func (RootConfig) Prefix() string { return constant.DUBBO } +// InitConfig init config func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { for _, opt := range opts { opt.apply(rc) } - // if rc.ConfigCenter != nil && !rc.refresh { if err := startConfigCenter(rc); err != nil { return err From 8e32515744947eb0a65a1f679d5098678b9fa75d Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Tue, 3 Aug 2021 20:49:21 +0800 Subject: [PATCH 037/148] =?UTF-8?q?up:=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/root_config.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/root_config.go b/config/root_config.go index 09cb3f41a7..b2818f12c2 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -133,10 +133,6 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { if err := initConsumerConfig(rc); err != nil { return err } - - //rc.Provider.Load() - //rc.Consumer.Load() - return nil } From 45143a83d1835875ca52096fab2c51f8e1b5de53 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Tue, 3 Aug 2021 21:57:08 +0800 Subject: [PATCH 038/148] =?UTF-8?q?up:router=E4=B8=BA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/root_config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/root_config.go b/config/root_config.go index b2818f12c2..0088ce1190 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -38,9 +38,10 @@ type RootConfig struct { // Shutdown config Shutdown *ShutdownConfig `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` + // Deprecated Network map[interface{}]interface{} `yaml:"network" json:"network,omitempty" property:"network"` - Router *RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` + Router []*RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` // is refresh action refresh bool // prefix string From a648a96f05f26571c0dda3197af3f6c582f76684 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Tue, 3 Aug 2021 22:07:01 +0800 Subject: [PATCH 039/148] =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/consumer_config.go | 19 ++++++------------- config/provider_config.go | 2 +- config/reference_config.go | 10 ---------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index f1ec48b10c..1ca32311cc 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -45,7 +45,7 @@ type ConsumerConfig struct { Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` RequestTimeout string `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"` - ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` + ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` Check bool `yaml:"check" json:"check,omitempty" property:"check"` References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` @@ -70,7 +70,7 @@ func initConsumerConfig(rc *RootConfig) error { if err := initReferenceConfig(consumer); err != nil { return err } - if err := defaults.Set(consumer); err != nil { + if err := consumer.check(); err != nil { return err } for { @@ -83,18 +83,11 @@ func initConsumerConfig(rc *RootConfig) error { return nil } -func (c *ConsumerConfig) CheckConfig() error { - // todo check - defaults.MustSet(c) - return verify(c) -} - -func (c *ConsumerConfig) Validate(rootConfig *RootConfig) { - for k, _ := range c.References { - c.References[k].Validate(rootConfig) +func (c *ConsumerConfig) check() error { + if err := defaults.Set(c); err != nil { + return err } - c.rootConfig = rootConfig - // todo set default application + return verify(c) } func (c *ConsumerConfig) Load() { diff --git a/config/provider_config.go b/config/provider_config.go index 1740e68fb5..04adb8bf57 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -40,7 +40,7 @@ type ProviderConfig struct { // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` - ProxyFactory string `default:"default" yaml:"proxy-factory" json:"proxy-factory,omitempty" property:"proxy-factory"` + ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` // Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` diff --git a/config/reference_config.go b/config/reference_config.go index c6e1c24cd7..80a23a2460 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -105,16 +105,6 @@ func (rc *ReferenceConfig) check() error { rc.rootConfig = rootConfig return verify(rc) } -func (rc *ReferenceConfig) CheckConfig() error { - // todo check - defaults.MustSet(rc) - return verify(rc) -} - -func (rc *ReferenceConfig) Validate(rootConfig *RootConfig) { - rc.rootConfig = rootConfig - // todo set default application -} // Refer ... func (rc *ReferenceConfig) Refer(_ interface{}) { From 1461fbd37b4ac6f7bc423f89a29cc793048cdb62 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Wed, 4 Aug 2021 19:59:24 +0800 Subject: [PATCH 040/148] add:duration func --- common/url.go | 10 ++++++++++ config/root_config.go | 6 +++++- protocol/dubbo/dubbo_invoker.go | 10 +++------- protocol/dubbo3/dubbo3_invoker.go | 11 ++++------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/common/url.go b/common/url.go index 36e0d88d93..a85a273136 100644 --- a/common/url.go +++ b/common/url.go @@ -27,6 +27,7 @@ import ( "strconv" "strings" "sync" + "time" ) import ( @@ -869,3 +870,12 @@ func SetCompareURLEqualFunc(f CompareURLEqualFunc) { func GetCompareURLEqualFunc() CompareURLEqualFunc { return compareURLEqualFunc } + +//GetParamDuration get duration if err return 3s +func (c *URL) GetParamDuration(s string, d string) time.Duration { + timeStr := c.GetParam(s, d) + if t, err := time.ParseDuration(timeStr); err == nil { + return t + } + return 3 * time.Second +} \ No newline at end of file diff --git a/config/root_config.go b/config/root_config.go index 0088ce1190..9d223f578a 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -38,7 +38,7 @@ type RootConfig struct { // Shutdown config Shutdown *ShutdownConfig `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` - // Deprecated + // Deprecated Network map[interface{}]interface{} `yaml:"network" json:"network,omitempty" property:"network"` Router []*RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` @@ -235,6 +235,10 @@ func GetConsumerConfig() *ConsumerConfig { return NewConsumerConfig() } +func GetApplicationConfig() *ApplicationConfig { + return rootConfig.Application +} + // GetConfigCenterConfig get config center config //func GetConfigCenterConfig() (*CenterConfig, error) { // if err := check(); err != nil { diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index f7222bce4e..4e8c8012a1 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -57,13 +57,9 @@ type DubboInvoker struct { // NewDubboInvoker constructor func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient) *DubboInvoker { - requestTimeout := config.GetConsumerConfig().RequestTimeout - // todo set timeout - timeout := 3 * time.Second - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, requestTimeout) - if t, err := time.ParseDuration(requestTimeoutStr); err == nil { - timeout = t - } + rt := config.GetConsumerConfig().RequestTimeout + + timeout := url.GetParamDuration(constant.TIMEOUT_KEY,rt) di := &DubboInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), clientGuard: &sync.RWMutex{}, diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 5c152c774f..81ddfa7354 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -56,12 +56,9 @@ type DubboInvoker struct { // NewDubboInvoker constructor func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { - requestTimeout := config.GetConsumerConfig().RequestTimeout - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) - if t, err := time.ParseDuration(requestTimeoutStr); err == nil { - requestTimeout = t - } + rt := config.GetConsumerConfig().RequestTimeout + timeout:=url.GetParamDuration(constant.TIMEOUT_KEY,rt) key := url.GetParam(constant.BEAN_NAME_KEY, "") consumerService := config.GetConsumerService(key) @@ -69,7 +66,7 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { triCodecType := tripleConstant.CodecType(dubboSerializaerType) // new triple client triOption := triConfig.NewTripleOption( - triConfig.WithClientTimeout(uint32(requestTimeout.Seconds())), + triConfig.WithClientTimeout(uint32(timeout.Seconds())), triConfig.WithCodecType(triCodecType), triConfig.WithLocation(url.Location), triConfig.WithHeaderAppVersion(url.GetParam(constant.APP_VERSION_KEY, "")), @@ -85,7 +82,7 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { return &DubboInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), client: client, - timeout: requestTimeout, + timeout: timeout, clientGuard: &sync.RWMutex{}, }, nil } From 7d7775566cb87f5fe5635176183f101b0410be70 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Wed, 4 Aug 2021 20:03:54 +0800 Subject: [PATCH 041/148] add: license --- config/root_config.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/root_config.go b/config/root_config.go index 9d223f578a..94d4bc5fb1 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -1,3 +1,20 @@ +/* + * 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 import ( From 2f9c1cd371aa14c8ca8c0f06956e67ffefd2b490 Mon Sep 17 00:00:00 2001 From: qiuyiliang <1162922438@qq.com> Date: Thu, 5 Aug 2021 17:08:00 +0800 Subject: [PATCH 042/148] =?UTF-8?q?up:=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/router_config.go | 69 ++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/config/router_config.go b/config/router_config.go index 26f3a95839..a0570572a7 100644 --- a/config/router_config.go +++ b/config/router_config.go @@ -19,24 +19,71 @@ package config import ( "github.com/apache/dubbo-go/cluster/router/chain" + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/yaml" + "github.com/creasty/defaults" ) -// LocalRouterRules defines the local router config structure -type LocalRouterRules struct { - RouterRules []interface{} `yaml:"routerRules"` +// RouterConfig is the configuration of the router. +type RouterConfig struct { + // Scope must be chosen from `service` and `application`. + Scope string `validate:"required" yaml:"scope" json:"scope,omitempty" property:"scope"` + // Key specifies which service or application the rule body acts on. + Key string `validate:"required" yaml:"key" json:"key,omitempty" property:"key"` + Force bool `default:"false" yaml:"force" json:"force,omitempty" property:"force"` + Runtime bool `default:"false" yaml:"runtime" json:"runtime,omitempty" property:"runtime"` + Enable bool `default:"true" yaml:"enable" json:"enable,omitempty" property:"enable"` + Valid bool `default:"true" yaml:"valid" json:"valid,omitempty" property:"valid"` + Priority int `default:"0" yaml:"priority" json:"priority,omitempty" property:"priority"` + Conditions []string `yaml:"conditions" json:"conditions,omitempty" property:"conditions"` + Tags []Tag `yaml:"tags" json:"tags,omitempty" property:"tags"` } -// RouterInit Set config file to init router config -func RouterInit(vsConfigPath, drConfigPath string) error { - vsBytes, err := yaml.LoadYMLConfig(vsConfigPath) - if err != nil { +type Tag struct { + Name string `yaml:"name" json:"name,omitempty" property:"name"` + Addresses []string `yaml:"addresses" json:"addresses,omitempty" property:"addresses"` +} + +// Prefix dubbo.router +func (c *RouterConfig) Prefix() string { + return constant.RouterConfigPrefix +} + +func (c *RouterConfig) check() error { + if err := defaults.Set(c); err != nil { return err } - drBytes, err := yaml.LoadYMLConfig(drConfigPath) - if err != nil { - return err + return verify(c) +} + +func initRouterConfig(rc *RootConfig) error { + routers := rc.Router + if len(routers) > 0 { + for _, r := range routers { + if err := r.check(); err != nil { + return err + } + } + rc.Router = routers } - chain.SetVSAndDRConfigByte(vsBytes, drBytes) return nil } + +//// LocalRouterRules defines the local router config structure +//type LocalRouterRules struct { +// RouterRules []interface{} `yaml:"routerRules"` +//} +// +//// RouterInit Set config file to init router config +//func RouterInit(vsConfigPath, drConfigPath string) error { +// vsBytes, err := yaml.LoadYMLConfig(vsConfigPath) +// if err != nil { +// return err +// } +// drBytes, err := yaml.LoadYMLConfig(drConfigPath) +// if err != nil { +// return err +// } +// chain.SetVSAndDRConfigByte(vsBytes, drBytes) +// return nil +//} From 56068b229bc47a9850f12243b619d93092d715d6 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Thu, 5 Aug 2021 22:35:05 +0800 Subject: [PATCH 043/148] =?UTF-8?q?fix:nacos=20registry=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0group=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/rest/rest_protocol_test.go | 4 ++-- registry/nacos/listener.go | 3 ++- registry/nacos/registry.go | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index c28f9c54ae..4748e96dea 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -44,8 +44,8 @@ func TestRestProtocolRefer(t *testing.T) { url, err := common.NewURL(mockRestCommonUrl) assert.NoError(t, err) con := config.ConsumerConfig{ - ConnectTimeout: 5 * time.Second, - RequestTimeout: 5 * time.Second, + ConnectTimeout: "5s", + RequestTimeout: "5s", } config.SetConsumerConfig(con) configMap := make(map[string]*rest_config.RestServiceConfig) diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go index 3a538cc91d..45a0b21a52 100644 --- a/registry/nacos/listener.go +++ b/registry/nacos/listener.go @@ -186,7 +186,8 @@ func (nl *nacosListener) startListen() error { return perrors.New("nacos naming namingClient stopped") } serviceName := getSubscribeName(nl.listenUrl) - nl.subscribeParam = &vo.SubscribeParam{ServiceName: serviceName, SubscribeCallback: nl.Callback} + group := nl.listenUrl.GetParam(constant.GROUP_KEY, defaultGroup) + nl.subscribeParam = &vo.SubscribeParam{ServiceName: serviceName, GroupName: group, SubscribeCallback: nl.Callback} go func() { _ = nl.namingClient.Client().Subscribe(nl.subscribeParam) }() diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index b29f97f30d..a06ba781d5 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -109,6 +109,7 @@ func createRegisterParam(url *common.URL, serviceName string) vo.RegisterInstanc Healthy: true, Ephemeral: true, ServiceName: serviceName, + GroupName: url.GetParam(constant.GROUP_KEY, defaultGroup), } return instance } @@ -168,7 +169,9 @@ func (nr *nacosRegistry) subscribe(conf *common.URL) (registry.Listener, error) // subscribe from registry func (nr *nacosRegistry) Subscribe(url *common.URL, notifyListener registry.NotifyListener) error { - role, _ := strconv.Atoi(nr.URL.GetParam(constant.ROLE_KEY, "")) + // TODO + // role, _ := strconv.Atoi(nr.URL.GetParam(constant.ROLE_KEY, "")) + role, _ := strconv.Atoi(url.GetParam(constant.ROLE_KEY, "")) if role != common.CONSUMER { return nil } From b78debda11ebef45d7aa498d926f61b20b3591c3 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 8 Aug 2021 22:48:36 +0800 Subject: [PATCH 044/148] =?UTF-8?q?add:=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E5=BF=83=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_center_config.go | 45 ++++++++++++++++++++++++---------- config/config_loader.go | 5 ++-- config/root_config.go | 8 +++--- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/config/config_center_config.go b/config/config_center_config.go index fd1a5b3104..d2a7f308e4 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -18,7 +18,9 @@ package config import ( - "gopkg.in/yaml.v2" + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/rawbytes" "net/url" "strings" ) @@ -68,9 +70,10 @@ type CenterConfig struct { Params map[string]string `yaml:"params" json:"parameters,omitempty"` } -func (c *CenterConfig) CheckConfig() error { - // todo check - defaults.MustSet(c) +func (c *CenterConfig) check() error { + if err := defaults.Set(c); err != nil { + return err + } c.translateConfigAddress() return verify(c) } @@ -79,13 +82,25 @@ func (c *CenterConfig) Validate() { // todo set default application } -// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function -func (c *CenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { - if err := defaults.Set(c); err != nil { +func (c *CenterConfig) Init() error { + if c != nil { + if err := c.check(); err != nil { + return err + } + + } + return nil +} + +func initConfigCenter(rc *RootConfig) error { + center := rc.ConfigCenter + if center == nil || rc.refresh { + return nil + } + if err := center.check(); err != nil { return err } - type plain CenterConfig - return unmarshal((*plain)(c)) + return startConfigCenter(rc) } // GetUrlMap gets url map from ConfigCenterConfig @@ -148,17 +163,21 @@ func (c *CenterConfig) toURL() (*common.URL, error) { // it will prepare the environment func startConfigCenter(rc *RootConfig) error { cc := rc.ConfigCenter - - newUrl, err := cc.toURL() + configCenterUrl, err := cc.toURL() if err != nil { return err } - strConf, err := cc.prepareEnvironment(newUrl) + strConf, err := cc.prepareEnvironment(configCenterUrl) if err != nil { return errors.WithMessagef(err, "start config center error!") } - if err = yaml.Unmarshal([]byte(strConf), rc); err != nil { + koan := koanf.New(".") + if err = koan.Load(rawbytes.Provider([]byte(strConf)), yaml.Parser()); err != nil { + return err + } + if err = koan.UnmarshalWithConf(rc.Prefix(), + rc, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err } rc.refresh = false diff --git a/config/config_loader.go b/config/config_loader.go index bee96cae43..1998b43ba2 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -36,7 +36,6 @@ import ( var ( rootConfig *RootConfig - //consumerConfig *consumer.ShutdownConfig //providerConfig *provider.ProviderConfig //// baseConfig = providerConfig.BaseConfig or consumerConfig @@ -55,8 +54,8 @@ func Load(opts ...LoaderConfOption) error { conf := NewLoaderConf(opts...) // init config rootConfig = new(RootConfig) - viper := getKoanf(conf) - if err := viper.UnmarshalWithConf(rootConfig.Prefix(), + koan := getKoanf(conf) + if err := koan.UnmarshalWithConf(rootConfig.Prefix(), rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err } diff --git a/config/root_config.go b/config/root_config.go index 94d4bc5fb1..eadb58531b 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -112,14 +112,12 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { for _, opt := range opts { opt.apply(rc) } - if rc.ConfigCenter != nil && !rc.refresh { - if err := startConfigCenter(rc); err != nil { - return err - } - } if err := initApplicationConfig(rc); err != nil { return err } + if err := initConfigCenter(rc); err != nil { + return err + } if err := initProtocolsConfig(rc); err != nil { return err } From 2411e3190ead7a8751b8064a8d0f3c435c661d29 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 8 Aug 2021 23:01:34 +0800 Subject: [PATCH 045/148] =?UTF-8?q?=E5=88=A0=E9=99=A4nacos=20registry=20gr?= =?UTF-8?q?oup=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registry/nacos/listener.go | 3 +-- registry/nacos/registry.go | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go index 45a0b21a52..3a538cc91d 100644 --- a/registry/nacos/listener.go +++ b/registry/nacos/listener.go @@ -186,8 +186,7 @@ func (nl *nacosListener) startListen() error { return perrors.New("nacos naming namingClient stopped") } serviceName := getSubscribeName(nl.listenUrl) - group := nl.listenUrl.GetParam(constant.GROUP_KEY, defaultGroup) - nl.subscribeParam = &vo.SubscribeParam{ServiceName: serviceName, GroupName: group, SubscribeCallback: nl.Callback} + nl.subscribeParam = &vo.SubscribeParam{ServiceName: serviceName, SubscribeCallback: nl.Callback} go func() { _ = nl.namingClient.Client().Subscribe(nl.subscribeParam) }() diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index a06ba781d5..7cf4978d92 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -109,7 +109,6 @@ func createRegisterParam(url *common.URL, serviceName string) vo.RegisterInstanc Healthy: true, Ephemeral: true, ServiceName: serviceName, - GroupName: url.GetParam(constant.GROUP_KEY, defaultGroup), } return instance } From c5802c521a1cbb2752330d2064375622fe97f54f Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Mon, 9 Aug 2021 12:14:34 +0800 Subject: [PATCH 046/148] Use class name as the default reference name (#1339) * 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] * improve etcd version and change create to put (#1203) * Remove RPC Service * use type assertion before reflect * modify comment * modify comment of BaseMetadataService * add the type alias of interface{} * modify RPCService Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy --- common/rpc_service.go | 33 +++++++++++++++++++++++++++++-- common/rpc_service_test.go | 33 +++++++++++++++++++++++++++++++ config/config_loader.go | 3 ++- config/service.go | 6 ++++-- metadata/service/local_service.go | 4 ++-- 5 files changed, 72 insertions(+), 7 deletions(-) diff --git a/common/rpc_service.go b/common/rpc_service.go index 224f8c8e1e..1a7cbc8b7c 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -34,14 +34,43 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// RPCService +// RPCService the type alias of interface{} +type RPCService = interface{} + +// ReferencedRPCService // rpc service interface -type RPCService interface { +type ReferencedRPCService interface { // Reference: // rpc service id or reference id Reference() string } +// GetReference return the reference id of the service. +// If the service implemented the ReferencedRPCService interface, +// it will call the Reference method. If not, it will +// return the struct name as the reference id. +func GetReference(service RPCService) string { + if s, ok := service.(ReferencedRPCService); ok { + return s.Reference() + } + + ref := "" + sType := reflect.TypeOf(service) + kind := sType.Kind() + switch kind { + case reflect.Struct: + ref = sType.Name() + case reflect.Ptr: + sName := sType.Elem().Name() + if sName != "" { + ref = sName + } else { + ref = sType.Elem().Field(0).Name + } + } + return ref +} + // AsyncCallbackService callback interface for async type AsyncCallbackService interface { // Callback: callback diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go index 8dc984f7a5..6143e472a5 100644 --- a/common/rpc_service_test.go +++ b/common/rpc_service_test.go @@ -218,3 +218,36 @@ func TestSuiteMethod(t *testing.T) { methodType = suiteMethod(method) assert.Nil(t, methodType) } + +type ServiceWithoutRef struct{} + +func TestGetReference(t *testing.T) { + s0 := &TestService{} + ref0 := GetReference(s0) + assert.Equal(t, referenceTestPath, ref0) + + //s1 := TestService{} + //ref1 := GetReference(s1) + //assert.Equal(t, referenceTestPath, ref1) + + s2 := &struct { + TestService + }{} + ref2 := GetReference(s2) + assert.Equal(t, referenceTestPath, ref2) + + expectedReference := "ServiceWithoutRef" + s3 := &ServiceWithoutRef{} + ref3 := GetReference(s3) + assert.Equal(t, expectedReference, ref3) + + s4 := ServiceWithoutRef{} + ref4 := GetReference(s4) + assert.Equal(t, expectedReference, ref4) + + s5 := &struct { + ServiceWithoutRef + }{} + ref5 := GetReference(s5) + assert.Equal(t, expectedReference, ref5) +} diff --git a/config/config_loader.go b/config/config_loader.go index 039d8fccb6..a87abf4aa5 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -401,7 +401,8 @@ func GetRPCService(name string) common.RPCService { // RPCService create rpc service for consumer func RPCService(service common.RPCService) { - consumerConfig.References[service.Reference()].Implement(service) + ref := common.GetReference(service) + consumerConfig.References[ref].Implement(service) } // GetMetricConfig find the MetricConfig diff --git a/config/service.go b/config/service.go index 12cc91e90b..a487abab07 100644 --- a/config/service.go +++ b/config/service.go @@ -28,12 +28,14 @@ var ( // SetConsumerService is called by init() of implement of RPCService func SetConsumerService(service common.RPCService) { - conServices[service.Reference()] = service + ref := common.GetReference(service) + conServices[ref] = service } // SetProviderService is called by init() of implement of RPCService func SetProviderService(service common.RPCService) { - proServices[service.Reference()] = service + ref := common.GetReference(service) + proServices[ref] = service } // GetConsumerService gets ConsumerService by @name diff --git a/metadata/service/local_service.go b/metadata/service/local_service.go index 135dae04fd..1230e3a1eb 100644 --- a/metadata/service/local_service.go +++ b/metadata/service/local_service.go @@ -30,7 +30,7 @@ import ( // MetadataService is used to define meta data related behaviors // usually the implementation should be singleton type MetadataService interface { - common.RPCService + common.ReferencedRPCService // ServiceName will get the service's name in meta service , which is application name ServiceName() (string, error) // ExportURL will store the exported url in metadata @@ -94,7 +94,7 @@ func (mts *BaseMetadataService) ServiceName() (string, error) { return mts.serviceName, nil } -// Version will return the version of metadata service +// Reference will return the reference id of metadata service func (mts *BaseMetadataService) Reference() string { return constant.SIMPLE_METADATA_SERVICE_NAME } From 495090f1cce1fd24a2ffb8a50f188bedde199d53 Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Sat, 14 Aug 2021 12:03:05 +0800 Subject: [PATCH 047/148] Feat/upgrade getty (#1345) * feat(getty): upgrade getty version to 1.4.4 * feat(getty): delete outdated getty params * delete time.Sleep in unit test * upgrade getty version to 1.4.5 * style(getty): format package getty imports Co-authored-by: dongjianhui03 --- config/testdata/consumer_config.yml | 1 - config/testdata/consumer_config_with_configcenter.yml | 1 - config/testdata/consumer_config_withoutProtocol.yml | 1 - config/testdata/provider_config.yml | 1 - config/testdata/provider_config_withoutProtocol.yml | 1 - config_center/apollo/impl_test.go | 1 - go.mod | 2 +- go.sum | 9 ++++----- .../service/exporter/configurable/exporter_test.go | 1 - protocol/dubbo/dubbo_invoker_test.go | 2 -- protocol/dubbo/dubbo_protocol_test.go | 2 -- registry/etcdv3/listener.go | 1 + registry/etcdv3/listener_test.go | 6 ++++-- registry/etcdv3/registry.go | 1 + registry/etcdv3/service_discovery.go | 2 ++ registry/kubernetes/listener.go | 1 + registry/kubernetes/registry.go | 6 ++++-- registry/kubernetes/registry_test.go | 1 + remoting/getty/config.go | 3 --- remoting/getty/dubbo_codec_for_test.go | 1 + remoting/getty/getty_client.go | 7 ++++++- remoting/getty/getty_client_test.go | 4 ++-- remoting/getty/getty_server.go | 3 +++ remoting/getty/listener.go | 6 +++++- remoting/getty/listener_test.go | 1 + remoting/getty/pool.go | 1 + remoting/getty/readwriter.go | 10 ++-------- remoting/getty/readwriter_test.go | 3 +-- test/integrate/dubbo/go-client/client.yml | 2 -- test/integrate/dubbo/go-server/server.yml | 2 -- 30 files changed, 41 insertions(+), 42 deletions(-) diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 2034186c0f..c011c9e40b 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -87,7 +87,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/consumer_config_with_configcenter.yml b/config/testdata/consumer_config_with_configcenter.yml index 89869dcff5..fe979dacd4 100644 --- a/config/testdata/consumer_config_with_configcenter.yml +++ b/config/testdata/consumer_config_with_configcenter.yml @@ -36,7 +36,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/consumer_config_withoutProtocol.yml b/config/testdata/consumer_config_withoutProtocol.yml index f3d9265442..6028a48db4 100644 --- a/config/testdata/consumer_config_withoutProtocol.yml +++ b/config/testdata/consumer_config_withoutProtocol.yml @@ -73,7 +73,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/provider_config.yml b/config/testdata/provider_config.yml index de22b79d72..3c081c0168 100644 --- a/config/testdata/provider_config.yml +++ b/config/testdata/provider_config.yml @@ -92,7 +92,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/provider_config_withoutProtocol.yml b/config/testdata/provider_config_withoutProtocol.yml index 3fa8100d84..651c2f4c6a 100644 --- a/config/testdata/provider_config_withoutProtocol.yml +++ b/config/testdata/provider_config_withoutProtocol.yml @@ -72,7 +72,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 3392868223..43c6abaf17 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -110,7 +110,6 @@ var mockConfigRes = `{ "application.environment": "dev", "services.UserProvider.protocol": "dubbo", "application.organization": "ikurento.com", - "protocol_conf.dubbo.getty_session_param.pkg_wq_size": "512", "services.UserProvider.methods[0].loadbalance": "random" }, "releaseKey": "20191104105242-0f13805d89f834a4" diff --git a/go.mod b/go.mod index 7bfbb6f5c6..449adaedc8 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alibaba/sentinel-golang v1.0.2 - github.com/apache/dubbo-getty v1.4.3 + github.com/apache/dubbo-getty v1.4.5 github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 diff --git a/go.sum b/go.sum index e511abf4e2..333e8b82ca 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTk github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 h1:zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA= github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= +github.com/apache/dubbo-getty v1.4.5 h1:MptKbjC0n2Mo/8eFPwirSInH2BfdNG4IZch43PdNvIM= +github.com/apache/dubbo-getty v1.4.5/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= @@ -148,7 +148,7 @@ github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= 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.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.14 h1:9lfcdILOmqTOVAW1fPHa5uf1NrD6jlIOBe4vf8576yQ= github.com/dubbogo/gost v1.11.14/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -467,6 +467,7 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= @@ -595,7 +596,6 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -647,7 +647,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 3ae67500ff..34dc20d969 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -46,7 +46,6 @@ func TestConfigurableExporter(t *testing.T) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 901547f91f..97a7cdaa9d 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -112,7 +112,6 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -130,7 +129,6 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 72f5b11682..30e985e9a0 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -52,7 +52,6 @@ func initDubboInvokerTest() { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -71,7 +70,6 @@ func initDubboInvokerTest() { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go index bc290aecca..92e55aa093 100644 --- a/registry/etcdv3/listener.go +++ b/registry/etcdv3/listener.go @@ -24,6 +24,7 @@ import ( import ( gxchan "github.com/dubbogo/gost/container/chan" + perrors "github.com/pkg/errors" ) diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index d9853b5c4f..97f95e0f47 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -24,8 +24,10 @@ import ( ) import ( - getty "github.com/apache/dubbo-getty" + gxtime "github.com/dubbogo/gost/time" + "github.com/stretchr/testify/suite" + "go.etcd.io/etcd/server/v3/embed" ) @@ -57,7 +59,7 @@ func (suite *RegistryTestSuite) SetupSuite() { select { case <-e.Server.ReadyNotify(): t.Log("Server is ready!") - case <-getty.GetTimeWheel().After(60 * time.Second): + case <-gxtime.After(60 * time.Second): e.Server.Stop() // trigger a shutdown t.Logf("Server took too long to start!") } diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index b6e4a15252..3ab9a2e86a 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -27,6 +27,7 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + perrors "github.com/pkg/errors" ) diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index c90633d165..85679f25cd 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -28,7 +28,9 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/hashicorp/vault/sdk/helper/jsonutil" + perrors "github.com/pkg/errors" ) diff --git a/registry/kubernetes/listener.go b/registry/kubernetes/listener.go index c02c07a84b..7605235686 100644 --- a/registry/kubernetes/listener.go +++ b/registry/kubernetes/listener.go @@ -23,6 +23,7 @@ import ( import ( gxchan "github.com/dubbogo/gost/container/chan" + perrors "github.com/pkg/errors" ) diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go index 239644e327..b6e110780c 100644 --- a/registry/kubernetes/registry.go +++ b/registry/kubernetes/registry.go @@ -25,8 +25,10 @@ import ( ) import ( - getty "github.com/apache/dubbo-getty" + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" ) @@ -210,7 +212,7 @@ LOOP: // try to connect to kubernetes, failTimes = 0 for { - after := getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)) + after := gxtime.After(timeSecondDuration(failTimes * ConnDelay)) select { case <-r.Done(): logger.Warnf("(KubernetesProviderRegistry)reconnectKubernetes Registry goroutine exit now...") diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go index 4ebb625e01..f217048cf4 100644 --- a/registry/kubernetes/registry_test.go +++ b/registry/kubernetes/registry_test.go @@ -28,6 +28,7 @@ import ( import ( "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" ) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index bd56291b38..05713c7a7c 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -39,7 +39,6 @@ type ( keepAlivePeriod time.Duration TcpRBufSize int `default:"262144" yaml:"tcp_r_buf_size" json:"tcp_r_buf_size,omitempty"` TcpWBufSize int `default:"65536" yaml:"tcp_w_buf_size" json:"tcp_w_buf_size,omitempty"` - PkgWQSize int `default:"1024" yaml:"pkg_wq_size" json:"pkg_wq_size,omitempty"` TcpReadTimeout string `default:"1s" yaml:"tcp_read_timeout" json:"tcp_read_timeout,omitempty"` tcpReadTimeout time.Duration TcpWriteTimeout string `default:"5s" yaml:"tcp_write_timeout" json:"tcp_write_timeout,omitempty"` @@ -122,7 +121,6 @@ func GetDefaultClientConfig() ClientConfig { KeepAlivePeriod: "180s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -147,7 +145,6 @@ func GetDefaultServerConfig() ServerConfig { KeepAlivePeriod: "180s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go index 572908b437..b7bd064f68 100644 --- a/remoting/getty/dubbo_codec_for_test.go +++ b/remoting/getty/dubbo_codec_for_test.go @@ -26,6 +26,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index cbe8245eb3..c1d09d563a 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -25,9 +25,14 @@ import ( import ( "github.com/apache/dubbo-getty" + gxsync "github.com/dubbogo/gost/sync" + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" + "gopkg.in/yaml.v2" ) @@ -201,7 +206,7 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo } select { - case <-getty.GetTimeWheel().After(timeout): + case <-gxtime.After(timeout): return perrors.WithStack(errClientReadTimeout) case <-response.Done: err = response.Err diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index a5b26ba3af..275649e6d9 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -28,7 +28,9 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) @@ -343,7 +345,6 @@ func InitTest(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -362,7 +363,6 @@ func InitTest(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index 9be3e055ad..ca6bd8a072 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -25,8 +25,11 @@ import ( import ( "github.com/apache/dubbo-getty" + gxsync "github.com/dubbogo/gost/sync" + perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go index 68275bb649..622d5575c2 100644 --- a/remoting/getty/listener.go +++ b/remoting/getty/listener.go @@ -26,7 +26,11 @@ import ( import ( "github.com/apache/dubbo-getty" + hessian "github.com/apache/dubbo-go-hessian2" + + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" ) @@ -378,7 +382,7 @@ func heartbeat(session getty.Session, timeout time.Duration, callBack func(err e go func() { var err1 error select { - case <-getty.GetTimeWheel().After(timeout): + case <-gxtime.After(timeout): err1 = errHeartbeatReadTimeout case <-resp.Done: err1 = resp.Err diff --git a/remoting/getty/listener_test.go b/remoting/getty/listener_test.go index 407255e4b4..6d22e37dd0 100644 --- a/remoting/getty/listener_test.go +++ b/remoting/getty/listener_test.go @@ -25,6 +25,7 @@ import ( import ( "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" + "github.com/stretchr/testify/assert" ) diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go index 7fc9eb813a..8b091a48bb 100644 --- a/remoting/getty/pool.go +++ b/remoting/getty/pool.go @@ -29,6 +29,7 @@ import ( import ( "github.com/apache/dubbo-getty" + perrors "github.com/pkg/errors" ) diff --git a/remoting/getty/readwriter.go b/remoting/getty/readwriter.go index 9ba96b283f..c78f354d65 100644 --- a/remoting/getty/readwriter.go +++ b/remoting/getty/readwriter.go @@ -24,7 +24,9 @@ import ( import ( "github.com/apache/dubbo-getty" + hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) @@ -87,14 +89,6 @@ func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) ([]by return nil, perrors.New("invalid rpc request") } -//////////////////////////////////////////// -// RpcServerPackageHandler -//////////////////////////////////////////// - -//var ( -// rpcServerPkgHandler = &RpcServerPackageHandler{} -//) - // RpcServerPackageHandler Read data from client and Write data to client type RpcServerPackageHandler struct { server *Server diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go index b1687e81ce..e9be67dca1 100644 --- a/remoting/getty/readwriter_test.go +++ b/remoting/getty/readwriter_test.go @@ -25,6 +25,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) @@ -98,7 +99,6 @@ func getServer(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -117,7 +117,6 @@ func getServer(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/test/integrate/dubbo/go-client/client.yml b/test/integrate/dubbo/go-client/client.yml index 93625d8020..8f17b6b88f 100644 --- a/test/integrate/dubbo/go-client/client.yml +++ b/test/integrate/dubbo/go-client/client.yml @@ -52,8 +52,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/test/integrate/dubbo/go-server/server.yml b/test/integrate/dubbo/go-server/server.yml index ff57a7d602..aa519ccb05 100644 --- a/test/integrate/dubbo/go-server/server.yml +++ b/test/integrate/dubbo/go-server/server.yml @@ -48,8 +48,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" From f192c1eaf847fdd38f3cda3d73dea6b02d0654b5 Mon Sep 17 00:00:00 2001 From: gaoxinge Date: Sat, 14 Aug 2021 17:53:55 +0800 Subject: [PATCH 048/148] support multi pb (#1361) --- protocol/grpc/internal/README.md | 1 + .../grpc/internal/helloworld/helloworld.pb.go | 19 +- protocol/grpc/internal/multiprotos/Makefile | 19 + .../grpc/internal/multiprotos/first.pb.go | 307 +++++++++ .../grpc/internal/multiprotos/first.proto | 32 + .../grpc/internal/multiprotos/second.pb.go | 589 ++++++++++++++++++ .../grpc/internal/multiprotos/second.proto | 35 ++ .../grpc/internal/routeguide/routeguide.pb.go | 46 +- .../protoc-gen-dubbo/plugin/dubbo/dubbo.go | 34 +- 9 files changed, 1046 insertions(+), 36 deletions(-) create mode 100644 protocol/grpc/internal/multiprotos/Makefile create mode 100644 protocol/grpc/internal/multiprotos/first.pb.go create mode 100644 protocol/grpc/internal/multiprotos/first.proto create mode 100644 protocol/grpc/internal/multiprotos/second.pb.go create mode 100644 protocol/grpc/internal/multiprotos/second.proto diff --git a/protocol/grpc/internal/README.md b/protocol/grpc/internal/README.md index 5dbf318013..746501308f 100644 --- a/protocol/grpc/internal/README.md +++ b/protocol/grpc/internal/README.md @@ -11,3 +11,4 @@ This internal package is for test. So don't use internal in production. - [helloworld](./helloworld): test unary process - [routeguide](./routeguide): test stream process +- [multiprotos](./multiprotos): use multi pb to generate multi pb.go diff --git a/protocol/grpc/internal/helloworld/helloworld.pb.go b/protocol/grpc/internal/helloworld/helloworld.pb.go index d59f28caf3..9a3ee69b44 100644 --- a/protocol/grpc/internal/helloworld/helloworld.pb.go +++ b/protocol/grpc/internal/helloworld/helloworld.pb.go @@ -250,16 +250,6 @@ func (c *GreeterClientImpl) GetDubboStub(cc *grpc.ClientConn) GreeterClient { return NewGreeterClient(cc) } -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} - type GreeterProviderBase struct { proxyImpl protocol.Invoker } @@ -281,6 +271,15 @@ func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec f if err := dec(in); err != nil { return nil, err } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } base := srv.(DubboGrpcService) args := []interface{}{} args = append(args, in) diff --git a/protocol/grpc/internal/multiprotos/Makefile b/protocol/grpc/internal/multiprotos/Makefile new file mode 100644 index 0000000000..31ce7446a0 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/Makefile @@ -0,0 +1,19 @@ +# 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. + +grpc-gen: + protoc -I ./ first.proto second.proto --go_out=plugins=grpc:. +dubbo-gen: + protoc -I ./ first.proto second.proto --dubbo_out=plugins=grpc+dubbo:. diff --git a/protocol/grpc/internal/multiprotos/first.pb.go b/protocol/grpc/internal/multiprotos/first.pb.go new file mode 100644 index 0000000000..8bd58131a6 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/first.pb.go @@ -0,0 +1,307 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: first.proto + +package multiprotos + +import ( + context "context" + fmt "fmt" + math "math" +) + +import ( + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type FirstRequest struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FirstRequest) Reset() { *m = FirstRequest{} } +func (m *FirstRequest) String() string { return proto.CompactTextString(m) } +func (*FirstRequest) ProtoMessage() {} +func (*FirstRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_55120e8023d656fd, []int{0} +} + +func (m *FirstRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FirstRequest.Unmarshal(m, b) +} +func (m *FirstRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FirstRequest.Marshal(b, m, deterministic) +} +func (m *FirstRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FirstRequest.Merge(m, src) +} +func (m *FirstRequest) XXX_Size() int { + return xxx_messageInfo_FirstRequest.Size(m) +} +func (m *FirstRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FirstRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FirstRequest proto.InternalMessageInfo + +func (m *FirstRequest) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type FirstResponse struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FirstResponse) Reset() { *m = FirstResponse{} } +func (m *FirstResponse) String() string { return proto.CompactTextString(m) } +func (*FirstResponse) ProtoMessage() {} +func (*FirstResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_55120e8023d656fd, []int{1} +} + +func (m *FirstResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FirstResponse.Unmarshal(m, b) +} +func (m *FirstResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FirstResponse.Marshal(b, m, deterministic) +} +func (m *FirstResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FirstResponse.Merge(m, src) +} +func (m *FirstResponse) XXX_Size() int { + return xxx_messageInfo_FirstResponse.Size(m) +} +func (m *FirstResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FirstResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_FirstResponse proto.InternalMessageInfo + +func (m *FirstResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func init() { + proto.RegisterType((*FirstRequest)(nil), "multiprotos.FirstRequest") + proto.RegisterType((*FirstResponse)(nil), "multiprotos.FirstResponse") +} + +func init() { proto.RegisterFile("first.proto", fileDescriptor_55120e8023d656fd) } + +var fileDescriptor_55120e8023d656fd = []byte{ + // 137 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4e, 0xcb, 0x2c, 0x2a, + 0x2e, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2d, 0xcd, 0x29, 0xc9, 0x04, 0xb3, + 0x8b, 0x95, 0x34, 0xb8, 0x78, 0xdc, 0x40, 0x72, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, + 0x12, 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, + 0x41, 0x30, 0xae, 0x92, 0x26, 0x17, 0x2f, 0x54, 0x65, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0x6e, + 0xa5, 0x46, 0x41, 0x5c, 0x3c, 0x6e, 0x45, 0x99, 0xc5, 0x25, 0xc1, 0xa9, 0x45, 0x65, 0x99, 0xc9, + 0xa9, 0x42, 0x4e, 0x5c, 0xec, 0x30, 0xa6, 0xa4, 0x1e, 0x92, 0xed, 0x7a, 0xc8, 0x56, 0x4b, 0x49, + 0x61, 0x93, 0x82, 0xd8, 0xa5, 0xc4, 0x90, 0xc4, 0x06, 0x16, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x83, 0xb7, 0xe6, 0xc5, 0xcb, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// FristServiceClient is the client API for FristService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type FristServiceClient interface { + Service(ctx context.Context, in *FirstRequest, opts ...grpc.CallOption) (*FirstResponse, error) +} + +type fristServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewFristServiceClient(cc grpc.ClientConnInterface) FristServiceClient { + return &fristServiceClient{cc} +} + +func (c *fristServiceClient) Service(ctx context.Context, in *FirstRequest, opts ...grpc.CallOption) (*FirstResponse, error) { + out := new(FirstResponse) + err := c.cc.Invoke(ctx, "/multiprotos.FristService/Service", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FristServiceServer is the server API for FristService service. +type FristServiceServer interface { + Service(context.Context, *FirstRequest) (*FirstResponse, error) +} + +// UnimplementedFristServiceServer can be embedded to have forward compatible implementations. +type UnimplementedFristServiceServer struct { +} + +func (*UnimplementedFristServiceServer) Service(ctx context.Context, req *FirstRequest) (*FirstResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Service not implemented") +} + +func RegisterFristServiceServer(s *grpc.Server, srv FristServiceServer) { + s.RegisterService(&_FristService_serviceDesc, srv) +} + +func _FristService_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FirstRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FristServiceServer).Service(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.FristService/Service", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FristServiceServer).Service(ctx, req.(*FirstRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _FristService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "multiprotos.FristService", + HandlerType: (*FristServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service", + Handler: _FristService_Service_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "first.proto", +} + +// FristServiceClientImpl is the client API for FristService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type FristServiceClientImpl struct { + Service func(ctx context.Context, in *FirstRequest, out *FirstResponse) error +} + +func (c *FristServiceClientImpl) Reference() string { + return "fristServiceImpl" +} + +func (c *FristServiceClientImpl) GetDubboStub(cc *grpc.ClientConn) FristServiceClient { + return NewFristServiceClient(cc) +} + +type FristServiceProviderBase struct { + proxyImpl protocol.Invoker +} + +func (s *FristServiceProviderBase) SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *FristServiceProviderBase) GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (c *FristServiceProviderBase) Reference() string { + return "fristServiceImpl" +} + +func _DUBBO_FristService_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FirstRequest) + if err := dec(in); err != nil { + return nil, err + } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + base := srv.(DubboGrpcService) + args := []interface{}{} + args = append(args, in) + invo := invocation.NewRPCInvocation("Service", args, nil) + if interceptor == nil { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.FristService/Service", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func (s *FristServiceProviderBase) ServiceDesc() *grpc.ServiceDesc { + return &grpc.ServiceDesc{ + ServiceName: "multiprotos.FristService", + HandlerType: (*FristServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service", + Handler: _DUBBO_FristService_Service_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "first.proto", + } +} diff --git a/protocol/grpc/internal/multiprotos/first.proto b/protocol/grpc/internal/multiprotos/first.proto new file mode 100644 index 0000000000..497cc11fa7 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/first.proto @@ -0,0 +1,32 @@ +/* + * 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. + */ + +syntax = "proto3"; + +package multiprotos; + +message FirstRequest { + string message = 1; +} + +message FirstResponse { + string message = 1; +} + +service FristService { + rpc Service (FirstRequest) returns (FirstResponse) {} +} diff --git a/protocol/grpc/internal/multiprotos/second.pb.go b/protocol/grpc/internal/multiprotos/second.pb.go new file mode 100644 index 0000000000..9cfc5ae130 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/second.pb.go @@ -0,0 +1,589 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: second.proto + +package multiprotos + +import ( + context "context" + fmt "fmt" + math "math" +) + +import ( + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type SecondRequest struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SecondRequest) Reset() { *m = SecondRequest{} } +func (m *SecondRequest) String() string { return proto.CompactTextString(m) } +func (*SecondRequest) ProtoMessage() {} +func (*SecondRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_83c4a0a7b0d4882f, []int{0} +} + +func (m *SecondRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SecondRequest.Unmarshal(m, b) +} +func (m *SecondRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SecondRequest.Marshal(b, m, deterministic) +} +func (m *SecondRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SecondRequest.Merge(m, src) +} +func (m *SecondRequest) XXX_Size() int { + return xxx_messageInfo_SecondRequest.Size(m) +} +func (m *SecondRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SecondRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SecondRequest proto.InternalMessageInfo + +func (m *SecondRequest) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type SecondResponse struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SecondResponse) Reset() { *m = SecondResponse{} } +func (m *SecondResponse) String() string { return proto.CompactTextString(m) } +func (*SecondResponse) ProtoMessage() {} +func (*SecondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_83c4a0a7b0d4882f, []int{1} +} + +func (m *SecondResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SecondResponse.Unmarshal(m, b) +} +func (m *SecondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SecondResponse.Marshal(b, m, deterministic) +} +func (m *SecondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SecondResponse.Merge(m, src) +} +func (m *SecondResponse) XXX_Size() int { + return xxx_messageInfo_SecondResponse.Size(m) +} +func (m *SecondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SecondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SecondResponse proto.InternalMessageInfo + +func (m *SecondResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func init() { + proto.RegisterType((*SecondRequest)(nil), "multiprotos.SecondRequest") + proto.RegisterType((*SecondResponse)(nil), "multiprotos.SecondResponse") +} + +func init() { proto.RegisterFile("second.proto", fileDescriptor_83c4a0a7b0d4882f) } + +var fileDescriptor_83c4a0a7b0d4882f = []byte{ + // 163 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x4e, 0x4d, 0xce, + 0xcf, 0x4b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2d, 0xcd, 0x29, 0xc9, 0x04, + 0xb3, 0x8b, 0x95, 0x34, 0xb9, 0x78, 0x83, 0xc1, 0x92, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, + 0x42, 0x12, 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, + 0x9c, 0x41, 0x30, 0xae, 0x92, 0x16, 0x17, 0x1f, 0x4c, 0x69, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, + 0x6e, 0xb5, 0x46, 0x9b, 0x99, 0x60, 0xe6, 0x06, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x0a, 0xb9, + 0x72, 0x71, 0x40, 0x99, 0x86, 0x42, 0x52, 0x7a, 0x48, 0x4e, 0xd0, 0x43, 0xb1, 0x5f, 0x4a, 0x1a, + 0xab, 0x1c, 0xc4, 0x42, 0x25, 0x06, 0x21, 0x77, 0xb8, 0x31, 0x46, 0x14, 0x18, 0x63, 0xc0, 0x88, + 0x64, 0x90, 0x31, 0x05, 0x06, 0x69, 0x30, 0x0a, 0x79, 0xc2, 0x0d, 0x32, 0xa1, 0xc8, 0x20, 0x03, + 0xc6, 0x24, 0x36, 0xb0, 0xa4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xba, 0xd2, 0x28, 0xb0, + 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// SecondServiceClient is the client API for SecondService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SecondServiceClient interface { + Service1(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (*SecondResponse, error) + Service2(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (SecondService_Service2Client, error) + Service3(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service3Client, error) + Service4(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service4Client, error) +} + +type secondServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSecondServiceClient(cc grpc.ClientConnInterface) SecondServiceClient { + return &secondServiceClient{cc} +} + +func (c *secondServiceClient) Service1(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (*SecondResponse, error) { + out := new(SecondResponse) + err := c.cc.Invoke(ctx, "/multiprotos.SecondService/Service1", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *secondServiceClient) Service2(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (SecondService_Service2Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[0], "/multiprotos.SecondService/Service2", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService2Client{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type SecondService_Service2Client interface { + Recv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService2Client struct { + grpc.ClientStream +} + +func (x *secondServiceService2Client) Recv() (*SecondResponse, error) { + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *secondServiceClient) Service3(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service3Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[1], "/multiprotos.SecondService/Service3", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService3Client{stream} + return x, nil +} + +type SecondService_Service3Client interface { + Send(*SecondRequest) error + CloseAndRecv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService3Client struct { + grpc.ClientStream +} + +func (x *secondServiceService3Client) Send(m *SecondRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *secondServiceService3Client) CloseAndRecv() (*SecondResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *secondServiceClient) Service4(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service4Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[2], "/multiprotos.SecondService/Service4", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService4Client{stream} + return x, nil +} + +type SecondService_Service4Client interface { + Send(*SecondRequest) error + Recv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService4Client struct { + grpc.ClientStream +} + +func (x *secondServiceService4Client) Send(m *SecondRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *secondServiceService4Client) Recv() (*SecondResponse, error) { + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// SecondServiceServer is the server API for SecondService service. +type SecondServiceServer interface { + Service1(context.Context, *SecondRequest) (*SecondResponse, error) + Service2(*SecondRequest, SecondService_Service2Server) error + Service3(SecondService_Service3Server) error + Service4(SecondService_Service4Server) error +} + +// UnimplementedSecondServiceServer can be embedded to have forward compatible implementations. +type UnimplementedSecondServiceServer struct { +} + +func (*UnimplementedSecondServiceServer) Service1(ctx context.Context, req *SecondRequest) (*SecondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Service1 not implemented") +} +func (*UnimplementedSecondServiceServer) Service2(req *SecondRequest, srv SecondService_Service2Server) error { + return status.Errorf(codes.Unimplemented, "method Service2 not implemented") +} +func (*UnimplementedSecondServiceServer) Service3(srv SecondService_Service3Server) error { + return status.Errorf(codes.Unimplemented, "method Service3 not implemented") +} +func (*UnimplementedSecondServiceServer) Service4(srv SecondService_Service4Server) error { + return status.Errorf(codes.Unimplemented, "method Service4 not implemented") +} + +func RegisterSecondServiceServer(s *grpc.Server, srv SecondServiceServer) { + s.RegisterService(&_SecondService_serviceDesc, srv) +} + +func _SecondService_Service1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SecondRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SecondServiceServer).Service1(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.SecondService/Service1", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SecondServiceServer).Service1(ctx, req.(*SecondRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SecondService_Service2_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(SecondRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SecondServiceServer).Service2(m, &secondServiceService2Server{stream}) +} + +type SecondService_Service2Server interface { + Send(*SecondResponse) error + grpc.ServerStream +} + +type secondServiceService2Server struct { + grpc.ServerStream +} + +func (x *secondServiceService2Server) Send(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _SecondService_Service3_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SecondServiceServer).Service3(&secondServiceService3Server{stream}) +} + +type SecondService_Service3Server interface { + SendAndClose(*SecondResponse) error + Recv() (*SecondRequest, error) + grpc.ServerStream +} + +type secondServiceService3Server struct { + grpc.ServerStream +} + +func (x *secondServiceService3Server) SendAndClose(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *secondServiceService3Server) Recv() (*SecondRequest, error) { + m := new(SecondRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _SecondService_Service4_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SecondServiceServer).Service4(&secondServiceService4Server{stream}) +} + +type SecondService_Service4Server interface { + Send(*SecondResponse) error + Recv() (*SecondRequest, error) + grpc.ServerStream +} + +type secondServiceService4Server struct { + grpc.ServerStream +} + +func (x *secondServiceService4Server) Send(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *secondServiceService4Server) Recv() (*SecondRequest, error) { + m := new(SecondRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _SecondService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "multiprotos.SecondService", + HandlerType: (*SecondServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service1", + Handler: _SecondService_Service1_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Service2", + Handler: _SecondService_Service2_Handler, + ServerStreams: true, + }, + { + StreamName: "Service3", + Handler: _SecondService_Service3_Handler, + ClientStreams: true, + }, + { + StreamName: "Service4", + Handler: _SecondService_Service4_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "second.proto", +} + +// SecondServiceClientImpl is the client API for SecondService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SecondServiceClientImpl struct { + Service1 func(ctx context.Context, in *SecondRequest, out *SecondResponse) error + Service2 func(ctx context.Context, in *SecondRequest) (SecondService_Service2Client, error) + Service3 func(ctx context.Context) (SecondService_Service3Client, error) + Service4 func(ctx context.Context) (SecondService_Service4Client, error) +} + +func (c *SecondServiceClientImpl) Reference() string { + return "secondServiceImpl" +} + +func (c *SecondServiceClientImpl) GetDubboStub(cc *grpc.ClientConn) SecondServiceClient { + return NewSecondServiceClient(cc) +} + +type SecondServiceProviderBase struct { + proxyImpl protocol.Invoker +} + +func (s *SecondServiceProviderBase) SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *SecondServiceProviderBase) GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (c *SecondServiceProviderBase) Reference() string { + return "secondServiceImpl" +} + +func _DUBBO_SecondService_Service1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SecondRequest) + if err := dec(in); err != nil { + return nil, err + } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + base := srv.(DubboGrpcService) + args := []interface{}{} + args = append(args, in) + invo := invocation.NewRPCInvocation("Service1", args, nil) + if interceptor == nil { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.SecondService/Service1", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func _DUBBO_SecondService_Service2_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service2", nil, nil) + if !ok { + fmt.Println(invo) + } + m := new(SecondRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SecondServiceServer).Service2(m, &secondServiceService2Server{stream}) +} + +func _DUBBO_SecondService_Service3_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service3", nil, nil) + if !ok { + fmt.Println(invo) + } + return srv.(SecondServiceServer).Service3(&secondServiceService3Server{stream}) +} + +func _DUBBO_SecondService_Service4_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service4", nil, nil) + if !ok { + fmt.Println(invo) + } + return srv.(SecondServiceServer).Service4(&secondServiceService4Server{stream}) +} + +func (s *SecondServiceProviderBase) ServiceDesc() *grpc.ServiceDesc { + return &grpc.ServiceDesc{ + ServiceName: "multiprotos.SecondService", + HandlerType: (*SecondServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service1", + Handler: _DUBBO_SecondService_Service1_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Service2", + Handler: _DUBBO_SecondService_Service2_Handler, + ServerStreams: true, + }, + { + StreamName: "Service3", + Handler: _DUBBO_SecondService_Service3_Handler, + ClientStreams: true, + }, + { + StreamName: "Service4", + Handler: _DUBBO_SecondService_Service4_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "second.proto", + } +} diff --git a/protocol/grpc/internal/multiprotos/second.proto b/protocol/grpc/internal/multiprotos/second.proto new file mode 100644 index 0000000000..9ce1681d30 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/second.proto @@ -0,0 +1,35 @@ +/* + * 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. + */ + +syntax = "proto3"; + +package multiprotos; + +message SecondRequest { + string message = 1; +} + +message SecondResponse { + string message = 1; +} + +service SecondService { + rpc Service1 (SecondRequest) returns (SecondResponse) {} + rpc Service2 (SecondRequest) returns (stream SecondResponse) {} + rpc Service3 (stream SecondRequest) returns (SecondResponse) {} + rpc Service4 (stream SecondRequest) returns (stream SecondResponse) {} +} diff --git a/protocol/grpc/internal/routeguide/routeguide.pb.go b/protocol/grpc/internal/routeguide/routeguide.pb.go index 4a6f9dcd87..2aa95330d8 100644 --- a/protocol/grpc/internal/routeguide/routeguide.pb.go +++ b/protocol/grpc/internal/routeguide/routeguide.pb.go @@ -725,16 +725,6 @@ func (c *RouteGuideClientImpl) GetDubboStub(cc *grpc.ClientConn) RouteGuideClien return NewRouteGuideClient(cc) } -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} - type RouteGuideProviderBase struct { proxyImpl protocol.Invoker } @@ -756,6 +746,15 @@ func _DUBBO_RouteGuide_GetFeature_Handler(srv interface{}, ctx context.Context, if err := dec(in); err != nil { return nil, err } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } base := srv.(DubboGrpcService) args := []interface{}{} args = append(args, in) @@ -776,6 +775,15 @@ func _DUBBO_RouteGuide_GetFeature_Handler(srv interface{}, ctx context.Context, } func _DUBBO_RouteGuide_ListFeatures_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("ListFeatures", nil, nil) if !ok { @@ -789,6 +797,15 @@ func _DUBBO_RouteGuide_ListFeatures_Handler(srv interface{}, stream grpc.ServerS } func _DUBBO_RouteGuide_RecordRoute_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("RecordRoute", nil, nil) if !ok { @@ -798,6 +815,15 @@ func _DUBBO_RouteGuide_RecordRoute_Handler(srv interface{}, stream grpc.ServerSt } func _DUBBO_RouteGuide_RouteChat_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("RouteChat", nil, nil) if !ok { diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go index 1a92ab1f7e..b3c5db2b09 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go +++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go @@ -165,18 +165,6 @@ func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb. g.P("}") g.P() - g.P(` -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} -`) - // Server interface. serverType := servName + "ProviderBase" g.P("type ", serverType, " struct {") @@ -271,9 +259,6 @@ func (g *dubboGrpc) generateClientSignature(servName string, method *pb.MethodDe return fmt.Sprintf("%s func(ctx %s.Context%s, %s) error", methName, contextPkg, reqArg, respName) } -//func (g *dubboGrpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { -//} - func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method *pb.MethodDescriptorProto) string { methName := generator.CamelCase(method.GetName()) hname := fmt.Sprintf("_DUBBO_%s_%s_Handler", servName, methName) @@ -283,7 +268,15 @@ func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method * g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, interceptor ", grpcPkg, ".UnaryServerInterceptor) (interface{}, error) {") g.P("in := new(", inType, ")") g.P("if err := dec(in); err != nil { return nil, err }") - + g.P(`// DubboGrpcService is gRPC service +type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc +}`) g.P("base := srv.(DubboGrpcService)") g.P("args := []interface{}{}") g.P("args = append(args, in)") @@ -311,6 +304,15 @@ func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method * } streamType := unexport(servName) + methName + "Server" g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") + g.P(`// DubboGrpcService is gRPC service +type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc +}`) g.P("_, ok := srv.(DubboGrpcService)") g.P(`invo := invocation.NewRPCInvocation("`, methName, `", nil, nil)`) g.P("if !ok {") From 9844b0b0596d55f000d513935d86e522af0c40c5 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 14 Aug 2021 18:26:00 +0800 Subject: [PATCH 049/148] fix: metadata report config --- common/constant/default.go | 1 + common/constant/env.go | 12 +- common/constant/key.go | 28 +-- common/extension/service_discovery.go | 4 +- config/application_config.go | 2 +- config/config_loader.go | 177 ++++++++--------- config/config_loader_options.go | 8 +- config/consumer_config.go | 32 ++- config/metadata_report_config.go | 111 ++++++----- config/method_config.go | 14 +- config/protocol_config.go | 45 ++++- config/provider_config.go | 26 +-- config/reference_config.go | 54 ++--- config/registry_config.go | 14 +- config/root_config.go | 10 +- config/service_config.go | 188 +++++++++++------- .../service/exporter/configurable/exporter.go | 56 +++--- registry/nacos/service_discovery.go | 35 ++-- .../service_discovery_registry.go | 14 +- registry/zookeeper/service_discovery.go | 26 +-- remoting/getty/getty_client.go | 7 +- remoting/getty/getty_server.go | 9 +- 22 files changed, 448 insertions(+), 425 deletions(-) diff --git a/common/constant/default.go b/common/constant/default.go index 037abeab58..6e2bf841d5 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -45,6 +45,7 @@ const ( DEFAULT_REST_CLIENT = "resty" DEFAULT_REST_SERVER = "go-restful" DEFAULT_PORT = 20000 + DEFAULT_METADATAPORT = 20005 DEFAULT_SERIALIZATION = HESSIAN2_SERIALIZATION ) diff --git a/common/constant/env.go b/common/constant/env.go index 0d7183af65..c2fb18b464 100644 --- a/common/constant/env.go +++ b/common/constant/env.go @@ -19,16 +19,8 @@ package constant // nolint const ( - // CONF_CONSUMER_FILE_PATH ... - CONF_CONSUMER_FILE_PATH = "CONF_CONSUMER_FILE_PATH" - // CONF_PROVIDER_FILE_PATH ... - CONF_PROVIDER_FILE_PATH = "CONF_PROVIDER_FILE_PATH" + // CONFIG_FILE_ENV_KEY is key of environment variable dubbogo configure file path + CONFIG_FILE_ENV_KEY = "DUBBO_GO_CONFIG_PATH" // APP_LOG_CONF_FILE ... APP_LOG_CONF_FILE = "APP_LOG_CONF_FILE" - // CONF_ROUTER_FILE_PATH Specify Path variable of router config file - CONF_ROUTER_FILE_PATH = "CONF_ROUTER_FILE_PATH" - // CONF_VIRTUAL_SERVICE_FILE_PATH Specify path to Virtual service of uniform router config file - CONF_VIRTUAL_SERVICE_FILE_PATH = "CONF_VIRTUAL_SERVICE_FILE_PATH" - // CONF_DEST_RULE_FILE_PATH Specify path to destination rule of uniform router config file - CONF_DEST_RULE_FILE_PATH = "CONF_DEST_RULE_FILE_PATH" ) diff --git a/common/constant/key.go b/common/constant/key.go index b1ec48ec73..de13fa4d78 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -52,8 +52,9 @@ const ( // DUBBO_KEY = "dubbo" SSL_ENABLED_KEY = "ssl-enabled" // PARAMS_TYPE_Key key used in pass through invoker factory, to define param type - PARAMS_TYPE_Key = "parameter-type-names" - DEFAULT_Key = "default" + PARAMS_TYPE_Key = "parameter-type-names" + DEFAULT_Key = "default" + METADATATYPE_KEY = "metadata-type" ) const ( @@ -122,16 +123,19 @@ const ( ) const ( - REGISTRY_KEY = "registry" - REGISTRY_PROTOCOL = "registry" - ROLE_KEY = "registry.role" - REGISTRY_DEFAULT_KEY = "registry.default" - REGISTRY_TIMEOUT_KEY = "registry.timeout" - REGISTRY_LABEL_KEY = "label" - PREFERRED_KEY = "preferred" - ZONE_KEY = "zone" - ZONE_FORCE_KEY = "zone.force" - REGISTRY_TTL_KEY = "registry.ttl" + REGISTRY_KEY = "registry" + REGISTRY_PROTOCOL = "registry" + SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry" + ROLE_KEY = "registry.role" + REGISTRY_DEFAULT_KEY = "registry.default" + REGISTRY_TIMEOUT_KEY = "registry.timeout" + REGISTRY_LABEL_KEY = "label" + PREFERRED_KEY = "preferred" + ZONE_KEY = "zone" + ZONE_FORCE_KEY = "zone.force" + REGISTRY_TTL_KEY = "registry.ttl" + SIMPLIFIED_KEY = "simplified" + NAMESPACE_KEY = "namespace" ) const ( diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go index 55725ddf16..fdcae0a466 100644 --- a/common/extension/service_discovery.go +++ b/common/extension/service_discovery.go @@ -38,10 +38,10 @@ func SetServiceDiscovery(protocol string, creator func(name string) (registry.Se // protocol indicate the implementation, like nacos // the name like nacos-1... // if not found, or initialize instance failed, it will return error. -func GetServiceDiscovery(protocol string, name string) (registry.ServiceDiscovery, error) { +func GetServiceDiscovery(protocol string) (registry.ServiceDiscovery, error) { creator, ok := discoveryCreatorMap[protocol] if !ok { return nil, perrors.New("Could not find the service discovery with discovery protocol: " + protocol) } - return creator(name) + return creator(protocol) } diff --git a/config/application_config.go b/config/application_config.go index c68492cf65..726802fde6 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -31,7 +31,7 @@ type ApplicationConfig struct { Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"` Environment string `default:"dev" yaml:"environment" json:"environment,omitempty" property:"environment"` // the metadata type. remote or local - MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` + MetadataType string `default:"local" yaml:"metadata-type" json:"metadataType,omitempty" property:"metadataType"` } // Prefix dubbo.applicationConfig diff --git a/config/config_loader.go b/config/config_loader.go index bee96cae43..b08904a31b 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -19,8 +19,15 @@ package config import ( "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/registry" "errors" "fmt" + hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" + "reflect" + "strconv" ) import ( "github.com/knadh/koanf" @@ -36,21 +43,13 @@ import ( var ( rootConfig *RootConfig - - //consumerConfig *consumer.ShutdownConfig - //providerConfig *provider.ProviderConfig - //// baseConfig = providerConfig.BaseConfig or consumerConfig - //baseConfig *root.ShutdownConfig - //sslEnabled = false - // - //// configAccessMutex is used to make sure that xxxxConfig will only be created once if needed. - //// it should be used combine with double-check to avoid the race condition - //configAccessMutex sync.Mutex - // - maxWait = 3 + maxWait = 3 ) func Load(opts ...LoaderConfOption) error { + hessian.RegisterPOJO(&common.MetadataInfo{}) + hessian.RegisterPOJO(&common.ServiceInfo{}) + hessian.RegisterPOJO(&common.URL{}) // conf conf := NewLoaderConf(opts...) // init config @@ -61,7 +60,12 @@ func Load(opts ...LoaderConfOption) error { return err } rootConfig.refresh = false - return rootConfig.InitConfig() + extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) + if err := rootConfig.InitConfig(); err != nil { + return err + } + registerServiceInstance() + return nil } func check() error { @@ -357,92 +361,65 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // registerServiceInstance() //} // -//// registerServiceInstance register service instance -//func registerServiceInstance() { -// url := selectMetadataServiceExportedURL() -// if url == nil { -// return -// } -// instance, err := createInstance(url) -// if err != nil { -// panic(err) -// } -// p := extension.GetProtocol(constant.REGISTRY_KEY) -// var rp registry.RegistryFactory -// var ok bool -// if rp, ok = p.(registry.RegistryFactory); !ok { -// panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") -// } -// rs := rp.GetRegistries() -// for _, r := range rs { -// var sdr registry.ServiceDiscoveryHolder -// if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { -// continue -// } -// err := sdr.GetServiceDiscovery().Register(instance) -// if err != nil { -// panic(err) -// } -// } -// // todo publish metadata to remote -// if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { -// remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) -// } -//} +// registerServiceInstance register service instance +func registerServiceInstance() { + url := selectMetadataServiceExportedURL() + if url == nil { + return + } + instance, err := createInstance(url) + if err != nil { + panic(err) + } + p := extension.GetProtocol(constant.REGISTRY_KEY) + var rp registry.RegistryFactory + var ok bool + if rp, ok = p.(registry.RegistryFactory); !ok { + panic("dubbo registry protocol{" + reflect.TypeOf(p).String() + "} is invalid") + } + rs := rp.GetRegistries() + for _, r := range rs { + var sdr registry.ServiceDiscoveryHolder + if sdr, ok = r.(registry.ServiceDiscoveryHolder); !ok { + continue + } + // publish app level data to registry + err := sdr.GetServiceDiscovery().Register(instance) + if err != nil { + panic(err) + } + } +} + // //// nolint -//func createInstance(url *common.URL) (registry.ServiceInstance, error) { -// appConfig := GetApplicationConfig() -// port, err := strconv.ParseInt(url.Port, 10, 32) -// if err != nil { -// return nil, perrors.WithMessage(err, "invalid port: "+url.Port) -// } -// -// host := url.Ip -// if len(host) == 0 { -// host = common.GetLocalIp() -// } -// -// // usually we will add more metadata -// metadata := make(map[string]string, 8) -// metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType -// -// return ®istry.DefaultServiceInstance{ -// ServiceName: appConfig.Name, -// Host: host, -// Port: int(port), -// ID: host + constant.KEY_SEPARATOR + url.Port, -// Enable: true, -// Healthy: true, -// Metadata: metadata, -// }, nil -//} -// -//// selectMetadataServiceExportedURL get already be exported url -//func selectMetadataServiceExportedURL() *common.URL { -// var selectedUrl *common.URL -// metaDataService, err := extension.GetLocalMetadataService("") -// if err != nil { -// logger.Warn(err) -// return nil -// } -// urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) -// if err != nil { -// panic(err) -// } -// if len(urlList) == 0 { -// return nil -// } -// for _, url := range urlList { -// selectedUrl = url -// // rest first -// if url.Protocol == "rest" { -// break -// } -// } -// return selectedUrl -//} -// +func createInstance(url *common.URL) (registry.ServiceInstance, error) { + appConfig := GetApplicationConfig() + port, err := strconv.ParseInt(url.Port, 10, 32) + if err != nil { + return nil, perrors.WithMessage(err, "invalid port: "+url.Port) + } + + host := url.Ip + if len(host) == 0 { + host = common.GetLocalIp() + } + + // usually we will add more metadata + metadata := make(map[string]string, 8) + metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType + + return ®istry.DefaultServiceInstance{ + ServiceName: appConfig.Name, + Host: host, + Port: int(port), + ID: host + constant.KEY_SEPARATOR + url.Port, + Enable: true, + Healthy: true, + Metadata: metadata, + }, nil +} + //func initRouter() { // if uniformDestRuleConfigPath != "" && uniformVirtualServiceConfigPath != "" { // if err := router.RouterInit(uniformVirtualServiceConfigPath, uniformDestRuleConfigPath); err != nil { @@ -475,7 +452,7 @@ func getKoanf(conf *loaderConf) *koanf.Koanf { // // init the shutdown callback // shutdown.GracefulShutdownInit() //} -// + // GetRPCService get rpc service for consumer func GetRPCService(name string) common.RPCService { return rootConfig.Consumer.References[name].GetRPCService() @@ -504,6 +481,10 @@ func GetMetricConfig() *MetricConfig { return rootConfig.MetricConfig } +func GetMetadataReportConfg() *MetadataReportConfig { + return rootConfig.MetadataReportConfig +} + // GetApplicationConfig find the applicationConfig config // if not, we will create one // Usually applicationConfig will be initialized when system start diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 685447ad07..3688a879ef 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -18,6 +18,7 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" "fmt" "os" "path/filepath" @@ -39,9 +40,14 @@ type loaderConf struct { } func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { + configFilePath := "../conf/dubbogo.yaml" + if configFilePathFromEnv := os.Getenv(constant.CONFIG_FILE_ENV_KEY); configFilePathFromEnv != "" { + configFilePath = configFilePathFromEnv + } + conf := &loaderConf{ genre: "yaml", - path: "./conf/application.yaml", + path: configFilePath, delim: ".", } diff --git a/config/consumer_config.go b/config/consumer_config.go index 1ca32311cc..334877e97a 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -62,32 +62,24 @@ func (ConsumerConfig) Prefix() string { return constant.ConsumerConfigPrefix } -func initConsumerConfig(rc *RootConfig) error { - consumer := rc.Consumer - if consumer == nil { - consumer = new(ConsumerConfig) +func (cc *ConsumerConfig) Init(rc *RootConfig) error { + if cc == nil { + return nil } - if err := initReferenceConfig(consumer); err != nil { - return err + for k, _ := range cc.References { + if err := cc.References[k].Init(rc); err != nil { + return err + } } - if err := consumer.check(); err != nil { + if err := defaults.Set(cc); err != nil { return err } - for { - if rc.Provider.ready.Load() { - consumer.Load() - break - } - } - rc.Consumer = consumer - return nil -} - -func (c *ConsumerConfig) check() error { - if err := defaults.Set(c); err != nil { + if err := verify(cc); err != nil { return err } - return verify(c) + cc.rootConfig = rc + cc.Load() + return nil } func (c *ConsumerConfig) Load() { diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index fb752be4b5..1184f91763 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -18,7 +18,9 @@ package config import ( - "github.com/creasty/defaults" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/extension" + "fmt" perrors "github.com/pkg/errors" ) @@ -35,51 +37,38 @@ type MetadataReportConfig struct { Password string `yaml:"password" json:"password,omitempty"` Timeout string `yaml:"timeout" json:"timeout,omitempty"` Group string `yaml:"group" json:"group,omitempty"` -} -func initMetadataReportConfig(rc *RootConfig) error { - return nil + MetadataReportType string } -func (c *MetadataReportConfig) CheckConfig() error { - // todo check - defaults.MustSet(c) - return verify(c) +// Prefix dubbo.consumer +func (MetadataReportConfig) Prefix() string { + return constant.MetadataReportPrefix } -func (c *MetadataReportConfig) Validate() { - - // todo set default application +func (m *MetadataReportConfig) Init(rc *RootConfig) error { + if m == nil { + return nil + } + m.MetadataReportType = rc.Application.MetadataType + return m.StartMetadataReport() } // nolint func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { - //urlMap := make(url.Values) - - //if c.Params != nil { - // for k, v := range c.Params { - // urlMap.Set(k, v) - // } - //} - // - //rc, ok := config.GetBaseConfig().GetRemoteConfig(c.RemoteRef) - // - //if !ok { - // return nil, perrors.New("Could not find out the remote ref config, name: " + c.RemoteRef) - //} - // - //res, err := common.NewURL(rc.Address, - // common.WithParams(urlMap), - // common.WithUsername(rc.Username), - // common.WithPassword(rc.Password), - // common.WithLocation(rc.Address), - // common.WithProtocol(c.Protocol), - //) - //if err != nil || len(res.Protocol) == 0 { - // return nil, perrors.New("Invalid MetadataReportConfig.") - //} - //res.SetParam("metadata", res.Protocol) - return nil, nil + res, err := common.NewURL(c.Address, + //common.WithParams(urlMap), + common.WithUsername(c.Username), + common.WithPassword(c.Password), + common.WithLocation(c.Address), + common.WithProtocol(c.Protocol), + common.WithParamsValue(constant.METADATATYPE_KEY, c.MetadataReportType), + ) + if err != nil || len(res.Protocol) == 0 { + return nil, perrors.New("Invalid MetadataReportConfig.") + } + res.SetParam("metadata", res.Protocol) + return res, nil } func (c *MetadataReportConfig) IsValid() bool { @@ -87,21 +76,49 @@ func (c *MetadataReportConfig) IsValid() bool { } // StartMetadataReport: The entry of metadata report start -func (c *MetadataReportConfig) StartMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { - if metadataReportConfig == nil || !metadataReportConfig.IsValid() { +func (c *MetadataReportConfig) StartMetadataReport() error { + if c == nil || !c.IsValid() { return nil } - // todo - // - //if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.RemoteRef) == 0 { - // return perrors.New("MetadataConfig remote ref can not be empty.") - //} - - if tmpUrl, err := metadataReportConfig.ToUrl(); err == nil { + if tmpUrl, err := c.ToUrl(); err == nil { instance.GetMetadataReportInstance(tmpUrl) + return nil } else { return perrors.Wrap(err, "Start MetadataReport failed.") } +} - return nil +func publishServiceDefinition(url *common.URL) { + if url.GetParam(constant.METADATATYPE_KEY, "") != constant.REMOTE_METADATA_STORAGE_TYPE { + return + } + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { + remoteMetadataService.PublishServiceDefinition(url) + } +} + +// +// selectMetadataServiceExportedURL get already be exported url +func selectMetadataServiceExportedURL() *common.URL { + var selectedUrl *common.URL + metaDataService, err := extension.GetLocalMetadataService("") + if err != nil { + fmt.Println("selectMetadataServiceExportedURL err = ", err) + return nil + } + urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) + if err != nil { + panic(err) + } + if len(urlList) == 0 { + return nil + } + for _, url := range urlList { + selectedUrl = url + // rest first + if url.Protocol == "rest" { + break + } + } + return selectedUrl } diff --git a/config/method_config.go b/config/method_config.go index 45becadce5..990ff69ae7 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -48,18 +48,8 @@ func (mc *MethodConfig) Prefix() string { return constant.DUBBO + "." + mc.InterfaceName + "." + mc.Name + "." } -func initConsumerMethodConfig(rc *ReferenceConfig) error { - methods := rc.Methods - if methods == nil { - return nil - } - for _, method := range methods { - if err := method.check(); err != nil { - return err - } - } - rc.Methods = methods - return nil +func (mc *MethodConfig) Init() error { + return mc.check() } func initProviderMethodConfig(sc *ServiceConfig) error { diff --git a/config/protocol_config.go b/config/protocol_config.go index 1ade142bb1..166449bcc5 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -18,10 +18,13 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "github.com/creasty/defaults" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + // ProtocolConfig is protocol configuration type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` @@ -51,3 +54,43 @@ func (p *ProtocolConfig) check() error { defaults.MustSet(p) return verify(p) } + +func NewDefaultProtocolConfig() *ProtocolConfig { + return &ProtocolConfig{ + Name: constant.DEFAULT_PROTOCOL, + Port: "20000", + Ip: "127.0.0.1", + } +} + +// NewProtocolConfig returns ProtocolConfig with given @opts +func NewProtocolConfig(opts ...ProtocolConfigOpt) *ProtocolConfig { + newConfig := NewDefaultProtocolConfig() + for _, v := range opts { + v(newConfig) + } + return newConfig +} + +type ProtocolConfigOpt func(config *ProtocolConfig) *ProtocolConfig + +func WithProtocolIP(ip string) ProtocolConfigOpt { + return func(config *ProtocolConfig) *ProtocolConfig { + config.Ip = ip + return config + } +} + +func WithProtocolName(protcolName string) ProtocolConfigOpt { + return func(config *ProtocolConfig) *ProtocolConfig { + config.Name = protcolName + return config + } +} + +func WithProtocolPort(port string) ProtocolConfigOpt { + return func(config *ProtocolConfig) *ProtocolConfig { + config.Port = port + return config + } +} diff --git a/config/provider_config.go b/config/provider_config.go index 04adb8bf57..918015c3b9 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -21,7 +21,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" "fmt" "github.com/creasty/defaults" - "go.uber.org/atomic" ) import ( @@ -46,8 +45,6 @@ type ProviderConfig struct { FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` - // 是否初始化完成 - ready *atomic.Bool } func (c *ProviderConfig) CheckConfig() error { @@ -56,21 +53,20 @@ func (c *ProviderConfig) CheckConfig() error { return verify(c) } -func initProviderConfig(rc *RootConfig) error { - provider := rc.Provider - if provider == nil { - provider = new(ProviderConfig) +func (c *ProviderConfig) Init(rc *RootConfig) error { + if c == nil { + return nil } - - if err := initServiceConfig(provider); err != nil { - return err + for k, _ := range c.Services { + if err := c.Services[k].Init(rc); err != nil { + return err + } } - if err := defaults.Set(provider); err != nil { + if err := defaults.Set(c); err != nil { return err } - provider.Registry = translateRegistryIds(provider.Registry) - provider.Load() - rc.Provider = provider + c.Registry = translateRegistryIds(c.Registry) + c.Load() return nil } @@ -111,7 +107,6 @@ func (c *ProviderConfig) Load() { // } // } //} - c.ready = atomic.NewBool(false) for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { @@ -124,7 +119,6 @@ func (c *ProviderConfig) Load() { panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } - c.ready = atomic.NewBool(true) } // SetProviderConfig sets provider config by @p diff --git a/config/reference_config.go b/config/reference_config.go index 80a23a2460..9022fcb3c8 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -61,7 +61,8 @@ type ReferenceConfig struct { RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` - rootConfig *RootConfig + rootConfig *RootConfig + metaDataType string } // nolint @@ -69,41 +70,20 @@ func (rc *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + rc.InterfaceName + "." } -// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function -//func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { -// type rf ReferenceConfig -// raw := rf{} // Put your defaults here -// if err := unmarshal(&raw); err != nil { -// return err -// } -// -// *c = ReferenceConfig(raw) -// return defaults.Set(c) -//} - -func initReferenceConfig(cc *ConsumerConfig) error { - references := cc.References - if references == nil { - references = make(map[string]*ReferenceConfig, 8) - } - for _, reference := range references { - if err := initConsumerMethodConfig(reference); err != nil { - return err - } - if err := reference.check(); err != nil { +func (cc *ReferenceConfig) Init(rc *RootConfig) error { + for k, _ := range cc.Methods { + if err := cc.Methods[k].Init(); err != nil { return err } } - cc.References = references - return nil -} - -func (rc *ReferenceConfig) check() error { if err := defaults.Set(rc); err != nil { return err } - rc.rootConfig = rootConfig - return verify(rc) + cc.rootConfig = rc + if rc.Application != nil { + cc.metaDataType = rc.Application.MetadataType + } + return verify(cc) } // Refer ... @@ -113,6 +93,7 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { common.WithProtocol(rc.Protocol), common.WithParams(rc.getURLMap()), common.WithParamsValue(constant.BEAN_NAME_KEY, rc.id), + common.WithParamsValue(constant.METADATATYPE_KEY, rc.metaDataType), ) if rc.ForceTag { cfgURL.AddParam(constant.ForceUseTag, "true") @@ -149,7 +130,8 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { } if len(rc.urls) == 1 { - rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) + + rc.invoker = extension.GetProtocol("registry").Refer(rc.urls[0]) // c.URL != "" is direct call if rc.URL != "" { //filter @@ -213,8 +195,8 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker rc.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) } - // publish consumer metadata - publishConsumerDefinition(cfgURL) + // publish consumer's metadata + publishServiceDefinition(cfgURL) // create proxy if rc.Async { callback := GetCallback(rc.id) @@ -310,12 +292,6 @@ func (rc *ReferenceConfig) GetInvoker() protocol.Invoker { return rc.invoker } -func publishConsumerDefinition(url *common.URL) { - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { - remoteMetadataService.PublishServiceDefinition(url) - } -} - // postProcessConfig asks registered ConfigPostProcessor to post-process the current ReferenceConfig. func (rc *ReferenceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { diff --git a/config/registry_config.go b/config/registry_config.go index 05aa5d1233..4e787a9cce 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -36,10 +36,11 @@ import ( // RegistryConfig is the configuration of the registry center type RegistryConfig struct { - Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second - Group string `yaml:"group" json:"group,omitempty" property:"group"` - TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute + Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second + Group string `yaml:"group" json:"group,omitempty" property:"group"` + Namespace string `yaml:"namespace" json:"namespace,omitempty" property:"namespace"` + TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry Address string `validate:"required" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` @@ -51,8 +52,9 @@ type RegistryConfig struct { Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"` // Affects traffic distribution among registriesConfig, // useful when subscribe to multiple registriesConfig Take effect only when no preferred registry is specified. - Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + RegistryType string `yaml:"registry-type"` } // Prefix dubbo.registriesConfig diff --git a/config/root_config.go b/config/root_config.go index 94d4bc5fb1..9fc53662cf 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -20,6 +20,7 @@ package config import ( "bytes" "dubbo.apache.org/dubbo-go/v3/common/constant" + "fmt" ) // RootConfig is the root config @@ -114,7 +115,8 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { } if rc.ConfigCenter != nil && !rc.refresh { if err := startConfigCenter(rc); err != nil { - return err + fmt.Println("start config center err = ", err) + //return err } } if err := initApplicationConfig(rc); err != nil { @@ -132,7 +134,7 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { if err := initServiceDiscoveryConfig(rc); err != nil { return err } - if err := initMetadataReportConfig(rc); err != nil { + if err := rc.MetadataReportConfig.Init(rc); err != nil { return err } if err := initMetricConfig(rc); err != nil { @@ -145,10 +147,10 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { return err } // provider、consumer must last init - if err := initProviderConfig(rc); err != nil { + if err := rc.Provider.Init(rc); err != nil { return err } - if err := initConsumerConfig(rc); err != nil { + if err := rc.Consumer.Init(rc); err != nil { return err } return nil diff --git a/config/service_config.go b/config/service_config.go index bfef0be59e..ba0bccba83 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -73,18 +73,19 @@ type ServiceConfig struct { Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - Protocols map[string]*ProtocolConfig - unexported *atomic.Bool - exported *atomic.Bool - export bool // a flag to control whether the current service should export or not - rpcService common.RPCService - cacheMutex sync.Mutex - cacheProtocol protocol.Protocol - - exportersLock sync.Mutex - exporters []protocol.Exporter - - rootConfig *RootConfig + Protocols map[string]*ProtocolConfig + Registries map[string]*RegistryConfig + ProxyFactoryKey string + unexported *atomic.Bool + exported *atomic.Bool + export bool // a flag to control whether the current service should export or not + rpcService common.RPCService + cacheMutex sync.Mutex + cacheProtocol protocol.Protocol + exportersLock sync.Mutex + exporters []protocol.Exporter + + metadataType string } // Prefix returns dubbo.service.${InterfaceName}. @@ -92,22 +93,24 @@ func (svc *ServiceConfig) Prefix() string { return constant.ServiceConfigPrefix + svc.id } -func initServiceConfig(rc *ProviderConfig) error { - services := rc.Services - if services == nil { - return nil +func (svc *ServiceConfig) Init(rc *RootConfig) error { + if err := initProviderMethodConfig(svc); err != nil { + return err } - for _, service := range services { - - if err := initProviderMethodConfig(service); err != nil { - return err - } - if err := service.check(); err != nil { - return err - } + if err := defaults.Set(svc); err != nil { + return err } - rc.Services = services - return nil + svc.exported = atomic.NewBool(false) + svc.metadataType = rc.Application.MetadataType + svc.unexported = atomic.NewBool(false) + svc.Registries = rc.Registries + svc.Protocols = rc.Protocols + if rc.Provider != nil { + svc.ProxyFactoryKey = rc.Provider.ProxyFactory + } + + svc.export = true + return verify(svc) } // UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function @@ -131,21 +134,7 @@ func (svc *ServiceConfig) CheckConfig() error { return verify(svc) } -func (svc *ServiceConfig) check() error { - if err := defaults.Set(svc); err != nil { - return err - } - // todo root config must ? - svc.rootConfig = rootConfig - svc.exported = atomic.NewBool(false) - svc.unexported = atomic.NewBool(false) - // svc.cacheProtocol = rootConfig.Protocols[0] - svc.export = true - return verify(svc) -} - func (svc *ServiceConfig) Validate(rootConfig *RootConfig) { - svc.rootConfig = rootConfig svc.exported = atomic.NewBool(false) svc.unexported = atomic.NewBool(false) svc.export = true @@ -218,8 +207,6 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { // Export exports the service func (svc *ServiceConfig) Export() error { - // TODO: config center start here - // TODO: delay export if svc.unexported != nil && svc.unexported.Load() { err := perrors.Errorf("The service %v has already unexported!", svc.Interface) @@ -231,9 +218,9 @@ func (svc *ServiceConfig) Export() error { return nil } - regUrls := loadRegistries(svc.Registry, svc.rootConfig.Registries, common.PROVIDER) + regUrls := loadRegistries(svc.Registry, svc.Registries, common.PROVIDER) urlMap := svc.getUrlMap() - protocolConfigs := loadProtocol(svc.Protocol, svc.rootConfig.Protocols) + protocolConfigs := loadProtocol(svc.Protocol, svc.Protocols) if len(protocolConfigs) == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", svc.Interface, svc.Protocol) return nil @@ -241,7 +228,7 @@ func (svc *ServiceConfig) Export() error { ports := getRandomPort(protocolConfigs) nextPort := ports.Front() - proxyFactory := extension.GetProxyFactory(svc.rootConfig.Provider.ProxyFactory) + proxyFactory := extension.GetProxyFactory(svc.ProxyFactoryKey) for _, proto := range protocolConfigs { // registry the service reflect methods, err := common.ServiceMap.Register(svc.Interface, proto.Name, svc.Group, svc.Version, svc.rpcService) @@ -267,6 +254,7 @@ func (svc *ServiceConfig) Export() error { //common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())), common.WithMethods(strings.Split(methods, ",")), common.WithToken(svc.Token), + common.WithParamsValue(constant.METADATATYPE_KEY, svc.metadataType), ) if len(svc.Tag) > 0 { ivkURL.AddParam(constant.Tagkey, svc.Tag) @@ -331,7 +319,7 @@ func loadProtocol(protocolIds []string, protocols map[string]*ProtocolConfig) [] } func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, roleType common.RoleType) []*common.URL { - var urls []*common.URL + var registryURLs []*common.URL //trSlice := strings.Split(targetRegistries, ",") for k, registryConf := range registries { @@ -358,9 +346,19 @@ func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, addresses := strings.Split(registryConf.Address, ",") address := addresses[0] address = registryConf.translateRegistryAddress() - url, err := common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, + var registryURLProtocol string + if registryConf.RegistryType == "service" { + // service discovery protocol + registryURLProtocol = constant.SERVICE_REGISTRY_PROTOCOL + } else { + registryURLProtocol = constant.REGISTRY_PROTOCOL + } + registryURL, err := common.NewURL(registryURLProtocol+"://"+address, common.WithParams(registryConf.getUrlMap(roleType)), - common.WithParamsValue("simplified", strconv.FormatBool(registryConf.Simplified)), + common.WithParamsValue(constant.SIMPLIFIED_KEY, strconv.FormatBool(registryConf.Simplified)), + common.WithParamsValue(constant.REGISTRY_KEY, registryConf.Protocol), + common.WithParamsValue(constant.GROUP_KEY, registryConf.Group), + common.WithParamsValue(constant.NAMESPACE_KEY, registryConf.Namespace), common.WithUsername(registryConf.Username), common.WithPassword(registryConf.Password), common.WithLocation(registryConf.Address), @@ -370,12 +368,12 @@ func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) panic(err) } else { - urls = append(urls, url) + registryURLs = append(registryURLs, registryURL) } } } - return urls + return registryURLs } // Unexport will call unexport of all exporters service config exported @@ -435,7 +433,11 @@ func (svc *ServiceConfig) getUrlMap() url.Values { //urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) // filter - urlMap.Set(constant.SERVICE_FILTER_KEY, mergeValue(svc.rootConfig.Provider.Filter, svc.Filter, constant.DEFAULT_SERVICE_FILTERS)) + if svc.Filter == "" { + urlMap.Set(constant.SERVICE_FILTER_KEY, constant.DEFAULT_SERVICE_FILTERS) + } else { + urlMap.Set(constant.SERVICE_FILTER_KEY, svc.Filter) + } // filter special config urlMap.Set(constant.AccessLogFilterKey, svc.AccessLog) @@ -486,10 +488,10 @@ func (svc *ServiceConfig) GetExportedUrls() []*common.URL { return nil } -func publishServiceDefinition(url *common.URL) { +func (svc *ServiceConfig) publishServiceDefinition(url *common.URL) { + //svc.rootConfig.MetadataReportConfig. if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { remoteMetadataService.PublishServiceDefinition(url) - } } @@ -500,30 +502,25 @@ func (svc *ServiceConfig) postProcessConfig(url *common.URL) { } } -// NewServiceConfig The only way to get a new ServiceConfig -func NewServiceConfig(id string) *ServiceConfig { - return &ServiceConfig{ - id: id, - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, - } -} - // ServiceConfigOpt is the option to init ServiceConfig type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig // NewDefaultServiceConfig returns default ServiceConfig func NewDefaultServiceConfig() *ServiceConfig { - newServiceConfig := NewServiceConfig("") + newServiceConfig := &ServiceConfig{ + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + Protocols: make(map[string]*ProtocolConfig), + Registries: make(map[string]*RegistryConfig), + } newServiceConfig.Params = make(map[string]string) newServiceConfig.Methods = make([]*MethodConfig, 0, 8) return newServiceConfig } -// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared -// NewServiceConfigByAPI returns ServiceConfig with given @opts -func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *ServiceConfig { +// NewServiceConfig returns ServiceConfig with given @opts +func NewServiceConfig(opts ...ServiceConfigOpt) *ServiceConfig { defaultServiceConfig := NewDefaultServiceConfig() for _, v := range opts { v(defaultServiceConfig) @@ -555,6 +552,14 @@ func WithServiceInterface(interfaceName string) ServiceConfigOpt { } } +// WithServiceMetadataType returns ServiceConfigOpt with given @metadataType +func WithServiceMetadataType(metadataType string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.metadataType = metadataType + return config + } +} + // WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb func WithServiceLoadBalance(lb string) ServiceConfigOpt { return func(config *ServiceConfig) *ServiceConfig { @@ -590,3 +595,52 @@ func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { return config } } + +func WithServiceProtocols(protocolName string, protocolConfig *ProtocolConfig) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Protocols[protocolName] = protocolConfig + return config + } +} + +func WithServiceRegistries(registryName string, registryConfig *RegistryConfig) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Registries[registryName] = registryConfig + return config + } +} + +func WithServiceGroup(group string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Group = group + return config + } +} + +func WithServiceVersion(version string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.Version = version + return config + } +} + +func WithProxyFactoryKey(proxyFactoryKey string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.ProxyFactoryKey = proxyFactoryKey + return config + } +} + +func WithRPCService(service common.RPCService) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.rpcService = service + return config + } +} + +func WithServiceID(id string) ServiceConfigOpt { + return func(config *ServiceConfig) *ServiceConfig { + config.id = id + return config + } +} diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index d6b4ebe7cf..3653c52202 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,8 +18,7 @@ package configurable import ( - "dubbo.apache.org/dubbo-go/v3/config" - "errors" + "strconv" "sync" ) @@ -27,8 +26,14 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" + + // these three import is necessary for inmemory metadata service, export or refer. + _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" ) // MetadataServiceExporter is the ConfigurableMetadataServiceExporter which implement MetadataServiceExporter interface @@ -48,34 +53,25 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte // Export will export the metadataService func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { - serviceConfig := config.NewServiceConfig(constant.SIMPLE_METADATA_SERVICE_NAME) - serviceConfig.Protocol = []string{constant.DEFAULT_PROTOCOL} - if url == nil || url.SubURL == nil { - return errors.New("metadata server url is nil, pls check your configuration") - } - serviceConfig.Protocols = map[string]*config.ProtocolConfig{ - constant.DEFAULT_PROTOCOL: { - Name: url.SubURL.Protocol, - Port: url.SubURL.Port, - }, - } - serviceConfig.Registry = []string{"N/A"} - serviceConfig.Interface = constant.METADATA_SERVICE_NAME - // identify this is a golang server - serviceConfig.Params = map[string]string{} - - serviceConfig.Group = config.GetApplicationConfig().Name - // now the error will always be nil - serviceConfig.Version, _ = exporter.metadataService.Version() - - var err error - func() { - exporter.lock.Lock() - defer exporter.lock.Unlock() - exporter.ServiceConfig = serviceConfig - exporter.ServiceConfig.Implement(exporter.metadataService) - err = exporter.ServiceConfig.Export() - }() + version, _ := exporter.metadataService.Version() + exporter.lock.Lock() + defer exporter.lock.Unlock() + exporter.ServiceConfig = config.NewServiceConfig( + config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME), + config.WithServiceProtocol(constant.DEFAULT_PROTOCOL), + config.WithServiceProtocols(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( + config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)), + )), + config.WithServiceRegistry("N/A"), + config.WithServiceInterface(constant.METADATA_SERVICE_NAME), + config.WithServiceGroup(config.GetApplicationConfig().Name), + config.WithServiceVersion(version), + config.WithProxyFactoryKey(constant.DEFAULT_Key), + config.WithServiceInterface(constant.METADATA_SERVICE_NAME), + config.WithServiceMetadataType(constant.REMOTE_METADATA_STORAGE_TYPE), + ) + exporter.ServiceConfig.Implement(exporter.metadataService) + err := exporter.ServiceConfig.Export() logger.Infof("The MetadataService exports urls : %v ", exporter.ServiceConfig.GetExportedUrls()) return err diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index e801521b72..17716472af 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -18,7 +18,9 @@ package nacos import ( + "dubbo.apache.org/dubbo-go/v3/common" "fmt" + "net/url" "sync" ) @@ -320,31 +322,24 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { if ok { return instance, nil } - - sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] - if !ok || len(sdc.RemoteRef) == 0 { - return nil, perrors.New("could not init the instance because the config is invalid") - } - - rc, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] - if !ok { - return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) - } - group := sdc.Group - if len(group) == 0 { - group = defaultGroup - } - // set protocol if remote not set - if len(rc.Protocol) <= 0 { - rc.Protocol = sdc.Protocol - } - client, err := nacos.NewNacosClient(rc) + metadataReportConfig := config.GetMetadataReportConfg() + url := common.NewURLWithOptions( + common.WithParams(make(url.Values)), + common.WithPassword(metadataReportConfig.Password), + common.WithUsername(metadataReportConfig.Username), + common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, metadataReportConfig.Timeout)) + url.Location = metadataReportConfig.Address + client, err := nacos.NewNacosClientByUrl(url) if err != nil { return nil, perrors.WithMessage(err, "create nacos namingClient failed.") } - descriptor := fmt.Sprintf("nacos-service-discovery[%s]", rc.Address) + descriptor := fmt.Sprintf("nacos-service-discovery[%s]", metadataReportConfig.Address) + group := metadataReportConfig.Group + if len(group) == 0 { + group = defaultGroup + } newInstance := &nacosServiceDiscovery{ group: group, namingClient: client, diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 1f3fcc29ed..7ab21bcbda 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -44,12 +44,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery/synthesizer" ) -const ( - protocolName = "service-discovery" -) - func init() { - extension.SetRegistry(protocolName, newServiceDiscoveryRegistry) + extension.SetRegistry(constant.SERVICE_REGISTRY_PROTOCOL, newServiceDiscoveryRegistry) } // serviceDiscoveryRegistry is the implementation of application-level registry. @@ -125,12 +121,8 @@ func (s *serviceDiscoveryRegistry) UnSubscribe(url *common.URL, listener registr } func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { - sdcName := url.GetParam(constant.SERVICE_DISCOVERY_KEY, "") - sdc, ok := config.GetRootConfig().ServiceDiscoveries[sdcName] - if !ok { - return nil, perrors.Errorf("The service discovery with name: %s is not found", sdcName) - } - originServiceDiscovery, err := extension.GetServiceDiscovery(sdc.Protocol, sdcName) + sdcName := url.GetParam(constant.REGISTRY_KEY, "") + originServiceDiscovery, err := extension.GetServiceDiscovery(sdcName) if err != nil { return nil, perrors.WithMessage(err, "Create service discovery fialed") } diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index 93534675af..7df24df598 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -29,7 +29,7 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" gxpage "github.com/dubbogo/gost/hash/page" - perrors "github.com/pkg/errors" + //perrors "github.com/pkg/errors" ) import ( @@ -44,11 +44,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/remoting/zookeeper/curator_discovery" ) -const ( - // ServiceDiscoveryZkClient zk client name - ServiceDiscoveryZkClient = "zk service discovery" -) - var ( // 16 would be enough. We won't use concurrentMap because in most cases, there are not race condition instanceMap = make(map[string]registry.ServiceDiscovery, 16) @@ -89,21 +84,14 @@ func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error return instance, nil } - sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] - if !ok || len(sdc.RemoteRef) == 0 { - return nil, perrors.New("could not init the instance because the config is invalid") - } - remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] - if !ok { - return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) - } - rootPath := remoteConfig.GetParam("rootPath", "/services") + metadataReportConfig := config.GetMetadataReportConfg() + rootPath := "/services" url := common.NewURLWithOptions( common.WithParams(make(url.Values)), - common.WithPassword(remoteConfig.Password), - common.WithUsername(remoteConfig.Username), - common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, remoteConfig.TimeoutStr)) - url.Location = remoteConfig.Address + common.WithPassword(metadataReportConfig.Password), + common.WithUsername(metadataReportConfig.Username), + common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, metadataReportConfig.Timeout)) + url.Location = metadataReportConfig.Address zksd := &zookeeperServiceDiscovery{ url: url, rootPath: rootPath, diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index b8f2150a28..22fb01c77c 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -56,10 +56,9 @@ func initClient(protocol string) { // load clientconfig from consumer_config // default use dubbo - //consumerConfig := config.GetConsumerConfig() - //if consumerConfig.ApplicationConfig == nil { - // return - //} + if config.GetApplicationConfig() == nil { + return + } protocolConf := config.GetRootConfig().Network defaultClientConfig := GetDefaultClientConfig() if protocolConf == nil { diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index 6e2cf051fe..f106e32d51 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -45,11 +45,10 @@ var srvConf *ServerConfig func initServer(protocol string) { // load clientconfig from provider_config // default use dubbo - //providerConfig := config.GetProviderConfig() - //if providerConfig.ApplicationConfig == nil { - // return - //} - protocolConf := config.GetRootConfig().Provider.ProtocolConf + if config.GetApplicationConfig() == nil { + return + } + protocolConf := config.GetProviderConfig().ProtocolConf defaultServerConfig := GetDefaultServerConfig() if protocolConf == nil { logger.Info("protocol_conf default use dubbo config") From 4b6cec3bc7cb2ec2b31b6a779ec9f8b8edc89dd1 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 14 Aug 2021 18:40:21 +0800 Subject: [PATCH 050/148] fix: fix conflict --- common/extension/service_discovery.go | 6 ++--- common/url.go | 2 +- config/interfaces/config.go | 2 +- protocol/dubbo/dubbo_invoker.go | 2 +- protocol/dubbo/dubbo_protocol.go | 4 ++-- protocol/dubbo3/dubbo3_invoker.go | 2 +- registry/etcdv3/service_discovery.go | 5 +++-- registry/file/service_discovery.go | 5 +++-- registry/nacos/service_discovery.go | 17 +------------- .../service_discovery_registry_test.go | 3 ++- registry/zookeeper/service_discovery.go | 22 +------------------ 11 files changed, 19 insertions(+), 51 deletions(-) diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go index fdcae0a466..45e0afeb1c 100644 --- a/common/extension/service_discovery.go +++ b/common/extension/service_discovery.go @@ -25,12 +25,12 @@ import ( "dubbo.apache.org/dubbo-go/v3/registry" ) -var discoveryCreatorMap = make(map[string]func(name string) (registry.ServiceDiscovery, error), 4) +var discoveryCreatorMap = make(map[string]func() (registry.ServiceDiscovery, error), 4) // SetServiceDiscovery will store the @creator and @name // protocol indicate the implementation, like nacos // the name like nacos-1... -func SetServiceDiscovery(protocol string, creator func(name string) (registry.ServiceDiscovery, error)) { +func SetServiceDiscovery(protocol string, creator func() (registry.ServiceDiscovery, error)) { discoveryCreatorMap[protocol] = creator } @@ -43,5 +43,5 @@ func GetServiceDiscovery(protocol string) (registry.ServiceDiscovery, error) { if !ok { return nil, perrors.New("Could not find the service discovery with discovery protocol: " + protocol) } - return creator(protocol) + return creator() } diff --git a/common/url.go b/common/url.go index a85a273136..7722762721 100644 --- a/common/url.go +++ b/common/url.go @@ -878,4 +878,4 @@ func (c *URL) GetParamDuration(s string, d string) time.Duration { return t } return 3 * time.Second -} \ No newline at end of file +} diff --git a/config/interfaces/config.go b/config/interfaces/config.go index 161df876c0..b4eb8ccd0e 100644 --- a/config/interfaces/config.go +++ b/config/interfaces/config.go @@ -10,4 +10,4 @@ type Config interface { func SetConfig(c Config) { configs[c.Prefix()] = c -} \ No newline at end of file +} diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 4e8c8012a1..0d65c885fc 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -59,7 +59,7 @@ type DubboInvoker struct { func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient) *DubboInvoker { rt := config.GetConsumerConfig().RequestTimeout - timeout := url.GetParamDuration(constant.TIMEOUT_KEY,rt) + timeout := url.GetParamDuration(constant.TIMEOUT_KEY, rt) di := &DubboInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), clientGuard: &sync.RWMutex{}, diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 808ca0b9e8..fe35e35681 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -203,8 +203,8 @@ func getExchangeClient(url *common.URL) *remoting.ExchangeClient { // todo set by config exchangeClientTmp = remoting.NewExchangeClient(url, getty.NewClient(getty.Options{ - ConnectTimeout: 3*time.Second, - RequestTimeout: 3*time.Second, + ConnectTimeout: 3 * time.Second, + RequestTimeout: 3 * time.Second, }), 3*time.Second, false) // input store if exchangeClientTmp != nil { diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 81ddfa7354..54d5be006b 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -58,7 +58,7 @@ type DubboInvoker struct { func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { rt := config.GetConsumerConfig().RequestTimeout - timeout:=url.GetParamDuration(constant.TIMEOUT_KEY,rt) + timeout := url.GetParamDuration(constant.TIMEOUT_KEY, rt) key := url.GetParam(constant.BEAN_NAME_KEY, "") consumerService := config.GetConsumerService(key) diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index 416d2af701..7124e5a74c 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -291,11 +291,12 @@ func (e *etcdV3ServiceDiscovery) DataChange(eventType remoting.Event) bool { } // netEcdv3ServiceDiscovery -func newEtcdV3ServiceDiscovery(name string) (registry.ServiceDiscovery, error) { +func newEtcdV3ServiceDiscovery() (registry.ServiceDiscovery, error) { initLock.Lock() defer initLock.Unlock() - sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] + // todo fix + sdc, ok := config.GetRootConfig().ServiceDiscoveries[""] if !ok || len(sdc.RemoteRef) == 0 { return nil, perrors.New("could not init the etcd service instance because the config is invalid") } diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index 562fece8ca..9a6afb7261 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -55,8 +55,9 @@ type fileSystemServiceDiscovery struct { fileMap map[string]string } -func newFileSystemServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - sdc, ok := config.GetRootConfig().ServiceDiscoveries[name] +func newFileSystemServiceDiscovery() (registry.ServiceDiscovery, error) { + // todo fix + sdc, ok := config.GetRootConfig().ServiceDiscoveries[""] if !ok || sdc.Protocol != constant.FILE_KEY { return nil, perrors.New("could not init the instance because the config is invalid") } diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 17716472af..8838191cdc 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -21,7 +21,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "fmt" "net/url" - "sync" ) import ( @@ -307,21 +306,8 @@ func (n *nacosServiceDiscovery) String() string { return n.descriptor } -var ( - // 16 would be enough. We won't use concurrentMap because in most cases, there are not race condition - instanceMap = make(map[string]registry.ServiceDiscovery, 16) - initLock sync.Mutex -) - // newNacosServiceDiscovery will create new service discovery instance -func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - initLock.Lock() - defer initLock.Unlock() - - instance, ok := instanceMap[name] - if ok { - return instance, nil - } +func newNacosServiceDiscovery() (registry.ServiceDiscovery, error) { metadataReportConfig := config.GetMetadataReportConfg() url := common.NewURLWithOptions( common.WithParams(make(url.Values)), @@ -346,6 +332,5 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { descriptor: descriptor, registryInstances: []registry.ServiceInstance{}, } - instanceMap[name] = newInstance return newInstance, nil } diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index a265ad50fc..09eb61f06e 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -18,6 +18,7 @@ package servicediscovery import ( + gxpage "github.com/dubbogo/gost/hash/page" "testing" ) @@ -50,7 +51,7 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { return }) - extension.SetServiceDiscovery("mock", func(name string) (discovery registry.ServiceDiscovery, err error) { + extension.SetServiceDiscovery("mock", func() (discovery registry.ServiceDiscovery, err error) { return &mockServiceDiscovery{}, nil }) diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index 7df24df598..b5ad4a5681 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -44,12 +44,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/remoting/zookeeper/curator_discovery" ) -var ( - // 16 would be enough. We won't use concurrentMap because in most cases, there are not race condition - instanceMap = make(map[string]registry.ServiceDiscovery, 16) - initLock sync.Mutex -) - // init will put the service discovery into extension func init() { extension.SetServiceDiscovery(constant.ZOOKEEPER_KEY, newZookeeperServiceDiscovery) @@ -69,21 +63,7 @@ type zookeeperServiceDiscovery struct { } // newZookeeperServiceDiscovery the constructor of newZookeeperServiceDiscovery -func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error) { - instance, ok := instanceMap[name] - if ok { - return instance, nil - } - - initLock.Lock() - defer initLock.Unlock() - - // double check - instance, ok = instanceMap[name] - if ok { - return instance, nil - } - +func newZookeeperServiceDiscovery() (registry.ServiceDiscovery, error) { metadataReportConfig := config.GetMetadataReportConfg() rootPath := "/services" url := common.NewURLWithOptions( From 3add3b60c107bc785812ae395465fbf40c5eb771 Mon Sep 17 00:00:00 2001 From: zhaoyunxing92 <2385585770@qq.com> Date: Sun, 15 Aug 2021 21:38:08 +0800 Subject: [PATCH 051/148] =?UTF-8?q?up:=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_center_config.go | 14 -------------- config/consumer_config.go | 19 ++++--------------- config/provider_config.go | 11 +---------- 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/config/config_center_config.go b/config/config_center_config.go index d2a7f308e4..d4e11429a4 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -78,20 +78,6 @@ func (c *CenterConfig) check() error { return verify(c) } -func (c *CenterConfig) Validate() { - // todo set default application -} - -func (c *CenterConfig) Init() error { - if c != nil { - if err := c.check(); err != nil { - return err - } - - } - return nil -} - func initConfigCenter(rc *RootConfig) error { center := rc.ConfigCenter if center == nil || rc.refresh { diff --git a/config/consumer_config.go b/config/consumer_config.go index 334877e97a..e2ddfd83a1 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -82,8 +82,8 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { return nil } -func (c *ConsumerConfig) Load() { - for key, ref := range c.References { +func (cc *ConsumerConfig) Load() { + for key, ref := range cc.References { if ref.Generic { genericService := generic.NewGenericService(key) SetConsumerService(genericService) @@ -98,24 +98,13 @@ func (c *ConsumerConfig) Load() { ref.Implement(rpcService) } - // todo Write current configuration to cache file. - //if c.CacheFile != "" { - // if data, err := yaml.MarshalYML(c); err != nil { - // logger.Errorf("Marshal consumer config err: %s", err.Error()) - // } else { - // if err := ioutil.WriteFile(c.CacheFile, data, 0666); err != nil { - // logger.Errorf("Write consumer config cache file err: %s", err.Error()) - // } - // } - //} - // wait for invoker is available, if wait over default 3s, then panic var count int for { checkok := true - for _, refconfig := range c.References { + for _, refconfig := range cc.References { if (refconfig.Check != nil && *refconfig.Check) || - (refconfig.Check == nil && c.Check) || + (refconfig.Check == nil && cc.Check) || (refconfig.Check == nil) { // default to true if refconfig.invoker != nil && !refconfig.invoker.IsAvailable() { diff --git a/config/provider_config.go b/config/provider_config.go index 918015c3b9..0632cb8b55 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -97,16 +97,7 @@ func (c *ProviderConfig) Prefix() string { } func (c *ProviderConfig) Load() { - // todo Write the current configuration to cache file. - //if c.CacheFile != "" { - // if data, err := yaml.MarshalYML(providerConfig); err != nil { - // logger.Errorf("Marshal provider config err: %s", err.Error()) - // } else { - // if err := ioutil.WriteFile(provider CacheFile, data, 0666); err != nil { - // logger.Errorf("Write provider config cache file err: %s", err.Error()) - // } - // } - //} + for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { From 72f87d1713c0b07b97485deee54d9715e47fc846 Mon Sep 17 00:00:00 2001 From: Changeden Date: Tue, 17 Aug 2021 16:47:38 +0800 Subject: [PATCH 052/148] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93getty?= =?UTF-8?q?=E7=9A=84tcp=20read/write=20timeout=E5=B0=8F=E4=BA=8E1s?= =?UTF-8?q?=E6=97=B6panic=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remoting/getty/config.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index 05713c7a7c..d3d5c37943 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -162,13 +162,18 @@ func (c *GettySessionParam) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(KeepAlivePeriod{%#v})", c.KeepAlivePeriod) } - if c.tcpReadTimeout, err = time.ParseDuration(c.TcpReadTimeout); err != nil { + var tcpTimeout *time.Duration + tcpTimeoutMinVal := time.Second * 1 + if tcpTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, &tcpTimeoutMinVal, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpReadTimeout{%#v})", c.TcpReadTimeout) } + c.tcpReadTimeout = *tcpTimeout - if c.tcpWriteTimeout, err = time.ParseDuration(c.TcpWriteTimeout); err != nil { + tcpTimeoutMinVal = time.Second * 5 + if tcpTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, &tcpTimeoutMinVal, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpWriteTimeout{%#v})", c.TcpWriteTimeout) } + c.tcpWriteTimeout = *tcpTimeout if c.waitTimeout, err = time.ParseDuration(c.WaitTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(WaitTimeout{%#v})", c.WaitTimeout) @@ -177,6 +182,23 @@ func (c *GettySessionParam) CheckValidity() error { return nil } +func parseTimeDurationByRange(timeStr string, min *time.Duration, max *time.Duration) (*time.Duration, error) { + result, err := time.ParseDuration(timeStr) + if err != nil { + return nil, err + } + if min != nil && max != nil && *min > *max { + min, max = max, min + } + if min != nil && result < *min { + result = *min + } + if max != nil && result > *max { + result = *max + } + return &result, nil +} + // CheckValidity confirm client params. func (c *ClientConfig) CheckValidity() error { var err error From 0d3ba241b15dd7bced4b9cff6f19d3564fb574b3 Mon Sep 17 00:00:00 2001 From: Changeden Date: Tue, 17 Aug 2021 22:25:28 +0800 Subject: [PATCH 053/148] =?UTF-8?q?TCP=20Read/Write=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=80=BC=E6=8F=90=E5=8F=96=E4=B8=BA=E5=85=A8=E5=B1=80=E5=8F=98?= =?UTF-8?q?=E9=87=8F=EF=BC=8C=E4=BC=98=E5=8C=96parseTimeDurationByRange?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remoting/getty/config.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index d3d5c37943..e87fdb06c9 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -29,6 +29,11 @@ import ( "dubbo.apache.org/dubbo-go/v3/config" ) +const ( + TCP_READ_TIMEOUT_MIN_VALUE = time.Second * 1 + TCP_WRITE_TIMEOUT_MIN_VALUE = time.Second * 5 +) + type ( // GettySessionParam is session configuration for getty GettySessionParam struct { @@ -162,18 +167,13 @@ func (c *GettySessionParam) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(KeepAlivePeriod{%#v})", c.KeepAlivePeriod) } - var tcpTimeout *time.Duration - tcpTimeoutMinVal := time.Second * 1 - if tcpTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, &tcpTimeoutMinVal, nil); err != nil { + if c.tcpReadTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, TCP_READ_TIMEOUT_MIN_VALUE, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpReadTimeout{%#v})", c.TcpReadTimeout) } - c.tcpReadTimeout = *tcpTimeout - tcpTimeoutMinVal = time.Second * 5 - if tcpTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, &tcpTimeoutMinVal, nil); err != nil { + if c.tcpWriteTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, TCP_WRITE_TIMEOUT_MIN_VALUE, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpWriteTimeout{%#v})", c.TcpWriteTimeout) } - c.tcpWriteTimeout = *tcpTimeout if c.waitTimeout, err = time.ParseDuration(c.WaitTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(WaitTimeout{%#v})", c.WaitTimeout) @@ -182,21 +182,21 @@ func (c *GettySessionParam) CheckValidity() error { return nil } -func parseTimeDurationByRange(timeStr string, min *time.Duration, max *time.Duration) (*time.Duration, error) { +func parseTimeDurationByRange(timeStr string, min time.Duration, max *time.Duration) (time.Duration, error) { result, err := time.ParseDuration(timeStr) if err != nil { - return nil, err + return min, err } - if min != nil && max != nil && *min > *max { - min, max = max, min + if max != nil && min > *max { + min, max = *max, &min } - if min != nil && result < *min { - result = *min + if result < min { + result = min } if max != nil && result > *max { result = *max } - return &result, nil + return result, nil } // CheckValidity confirm client params. From 77a8b5f2bc387ec5f56aaafc594a9f525bd4428a Mon Sep 17 00:00:00 2001 From: wangxw666 <2484713618@qq.com> Date: Wed, 18 Aug 2021 12:16:55 +0800 Subject: [PATCH 054/148] logo (#1382) --- README.md | 5 +++++ README_CN.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 40e3a118ee..6d87c6ea41 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,11 @@ If you are using [apache/dubbo-go](https://github.com/apache/dubbo-go) and think + + + + + diff --git a/README_CN.md b/README_CN.md index be43e95afd..a2023f4fce 100644 --- a/README_CN.md +++ b/README_CN.md @@ -150,6 +150,11 @@ go get dubbo.apache.org/dubbo-go/v3 + + + + + From f8f38b5afc309380845114d4f643fc02e8cab997 Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Wed, 18 Aug 2021 12:17:14 +0800 Subject: [PATCH 055/148] Change the key of a mock EchoFilter (#1381) * 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] * improve etcd version and change create to put (#1203) * change the mock filter key Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy --- .../protocolwrapper/protocol_filter_wrapper_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 842531ff8f..2400058e56 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -36,13 +36,15 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) +const mockFilterKey = "mockEcho" + func TestProtocolFilterWrapperExport(t *testing.T) { filtProto := extension.GetProtocol(FILTER) filtProto.(*ProtocolFilterWrapper).protocol = &protocol.BaseProtocol{} u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.SERVICE_FILTER_KEY, "echo ")) + common.WithParamsValue(constant.SERVICE_FILTER_KEY, mockFilterKey)) exporter := filtProto.Export(protocol.NewBaseInvoker(u)) _, ok := exporter.GetInvoker().(*FilterInvoker) assert.True(t, ok) @@ -54,15 +56,15 @@ func TestProtocolFilterWrapperRefer(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.REFERENCE_FILTER_KEY, " echo")) + common.WithParamsValue(constant.REFERENCE_FILTER_KEY, mockFilterKey)) invoker := filtProto.Refer(u) _, ok := invoker.(*FilterInvoker) assert.True(t, ok) } -// the same as echo filter, for test +// The initialization of mockEchoFilter, for test func init() { - extension.SetFilter("echo", newFilter) + extension.SetFilter(mockFilterKey, newFilter) } type mockEchoFilter struct{} From 3c55f4e8c745ec9df59ae7450b5b9d5abaedb3f6 Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Wed, 18 Aug 2021 12:17:14 +0800 Subject: [PATCH 056/148] Change the key of a mock EchoFilter (#1381) * 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] * improve etcd version and change create to put (#1203) * change the mock filter key Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .../protocolwrapper/protocol_filter_wrapper_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0c5d3e0a7c..5ce1a142f9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ **What this PR does**: diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 842531ff8f..2400058e56 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -36,13 +36,15 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) +const mockFilterKey = "mockEcho" + func TestProtocolFilterWrapperExport(t *testing.T) { filtProto := extension.GetProtocol(FILTER) filtProto.(*ProtocolFilterWrapper).protocol = &protocol.BaseProtocol{} u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.SERVICE_FILTER_KEY, "echo ")) + common.WithParamsValue(constant.SERVICE_FILTER_KEY, mockFilterKey)) exporter := filtProto.Export(protocol.NewBaseInvoker(u)) _, ok := exporter.GetInvoker().(*FilterInvoker) assert.True(t, ok) @@ -54,15 +56,15 @@ func TestProtocolFilterWrapperRefer(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.REFERENCE_FILTER_KEY, " echo")) + common.WithParamsValue(constant.REFERENCE_FILTER_KEY, mockFilterKey)) invoker := filtProto.Refer(u) _, ok := invoker.(*FilterInvoker) assert.True(t, ok) } -// the same as echo filter, for test +// The initialization of mockEchoFilter, for test func init() { - extension.SetFilter("echo", newFilter) + extension.SetFilter(mockFilterKey, newFilter) } type mockEchoFilter struct{} From fc81e1505a1a412111d3aa04fef2fc0a6c1ff46e Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Wed, 18 Aug 2021 21:29:51 +0800 Subject: [PATCH 057/148] fix: nacos service disc error log bug (#1390) --- go.mod | 4 ++-- go.sum | 8 ++++---- registry/nacos/service_discovery.go | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 449adaedc8..9700ad7aed 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.14 - github.com/dubbogo/triple v1.0.2 + github.com/dubbogo/gost v1.11.16 + github.com/dubbogo/triple v1.0.5 github.com/emicklei/go-restful/v3 v3.4.0 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index 333e8b82ca..0a073560a2 100644 --- a/go.sum +++ b/go.sum @@ -149,13 +149,13 @@ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl8 github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.11.14 h1:9lfcdILOmqTOVAW1fPHa5uf1NrD6jlIOBe4vf8576yQ= -github.com/dubbogo/gost v1.11.14/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= +github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.2 h1:+QKw6XbTyHP4yqUQ4gXRvV1FbhJZ7ldl9WrN0AjmCPM= -github.com/dubbogo/triple v1.0.2/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= +github.com/dubbogo/triple v1.0.5 h1:bDASS3u0ILC+KaUmWaDDuZ7/pVZcljyO/1TkwXMvcsM= +github.com/dubbogo/triple v1.0.5/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 174bf0bc82..57d4becd74 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -216,6 +216,7 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh serviceName := t.(string) err := n.namingClient.Client().Subscribe(&vo.SubscribeParam{ ServiceName: serviceName, + GroupName: n.group, SubscribeCallback: func(services []model.SubscribeService, err error) { if err != nil { logger.Errorf("Could not handle the subscribe notification because the err is not nil."+ From 384e13038f465b8e690deb3b00b0e77ad33d2aaa Mon Sep 17 00:00:00 2001 From: cjp Date: Thu, 19 Aug 2021 21:47:46 +0800 Subject: [PATCH 058/148] add logger config --- config/logger_config.go | 59 ++++++++++++++++++++- config/logger_config_test.go | 37 +++++++++++++ config/testdata/config/logger/empty_log.yml | 11 ++++ config/testdata/config/logger/log.yml | 36 +++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 config/logger_config_test.go create mode 100644 config/testdata/config/logger/empty_log.yml create mode 100644 config/testdata/config/logger/log.yml diff --git a/config/logger_config.go b/config/logger_config.go index a5d5f7462d..eb34da10a8 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -17,10 +17,67 @@ package config +import ( + "github.com/creasty/defaults" + "go.uber.org/zap" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/common/yaml" +) + type LoggerConfig struct { + Level string `default:"debug" json:"level" yaml:"level" property:"level"` + Development bool `default:"false" json:"development" yaml:"development" property:"development"` + DisableCaller bool `default:"false" json:"disableCaller" yaml:"disableCaller" property:"property"` + DisableStacktrace bool `default:"false" json:"disableStacktrace" yaml:"disableStacktrace" property:"disableStacktrace"` + Encoding string `default:"console" json:"encoding" yaml:"encoding" property:"encoding"` + EncoderConfig EncoderConfig `default:"" json:"encoderConfig" yaml:"encoderConfig" property:"encoderConfig"` + OutputPaths []string `default:"[\"stderr\"]" json:"outputPaths" yaml:"outputPaths" property:"outputPaths"` + ErrorOutputPaths []string `default:"[\"stderr\"]" json:"errorOutputPaths" yaml:"errorOutputPaths" property:"errorOutputPaths"` + InitialFields map[string]interface{} `default:"" json:"initialFields" yaml:"initialFields" property:"initialFields"` } -func initLoggerConfig(rc *RootConfig) error { +type EncoderConfig struct { + MessageKey string `default:"message" json:"messageKey" yaml:"messageKey" property:"messageKey"` + LevelKey string `default:"level" json:"levelKey" yaml:"levelKey" property:"levelKey"` + TimeKey string `default:"time" json:"timeKey" yaml:"timeKey" property:"timeKey"` + NameKey string `default:"logger" json:"nameKey" yaml:"nameKey" property:"nameKey"` + CallerKey string `default:"caller" json:"callerKey" yaml:"callerKey" property:"callerKey"` + StacktraceKey string `default:"stacktrace" json:"stacktraceKey" yaml:"stacktraceKey" property:"stacktraceKey"` + EncodeLevel string `default:"capitalColor" json:"levelEncoder" yaml:"levelEncoder" property:"levelEncoder"` + EncodeTime string `default:"iso8601" json:"timeEncoder" yaml:"timeEncoder" property:"timeEncoder"` + EncodeDuration string `default:"seconds" json:"durationEncoder" yaml:"durationEncoder" property:"durationEncoder"` + EncodeCaller string `default:"short" json:"callerEncoder" yaml:"callerEncoder" property:"callerEncoder"` +} +func initLoggerConfig(rc *RootConfig) error { + logConfig := rc.Logger + if logConfig == nil { + logConfig = new(LoggerConfig) + } + err := logConfig.check() + if err != nil { + return err + } + rc.Logger = logConfig + byte, err := yaml.MarshalYML(logConfig) + if err != nil { + return err + } + zapConfig := &zap.Config{} + err = yaml.UnmarshalYML(byte, zapConfig) + if err != nil { + return err + } + logger.InitLogger(zapConfig) return nil } + +func (l *LoggerConfig) check() error { + if err := defaults.Set(l); err != nil { + return err + } + return verify(l) +} diff --git a/config/logger_config_test.go b/config/logger_config_test.go new file mode 100644 index 0000000000..fcf2f1ca72 --- /dev/null +++ b/config/logger_config_test.go @@ -0,0 +1,37 @@ +package config + +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" +) + +func TestLoggerInit(t *testing.T) { + + t.Run("empty use default", func(t *testing.T) { + err := Load(WithPath("./testdata/config/logger/empty_log.yml")) + assert.Nil(t, err) + assert.NotNil(t, rootConfig) + loggerConfig := rootConfig.Logger + assert.NotNil(t, loggerConfig) + logger.Info("hello") + }) + + t.Run("use config", func(t *testing.T) { + err := Load(WithPath("./testdata/config/logger/log.yml")) + assert.Nil(t, err) + loggerConfig := rootConfig.Logger + assert.NotNil(t, loggerConfig) + // default + assert.Equal(t, "debug", loggerConfig.Level) + assert.Equal(t, "message", loggerConfig.EncoderConfig.MessageKey) + assert.Equal(t, "stacktrace", loggerConfig.EncoderConfig.StacktraceKey) + logger.Info("hello") + }) +} diff --git a/config/testdata/config/logger/empty_log.yml b/config/testdata/config/logger/empty_log.yml new file mode 100644 index 0000000000..80bcc1d06e --- /dev/null +++ b/config/testdata/config/logger/empty_log.yml @@ -0,0 +1,11 @@ +dubbo: + logger: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 \ No newline at end of file diff --git a/config/testdata/config/logger/log.yml b/config/testdata/config/logger/log.yml new file mode 100644 index 0000000000..800e18e005 --- /dev/null +++ b/config/testdata/config/logger/log.yml @@ -0,0 +1,36 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 + logger: + level: "debug" + development: false + disableCaller: false + disableStacktrace: false + sampling: + encoding: "console" + # encoder + encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + outputPaths: + - "stderr" + errorOutputPaths: + - "stderr" + initialFields: From 1af33a4982136112aeab1032a55e18797aba1afb Mon Sep 17 00:00:00 2001 From: Changeden Date: Fri, 20 Aug 2021 09:42:06 +0800 Subject: [PATCH 059/148] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remoting/getty/config.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index e87fdb06c9..d713b7c8aa 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -30,8 +30,7 @@ import ( ) const ( - TCP_READ_TIMEOUT_MIN_VALUE = time.Second * 1 - TCP_WRITE_TIMEOUT_MIN_VALUE = time.Second * 5 + TCP_READ_WRITE_TIMEOUT_MIN_VALUE = time.Second * 1 ) type ( @@ -167,11 +166,12 @@ func (c *GettySessionParam) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(KeepAlivePeriod{%#v})", c.KeepAlivePeriod) } - if c.tcpReadTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, TCP_READ_TIMEOUT_MIN_VALUE, nil); err != nil { + var tcpTimeoutMinVal = TCP_READ_WRITE_TIMEOUT_MIN_VALUE + if c.tcpReadTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, &tcpTimeoutMinVal, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpReadTimeout{%#v})", c.TcpReadTimeout) } - if c.tcpWriteTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, TCP_WRITE_TIMEOUT_MIN_VALUE, nil); err != nil { + if c.tcpWriteTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, &tcpTimeoutMinVal, nil); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpWriteTimeout{%#v})", c.TcpWriteTimeout) } @@ -182,16 +182,16 @@ func (c *GettySessionParam) CheckValidity() error { return nil } -func parseTimeDurationByRange(timeStr string, min time.Duration, max *time.Duration) (time.Duration, error) { +func parseTimeDurationByRange(timeStr string, min *time.Duration, max *time.Duration) (time.Duration, error) { result, err := time.ParseDuration(timeStr) if err != nil { - return min, err + return *min, err } - if max != nil && min > *max { - min, max = *max, &min + if min != nil && max != nil && *min > *max { // swap + min, max = max, min } - if result < min { - result = min + if min != nil && result < *min { + result = *min } if max != nil && result > *max { result = *max From 24c1816e56e5cbfcb5a08a14934de2bd5a2d6dba Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Fri, 20 Aug 2021 08:38:34 +0800 Subject: [PATCH 060/148] fix:registry timeout not pars (#1392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix:registry timeout not pars * up:fmt * up:统一超时时间key * fix:修改测试顺序问题 * up:fmt --- common/constant/key.go | 1 + common/url.go | 10 ++++ config/registry_config.go | 2 +- config/remote_config.go | 7 +-- go.mod | 10 ++-- go.sum | 69 +++++++++++++++++-------- metadata/report/etcd/report.go | 3 +- registry/etcdv3/registry.go | 8 +-- registry/zookeeper/service_discovery.go | 2 +- remoting/nacos/builder.go | 5 +- remoting/nacos/builder_test.go | 45 ++++++++++++++-- remoting/zookeeper/client.go | 9 +--- 12 files changed, 115 insertions(+), 56 deletions(-) diff --git a/common/constant/key.go b/common/constant/key.go index ae27581f46..38db23d018 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -125,6 +125,7 @@ const ( REGISTRY_PROTOCOL = "registry" ROLE_KEY = "registry.role" REGISTRY_DEFAULT_KEY = "registry.default" + // Deprecated use CONFIG_TIMEOUT_KEY key REGISTRY_TIMEOUT_KEY = "registry.timeout" REGISTRY_LABEL_KEY = "label" PREFERRED_KEY = "preferred" diff --git a/common/url.go b/common/url.go index b279ecae2a..5b2885cc46 100644 --- a/common/url.go +++ b/common/url.go @@ -27,6 +27,7 @@ import ( "strconv" "strings" "sync" + "time" ) import ( @@ -860,3 +861,12 @@ func SetCompareURLEqualFunc(f CompareURLEqualFunc) { func GetCompareURLEqualFunc() CompareURLEqualFunc { return compareURLEqualFunc } + +//GetParamDuration get duration if param is invalid or missing will return 3s +func (c *URL) GetParamDuration(s string, d string) time.Duration { + + if t, err := time.ParseDuration(c.GetParam(s, d)); err == nil { + return t + } + return 3 * time.Second +} diff --git a/config/registry_config.go b/config/registry_config.go index 92d92a666d..2b227331e2 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -121,7 +121,7 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { urlMap.Set(constant.GROUP_KEY, c.Group) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) urlMap.Set(constant.REGISTRY_KEY, c.Protocol) - urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.TimeoutStr) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, c.TimeoutStr) // multi registry invoker weight label for load balance urlMap.Set(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, strconv.FormatBool(true)) urlMap.Set(constant.REGISTRY_KEY+"."+constant.PREFERRED_KEY, strconv.FormatBool(c.Preferred)) diff --git a/config/remote_config.go b/config/remote_config.go index 292a89e9d3..820f744b0b 100644 --- a/config/remote_config.go +++ b/config/remote_config.go @@ -29,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // RemoteConfig: usually we need some middleware, including nacos, zookeeper @@ -45,8 +44,8 @@ type RemoteConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty"` } -// Prefix -func (c *RemoteConfig) Prefix() string { +// Prefix dubbo.remote. +func (rc *RemoteConfig) Prefix() string { return constant.RemotePrefix } @@ -56,8 +55,6 @@ 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) return 5 * time.Second } diff --git a/go.mod b/go.mod index 9700ad7aed..2ac6b3f388 100644 --- a/go.mod +++ b/go.mod @@ -30,17 +30,17 @@ require ( github.com/natefinch/lumberjack v2.0.0+incompatible github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.9.0 + github.com/prometheus/client_golang v1.11.0 github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 - 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/api/v3 v3.5.0 + go.etcd.io/etcd/client/v3 v3.5.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 + go.uber.org/zap v1.17.0 google.golang.org/grpc v1.38.0 - google.golang.org/protobuf v1.26.0 + google.golang.org/protobuf v1.27.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.16.9 diff --git a/go.sum b/go.sum index 0a073560a2..6532779bc8 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,9 @@ 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.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -209,6 +210,7 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -231,6 +233,7 @@ github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr6 github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -279,6 +282,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= @@ -316,8 +320,9 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92Bcuy github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= @@ -391,8 +396,9 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV 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/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -553,8 +559,9 @@ github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeD github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= 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_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= 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= @@ -570,8 +577,9 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 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= +github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -580,8 +588,9 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= @@ -674,6 +683,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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= @@ -682,12 +692,16 @@ 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/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/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/6PU= +go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= 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/client/v3 v3.5.0 h1:62Eh0XOro+rDwkrypAGDfgmNh5Joq+z+W9HZdlXMzek= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= 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= @@ -707,15 +721,16 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= 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.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= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -746,8 +761,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -755,8 +770,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -786,8 +801,9 @@ golang.org/x/net v0.0.0-20200602114024-627f9648deb9/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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -801,6 +817,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -846,15 +864,21 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w 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= golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -894,8 +918,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK 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/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -927,8 +951,9 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG 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/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -945,6 +970,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= @@ -959,8 +985,9 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -997,8 +1024,9 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= @@ -1007,7 +1035,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= k8s.io/api v0.16.9 h1:3vCx0WX9qcg1Hv4aQ/G1tiIKectGVuimvPVTJU4VOCA= k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go index 836b43b329..2d83fa3dde 100644 --- a/metadata/report/etcd/report.go +++ b/metadata/report/etcd/report.go @@ -20,7 +20,6 @@ package etcd import ( "encoding/json" "strings" - "time" ) import ( @@ -146,7 +145,7 @@ type etcdMetadataReportFactory struct{} // CreateMetadataReport get the MetadataReport instance of etcd func (e *etcdMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport { - timeout, _ := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) addresses := strings.Split(url.Location, ",") client, err := gxetcd.NewClient(gxetcd.MetadataETCDV3Client, addresses, timeout, 1) if err != nil { diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index 3ab9a2e86a..c77715410b 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -22,7 +22,6 @@ import ( "path" "strings" "sync" - "time" ) import ( @@ -75,12 +74,7 @@ func (r *etcdV3Registry) ClientLock() *sync.Mutex { } func newETCDV3Registry(url *common.URL) (registry.Registry, error) { - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - logger.Errorf("timeout config %v is invalid ,err is %v", - url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), err.Error()) - return nil, perrors.WithMessagef(err, "new etcd registry(address:%+v)", url.Location) - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) logger.Infof("etcd address is: %v, timeout is: %s", url.Location, timeout.String()) diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index b2a966d3ba..15cf134be0 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -102,7 +102,7 @@ func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error common.WithParams(make(url.Values)), common.WithPassword(remoteConfig.Password), common.WithUsername(remoteConfig.Username), - common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, remoteConfig.TimeoutStr)) + common.WithParamsValue(constant.CONFIG_TIMEOUT_KEY, remoteConfig.TimeoutStr)) url.Location = remoteConfig.Address zksd := &zookeeperServiceDiscovery{ url: url, diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go index c42cc93e93..037169f4c2 100644 --- a/remoting/nacos/builder.go +++ b/remoting/nacos/builder.go @@ -68,10 +68,7 @@ func GetNacosConfig(url *common.URL) ([]nacosConstant.ServerConfig, nacosConstan serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{IpAddr: ip, Port: uint64(port)}) } - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - return []nacosConstant.ServerConfig{}, nacosConstant.ClientConfig{}, err - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) clientConfig := nacosConstant.ClientConfig{ TimeoutMs: uint64(int32(timeout / time.Millisecond)), diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go index 959d27e2fe..89992d6cb8 100644 --- a/remoting/nacos/builder_test.go +++ b/remoting/nacos/builder_test.go @@ -19,8 +19,8 @@ package nacos import ( "net/url" - "strconv" "testing" + "time" ) import ( @@ -83,15 +83,54 @@ func TestNewNacosClientByUrl(t *testing.T) { assert.NotNil(t, client) } +func TestTimeoutConfig(t *testing.T) { + regurlMap := url.Values{} + regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true") + // regurlMap.Set(constant.NACOS_USERNAME, "nacos") + // regurlMap.Set(constant.NACOS_PASSWORD, "nacos") + regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos") + + t.Run("default timeout", func(t *testing.T) { + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(10*time.Second/time.Millisecond))) + }) + + t.Run("right timeout", func(t *testing.T) { + + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s") + + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(5*time.Second/time.Millisecond))) + }) + + t.Run("invalid timeout", func(t *testing.T) { + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5ab") + + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(3*time.Second/time.Millisecond))) + }) + +} + func getRegUrl() *common.URL { regurlMap := url.Values{} - regurlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true") // regurlMap.Set(constant.NACOS_USERNAME, "nacos") // regurlMap.Set(constant.NACOS_PASSWORD, "nacos") regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos") - regurlMap.Set(constant.REGISTRY_TIMEOUT_KEY, "5s") + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s") regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 1ed183f375..a324fc7854 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -19,7 +19,6 @@ package zookeeper import ( "strings" - "time" ) import ( @@ -55,12 +54,8 @@ func ValidateZookeeperClient(container ZkClientFacade, zkName string) error { if container.ZkClient() == nil { // in dubbo, every registry only connect one node, so this is []string{r.Address} - timeout, paramErr := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if paramErr != nil { - logger.Errorf("timeout config %v is invalid, err is %v", - url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), paramErr.Error()) - return perrors.WithMessagef(paramErr, "newZookeeperClient(address:%+v)", url.Location) - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) + zkAddresses := strings.Split(url.Location, ",") newClient, cltErr := gxzookeeper.NewZookeeperClient(zkName, zkAddresses, true, gxzookeeper.WithZkTimeOut(timeout)) if cltErr != nil { From 1ac95c70c36f74da8ed052e079b2b8522f7b0ed8 Mon Sep 17 00:00:00 2001 From: AlexStocks Date: Fri, 20 Aug 2021 10:02:36 +0800 Subject: [PATCH 061/148] change dependabot target branch --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6ce0286102..3bd8d9cb19 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" - target-branch: "develop" + target-branch: "3.0" - package-ecosystem: "github-actions" # Workflow files stored in the @@ -17,4 +17,4 @@ updates: directory: "/" schedule: interval: "weekly" - target-branch: "develop" \ No newline at end of file + target-branch: "3.0" From e855fdebfcb5787f0bd44d868b5631a4c3737c5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:21:34 +0800 Subject: [PATCH 062/148] build(deps): bump github.com/fsnotify/fsnotify from 1.4.9 to 1.5.0 (#1400) * 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] * improve etcd version and change create to put (#1203) * build(deps): bump github.com/dubbogo/gost from 1.11.14 to 1.11.16 (#1387) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.14 to 1.11.16. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.14...v1.11.16) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.1 (#1386) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.26.0 to 1.27.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.26.0...v1.27.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump go.etcd.io/etcd/client/v3 from 3.5.0-alpha.0 to 3.5.0 (#1383) Bumps [go.etcd.io/etcd/client/v3](https://github.com/etcd-io/etcd) from 3.5.0-alpha.0 to 3.5.0. - [Release notes](https://github.com/etcd-io/etcd/releases) - [Changelog](https://github.com/etcd-io/etcd/blob/main/CHANGELOG-3.5.md) - [Commits](https://github.com/etcd-io/etcd/compare/v3.5.0-alpha.0...v3.5.0) --- updated-dependencies: - dependency-name: go.etcd.io/etcd/client/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/fsnotify/fsnotify from 1.4.9 to 1.5.0 Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.4.9 to 1.5.0. - [Release notes](https://github.com/fsnotify/fsnotify/releases) - [Changelog](https://github.com/fsnotify/fsnotify/blob/master/CHANGELOG.md) - [Commits](https://github.com/fsnotify/fsnotify/compare/v1.4.9...v1.5.0) --- updated-dependencies: - dependency-name: github.com/fsnotify/fsnotify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 2ac6b3f388..73b7fe4e7f 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/dubbogo/gost v1.11.16 github.com/dubbogo/triple v1.0.5 github.com/emicklei/go-restful/v3 v3.4.0 - github.com/fsnotify/fsnotify v1.4.9 + github.com/fsnotify/fsnotify v1.5.0 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 github.com/go-resty/resty/v2 v2.3.0 diff --git a/go.sum b/go.sum index 6532779bc8..f35822b03e 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/frankban/quicktest v1.10.0 h1:Gfh+GAJZOAoKZsIZeZbdn2JF10kN1XHNvjsvQK8gVkE= github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= 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/fsnotify/fsnotify v1.5.0 h1:NO5hkcB+srp1x6QmwvNZLeaOgbM8cmBTN32THzjvu2k= +github.com/fsnotify/fsnotify v1.5.0/go.mod h1:BX0DCEr5pT4jm2CnQdVP1lFV521fcCNcyEeNp4DQQDk= 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= @@ -846,7 +846,6 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -869,8 +868,9 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 7379c14246410be6026e17b42dc86cb2bd64a70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Fri, 20 Aug 2021 23:41:25 +0800 Subject: [PATCH 063/148] feat: add getUrlMap & replace hump to underscore --- config/logger_config.go | 46 +++++++++++++++++---------- config/root_config.go | 6 ++-- config/testdata/config/logger/log.yml | 36 ++++++++++----------- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/config/logger_config.go b/config/logger_config.go index eb34da10a8..4fa89d6b0c 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -17,6 +17,10 @@ package config +import ( + "net/url" +) + import ( "github.com/creasty/defaults" "go.uber.org/zap" @@ -30,26 +34,27 @@ import ( type LoggerConfig struct { Level string `default:"debug" json:"level" yaml:"level" property:"level"` Development bool `default:"false" json:"development" yaml:"development" property:"development"` - DisableCaller bool `default:"false" json:"disableCaller" yaml:"disableCaller" property:"property"` - DisableStacktrace bool `default:"false" json:"disableStacktrace" yaml:"disableStacktrace" property:"disableStacktrace"` + DisableCaller bool `default:"false" json:"disable_caller" yaml:"disable_caller" property:"disable_caller"` + DisableStacktrace bool `default:"false" json:"disable_stacktrace" yaml:"disable_stacktrace" property:"disable_stacktrace"` Encoding string `default:"console" json:"encoding" yaml:"encoding" property:"encoding"` - EncoderConfig EncoderConfig `default:"" json:"encoderConfig" yaml:"encoderConfig" property:"encoderConfig"` - OutputPaths []string `default:"[\"stderr\"]" json:"outputPaths" yaml:"outputPaths" property:"outputPaths"` - ErrorOutputPaths []string `default:"[\"stderr\"]" json:"errorOutputPaths" yaml:"errorOutputPaths" property:"errorOutputPaths"` - InitialFields map[string]interface{} `default:"" json:"initialFields" yaml:"initialFields" property:"initialFields"` + EncoderConfig EncoderConfig `default:"" json:"encoder_config" yaml:"encoder_config" property:"encoder_config"` + OutputPaths []string `default:"[\"stderr\"]" json:"output_paths" yaml:"output_paths" property:"output_paths"` + ErrorOutputPaths []string `default:"[\"stderr\"]" json:"error_output_paths" yaml:"error_output_paths" property:"error_output_paths"` + InitialFields map[string]interface{} `default:"" json:"initial_fields" yaml:"initial_fields" property:"initial_fields"` } type EncoderConfig struct { - MessageKey string `default:"message" json:"messageKey" yaml:"messageKey" property:"messageKey"` - LevelKey string `default:"level" json:"levelKey" yaml:"levelKey" property:"levelKey"` - TimeKey string `default:"time" json:"timeKey" yaml:"timeKey" property:"timeKey"` - NameKey string `default:"logger" json:"nameKey" yaml:"nameKey" property:"nameKey"` - CallerKey string `default:"caller" json:"callerKey" yaml:"callerKey" property:"callerKey"` - StacktraceKey string `default:"stacktrace" json:"stacktraceKey" yaml:"stacktraceKey" property:"stacktraceKey"` - EncodeLevel string `default:"capitalColor" json:"levelEncoder" yaml:"levelEncoder" property:"levelEncoder"` - EncodeTime string `default:"iso8601" json:"timeEncoder" yaml:"timeEncoder" property:"timeEncoder"` - EncodeDuration string `default:"seconds" json:"durationEncoder" yaml:"durationEncoder" property:"durationEncoder"` - EncodeCaller string `default:"short" json:"callerEncoder" yaml:"callerEncoder" property:"callerEncoder"` + MessageKey string `default:"message" json:"message_key" yaml:"message_key" property:"message_key"` + LevelKey string `default:"level" json:"level_key" yaml:"level_key" property:"level_key"` + TimeKey string `default:"time" json:"time_key" yaml:"time_key" property:"time_key"` + NameKey string `default:"logger" json:"name_key" yaml:"name_key" property:"name_key"` + CallerKey string `default:"caller" json:"caller_key" yaml:"caller_key" property:"caller_key"` + StacktraceKey string `default:"stacktrace" json:"stacktrace_key" yaml:"stacktrace_key" property:"stacktrace_key"` + EncodeLevel string `default:"capitalColor" json:"level_encoder" yaml:"level_encoder" property:"level_encoder"` + EncodeTime string `default:"iso8601" json:"time_encoder" yaml:"time_encoder" property:"time_encoder"` + EncodeDuration string `default:"seconds" json:"duration_encoder" yaml:"duration_encoder" property:"duration_encoder"` + EncodeCaller string `default:"short" json:"caller_encoder" yaml:"caller_encoder" property:"caller_encoder"` + Params map[string]string `yaml:"params" json:"params,omitempty"` } func initLoggerConfig(rc *RootConfig) error { @@ -81,3 +86,12 @@ func (l *LoggerConfig) check() error { } return verify(l) } + +func (l *LoggerConfig) getUrlMap() url.Values { + urlMap := url.Values{} + + for key, val := range l.EncoderConfig.Params { + urlMap.Set(key, val) + } + return urlMap +} diff --git a/config/root_config.go b/config/root_config.go index 74be3cd7a2..93a90bb7e0 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -116,6 +116,9 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { opt.apply(rc) } + if err := initLoggerConfig(rc); err != nil { + return err + } if err := initApplicationConfig(rc); err != nil { return err } @@ -128,9 +131,6 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { if err := initRegistriesConfig(rc); err != nil { return err } - if err := initLoggerConfig(rc); err != nil { - return err - } if err := initServiceDiscoveryConfig(rc); err != nil { return err } diff --git a/config/testdata/config/logger/log.yml b/config/testdata/config/logger/log.yml index 800e18e005..55162b13b7 100644 --- a/config/testdata/config/logger/log.yml +++ b/config/testdata/config/logger/log.yml @@ -11,26 +11,26 @@ dubbo: logger: level: "debug" development: false - disableCaller: false - disableStacktrace: false + disable_caller: false + disable_stacktrace: false sampling: encoding: "console" # encoder - encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - outputPaths: + encoder_config: + message_key: "message" + level_key: "level" + time_key: "time" + name_key: "logger" + caller_key: "caller" + stacktrace_key: "stacktrace" + line_ending: "" + level_encoder: "capitalColor" + time_encoder: "iso8601" + duration_encoder: "seconds" + caller_encoder: "short" + name_encoder: "" + output_paths: - "stderr" - errorOutputPaths: + error_output_paths: - "stderr" - initialFields: + initial_fields: From fb27e5a9934d1aceba37caf10066104e10a50dc9 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 21 Aug 2021 15:08:41 +0800 Subject: [PATCH 064/148] fix: prepare to refactor samples --- config/protocol_config.go | 2 +- config/provider_config.go | 2 +- imports/imports.go | 32 ++++++++++++++++++++++++++++ protocol/grpc/client.go | 10 +++++---- protocol/jsonrpc/jsonrpc_protocol.go | 10 ++++----- protocol/rest/rest_protocol.go | 10 +++++---- 6 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 imports/imports.go diff --git a/config/protocol_config.go b/config/protocol_config.go index 166449bcc5..798ff1e2dd 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -28,7 +28,7 @@ import ( // ProtocolConfig is protocol configuration type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` - Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` + Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"` Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` } diff --git a/config/provider_config.go b/config/provider_config.go index 0632cb8b55..fac9eddafe 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -97,7 +97,7 @@ func (c *ProviderConfig) Prefix() string { } func (c *ProviderConfig) Load() { - + for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { diff --git a/imports/imports.go b/imports/imports.go new file mode 100644 index 0000000000..d093efc9ef --- /dev/null +++ b/imports/imports.go @@ -0,0 +1,32 @@ +package imports + +import ( + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + + _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + + _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" + _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" + _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" + + _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" + + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" + + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" + _ "dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc" + _ "dubbo.apache.org/dubbo-go/v3/protocol/rest" + + _ "dubbo.apache.org/dubbo-go/v3/registry/etcdv3" + _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" + _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" + _ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery" + _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" +) diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 84d812dfe2..bf9e5b993d 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -20,6 +20,7 @@ package grpc import ( "reflect" "strconv" + "time" ) import ( @@ -59,12 +60,12 @@ func init() { if rootConfig.Application == nil { return } - protocolConf := config.GetConsumerConfig().ProtocolConf + protocolConf := config.GetRootConfig().Protocols if protocolConf == nil { logger.Info("protocol_conf default use dubbo config") } else { - grpcConf := protocolConf.(map[interface{}]interface{})[GRPC] + grpcConf := protocolConf[GRPC] if grpcConf == nil { logger.Warnf("grpcConf is nil") return @@ -95,12 +96,13 @@ func NewClient(url *common.URL) (*Client, error) { maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4")) // consumer config client connectTimeout - connectTimeout := config.GetConsumerConfig().ConnectTimeout + //connectTimeout := config.GetConsumerConfig().ConnectTimeout dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), - grpc.WithTimeout(connectTimeout), + // todo config network timeout + grpc.WithTimeout(time.Second*3), grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())), grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(tracer, otgrpc.LogPayloads())), grpc.WithDefaultCallOptions( diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 2792733407..6a2f899dc6 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -25,10 +25,8 @@ import ( import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -77,15 +75,17 @@ func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter { // Refer a remote JSON PRC service from registry func (jp *JsonrpcProtocol) Refer(url *common.URL) protocol.Invoker { // default requestTimeout - requestTimeout := config.GetConsumerConfig().RequestTimeout + // todo config timeout + requestTimeout := time.Duration(3 * time.Second) //config.GetConsumerConfig().RequestTimeout - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) + // todo config timeout + requestTimeoutStr := "3s" //url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) if t, err := time.ParseDuration(requestTimeoutStr); err == nil { requestTimeout = t } invoker := NewJsonrpcInvoker(url, NewHTTPClient(&HTTPOptions{ - HandshakeTimeout: config.GetConsumerConfig().ConnectTimeout, + HandshakeTimeout: time.Second, // todo config timeout config.GetConsumerConfig().ConnectTimeout, HTTPTimeout: requestTimeout, })) jp.SetInvokers(invoker) diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index d0046a2413..476a9fe6f1 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -27,7 +27,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" _ "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" @@ -86,9 +85,12 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter { // Refer create rest service reference func (rp *RestProtocol) Refer(url *common.URL) protocol.Invoker { // create rest_invoker - requestTimeout := config.GetConsumerConfig().RequestTimeout - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) - connectTimeout := config.GetConsumerConfig().ConnectTimeout + // todo fix timeout config + // start + requestTimeout := time.Duration(3 * time.Second) + requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, "3s") + connectTimeout := requestTimeout // config.GetConsumerConfig().ConnectTimeout + // end if t, err := time.ParseDuration(requestTimeoutStr); err == nil { requestTimeout = t } From 8cb93935d529edcfb3c52c54da6db5d493ca0aa0 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 21 Aug 2021 15:10:19 +0800 Subject: [PATCH 065/148] fix: prepare to refactor samples (#1407) --- config/protocol_config.go | 2 +- config/provider_config.go | 2 +- imports/imports.go | 32 ++++++++++++++++++++++++++++ protocol/grpc/client.go | 10 +++++---- protocol/jsonrpc/jsonrpc_protocol.go | 10 ++++----- protocol/rest/rest_protocol.go | 10 +++++---- 6 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 imports/imports.go diff --git a/config/protocol_config.go b/config/protocol_config.go index 166449bcc5..798ff1e2dd 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -28,7 +28,7 @@ import ( // ProtocolConfig is protocol configuration type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` - Ip string `default:"127.0.0.1" yaml:"ip" json:"ip,omitempty" property:"ip"` + Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"` Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` } diff --git a/config/provider_config.go b/config/provider_config.go index 0632cb8b55..fac9eddafe 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -97,7 +97,7 @@ func (c *ProviderConfig) Prefix() string { } func (c *ProviderConfig) Load() { - + for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { diff --git a/imports/imports.go b/imports/imports.go new file mode 100644 index 0000000000..d093efc9ef --- /dev/null +++ b/imports/imports.go @@ -0,0 +1,32 @@ +package imports + +import ( + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + + _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + + _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" + _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" + _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" + + _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" + + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" + _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" + + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" + _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" + _ "dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc" + _ "dubbo.apache.org/dubbo-go/v3/protocol/rest" + + _ "dubbo.apache.org/dubbo-go/v3/registry/etcdv3" + _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" + _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" + _ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery" + _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" +) diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 84d812dfe2..bf9e5b993d 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -20,6 +20,7 @@ package grpc import ( "reflect" "strconv" + "time" ) import ( @@ -59,12 +60,12 @@ func init() { if rootConfig.Application == nil { return } - protocolConf := config.GetConsumerConfig().ProtocolConf + protocolConf := config.GetRootConfig().Protocols if protocolConf == nil { logger.Info("protocol_conf default use dubbo config") } else { - grpcConf := protocolConf.(map[interface{}]interface{})[GRPC] + grpcConf := protocolConf[GRPC] if grpcConf == nil { logger.Warnf("grpcConf is nil") return @@ -95,12 +96,13 @@ func NewClient(url *common.URL) (*Client, error) { maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4")) // consumer config client connectTimeout - connectTimeout := config.GetConsumerConfig().ConnectTimeout + //connectTimeout := config.GetConsumerConfig().ConnectTimeout dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), - grpc.WithTimeout(connectTimeout), + // todo config network timeout + grpc.WithTimeout(time.Second*3), grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())), grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(tracer, otgrpc.LogPayloads())), grpc.WithDefaultCallOptions( diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 2792733407..6a2f899dc6 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -25,10 +25,8 @@ import ( import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -77,15 +75,17 @@ func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter { // Refer a remote JSON PRC service from registry func (jp *JsonrpcProtocol) Refer(url *common.URL) protocol.Invoker { // default requestTimeout - requestTimeout := config.GetConsumerConfig().RequestTimeout + // todo config timeout + requestTimeout := time.Duration(3 * time.Second) //config.GetConsumerConfig().RequestTimeout - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) + // todo config timeout + requestTimeoutStr := "3s" //url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) if t, err := time.ParseDuration(requestTimeoutStr); err == nil { requestTimeout = t } invoker := NewJsonrpcInvoker(url, NewHTTPClient(&HTTPOptions{ - HandshakeTimeout: config.GetConsumerConfig().ConnectTimeout, + HandshakeTimeout: time.Second, // todo config timeout config.GetConsumerConfig().ConnectTimeout, HTTPTimeout: requestTimeout, })) jp.SetInvokers(invoker) diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index d0046a2413..476a9fe6f1 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -27,7 +27,6 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" _ "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" @@ -86,9 +85,12 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter { // Refer create rest service reference func (rp *RestProtocol) Refer(url *common.URL) protocol.Invoker { // create rest_invoker - requestTimeout := config.GetConsumerConfig().RequestTimeout - requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout) - connectTimeout := config.GetConsumerConfig().ConnectTimeout + // todo fix timeout config + // start + requestTimeout := time.Duration(3 * time.Second) + requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, "3s") + connectTimeout := requestTimeout // config.GetConsumerConfig().ConnectTimeout + // end if t, err := time.ParseDuration(requestTimeoutStr); err == nil { requestTimeout = t } From 186dc226453baba705a63d93ea2627d5e052dec6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Aug 2021 22:08:19 +0800 Subject: [PATCH 066/148] build(deps): bump github.com/emicklei/go-restful/v3 from 3.4.0 to 3.5.2 (#1403) Bumps [github.com/emicklei/go-restful/v3](https://github.com/emicklei/go-restful) from 3.4.0 to 3.5.2. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v3.4.0...v3.5.2) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 73b7fe4e7f..cebfe086d5 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 github.com/dubbogo/triple v1.0.5 - github.com/emicklei/go-restful/v3 v3.4.0 + github.com/emicklei/go-restful/v3 v3.5.2 github.com/fsnotify/fsnotify v1.5.0 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 diff --git a/go.sum b/go.sum index f35822b03e..8e77f8230a 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0 h1:IIDhql3oyWZj1ay2xBZGb4sTOWMad0HVW8rwhVxN/Yk= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.5.2 h1:RCNMSbcGIVafG4ZfgIXIEHTaV59ZRsi41IvZ7RC9+ls= +github.com/emicklei/go-restful/v3 v3.5.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= From 06db69b6077b0e6c9bf366df6dc80f662a95e7ee Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 22 Aug 2021 12:50:00 +0800 Subject: [PATCH 067/148] fix: config-center init two times bug --- config/application_config.go | 14 +++++--------- config/config_center_config.go | 9 ++++----- config/root_config.go | 5 ++--- remoting/nacos/builder.go | 17 +++++------------ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 726802fde6..0f41e12fc2 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -39,20 +39,16 @@ func (ApplicationConfig) Prefix() string { return constant.DUBBO + ".application" } -func initApplicationConfig(rc *RootConfig) error { +func (ac *ApplicationConfig) Init(rc *RootConfig) error { // ignore refresh action - if rc.refresh { + if rc.refresh || ac == nil { + rootConfig.Application = new(ApplicationConfig) return nil } - application := rc.Application - if application == nil { - application = new(ApplicationConfig) - } - defaults.MustSet(application) - if err := application.check(); err != nil { + defaults.MustSet(ac) + if err := ac.check(); err != nil { return err } - rc.Application = application return nil } diff --git a/config/config_center_config.go b/config/config_center_config.go index d4e11429a4..24eff5ec4b 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -78,12 +78,11 @@ func (c *CenterConfig) check() error { return verify(c) } -func initConfigCenter(rc *RootConfig) error { - center := rc.ConfigCenter - if center == nil || rc.refresh { +func (c *CenterConfig) Init(rc *RootConfig) error { + if rc.refresh || c == nil { return nil } - if err := center.check(); err != nil { + if err := c.check(); err != nil { return err } return startConfigCenter(rc) @@ -168,7 +167,7 @@ func startConfigCenter(rc *RootConfig) error { } rc.refresh = false rc.ConfigCenter = nil - return rc.InitConfig() + return nil } func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, error) { diff --git a/config/root_config.go b/config/root_config.go index 74be3cd7a2..e292f691f5 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -115,11 +115,10 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { for _, opt := range opts { opt.apply(rc) } - - if err := initApplicationConfig(rc); err != nil { + if err := rc.ConfigCenter.Init(rc); err != nil { return err } - if err := initConfigCenter(rc); err != nil { + if err := rc.Application.Init(rc); err != nil { return err } if err := initProtocolsConfig(rc); err != nil { diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go index c42cc93e93..fbc5d185c7 100644 --- a/remoting/nacos/builder.go +++ b/remoting/nacos/builder.go @@ -36,13 +36,15 @@ import ( "dubbo.apache.org/dubbo-go/v3/config" ) +const nacosClientName = "nacos-client" + // NewNacosConfigClientByUrl read the config from url and build an instance func NewNacosConfigClientByUrl(url *common.URL) (*nacosClient.NacosConfigClient, error) { sc, cc, err := GetNacosConfig(url) if err != nil { return nil, err } - return nacosClient.NewNacosConfigClient(getNacosClientName(), true, sc, cc) + return nacosClient.NewNacosConfigClient(nacosClientName, true, sc, cc) } // GetNacosConfig will return the nacos config @@ -105,7 +107,7 @@ func NewNacosClient(rc *config.RemoteConfig) (*nacosClient.NacosNamingClient, er if err != nil { return nil, err } - return nacosClient.NewNacosNamingClient(getNacosClientName(), true, scs, cc) + return nacosClient.NewNacosNamingClient(nacosClientName, true, scs, cc) } // NewNacosClientByUrl created @@ -114,14 +116,5 @@ func NewNacosClientByUrl(url *common.URL) (*nacosClient.NacosNamingClient, error if err != nil { return nil, err } - return nacosClient.NewNacosNamingClient(getNacosClientName(), true, scs, cc) -} - -// getNacosClientName get nacos client name -func getNacosClientName() string { - name := config.GetApplicationConfig().Name - if len(name) > 0 { - return name - } - return "nacos-client" + return nacosClient.NewNacosNamingClient(nacosClientName, true, scs, cc) } From eb56cfbf828ee3e16667f7965f4d8b3ff5282418 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 22 Aug 2021 16:22:10 +0800 Subject: [PATCH 068/148] fix: some bugs of 3.0 config samples --- config/config_api.go | 6 +- config/config_api_test.go | 4 +- config/config_center_config.go | 64 +++++++ config/config_loader.go | 4 +- config/protocol_config.go | 2 + config/provider_config.go | 6 +- config/reference_config.go | 8 +- config/registry_config.go | 173 ++++++++++++++++++ config/root_config.go | 129 ++++++++----- config/service_config.go | 31 +--- go.mod | 4 +- go.sum | 3 + .../service/exporter/configurable/exporter.go | 5 +- 13 files changed, 353 insertions(+), 86 deletions(-) diff --git a/config/config_api.go b/config/config_api.go index ebcabd4ab0..9ef2c667aa 100644 --- a/config/config_api.go +++ b/config/config_api.go @@ -44,11 +44,11 @@ package config // defaultRegistryTimeout = "3s" //) // -//// NewDefaultRegistryConfig New default registry config +//// NewRegistryConfigWithProtocolDefaultPort New default registry config //// the input @protocol can only be: //// "zookeeper" with default addr "127.0.0.1:2181" //// "nacos" with default addr "127.0.0.1:8848" -//func NewDefaultRegistryConfig(protocol string) *registry.RegistryConfig { +//func NewRegistryConfigWithProtocolDefaultPort(protocol string) *registry.RegistryConfig { // switch protocol { // case "zookeeper": // return ®istry.RegistryConfig{ @@ -74,7 +74,7 @@ package config // //// NewRegistryConfig creates New RegistryConfig with @opts //func NewRegistryConfig(opts ...RegistryConfigOpt) *registry.RegistryConfig { -// newRegistryConfig := NewDefaultRegistryConfig("") +// newRegistryConfig := NewRegistryConfigWithProtocolDefaultPort("") // for _, v := range opts { // newRegistryConfig = v(newRegistryConfig) // } diff --git a/config/config_api_test.go b/config/config_api_test.go index 65899edbad..ade90325bc 100644 --- a/config/config_api_test.go +++ b/config/config_api_test.go @@ -95,7 +95,7 @@ package config // WithReferenceProtocol("test-protocol"), // WithReferenceRegistry("test-registry"), // ) -// defaultZKRegistry := NewDefaultRegistryConfig("zookeeper") +// defaultZKRegistry := NewRegistryConfigWithProtocolDefaultPort("zookeeper") // assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr) // assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper") // assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout) @@ -129,7 +129,7 @@ package config // WithServiceWarmUpTime("test-warmup"), // ) // -// defaultNacosRegistry := NewDefaultRegistryConfig("nacos") +// defaultNacosRegistry := NewRegistryConfigWithProtocolDefaultPort("nacos") // assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr) // assert.Equal(t, defaultNacosRegistry.Protocol, "nacos") // assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout) diff --git a/config/config_center_config.go b/config/config_center_config.go index 24eff5ec4b..6a03345bb7 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -75,6 +75,9 @@ func (c *CenterConfig) check() error { return err } c.translateConfigAddress() + if c.Address == "" || c.Protocol == "" { + return errors.Errorf("invalid config center config %+v", c) + } return verify(c) } @@ -221,3 +224,64 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, // envInstance.UpdateAppExternalConfigMap(appMapContent) //} } + +type CenterConfigOpt func(config *CenterConfig) + +func NewConfigCenterConfig(opts ...CenterConfigOpt) *CenterConfig { + centerConfig := &CenterConfig{ + Params: make(map[string]string), + } + for _, o := range opts { + o(centerConfig) + } + return centerConfig +} + +// WithConfigCenterProtocol set ProtocolConfig with given protocolName protocol +func WithConfigCenterProtocol(protocol string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Protocol = protocol + } +} + +// WithConfigCenterAddress set ProtocolConfig with given @addr +func WithConfigCenterAddress(addr string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Address = addr + } +} + +// WithConfigCenterDataID set ProtocolConfig with given @dataID +func WithConfigCenterDataID(dataID string) CenterConfigOpt { + return func(config *CenterConfig) { + config.DataId = dataID + } +} + +// WithConfigCenterGroup set ProtocolConfig with given @group +func WithConfigCenterGroup(group string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Group = group + } +} + +// WithConfigCenterUsername set ProtocolConfig with given @username +func WithConfigCenterUsername(username string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Username = username + } +} + +// WithConfigCenterPassword set ProtocolConfig with given @password +func WithConfigCenterPassword(password string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Password = password + } +} + +// WithConfigCenterNamespace set ProtocolConfig with given @namespace +func WithConfigCenterNamespace(namespace string) CenterConfigOpt { + return func(config *CenterConfig) { + config.Namespace = namespace + } +} diff --git a/config/config_loader.go b/config/config_loader.go index 67c163670e..c9cd5b58b0 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -61,7 +61,7 @@ func Load(opts ...LoaderConfOption) error { } rootConfig.refresh = false extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) - if err := rootConfig.InitConfig(); err != nil { + if err := rootConfig.Init(); err != nil { return err } registerServiceInstance() @@ -428,7 +428,7 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) { // } //} // -//// Load Dubbo InitConfig +//// Load Dubbo Init //func Load() { // options := DefaultInit() // LoadWithOptions(options...) diff --git a/config/protocol_config.go b/config/protocol_config.go index 798ff1e2dd..11eeb7b3ac 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -74,6 +74,8 @@ func NewProtocolConfig(opts ...ProtocolConfigOpt) *ProtocolConfig { type ProtocolConfigOpt func(config *ProtocolConfig) *ProtocolConfig +// WithProtocolIP set ProtocolConfig with given binding @ip +// Deprecated: the param @ip would be used as service lisener binding and would be registered to registry center func WithProtocolIP(ip string) ProtocolConfigOpt { return func(config *ProtocolConfig) *ProtocolConfig { config.Ip = ip diff --git a/config/provider_config.go b/config/provider_config.go index fac9eddafe..c5bc7877dc 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -177,15 +177,15 @@ func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { } // WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -func WithProviderServices(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { +func WithProviderService(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { return func(config *ProviderConfig) *ProviderConfig { config.Services[serviceName] = serviceConfig return config } } -// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig -func WithProviderRegistry(registryKey ...string) ProviderConfigOpt { +// WithProviderRegistryKeys returns ProviderConfigOpt with given @registryKey and registry @registryConfig +func WithProviderRegistryKeys(registryKey ...string) ProviderConfigOpt { return func(config *ProviderConfig) *ProviderConfig { config.Registry = append(config.Registry, registryKey...) return config diff --git a/config/reference_config.go b/config/reference_config.go index 9022fcb3c8..ec6e9457db 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -327,15 +327,15 @@ func NewReferenceConfig(opts ...ReferenceConfigOpt) *ReferenceConfig { } // WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry -func WithReferenceRegistry(registry ...string) ReferenceConfigOpt { +func WithReferenceRegistry(registryKeys ...string) ReferenceConfigOpt { return func(config *ReferenceConfig) *ReferenceConfig { - config.Registry = registry + config.Registry = registryKeys return config } } -// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol -func WithReferenceProtocol(protocol string) ReferenceConfigOpt { +// WithReferenceProtocolName returns ReferenceConfigOpt with given protocolName: @protocol +func WithReferenceProtocolName(protocol string) ReferenceConfigOpt { return func(config *ReferenceConfig) *ReferenceConfig { config.Protocol = protocol return config diff --git a/config/registry_config.go b/config/registry_config.go index 4e787a9cce..4421fc70b3 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -18,6 +18,7 @@ package config import ( + "dubbo.apache.org/dubbo-go/v3/registry" "net/url" "strconv" "strings" @@ -31,6 +32,7 @@ import ( import ( "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" ) @@ -116,3 +118,174 @@ func (c *RegistryConfig) translateRegistryAddress() string { } return c.Address } + +func (c *RegistryConfig) GetInstance(roleType common.RoleType) (registry.Registry, error) { + url, err := c.toURL(roleType) + if err != nil { + return nil, err + } + // if the protocol == registry, set protocol the registry value in url.params + if url.Protocol == constant.REGISTRY_PROTOCOL { + url.Protocol = url.GetParam(constant.REGISTRY_KEY, "") + } + return extension.GetRegistry(url.Protocol, url) +} + +func (c *RegistryConfig) toURL(roleType common.RoleType) (*common.URL, error) { + addresses := strings.Split(c.Address, ",") + address := addresses[0] + address = c.translateRegistryAddress() + var registryURLProtocol string + if c.RegistryType == "service" { + // service discovery protocol + registryURLProtocol = constant.SERVICE_REGISTRY_PROTOCOL + } else { + registryURLProtocol = constant.REGISTRY_PROTOCOL + } + return common.NewURL(registryURLProtocol+"://"+address, + common.WithParams(c.getUrlMap(roleType)), + common.WithParamsValue(constant.SIMPLIFIED_KEY, strconv.FormatBool(c.Simplified)), + common.WithParamsValue(constant.REGISTRY_KEY, c.Protocol), + common.WithParamsValue(constant.GROUP_KEY, c.Group), + common.WithParamsValue(constant.NAMESPACE_KEY, c.Namespace), + common.WithUsername(c.Username), + common.WithPassword(c.Password), + common.WithLocation(c.Address), + ) +} + +///////////////////////////////////// registry config api +const ( + // defaultZKAddr is the default registry address of zookeeper + defaultZKAddr = "127.0.0.1:2181" + + // defaultNacosAddr is the default registry address of nacos + defaultNacosAddr = "127.0.0.1:8848" + + // defaultRegistryTimeout is the default registry timeout + defaultRegistryTimeout = "3s" +) + +type RegistryConfigOpt func(config *RegistryConfig) *RegistryConfig + +// NewRegistryConfigWithProtocolDefaultPort New default registry config +// the input @protocol can only be: +// "zookeeper" with default addr "127.0.0.1:2181" +// "nacos" with default addr "127.0.0.1:8848" +func NewRegistryConfigWithProtocolDefaultPort(protocol string) *RegistryConfig { + switch protocol { + case "zookeeper": + return &RegistryConfig{ + Protocol: protocol, + Address: defaultZKAddr, + Timeout: defaultRegistryTimeout, + } + case "nacos": + return &RegistryConfig{ + Protocol: protocol, + Address: defaultNacosAddr, + Timeout: defaultRegistryTimeout, + } + default: + return &RegistryConfig{ + Protocol: protocol, + } + } +} + +// NewRegistryConfig creates New RegistryConfig with @opts +func NewRegistryConfig(opts ...RegistryConfigOpt) *RegistryConfig { + newRegistryConfig := NewRegistryConfigWithProtocolDefaultPort("") + for _, v := range opts { + newRegistryConfig = v(newRegistryConfig) + } + return newRegistryConfig +} + +// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name +func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Protocol = regProtocol + return config + } +} + +// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address +func WithRegistryAddress(addr string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Address = addr + return config + } +} + +// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config +func WithRegistryTimeOut(timeout string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Timeout = timeout + return config + } +} + +// WithRegistryGroup returns RegistryConfigOpt with given @group registry group +func WithRegistryGroup(group string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Group = group + return config + } +} + +// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl +func WithRegistryTTL(ttl string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.TTL = ttl + return config + } +} + +// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName +func WithRegistryUserName(userName string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Username = userName + return config + } +} + +// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password +func WithRegistryPassword(psw string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Password = psw + return config + } +} + +// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag +func WithRegistrySimplified(simplified bool) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Simplified = simplified + return config + } +} + +// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag +func WithRegistryPreferred(preferred bool) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Preferred = preferred + return config + } +} + +// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag +func WithRegistryWeight(weight int64) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Weight = weight + return config + } +} + +// WithRegistryParams returns RegistryConfigOpt with given registry @params +func WithRegistryParams(params map[string]string) RegistryConfigOpt { + return func(config *RegistryConfig) *RegistryConfig { + config.Params = params + return config + } +} diff --git a/config/root_config.go b/config/root_config.go index e292f691f5..c581b83d33 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -19,6 +19,7 @@ package config import ( "bytes" + "dubbo.apache.org/dubbo-go/v3/common/logger" ) import ( @@ -81,42 +82,15 @@ func SetRootConfig(r RootConfig) { rootConfig = &r } -func NewRootConfig() *RootConfig { - return &RootConfig{ - ConfigCenter: &CenterConfig{}, - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReportConfig: &MetadataReportConfig{}, - Application: &ApplicationConfig{}, - Registries: make(map[string]*RegistryConfig), - Protocols: make(map[string]*ProtocolConfig), - Provider: NewProviderConfig(), - Consumer: NewConsumerConfig(), - MetricConfig: &MetricConfig{}, - } -} - -type rootConfOption interface { - apply(vc *RootConfig) -} - -type RootConfFunc func(*RootConfig) - -func (fn RootConfFunc) apply(vc *RootConfig) { - fn(vc) -} - // Prefix dubbo func (RootConfig) Prefix() string { return constant.DUBBO } -// InitConfig init config -func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { - for _, opt := range opts { - opt.apply(rc) - } +// Init init config +func (rc *RootConfig) Init() error { if err := rc.ConfigCenter.Init(rc); err != nil { - return err + logger.Info("config center doesn't start.") } if err := rc.Application.Init(rc); err != nil { return err @@ -155,18 +129,6 @@ func (rc *RootConfig) InitConfig(opts ...rootConfOption) error { return nil } -func WithApplication(ac *ApplicationConfig) RootConfFunc { - return RootConfFunc(func(conf *RootConfig) { - conf.Application = ac - }) -} - -func WithProtocols(protocols map[string]*ProtocolConfig) RootConfFunc { - return RootConfFunc(func(conf *RootConfig) { - conf.Protocols = protocols - }) -} - //func (rc *RootConfig) CheckConfig() error { // defaults.MustSet(rc) // @@ -347,3 +309,86 @@ func GetApplicationConfig() *ApplicationConfig { // } // return removeDuplicateElement(ids) //} + +func NewRootConfig(opts ...RootConfigOpt) *RootConfig { + newRootConfig := &RootConfig{ + ConfigCenter: &CenterConfig{}, + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReportConfig: &MetadataReportConfig{}, + Application: &ApplicationConfig{}, + Registries: make(map[string]*RegistryConfig), + Protocols: make(map[string]*ProtocolConfig), + Provider: NewProviderConfig(), + Consumer: NewConsumerConfig(), + MetricConfig: &MetricConfig{}, + } + for _, o := range opts { + o(newRootConfig) + } + return newRootConfig +} + +type RootConfigOpt func(config *RootConfig) + +// WithMetricsConfig set root config with given @metricsConfig +func WithMetricsConfig(metricsConfig *MetricConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.MetricConfig = metricsConfig + } +} + +// WithRootConsumerConfig set root config with given @consumerConfig +func WithRootConsumerConfig(consumerConfig *ConsumerConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.Consumer = consumerConfig + } +} + +// WithRootProviderConfig set root config with given @providerConfig +func WithRootProviderConfig(providerConfig *ProviderConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.Provider = providerConfig + } +} + +// WithRootProtocolConfig set root config with key @protocolName and given @protocolConfig +func WithRootProtocolConfig(protocolName string, protocolConfig *ProtocolConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.Protocols[protocolName] = protocolConfig + } +} + +// WithRootRegistryConfig set root config with key @registryKey and given @regConfig +func WithRootRegistryConfig(registryKey string, regConfig *RegistryConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.Registries[registryKey] = regConfig + } +} + +// WithRootApplicationConfig set root config with given @appConfig +func WithRootApplicationConfig(appConfig *ApplicationConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.Application = appConfig + } +} + +// WithRootMetadataReportConfig set root config with given @metadataReportConfig +func WithRootMetadataReportConfig(metadataReportConfig *MetadataReportConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.MetadataReportConfig = metadataReportConfig + } +} + +// WithRootServiceDiscoverConfig set root config with given @serviceDiscConfig and key @name +func WithRootServiceDiscoverConfig(name string, serviceDiscConfig *ServiceDiscoveryConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.ServiceDiscoveries[name] = serviceDiscConfig + } +} + +// WithRootCenterConfig set root config with given centerConfig +func WithRootCenterConfig(centerConfig *CenterConfig) RootConfigOpt { + return func(rc *RootConfig) { + rc.ConfigCenter = centerConfig + } +} diff --git a/config/service_config.go b/config/service_config.go index ba0bccba83..1ca3e9ef41 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -343,28 +343,7 @@ func loadRegistries(registryIds []string, registries map[string]*RegistryConfig, } if target { - addresses := strings.Split(registryConf.Address, ",") - address := addresses[0] - address = registryConf.translateRegistryAddress() - var registryURLProtocol string - if registryConf.RegistryType == "service" { - // service discovery protocol - registryURLProtocol = constant.SERVICE_REGISTRY_PROTOCOL - } else { - registryURLProtocol = constant.REGISTRY_PROTOCOL - } - registryURL, err := common.NewURL(registryURLProtocol+"://"+address, - common.WithParams(registryConf.getUrlMap(roleType)), - common.WithParamsValue(constant.SIMPLIFIED_KEY, strconv.FormatBool(registryConf.Simplified)), - common.WithParamsValue(constant.REGISTRY_KEY, registryConf.Protocol), - common.WithParamsValue(constant.GROUP_KEY, registryConf.Group), - common.WithParamsValue(constant.NAMESPACE_KEY, registryConf.Namespace), - common.WithUsername(registryConf.Username), - common.WithPassword(registryConf.Password), - common.WithLocation(registryConf.Address), - ) - - if err != nil { + if registryURL, err := registryConf.toURL(roleType); err != nil { logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) panic(err) } else { @@ -536,10 +515,10 @@ func WithServiceRegistry(registry string) ServiceConfigOpt { } } -// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol -func WithServiceProtocol(protocol string) ServiceConfigOpt { +// WithServiceProtocolKeys returns ServiceConfigOpt with given protocolKey @protocol +func WithServiceProtocolKeys(protocolKeys ...string) ServiceConfigOpt { return func(config *ServiceConfig) *ServiceConfig { - config.Protocol = append(config.Protocol, protocol) + config.Protocol = protocolKeys return config } } @@ -596,7 +575,7 @@ func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { } } -func WithServiceProtocols(protocolName string, protocolConfig *ProtocolConfig) ServiceConfigOpt { +func WithServiceProtocol(protocolName string, protocolConfig *ProtocolConfig) ServiceConfigOpt { return func(config *ServiceConfig) *ServiceConfig { config.Protocols[protocolName] = protocolConfig return config diff --git a/go.mod b/go.mod index 1fa906227c..4f3c85b55c 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.13 - github.com/dubbogo/triple v1.0.1 + github.com/dubbogo/gost v1.11.16 + github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df github.com/emicklei/go-restful/v3 v3.4.0 github.com/frankban/quicktest v1.4.1 // indirect github.com/fsnotify/fsnotify v1.4.9 diff --git a/go.sum b/go.sum index 5411fce5c6..4bcd6f23e0 100644 --- a/go.sum +++ b/go.sum @@ -130,11 +130,14 @@ github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fAD github.com/dubbogo/gost v1.10.1/go.mod h1:+mQGS51XQEUWZP2JeGZTxJwipjRKtJO7Tr+FOg+72rI= github.com/dubbogo/gost v1.11.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= github.com/dubbogo/triple v1.0.1 h1:fdBkXTR0I4UBBCDcN+k22uJWU338ZK5mvOPpIBIL5h8= github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= +github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df h1:YSfvAnU0ebwLqWnD+5HTTsFhqA+aE4Si2c10zBsUW7c= +github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 3653c52202..65f9f8e68f 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -58,8 +58,9 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { defer exporter.lock.Unlock() exporter.ServiceConfig = config.NewServiceConfig( config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME), - config.WithServiceProtocol(constant.DEFAULT_PROTOCOL), - config.WithServiceProtocols(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( + config.WithServiceProtocolKeys(constant.DEFAULT_PROTOCOL), + config.WithServiceProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( + config.WithProtocolName(constant.DEFAULT_PROTOCOL), config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)), )), config.WithServiceRegistry("N/A"), From 1bfface3303e172cb2ee6e4976bb8f269dd74c42 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 22 Aug 2021 16:24:25 +0800 Subject: [PATCH 069/148] fix: run tidy --- go.sum | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/go.sum b/go.sum index 4bcd6f23e0..231e6682c9 100644 --- a/go.sum +++ b/go.sum @@ -128,14 +128,11 @@ 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.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= -github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.1 h1:fdBkXTR0I4UBBCDcN+k22uJWU338ZK5mvOPpIBIL5h8= -github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df h1:YSfvAnU0ebwLqWnD+5HTTsFhqA+aE4Si2c10zBsUW7c= github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= From 6c3e38b768013b1fd04c970938976857ecc5382f Mon Sep 17 00:00:00 2001 From: Changeden Date: Tue, 24 Aug 2021 09:14:22 +0800 Subject: [PATCH 070/148] =?UTF-8?q?=E6=9B=B4=E6=96=B0TCP=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=9C=80=E5=B0=8F=E5=80=BC=E5=91=BD=E5=90=8D?= =?UTF-8?q?;=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E6=AF=94=E8=BE=83;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remoting/getty/config.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index d713b7c8aa..9971d5c218 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -30,7 +30,7 @@ import ( ) const ( - TCP_READ_WRITE_TIMEOUT_MIN_VALUE = time.Second * 1 + TCPReadWriteTimeoutMinValue = time.Second * 1 ) type ( @@ -166,12 +166,11 @@ func (c *GettySessionParam) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(KeepAlivePeriod{%#v})", c.KeepAlivePeriod) } - var tcpTimeoutMinVal = TCP_READ_WRITE_TIMEOUT_MIN_VALUE - if c.tcpReadTimeout, err = parseTimeDurationByRange(c.TcpReadTimeout, &tcpTimeoutMinVal, nil); err != nil { + if c.tcpReadTimeout, err = parseTcpTimeoutDuration(c.TcpReadTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpReadTimeout{%#v})", c.TcpReadTimeout) } - if c.tcpWriteTimeout, err = parseTimeDurationByRange(c.TcpWriteTimeout, &tcpTimeoutMinVal, nil); err != nil { + if c.tcpWriteTimeout, err = parseTcpTimeoutDuration(c.TcpWriteTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpWriteTimeout{%#v})", c.TcpWriteTimeout) } @@ -182,19 +181,13 @@ func (c *GettySessionParam) CheckValidity() error { return nil } -func parseTimeDurationByRange(timeStr string, min *time.Duration, max *time.Duration) (time.Duration, error) { +func parseTcpTimeoutDuration(timeStr string) (time.Duration, error) { result, err := time.ParseDuration(timeStr) if err != nil { - return *min, err + return 0, err } - if min != nil && max != nil && *min > *max { // swap - min, max = max, min - } - if min != nil && result < *min { - result = *min - } - if max != nil && result > *max { - result = *max + if result < TCPReadWriteTimeoutMinValue { + return TCPReadWriteTimeoutMinValue, nil } return result, nil } From 3ac2f1cbf67de9c7553ec25aca853f23ec64a8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Wed, 25 Aug 2021 08:36:17 +0800 Subject: [PATCH 071/148] del protoc-gen-dubbo3 & protoc-gen-dubbo (#1313) --- .../protoc-gen-dubbo3/examples/Makefile | 19 - .../examples/helloworld.pb.go | 326 ----- .../examples/helloworld.proto | 40 - protocol/dubbo3/protoc-gen-dubbo3/go.mod | 11 - protocol/dubbo3/protoc-gen-dubbo3/go.sum | 1092 ----------------- protocol/dubbo3/protoc-gen-dubbo3/main.go | 71 -- .../protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go | 372 ------ protocol/grpc/protoc-gen-dubbo/main.go | 74 -- .../grpc/protoc-gen-dubbo/plugin/dubbo/doc.go | 19 - 9 files changed, 2024 deletions(-) delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/go.mod delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/go.sum delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/main.go delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go delete mode 100644 protocol/grpc/protoc-gen-dubbo/main.go delete mode 100644 protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile b/protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile deleted file mode 100644 index b84a6da4bf..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile +++ /dev/null @@ -1,19 +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. - -grpc-gen: - protoc -I ./ helloworld.proto --go_out=plugins=grpc:. -dubbo3-gen: - protoc -I ./ helloworld.proto --dubbo3_out=plugins=grpc+dubbo:. diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go deleted file mode 100644 index 1d2fe7fc45..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go +++ /dev/null @@ -1,326 +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. - */ - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: helloworld.proto - -package main - -import ( - context "context" - fmt "fmt" - math "math" -) - -import ( - tripleConstant "github.com/dubbogo/triple/pkg/common/constant" - dubbo3 "github.com/dubbogo/triple/pkg/triple" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/protocol" - dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// The request message containing the user's name. -type HelloRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HelloRequest) Reset() { *m = HelloRequest{} } -func (m *HelloRequest) String() string { return proto.CompactTextString(m) } -func (*HelloRequest) ProtoMessage() {} -func (*HelloRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_17b8c58d586b62f2, []int{0} -} - -func (m *HelloRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloRequest.Unmarshal(m, b) -} -func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic) -} -func (m *HelloRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloRequest.Merge(m, src) -} -func (m *HelloRequest) XXX_Size() int { - return xxx_messageInfo_HelloRequest.Size(m) -} -func (m *HelloRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HelloRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloRequest proto.InternalMessageInfo - -func (m *HelloRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HelloReply) Reset() { *m = HelloReply{} } -func (m *HelloReply) String() string { return proto.CompactTextString(m) } -func (*HelloReply) ProtoMessage() {} -func (*HelloReply) Descriptor() ([]byte, []int) { - return fileDescriptor_17b8c58d586b62f2, []int{1} -} - -func (m *HelloReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloReply.Unmarshal(m, b) -} -func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic) -} -func (m *HelloReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloReply.Merge(m, src) -} -func (m *HelloReply) XXX_Size() int { - return xxx_messageInfo_HelloReply.Size(m) -} -func (m *HelloReply) XXX_DiscardUnknown() { - xxx_messageInfo_HelloReply.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloReply proto.InternalMessageInfo - -func (m *HelloReply) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func init() { - proto.RegisterType((*HelloRequest)(nil), "main.HelloRequest") - proto.RegisterType((*HelloReply)(nil), "main.HelloReply") -} - -func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) } - -var fileDescriptor_17b8c58d586b62f2 = []byte{ - // 185 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9, - 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, - 0xcc, 0xcc, 0x53, 0x52, 0xe2, 0xe2, 0xf1, 0x00, 0xc9, 0x04, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, - 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, - 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95, 0x42, 0x12, 0x5c, 0xec, 0xb9, 0xa9, - 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x91, 0x2d, 0x17, 0xbb, 0x7b, 0x51, 0x6a, 0x6a, - 0x49, 0x6a, 0x91, 0x90, 0x11, 0x17, 0x47, 0x70, 0x62, 0x25, 0x58, 0x97, 0x90, 0x90, 0x1e, 0xc8, - 0x26, 0x3d, 0x64, 0x6b, 0xa4, 0x04, 0x50, 0xc4, 0x0a, 0x72, 0x2a, 0x95, 0x18, 0x9c, 0xcc, 0xb8, - 0xa4, 0x33, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a, 0x92, 0xf5, 0x52, 0x2b, 0x12, 0x73, 0x0b, 0x72, 0x52, - 0x8b, 0xf5, 0x10, 0xae, 0x76, 0xe2, 0x07, 0x2b, 0x0e, 0x07, 0xb1, 0x03, 0x40, 0x1e, 0x08, 0x60, - 0x5c, 0xc4, 0xc4, 0xec, 0xe1, 0x13, 0x9e, 0xc4, 0x06, 0xf6, 0x8f, 0x31, 0x20, 0x00, 0x00, 0xff, - 0xff, 0xd2, 0x16, 0x5f, 0x34, 0xe3, 0x00, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/main.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) -} - -// UnimplementedGreeterServer can be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} - -func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { - s.RegisterService(&_Greeter_serviceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/main.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Greeter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "main.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} - -type greeterDubbo3Client struct { - cc *dubbo3.TripleConn -} - -func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { - return &greeterDubbo3Client{cc} -} -func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opt ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - err := c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterClientImpl is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClientImpl struct { - // Sends a greeting - SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error -} - -func (c *GreeterClientImpl) Reference() string { - return "greeterImpl" -} - -func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - return NewGreeterDubbo3Client(cc) -} - -type GreeterProviderBase struct { - proxyImpl protocol.Invoker -} - -func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - s.proxyImpl = impl -} - -func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker { - return s.proxyImpl -} - -func (c *GreeterProviderBase) Reference() string { - return "greeterImpl" -} - -func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - base := srv.(dgrpc.Dubbo3GrpcService) - args := []interface{}{} - args = append(args, in) - invo := invocation.NewRPCInvocation("SayHello", args, nil) - if interceptor == nil { - result := base.GetProxyImpl().Invoke(ctx, invo) - return result.Result(), result.Error() - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/main.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() - } - return interceptor(ctx, in, info, handler) -} - -func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc { - return &grpc.ServiceDesc{ - ServiceName: "main.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _DUBBO_Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", - } -} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto deleted file mode 100644 index 81817e87c8..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto +++ /dev/null @@ -1,40 +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. - */ -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "io.grpc.examples.helloworld"; -option java_outer_classname = "HelloWorldProto"; -option objc_class_prefix = "HLW"; - -package main; - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/go.mod b/protocol/dubbo3/protoc-gen-dubbo3/go.mod deleted file mode 100644 index a12e52d23f..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module github.com/apache/dubbo-go/protocol/dubbo3/protoc-gen-dubbo3 - -go 1.15 - -require ( - dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2 - github.com/dubbogo/triple v1.0.1 - github.com/golang/protobuf v1.5.2 - golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect - google.golang.org/grpc v1.38.0 -) diff --git a/protocol/dubbo3/protoc-gen-dubbo3/go.sum b/protocol/dubbo3/protoc-gen-dubbo3/go.sum deleted file mode 100644 index 44b15c7381..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/go.sum +++ /dev/null @@ -1,1092 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2 h1:cNli2R5zN/WHSXTgJckAExtRCfqoxgXlGq0KY0VRYkM= -dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2/go.mod h1:2l+IXuSuJvEk2g/ze1la8t1sX+yJH220aHo6JJVriM8= -github.com/Azure/azure-sdk-for-go v40.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= -github.com/Azure/go-autorest/autorest v0.10.0/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= -github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= -github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.7.1 h1:HkcLv8q/kwGJnhEWe+vinu+04DGDdQ7nVivMhNhxP2g= -github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTrRXv9zpIg= -github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1 h1:ceSsU/9z/gv3hzUpl8GceEhQvF3i0BionfdHUGMmjHU= -github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= -github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -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/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -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/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= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= -github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk= -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.11 h1:u6kY0oJEZEKLCdo9Hz5eAqeDZev2e7+3rJrUkqgC24s= -github.com/dubbogo/gost v1.11.11/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= -github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.1 h1:fdBkXTR0I4UBBCDcN+k22uJWU338ZK5mvOPpIBIL5h8= -github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvyukov/go-fuzz v0.0.0-20210429054444-fca39067bc72/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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/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/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= -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/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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= -github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -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= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -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= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= -github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul v1.8.0/go.mod h1:Gg9/UgAQ9rdY3CTvzQZ6g2jcIb7NlIfjI+0pvLk5D1A= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/api v1.5.0/go.mod h1:LqwrLNW876eYSuUOo4ZLHBcdKc038txr/IMfbLPATa4= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.5.0/go.mod h1:fY08Y9z5SvJqevyZNy6WWPXiG3KwBPAvlcdx16zZ0fM= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-bexpr v0.1.2/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= -github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-connlimit v0.2.0/go.mod h1:OUj9FGL1tPIhl/2RCfzYHrIiWj+VVPGNyVPnUX8AqS0= -github.com/hashicorp/go-discover v0.0.0-20200501174627-ad1e96bde088/go.mod h1:vZu6Opqf49xX5lsFAu7iFNewkcVF1sn/wyapZh5ytlg= -github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= -github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-memdb v1.0.3/go.mod h1:LWQ8R70vPrS4OEY9k28D2z8/Zzyu34NVzeRibGAzHO0= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= -github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= -github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.0/go.mod h1:YL0HO+FifKOW2u1ke99DGVu1zhcpZzNwrLIqBC7vbYU= -github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff/go.mod h1:Uf8LaHyrYsgVgHzO2tMZKhqRGlL3UJ6XaSwW2EA1Iqo= -github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20191108161836-82f2b5571044/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= -github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= -github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -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= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= -github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -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= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= -github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.0/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.0.0/go.mod h1:k4XwG94++jLVsSiTxo7qdIfXA9pj9EAeo0QsNNJOLZ8= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= -github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= -github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -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/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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -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/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rboyer/safeio v0.2.1/go.mod h1:Cq/cEPK+YXFn622lsQ0K4KsPZSPtaptHHEldsy7Fmig= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= -github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/conswriter v0.0.0-20180208195008-f5ae3917a627/go.mod h1:7zjs06qF79/FKAJpBvFx3P8Ww4UTIMAe+lpNXDHziac= -github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod h1:BeybITEsBEg6qbIiqJ6/Bqeq25bCLbL7YFmpaFfJDuM= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= -github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -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= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -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= -github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -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/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= -github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= -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/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E= -github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= -github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -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/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= -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/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= -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/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= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= -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.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= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -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-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/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= -golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -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/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -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 h1:VwGa2Wf+rHGIxvsssCkUNIyFv8jQY0VCBCNWtikoWq0= -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= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -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.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= -k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= -k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= -k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= -k8s.io/client-go v0.16.9/go.mod h1:ThjPlh7Kx+XoBFOCt775vx5J7atwY7F/zaFzTco5gL0= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/protocol/dubbo3/protoc-gen-dubbo3/main.go b/protocol/dubbo3/protoc-gen-dubbo3/main.go deleted file mode 100644 index 24add89654..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/main.go +++ /dev/null @@ -1,71 +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 main - -import ( - "io/ioutil" - "os" -) - -import ( - _ "github.com/apache/dubbo-go/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/generator" - _ "github.com/golang/protobuf/protoc-gen-go/grpc" -) - -func main() { - // Begin by allocating a generate. The request and response structures are stored there - // so we can do error handling easily - the response structure contains the field to - // report failure. - g := generator.New() - - data, err := ioutil.ReadAll(os.Stdin) - if err != nil { - g.Error(err, "reading input") - } - - if err := proto.Unmarshal(data, g.Request); err != nil { - g.Error(err, "parsing input proto") - } - - if len(g.Request.FileToGenerate) == 0 { - g.Fail("no files to generate") - } - - g.CommandLineParameters(g.Request.GetParameter()) - - // Create a wrapped version of the Descriptors and EnumDescriptors that - // point to the file that defines them. - g.WrapTypes() - - g.SetPackageNames() - g.BuildTypeNameMap() - - g.GenerateAllFiles() - - // Send back the results. - data, err = proto.Marshal(g.Response) - if err != nil { - g.Error(err, "failed to marshal output proto") - } - _, err = os.Stdout.Write(data) - if err != nil { - g.Error(err, "failed to write output proto") - } -} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go b/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go deleted file mode 100644 index 73156644a7..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go +++ /dev/null @@ -1,372 +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 dubbo - -import ( - "fmt" - "strconv" - "strings" -) - -import ( - pb "github.com/golang/protobuf/protoc-gen-go/descriptor" - "github.com/golang/protobuf/protoc-gen-go/generator" -) - -// generatedCodeVersion indicates a version of the generated codes. -// It is incremented whenever an incompatibility between the generated codes and -// the grpc package is introduced; the generated codes references -// a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 4 - -// Paths for packages used by codes generated in this file, -// relative to the import_prefix of the generator.Generator. -const ( - contextPkgPath = "context" - grpcPkgPath = "google.golang.org/grpc" - codePkgPath = "google.golang.org/grpc/codes" - statusPkgPath = "google.golang.org/grpc/status" -) - -func init() { - generator.RegisterPlugin(new(dubboGrpc)) -} - -// grpc is an implementation of the Go protocol buffer compiler's -// plugin architecture. It generates bindings for gRPC-dubbo support. -type dubboGrpc struct { - gen *generator.Generator -} - -// Name returns the name of this plugin, "grpc". -func (g *dubboGrpc) Name() string { - return "dubbo" -} - -// The names for packages imported in the generated codes. -// They may vary from the final path component of the import path -// if the name is used by other packages. -var ( - contextPkg string - grpcPkg string -) - -// Init initializes the plugin. -func (g *dubboGrpc) Init(gen *generator.Generator) { - g.gen = gen -} - -// Given a type name defined in a .proto, return its object. -// Also record that we're using it, to guarantee the associated import. -func (g *dubboGrpc) objectNamed(name string) generator.Object { - g.gen.RecordTypeUse(name) - return g.gen.ObjectNamed(name) -} - -// Given a type name defined in a .proto, return its name as we will print it. -func (g *dubboGrpc) typeName(str string) string { - return g.gen.TypeName(g.objectNamed(str)) -} - -// P forwards to g.gen.P. -func (g *dubboGrpc) P(args ...interface{}) { g.gen.P(args...) } - -// Generate generates codes for the services in the given file. -// be consistent with grpc plugin -func (g *dubboGrpc) Generate(file *generator.FileDescriptor) { - if len(file.FileDescriptorProto.Service) == 0 { - return - } - - contextPkg = string(g.gen.AddImport(contextPkgPath)) - grpcPkg = string(g.gen.AddImport(grpcPkgPath)) - - for i, service := range file.FileDescriptorProto.Service { - g.generateService(file, service, i) - } -} - -// GenerateImports generates the import declaration for this file. -func (g *dubboGrpc) GenerateImports(file *generator.FileDescriptor) { - g.P("import (") - g.P(`dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"`) - g.P(`"dubbo.apache.org/dubbo-go/v3/protocol/invocation"`) - g.P(`"dubbo.apache.org/dubbo-go/v3/protocol"`) - g.P(`dubbo3 "github.com/dubbogo/triple/pkg/triple"`) - g.P(`tripleConstant "github.com/dubbogo/triple/pkg/common/constant"`) - g.P(` ) `) -} - -func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] } - -// deprecationComment is the standard comment added to deprecated -// messages, fields, enums, and enum values. -var deprecationComment = "// Deprecated: Do not use." - -// generateService generates all the codes for the named service. -func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) { - path := fmt.Sprintf("6,%d", index) // 6 means service. - - origServName := service.GetName() - fullServName := origServName - if pkg := file.GetPackage(); pkg != "" { - fullServName = pkg + "." + fullServName - } - servName := generator.CamelCase(origServName) - lowerServName := strings.ToLower(servName) - lowerFrontServeName := strings.ToLower(servName[:1]) + servName[1:] - g.P(fmt.Sprintf("type %sDubbo3Client struct {", lowerServName)) - g.P(fmt.Sprintf("cc *dubbo3.TripleConn")) - g.P("}") - - g.P(fmt.Sprintf("func New%sDubbo3Client (cc *dubbo3.TripleConn) %sClient {", servName, servName)) - g.P(fmt.Sprintf("return &%sDubbo3Client{cc}", lowerServName)) - g.P(fmt.Sprintf("}")) - - for _, method := range service.Method { - inputTypeNames := strings.Split(method.GetInputType(), ".") - inputTypeName := inputTypeNames[len(inputTypeNames)-1] - outputTypeNames := strings.Split(method.GetOutputType(), ".") - outputTypeName := outputTypeNames[len(outputTypeNames)-1] - if method.GetServerStreaming() || method.GetClientStreaming() { - //now we only support two way streaming - g.P(fmt.Sprintf("func (c *%sDubbo3Client) %s(ctx %s.Context,opt ...grpc.CallOption) (%s, error) {", - lowerServName, method.GetName(), contextPkg, servName+"_"+method.GetName()+"Client")) - g.P(fmt.Sprintf("interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)")) - g.P(fmt.Sprintf("stream, err := c.cc.NewStream(ctx, \"/\" + interfaceKey + \"/%s\", opt...)", method.GetName())) - g.P("if err != nil {") - g.P("return nil, err") - g.P("}") - g.P(fmt.Sprintf("x := &%s%sClient{stream}", lowerFrontServeName, method.GetName())) - g.P("return x, nil") - g.P("}") - continue - } - // unary rpc method client - g.P(fmt.Sprintf("func (c *%sDubbo3Client) %s(ctx %s.Context, in *%s, opt ...grpc.CallOption) (*%s, error) {", - lowerServName, method.GetName(), contextPkg, inputTypeName, outputTypeName)) - g.P(fmt.Sprintf("out := new(%s)", outputTypeName)) - g.P(fmt.Sprintf("interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)")) - g.P(fmt.Sprintf("err := c.cc.Invoke(ctx, \"/\" + interfaceKey + \"/%s\", in, out)", method.GetName())) - g.P("if err != nil {") - g.P("return nil, err") - g.P("}") - g.P("return out, nil") - g.P("}") - } - - deprecated := service.GetOptions().GetDeprecated() - - g.P() - g.P(fmt.Sprintf(`// %sClientImpl is the client API for %s service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.`, servName, servName)) - - // Client interface. - if deprecated { - g.P("//") - g.P(deprecationComment) - } - dubboSrvName := servName + "ClientImpl" - g.P("type ", dubboSrvName, " struct {") - for i, method := range service.Method { - g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. - if method.GetOptions().GetDeprecated() { - g.P("//") - g.P(deprecationComment) - } - g.P(g.generateClientSignature(servName, method)) - } - g.P("}") - g.P() - - // NewClient factory. - if deprecated { - g.P(deprecationComment) - } - - // add Reference method - //func (u *GrpcGreeterImpl) Reference() string { - // return "GrpcGreeterImpl" - //} - g.P("func (c *", dubboSrvName, ") ", " Reference() string ", "{") - g.P(`return "`, unexport(servName), `Impl"`) - g.P("}") - g.P() - - // add GetDubboStub method - // func (u *GrpcGreeterImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - // return NewGreeterClient(cc) - //} - g.P("func (c *", dubboSrvName, ") ", " GetDubboStub(cc *dubbo3.TripleConn) ", servName, "Client {") - g.P(`return New`, servName, `Dubbo3Client(cc)`) - g.P("}") - g.P() - - // Server interface. - serverType := servName + "ProviderBase" - g.P("type ", serverType, " struct {") - g.P("proxyImpl protocol.Invoker") - g.P("}") - g.P() - - // add set method - //func (g *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - // g.proxyImpl = impl - //} - g.P("func (s *", serverType, ") SetProxyImpl(impl protocol.Invoker) {") - g.P(`s.proxyImpl = impl`) - g.P("}") - g.P() - - // return get method - g.P("func (s *", serverType, ") GetProxyImpl() protocol.Invoker {") - g.P(`return s.proxyImpl`) - g.P("}") - g.P() - - // return reference - g.P("func (c *", serverType, ") ", " Reference() string ", "{") - g.P(`return "`, unexport(servName), `Impl"`) - g.P("}") - g.P() - - // add handler - var handlerNames []string - for _, method := range service.Method { - hname := g.generateServerMethod(servName, fullServName, method) - handlerNames = append(handlerNames, hname) - } - - grpcserverType := servName + "Server" - // return service desc - g.P("func (s *", serverType, ") ServiceDesc() *grpc.ServiceDesc {") - g.P(`return &grpc.ServiceDesc{`) - g.P("ServiceName: ", strconv.Quote(fullServName), ",") - g.P("HandlerType: (*", grpcserverType, ")(nil),") - g.P("Methods: []", grpcPkg, ".MethodDesc{") - for i, method := range service.Method { - if method.GetServerStreaming() || method.GetClientStreaming() { - continue - } - g.P("{") - g.P("MethodName: ", strconv.Quote(method.GetName()), ",") - g.P("Handler: ", handlerNames[i], ",") - g.P("},") - } - g.P("},") - g.P("Streams: []", grpcPkg, ".StreamDesc{") - for i, method := range service.Method { - if !method.GetClientStreaming() && !method.GetServerStreaming() { - continue - } - g.P("{") - g.P("StreamName: ", strconv.Quote(method.GetName()), ",") - g.P("Handler: ", handlerNames[i], ",") - if method.GetServerStreaming() { - g.P("ServerStreams: true,") - } - if method.GetClientStreaming() { - g.P("ClientStreams: true,") - } - g.P("},") - } - g.P("},") - g.P("Metadata: \"", file.GetName(), "\",") - g.P("}") - g.P("}") - g.P() -} - -// generateClientSignature returns the client-side signature for a method. -func (g *dubboGrpc) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { - origMethName := method.GetName() - methName := generator.CamelCase(origMethName) - //if reservedClientName[methName] { - // methName += "_" - //} - reqArg := ", in *" + g.typeName(method.GetInputType()) - if method.GetClientStreaming() { - reqArg = "" - } - respName := "out *" + g.typeName(method.GetOutputType()) - if method.GetServerStreaming() || method.GetClientStreaming() { - respName = servName + "_" + generator.CamelCase(origMethName) + "Client" - return fmt.Sprintf("%s func(ctx %s.Context%s) (%s, error)", methName, contextPkg, reqArg, respName) - } - return fmt.Sprintf("%s func(ctx %s.Context%s, %s) error", methName, contextPkg, reqArg, respName) -} - -func (g *dubboGrpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { -} - -func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method *pb.MethodDescriptorProto) string { - methName := generator.CamelCase(method.GetName()) - hname := fmt.Sprintf("_DUBBO_%s_%s_Handler", servName, methName) - inType := g.typeName(method.GetInputType()) - - if !method.GetServerStreaming() && !method.GetClientStreaming() { - g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, interceptor ", grpcPkg, ".UnaryServerInterceptor) (interface{}, error) {") - g.P("in := new(", inType, ")") - g.P("if err := dec(in); err != nil { return nil, err }") - - g.P("base := srv.(dgrpc.Dubbo3GrpcService)") - g.P("args := []interface{}{}") - g.P("args = append(args, in)") - g.P(`invo := invocation.NewRPCInvocation("`, methName, `", args, nil)`) - - g.P("if interceptor == nil {") - g.P("result := base.GetProxyImpl().Invoke(ctx, invo)") - g.P("return result.Result(), result.Error()") - g.P("}") - - g.P("info := &", grpcPkg, ".UnaryServerInfo{") - g.P("Server: srv,") - g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", fullServName, methName)), ",") - g.P("}") - - g.P("handler := func(ctx ", contextPkg, ".Context, req interface{}) (interface{}, error) {") - g.P("result := base.GetProxyImpl().Invoke(context.Background(), invo)") - g.P("return result.Result(), result.Error()") - g.P("}") - - g.P("return interceptor(ctx, in, info, handler)") - g.P("}") - g.P() - return hname - } - // streaming rpc - streamType := unexport(servName) + methName + "Server" - g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") - g.P("_, ok := srv.(dgrpc.Dubbo3GrpcService)") - g.P(`invo := invocation.NewRPCInvocation("`, methName, `", nil, nil)`) - g.P("if !ok {") - g.P("fmt.Println(invo)") - g.P("}") - if !method.GetClientStreaming() { - g.P("m := new(", inType, ")") - g.P("if err := stream.RecvMsg(m); err != nil { return err }") - g.P("return srv.(", servName, "Server).", methName, "(m, &", streamType, "{stream})") - } else { - g.P("return srv.(", servName, "Server).", methName, "(&", streamType, "{stream})") - } - g.P("}") - g.P() - - return hname -} diff --git a/protocol/grpc/protoc-gen-dubbo/main.go b/protocol/grpc/protoc-gen-dubbo/main.go deleted file mode 100644 index 48d0428688..0000000000 --- a/protocol/grpc/protoc-gen-dubbo/main.go +++ /dev/null @@ -1,74 +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 main - -import ( - "io/ioutil" - "os" -) - -import ( - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/generator" - _ "github.com/golang/protobuf/protoc-gen-go/grpc" -) - -import ( - _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc/protoc-gen-dubbo/plugin/dubbo" -) - -func main() { - // Begin by allocating a generate. The request and response structures are stored there - // so we can do error handling easily - the response structure contains the field to - // report failure. - g := generator.New() - - data, err := ioutil.ReadAll(os.Stdin) - if err != nil { - g.Error(err, "reading input") - } - - if err = proto.Unmarshal(data, g.Request); err != nil { - g.Error(err, "parsing input proto") - } - - if len(g.Request.FileToGenerate) == 0 { - g.Fail("no files to generate") - } - - g.CommandLineParameters(g.Request.GetParameter()) - - // Create a wrapped version of the Descriptors and EnumDescriptors that - // point to the file that defines them. - g.WrapTypes() - - g.SetPackageNames() - g.BuildTypeNameMap() - - g.GenerateAllFiles() - - // Send back the results. - data, err = proto.Marshal(g.Response) - if err != nil { - g.Error(err, "failed to marshal output proto") - } - _, err = os.Stdout.Write(data) - if err != nil { - g.Error(err, "failed to write output proto") - } -} diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go deleted file mode 100644 index 76fbf64724..0000000000 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go +++ /dev/null @@ -1,19 +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 dubbo plugin for protobuf. -package dubbo From 8ef173e7a77b493d33f83cc779b7efcf792e1f21 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:44:58 +0800 Subject: [PATCH 072/148] merge 3.0 to ensure samples runnable (#1414) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: change register event chan to unbundent chan (#1330) * fix: #1323 delete zk registry when set defualt consumer/provider config (#1324) * Ftr: Generic invocation supports Generalizer (#1315) * generic filter * sync * feat: get java name from POJO * todo: unittests for generic filter * unittests for generic filter * map generalizer * adjust import block * generic service filter is ready for generalizer * add unittests for GenericServiceFilter * ReferenceConfig supports new format of generic key * go fmt * fix license * fix license * fix bugs encountering in integrated tests * go fmt * fix serialization bugs * ftr: generic invocation supports protobuf-json * go fmt * go fmt * disable protobuf-json * go fmt * update comments * fix logging level (#1341) * Ftr: add lumberjack log config (#1335) * add lumberjack & union test * fix go fmt error,modify go.sum file * Ftr: add json generalizer (#1343) * Ftr: add json generalizer Fix: go fmt * Fix: hessian pojo * fix: restart ci * Fix: imports format * style(*): format imports with dubbogo/tools/imports-formatter (#1346) * fix Fixed the problem that the timeout period of the original method level does not take effect (#1336) * fix Fixed the problem that the timeout period of the original method level does not take effect * fix Fixed the problem that the timeout period of the original method level does not take effect Co-authored-by: 董振兴 * fix:#1143 Feature/reduce etcd registry conn; wait group modify (#1297) * modify map use in nacos service_discovery * fix map double write bug * modify etcd registry restart mechanism * add sync.once for HandleClientRestart * modify the logic when add() or done() of wait group in zk,etcd and k8s registry * modify the logic when add() or done() of wait group in zk,etcd and k8s registry * add handleClientRestart func * add handleClientRestart func * go fmt * fix: update linter Co-authored-by: yexiaobo Co-authored-by: LaurenceLiZhixin <382673304@qq.com> * ftr: triple multi params support (#1344) * ftr: triple multi params support * fix: import * fix: fix ci and gomod * fix: fmt * fix: add develop back to branch * fix: remove unused getty import * fix: mock zk registry (#1351) * 优化Nacos下的ServiceName的命名风格 (#1352) Co-authored-by: Changeden * remove zk test (#1357) * Use class name as the default reference name (#1339) * 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] * improve etcd version and change create to put (#1203) * Remove RPC Service * use type assertion before reflect * modify comment * modify comment of BaseMetadataService * add the type alias of interface{} * modify RPCService Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy * Feat/upgrade getty (#1345) * feat(getty): upgrade getty version to 1.4.4 * feat(getty): delete outdated getty params * delete time.Sleep in unit test * upgrade getty version to 1.4.5 * style(getty): format package getty imports Co-authored-by: dongjianhui03 * support multi pb (#1361) * 修复当getty的tcp read/write timeout小于1s时panic的问题 * TCP Read/Write最小值提取为全局变量,优化parseTimeDurationByRange逻辑 * logo (#1382) * Change the key of a mock EchoFilter (#1381) * 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] * improve etcd version and change create to put (#1203) * change the mock filter key Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy * Change the key of a mock EchoFilter (#1381) * 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] * improve etcd version and change create to put (#1203) * change the mock filter key Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy * fix: nacos service disc error log bug (#1390) * 优化代码逻辑 * fix:registry timeout not pars (#1392) * fix:registry timeout not pars * up:fmt * up:统一超时时间key * fix:修改测试顺序问题 * up:fmt * change dependabot target branch * build(deps): bump github.com/fsnotify/fsnotify from 1.4.9 to 1.5.0 (#1400) * 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] * improve etcd version and change create to put (#1203) * build(deps): bump github.com/dubbogo/gost from 1.11.14 to 1.11.16 (#1387) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.14 to 1.11.16. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.14...v1.11.16) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.1 (#1386) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.26.0 to 1.27.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.26.0...v1.27.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump go.etcd.io/etcd/client/v3 from 3.5.0-alpha.0 to 3.5.0 (#1383) Bumps [go.etcd.io/etcd/client/v3](https://github.com/etcd-io/etcd) from 3.5.0-alpha.0 to 3.5.0. - [Release notes](https://github.com/etcd-io/etcd/releases) - [Changelog](https://github.com/etcd-io/etcd/blob/main/CHANGELOG-3.5.md) - [Commits](https://github.com/etcd-io/etcd/compare/v3.5.0-alpha.0...v3.5.0) --- updated-dependencies: - dependency-name: go.etcd.io/etcd/client/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/fsnotify/fsnotify from 1.4.9 to 1.5.0 Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.4.9 to 1.5.0. - [Release notes](https://github.com/fsnotify/fsnotify/releases) - [Changelog](https://github.com/fsnotify/fsnotify/blob/master/CHANGELOG.md) - [Commits](https://github.com/fsnotify/fsnotify/compare/v1.4.9...v1.5.0) --- updated-dependencies: - dependency-name: github.com/fsnotify/fsnotify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy * build(deps): bump github.com/emicklei/go-restful/v3 from 3.4.0 to 3.5.2 (#1403) Bumps [github.com/emicklei/go-restful/v3](https://github.com/emicklei/go-restful) from 3.4.0 to 3.5.2. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v3.4.0...v3.5.2) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * 更新TCP读写超时最小值命名;不再使用范围比较; * del protoc-gen-dubbo3 & protoc-gen-dubbo (#1313) Co-authored-by: Mulavar <978007503@qq.com> Co-authored-by: XavierNiu Co-authored-by: 氕氘氚 Co-authored-by: EnableAsync <43645467+EnableAsync@users.noreply.github.com> Co-authored-by: XX <45752021+Threadalive@users.noreply.github.com> Co-authored-by: 董振兴 Co-authored-by: WilliamLeaves Co-authored-by: yexiaobo Co-authored-by: ChangedenChan Co-authored-by: Changeden Co-authored-by: YuDong Tang <583125614@qq.com> Co-authored-by: alchemy-lee <2769566951@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy Co-authored-by: dongjianhui03 Co-authored-by: gaoxinge Co-authored-by: wangxw666 <2484713618@qq.com> Co-authored-by: zhaoyunxing <2385585770@qq.com> Co-authored-by: Joe Zou --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/dependabot.yml | 4 +- .github/workflows/github-actions.yml | 4 +- .gitignore | 1 + README.md | 5 + README_CN.md | 5 + .../available_cluster_invoker_test.go | 1 + cluster/cluster_impl/base_cluster_invoker.go | 1 + .../broadcast_cluster_invoker_test.go | 1 + cluster/cluster_impl/failback_cluster_test.go | 2 + cluster/cluster_impl/failfast_cluster_test.go | 2 + cluster/cluster_impl/failover_cluster_test.go | 5 +- cluster/cluster_impl/failsafe_cluster_test.go | 2 + cluster/cluster_impl/forking_cluster_test.go | 1 + .../zone_aware_cluster_invoker_test.go | 1 + cluster/router/chain/chain.go | 1 + .../judger/attachment_match_judger_test.go | 2 +- .../v3router/judger/bool_match_judger_test.go | 5 +- .../judger/double_match_judger_test.go | 5 +- .../judger/double_range_match_judger_test.go | 5 +- .../judger/list_double_match_judger_test.go | 5 +- .../judger/list_string_match_judger_test.go | 5 +- .../judger/method_match_judger_test.go | 2 +- .../v3router/judger/string_match_judger.go | 5 +- .../judger/string_match_judger_test.go | 5 +- .../v3router/k8s_api/listener_handler_impl.go | 4 +- cluster/router/v3router/k8s_crd/client.go | 3 + .../v3router/k8s_crd/listener_handler.go | 1 + cluster/router/v3router/router_chain.go | 2 +- cluster/router/v3router/router_chain_test.go | 13 +- cluster/router/v3router/uniform_rule.go | 2 +- common/constant/default.go | 8 - common/constant/key.go | 9 + .../{serializtion.go => serialization.go} | 0 common/host_util.go | 4 +- common/logger/file_log.yml | 36 + common/logger/logger.go | 62 +- common/logger/logger_test.go | 54 + common/proxy/proxy.go | 27 +- common/proxy/proxy_factory/default.go | 9 +- common/proxy/proxy_test.go | 1 + common/rpc_service.go | 40 +- common/rpc_service_test.go | 33 + common/url.go | 22 +- common/yaml/yaml.go | 1 + config/application_config.go | 5 +- config/config_center_config.go | 8 +- config/config_loader.go | 34 +- config/config_loader_options.go | 6 +- config/config_loader_options_test.go | 4 +- config/config_loader_test.go | 11 +- config/config_utils.go | 8 +- config/consumer_config.go | 6 +- config/generic/generic_service.go | 4 +- config/interfaces/config_reader.go | 4 +- config/metadata_report_config.go | 7 +- config/method_config.go | 5 +- config/provider_config.go | 5 +- config/reference_config.go | 25 +- config/registry_config.go | 3 +- config/remote_config.go | 7 +- config/root_config.go | 2 +- config/router_config.go | 5 +- config/router_config_test.go | 10 +- config/service.go | 6 +- config/service_config.go | 5 +- config/service_discovery_config.go | 4 +- .../testdata/config/service/hello_service.go | 2 +- .../testdata/config/service/order_service.go | 2 +- config/testdata/consumer_config.yml | 1 - .../consumer_config_with_configcenter.yml | 1 - .../consumer_config_withoutProtocol.yml | 1 - config/testdata/provider_config.yml | 1 - .../provider_config_withoutProtocol.yml | 1 - config/uniform_router_config.go | 1 + config_center/apollo/impl.go | 2 + config_center/apollo/impl_test.go | 3 +- config_center/apollo/listener.go | 1 + config_center/file/impl.go | 1 + config_center/mock_dynamic_config.go | 1 + config_center/nacos/client.go | 1 + config_center/nacos/impl.go | 2 + config_center/parser/configuration_parser.go | 2 + config_center/zookeeper/impl.go | 1 + config_center/zookeeper/impl_test.go | 232 ---- config_center/zookeeper/listener_test.go | 101 -- filter/accesslog/filter_test.go | 1 + filter/active/filter_test.go | 1 + filter/auth/consumer_sign_filter_test.go | 1 + filter/auth/provider_auth_filter_test.go | 1 + filter/generic/filter.go | 139 +-- filter/generic/filter_test.go | 175 ++- filter/generic/generalizer/example.pb.go | 260 +++++ filter/generic/generalizer/generalizer.go | 37 + filter/generic/generalizer/gson.go | 100 ++ filter/generic/generalizer/gson_test.go | 97 ++ filter/generic/generalizer/map.go | 208 ++++ filter/generic/generalizer/map_test.go | 249 ++++ filter/generic/generalizer/protobuf_json.go | 92 ++ .../generic/generalizer/protobuf_json_test.go | 59 + filter/generic/service_filter.go | 134 +-- filter/generic/service_filter_test.go | 262 +++-- filter/generic/util.go | 80 ++ filter/hystrix/filter.go | 2 + filter/hystrix/filter_test.go | 2 + filter/sentinel/filter.go | 1 - filter/sentinel/filter_test.go | 1 + filter/tps/filter_test.go | 1 + filter/tps/limiter/method_service_test.go | 3 +- filter/tps/strategy/mock.go | 4 +- go.mod | 29 +- go.sum | 190 ++- imports/imports.go | 6 - .../mapping/dynamic/service_name_mapping.go | 3 +- .../dynamic/service_name_mapping_test.go | 3 +- .../mapping/memory/service_name_mapping.go | 2 +- metadata/report/delegate/delegate_report.go | 2 + .../report/delegate/delegate_report_test.go | 1 + metadata/report/etcd/report.go | 3 +- metadata/report/etcd/report_test.go | 1 + metadata/report/nacos/report.go | 2 + metadata/report/zookeeper/report.go | 1 + metadata/report/zookeeper/report_test.go | 203 ---- .../service/exporter/configurable/exporter.go | 4 +- .../exporter/configurable/exporter_test.go | 3 +- metadata/service/local/service.go | 2 +- metadata/service/local_service.go | 4 +- protocol/dubbo/dubbo_codec.go | 1 + protocol/dubbo/dubbo_invoker.go | 6 +- protocol/dubbo/dubbo_invoker_test.go | 5 +- protocol/dubbo/dubbo_protocol_test.go | 2 - protocol/dubbo/hessian2/hessian_dubbo.go | 1 + protocol/dubbo/hessian2/hessian_dubbo_test.go | 1 + protocol/dubbo/hessian2/hessian_request.go | 96 +- .../dubbo/hessian2/hessian_request_test.go | 1 + protocol/dubbo/hessian2/hessian_response.go | 7 +- .../dubbo/hessian2/hessian_response_test.go | 1 + protocol/dubbo/hessian2/java_class.go | 201 ++++ protocol/dubbo/hessian2/java_class_test.go | 132 +++ protocol/dubbo/impl/codec.go | 1 + protocol/dubbo/impl/const.go | 2 + protocol/dubbo/impl/hessian.go | 1 + protocol/dubbo3/common_test.go | 2 +- protocol/dubbo3/dubbo3_protocol.go | 53 +- protocol/dubbo3/dubbo3_protocol_test.go | 64 + protocol/dubbo3/internal/client.go | 5 +- protocol/dubbo3/internal/helloworld.pb.go | 11 +- .../examples/helloworld.pb.go | 323 ----- protocol/dubbo3/protoc-gen-dubbo3/go.mod | 9 - protocol/dubbo3/protoc-gen-dubbo3/go.sum | 1034 ----------------- protocol/dubbo3/protoc-gen-dubbo3/main.go | 74 -- .../protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go | 372 ------ protocol/grpc/client.go | 3 + protocol/grpc/codec.go | 1 + protocol/grpc/grpc_invoker.go | 2 + protocol/grpc/grpc_protocol_test.go | 2 +- protocol/grpc/internal/README.md | 1 + protocol/grpc/internal/helloworld/client.go | 5 +- .../grpc/internal/helloworld/helloworld.pb.go | 25 +- .../internal/multiprotos}/Makefile | 38 +- .../grpc/internal/multiprotos/first.pb.go | 308 +++++ .../multiprotos/first.proto} | 17 +- .../grpc/internal/multiprotos/second.pb.go | 590 ++++++++++ .../internal/multiprotos/second.proto} | 27 +- protocol/grpc/internal/routeguide/client.go | 5 +- .../grpc/internal/routeguide/routeguide.pb.go | 52 +- protocol/grpc/internal/routeguide/server.go | 1 + protocol/grpc/protoc-gen-dubbo/main.go | 74 -- .../protoc-gen-dubbo/plugin/dubbo/dubbo.go | 34 +- protocol/grpc/server.go | 2 + protocol/invocation/rpcinvocation.go | 4 - protocol/invoker.go | 1 + protocol/jsonrpc/http.go | 5 +- protocol/jsonrpc/http_test.go | 2 + protocol/jsonrpc/jsonrpc_protocol_test.go | 2 +- protocol/jsonrpc/server.go | 1 + .../protocol_filter_wrapper_test.go | 10 +- .../rest/client/client_impl/resty_client.go | 1 + .../rest/config/reader/rest_config_reader.go | 1 + protocol/rest/rest_invoker_test.go | 3 +- protocol/rest/rest_protocol_test.go | 2 +- .../server/server_impl/go_restful_server.go | 1 + registry/base_registry.go | 6 +- registry/directory/directory.go | 2 +- registry/directory/directory_test.go | 2 +- registry/etcdv3/listener.go | 11 +- registry/etcdv3/listener_test.go | 6 +- registry/etcdv3/registry.go | 18 +- registry/etcdv3/service_discovery.go | 2 + ...vent_publishing_service_deiscovery_test.go | 3 +- ...data_service_url_params_customizer_test.go | 1 + .../event/service_config_exported_event.go | 2 +- registry/file/listener.go | 4 +- registry/file/service_discovery.go | 1 + registry/kubernetes/listener.go | 11 +- registry/kubernetes/registry.go | 11 +- registry/kubernetes/registry_test.go | 1 + registry/nacos/listener.go | 17 +- registry/nacos/registry.go | 6 +- registry/nacos/registry_test.go | 1 + registry/nacos/service_discovery.go | 5 +- registry/nacos/service_discovery_test.go | 1 + registry/protocol/protocol.go | 1 + registry/protocol/protocol_test.go | 3 +- registry/service_instance.go | 4 +- .../service_instances_changed_listener.go | 10 +- .../service_discovery_registry.go | 2 + .../service_discovery_registry_test.go | 3 +- registry/zookeeper/listener.go | 11 +- registry/zookeeper/listener_test.go | 46 - registry/zookeeper/registry.go | 11 +- registry/zookeeper/registry_test.go | 185 --- registry/zookeeper/service_discovery.go | 1 - registry/zookeeper/service_discovery_test.go | 2 + remoting/etcdv3/client.go | 1 + remoting/etcdv3/facade.go | 53 +- remoting/etcdv3/listener.go | 3 + remoting/etcdv3/listener_test.go | 2 + remoting/getty/config.go | 27 +- remoting/getty/dubbo_codec_for_test.go | 1 + remoting/getty/getty_client.go | 7 +- remoting/getty/getty_client_test.go | 4 +- remoting/getty/getty_server.go | 3 + remoting/getty/listener.go | 6 +- remoting/getty/listener_test.go | 1 + remoting/getty/pool.go | 1 + remoting/getty/readwriter.go | 14 +- remoting/getty/readwriter_test.go | 3 +- remoting/kubernetes/client.go | 2 + remoting/kubernetes/facade.go | 4 +- remoting/kubernetes/registry_controller.go | 7 + remoting/nacos/builder.go | 7 +- remoting/nacos/builder_test.go | 45 +- remoting/zookeeper/client.go | 10 +- .../curator_discovery/service_discovery.go | 2 + remoting/zookeeper/facade.go | 1 + remoting/zookeeper/facade_test.go | 125 -- remoting/zookeeper/listener.go | 5 +- remoting/zookeeper/listener_test.go | 104 -- test/integrate/dubbo/go-client/client.go | 2 +- test/integrate/dubbo/go-client/client.yml | 2 - test/integrate/dubbo/go-client/user.go | 6 +- test/integrate/dubbo/go-server/server.go | 2 +- test/integrate/dubbo/go-server/server.yml | 2 - test/integrate/dubbo/go-server/user.go | 5 +- 245 files changed, 3909 insertions(+), 3871 deletions(-) rename common/constant/{serializtion.go => serialization.go} (100%) create mode 100644 common/logger/file_log.yml delete mode 100644 config_center/zookeeper/impl_test.go delete mode 100644 config_center/zookeeper/listener_test.go create mode 100644 filter/generic/generalizer/example.pb.go create mode 100644 filter/generic/generalizer/generalizer.go create mode 100644 filter/generic/generalizer/gson.go create mode 100644 filter/generic/generalizer/gson_test.go create mode 100644 filter/generic/generalizer/map.go create mode 100644 filter/generic/generalizer/map_test.go create mode 100644 filter/generic/generalizer/protobuf_json.go create mode 100644 filter/generic/generalizer/protobuf_json_test.go create mode 100644 filter/generic/util.go delete mode 100644 metadata/report/zookeeper/report_test.go create mode 100644 protocol/dubbo/hessian2/java_class.go create mode 100644 protocol/dubbo/hessian2/java_class_test.go delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/go.mod delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/go.sum delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/main.go delete mode 100644 protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go rename protocol/{dubbo3/protoc-gen-dubbo3/examples => grpc/internal/multiprotos}/Makefile (82%) create mode 100644 protocol/grpc/internal/multiprotos/first.pb.go rename protocol/grpc/{protoc-gen-dubbo/plugin/dubbo/doc.go => internal/multiprotos/first.proto} (78%) create mode 100644 protocol/grpc/internal/multiprotos/second.pb.go rename protocol/{dubbo3/protoc-gen-dubbo3/examples/helloworld.proto => grpc/internal/multiprotos/second.proto} (62%) delete mode 100644 protocol/grpc/protoc-gen-dubbo/main.go delete mode 100644 registry/zookeeper/listener_test.go delete mode 100644 registry/zookeeper/registry_test.go delete mode 100644 remoting/zookeeper/facade_test.go diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0c5d3e0a7c..5ce1a142f9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ **What this PR does**: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6ce0286102..3bd8d9cb19 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: directory: "/" # Location of package manifests schedule: interval: "weekly" - target-branch: "develop" + target-branch: "3.0" - package-ecosystem: "github-actions" # Workflow files stored in the @@ -17,4 +17,4 @@ updates: directory: "/" schedule: interval: "weekly" - target-branch: "develop" \ No newline at end of file + target-branch: "3.0" diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 952e58dcbd..0ffb5c6f53 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [master, develop] + branches: [master, develop, "1.5", "3.0"] pull_request: branches: "*" @@ -59,7 +59,7 @@ jobs: # diff -u <(echo -n) <(gofmt -d -s .) - name: Install go ci lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1 - name: Run Linter run: golangci-lint run --timeout=10m -v diff --git a/.gitignore b/.gitignore index 135b147937..25cf086b53 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.so *.dylib *.jar +*.log # Test binary, build with `go test -c` *.test diff --git a/README.md b/README.md index 40e3a118ee..6d87c6ea41 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,11 @@ If you are using [apache/dubbo-go](https://github.com/apache/dubbo-go) and think + + + + + diff --git a/README_CN.md b/README_CN.md index be43e95afd..a2023f4fce 100644 --- a/README_CN.md +++ b/README_CN.md @@ -150,6 +150,11 @@ go get dubbo.apache.org/dubbo-go/v3 + + + + + diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster_impl/available_cluster_invoker_test.go index 2bb111935a..c97f4f2652 100644 --- a/cluster/cluster_impl/available_cluster_invoker_test.go +++ b/cluster/cluster_impl/available_cluster_invoker_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go index 925a039ab2..1d1f86636c 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster_impl/base_cluster_invoker.go @@ -19,6 +19,7 @@ package cluster_impl import ( perrors "github.com/pkg/errors" + "go.uber.org/atomic" ) diff --git a/cluster/cluster_impl/broadcast_cluster_invoker_test.go b/cluster/cluster_impl/broadcast_cluster_invoker_test.go index 78abcd9e28..678598e9a4 100644 --- a/cluster/cluster_impl/broadcast_cluster_invoker_test.go +++ b/cluster/cluster_impl/broadcast_cluster_invoker_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/failback_cluster_test.go b/cluster/cluster_impl/failback_cluster_test.go index 93ee3b7d2d..f730c9d745 100644 --- a/cluster/cluster_impl/failback_cluster_test.go +++ b/cluster/cluster_impl/failback_cluster_test.go @@ -27,7 +27,9 @@ import ( import ( "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/failfast_cluster_test.go b/cluster/cluster_impl/failfast_cluster_test.go index 2c964fc58f..74d570730a 100644 --- a/cluster/cluster_impl/failfast_cluster_test.go +++ b/cluster/cluster_impl/failfast_cluster_test.go @@ -25,7 +25,9 @@ import ( import ( "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go index 743c51aba0..eb29270f73 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster_impl/failover_cluster_test.go @@ -26,6 +26,7 @@ import ( import ( perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) @@ -40,10 +41,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) -// /////////////////////////// -// mock invoker -// /////////////////////////// - // nolint type MockInvoker struct { url *common.URL diff --git a/cluster/cluster_impl/failsafe_cluster_test.go b/cluster/cluster_impl/failsafe_cluster_test.go index 2c46acc828..de67fddd49 100644 --- a/cluster/cluster_impl/failsafe_cluster_test.go +++ b/cluster/cluster_impl/failsafe_cluster_test.go @@ -25,7 +25,9 @@ import ( import ( "github.com/golang/mock/gomock" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/forking_cluster_test.go b/cluster/cluster_impl/forking_cluster_test.go index a5bc341bd1..bbb12bb9b4 100644 --- a/cluster/cluster_impl/forking_cluster_test.go +++ b/cluster/cluster_impl/forking_cluster_test.go @@ -28,6 +28,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go b/cluster/cluster_impl/zone_aware_cluster_invoker_test.go index 49b46a7745..62433f3e01 100644 --- a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go +++ b/cluster/cluster_impl/zone_aware_cluster_invoker_test.go @@ -25,6 +25,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 81839f75d5..250e183499 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -24,6 +24,7 @@ import ( import ( perrors "github.com/pkg/errors" + "go.uber.org/atomic" ) diff --git a/cluster/router/v3router/judger/attachment_match_judger_test.go b/cluster/router/v3router/judger/attachment_match_judger_test.go index eabc312f35..26a8d5ed59 100644 --- a/cluster/router/v3router/judger/attachment_match_judger_test.go +++ b/cluster/router/v3router/judger/attachment_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -27,6 +26,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/cluster/router/v3router/judger/bool_match_judger_test.go b/cluster/router/v3router/judger/bool_match_judger_test.go index fb7fc2086a..a86651e400 100644 --- a/cluster/router/v3router/judger/bool_match_judger_test.go +++ b/cluster/router/v3router/judger/bool_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ import ( "github.com/stretchr/testify/assert" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestBoolMatchJudger(t *testing.T) { assert.True(t, newBoolMatchJudger(&config.BoolMatch{ Exact: true, diff --git a/cluster/router/v3router/judger/double_match_judger_test.go b/cluster/router/v3router/judger/double_match_judger_test.go index f15f604614..a2ba18b255 100644 --- a/cluster/router/v3router/judger/double_match_judger_test.go +++ b/cluster/router/v3router/judger/double_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ import ( "github.com/stretchr/testify/assert" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestDoubleMatchJudger(t *testing.T) { assert.True(t, newDoubleMatchJudger(&config.DoubleMatch{ Exact: 3.14159, diff --git a/cluster/router/v3router/judger/double_range_match_judger_test.go b/cluster/router/v3router/judger/double_range_match_judger_test.go index e8c6b6fd38..9487e404c7 100644 --- a/cluster/router/v3router/judger/double_range_match_judger_test.go +++ b/cluster/router/v3router/judger/double_range_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ import ( "github.com/stretchr/testify/assert" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestDoubleRangeMatchJudger(t *testing.T) { assert.True(t, newDoubleRangeMatchJudger(&config.DoubleRangeMatch{ Start: 1.0, diff --git a/cluster/router/v3router/judger/list_double_match_judger_test.go b/cluster/router/v3router/judger/list_double_match_judger_test.go index 696be6bef8..bc84c7801f 100644 --- a/cluster/router/v3router/judger/list_double_match_judger_test.go +++ b/cluster/router/v3router/judger/list_double_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ import ( "github.com/stretchr/testify/assert" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestListDoubleMatchJudger_Judge(t *testing.T) { assert.True(t, newListDoubleMatchJudger(&config.ListDoubleMatch{ Oneof: []*config.DoubleMatch{ diff --git a/cluster/router/v3router/judger/list_string_match_judger_test.go b/cluster/router/v3router/judger/list_string_match_judger_test.go index 169ee57f2b..1816b9503f 100644 --- a/cluster/router/v3router/judger/list_string_match_judger_test.go +++ b/cluster/router/v3router/judger/list_string_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ 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"}}, diff --git a/cluster/router/v3router/judger/method_match_judger_test.go b/cluster/router/v3router/judger/method_match_judger_test.go index d0f5023075..71e90aacb5 100644 --- a/cluster/router/v3router/judger/method_match_judger_test.go +++ b/cluster/router/v3router/judger/method_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -28,6 +27,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/cluster/router/v3router/judger/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go index a502cc3b91..fae5278fb2 100644 --- a/cluster/router/v3router/judger/string_match_judger.go +++ b/cluster/router/v3router/judger/string_match_judger.go @@ -18,11 +18,14 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "regexp" "strings" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + // nolint type StringMatchJudger struct { config.StringMatch diff --git a/cluster/router/v3router/judger/string_match_judger_test.go b/cluster/router/v3router/judger/string_match_judger_test.go index c9da665bc6..968eda96f7 100644 --- a/cluster/router/v3router/judger/string_match_judger_test.go +++ b/cluster/router/v3router/judger/string_match_judger_test.go @@ -18,7 +18,6 @@ package judger import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -26,6 +25,10 @@ import ( "github.com/stretchr/testify/assert" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestNewStringMatchJudger(t *testing.T) { assert.True(t, NewStringMatchJudger(&config.StringMatch{ Exact: "abc", diff --git a/cluster/router/v3router/k8s_api/listener_handler_impl.go b/cluster/router/v3router/k8s_api/listener_handler_impl.go index e6f660c50f..38f5748bb9 100644 --- a/cluster/router/v3router/k8s_api/listener_handler_impl.go +++ b/cluster/router/v3router/k8s_api/listener_handler_impl.go @@ -18,16 +18,18 @@ package k8s_api import ( - "dubbo.apache.org/dubbo-go/v3/config" metav "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" ) import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_crd" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/remoting" ) diff --git a/cluster/router/v3router/k8s_crd/client.go b/cluster/router/v3router/k8s_crd/client.go index bfb7d1d235..2dfe201961 100644 --- a/cluster/router/v3router/k8s_crd/client.go +++ b/cluster/router/v3router/k8s_crd/client.go @@ -29,8 +29,11 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/cache" ) diff --git a/cluster/router/v3router/k8s_crd/listener_handler.go b/cluster/router/v3router/k8s_crd/listener_handler.go index 2a522918e1..fa4272e692 100644 --- a/cluster/router/v3router/k8s_crd/listener_handler.go +++ b/cluster/router/v3router/k8s_crd/listener_handler.go @@ -21,6 +21,7 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/rest" ) diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go index b677d8f05c..ce8269493d 100644 --- a/cluster/router/v3router/router_chain.go +++ b/cluster/router/v3router/router_chain.go @@ -18,7 +18,6 @@ package v3router import ( - "dubbo.apache.org/dubbo-go/v3/config" "encoding/json" "io" "strings" @@ -33,6 +32,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/k8s_api" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/remoting" diff --git a/cluster/router/v3router/router_chain_test.go b/cluster/router/v3router/router_chain_test.go index e1af5328a5..ac4176931e 100644 --- a/cluster/router/v3router/router_chain_test.go +++ b/cluster/router/v3router/router_chain_test.go @@ -18,27 +18,22 @@ package v3router import ( - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "testing" ) import ( + "github.com/stretchr/testify/assert" + 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_center" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/yaml" + "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go index ef4b16ca36..3b552b89f0 100644 --- a/cluster/router/v3router/uniform_rule.go +++ b/cluster/router/v3router/uniform_rule.go @@ -18,7 +18,6 @@ package v3router import ( - "dubbo.apache.org/dubbo-go/v3/config" "math/rand" "time" ) @@ -31,6 +30,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/cluster/router/v3router/judger" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/common/constant/default.go b/common/constant/default.go index 6e2bf841d5..e7de3e6ed2 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -95,11 +95,3 @@ const ( DEFAULT_LOG_CONF_FILE_PATH = "../profiles/dev/log.yml" DEFAULT_ROUTER_CONF_FILE_PATH = "../profiles/dev/router.yml" ) - -// default config value -const ( - DEFAULT_REGISTRY_ZK_ID = "demoZK" - DEFAULT_REGISTRY_ZK_PROTOCOL = ZOOKEEPER_KEY - DEFAULT_REGISTRY_ZK_TIMEOUT = "3s" - DEFAULT_REGISTRY_ZK_ADDRESS = "127.0.0.1:2181" -) diff --git a/common/constant/key.go b/common/constant/key.go index de13fa4d78..5a5f9d65af 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -313,3 +313,12 @@ const ( // SERVICE_DISCOVERY_KEY indicate which service discovery instance will be used SERVICE_DISCOVERY_KEY = "service_discovery" ) + +// Generic Filter + +const ( + GenericSerializationDefault = "true" + // disable "protobuf-json" temporarily + //GenericSerializationProtobuf = "protobuf-json" + GenericSerializationGson = "gson" +) diff --git a/common/constant/serializtion.go b/common/constant/serialization.go similarity index 100% rename from common/constant/serializtion.go rename to common/constant/serialization.go diff --git a/common/host_util.go b/common/host_util.go index 9861c92bee..1f2c939b79 100644 --- a/common/host_util.go +++ b/common/host_util.go @@ -17,7 +17,9 @@ package common -import gxnet "github.com/dubbogo/gost/net" +import ( + gxnet "github.com/dubbogo/gost/net" +) var localIp string diff --git a/common/logger/file_log.yml b/common/logger/file_log.yml new file mode 100644 index 0000000000..75cc32c7ea --- /dev/null +++ b/common/logger/file_log.yml @@ -0,0 +1,36 @@ +lumberjackConfig: + filename: "logs.log" + maxSize: 1 + maxAge: 3 + maxBackups: 5 + localTime: true + compress: false + +zapConfig: + level: "debug" + development: false + disableCaller: false + disableStacktrace: false + sampling: + encoding: "console" + + # encoder + encoderConfig: + messageKey: "message" + levelKey: "level" + timeKey: "time" + nameKey: "logger" + callerKey: "caller" + stacktraceKey: "stacktrace" + lineEnding: "" + levelEncoder: "capitalColor" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + + outputPaths: + - "stderr" + errorOutputPaths: + - "stderr" + initialFields: diff --git a/common/logger/logger.go b/common/logger/logger.go index 0aa741050b..8f67836599 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -26,9 +26,14 @@ import ( import ( "github.com/apache/dubbo-getty" + + "github.com/natefinch/lumberjack" + perrors "github.com/pkg/errors" + "go.uber.org/zap" "go.uber.org/zap/zapcore" + "gopkg.in/yaml.v2" ) @@ -44,6 +49,11 @@ type DubboLogger struct { dynamicLevel zap.AtomicLevel } +type Config struct { + LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"` + ZapConfig *zap.Config `yaml:"zapConfig"` +} + // Logger is the interface for Logger types type Logger interface { Info(args ...interface{}) @@ -95,7 +105,7 @@ func InitLog(logConfFile string) error { return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", logConfFile, err) } - conf := &zap.Config{} + conf := &Config{} err = yaml.Unmarshal(confFileStream, conf) if err != nil { InitLogger(nil) @@ -108,9 +118,12 @@ func InitLog(logConfFile string) error { } // InitLogger use for init logger by @conf -func InitLogger(conf *zap.Config) { - var zapLoggerConfig zap.Config - if conf == nil { +func InitLogger(conf *Config) { + var ( + zapLogger *zap.Logger + config = &Config{} + ) + if conf == nil || conf.ZapConfig == nil { zapLoggerEncoderConfig := zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", @@ -123,7 +136,7 @@ func InitLogger(conf *zap.Config) { EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } - zapLoggerConfig = zap.Config{ + config.ZapConfig = &zap.Config{ Level: zap.NewAtomicLevelAt(zap.DebugLevel), Development: false, Encoding: "console", @@ -132,10 +145,17 @@ func InitLogger(conf *zap.Config) { ErrorOutputPaths: []string{"stderr"}, } } else { - zapLoggerConfig = *conf + config.ZapConfig = conf.ZapConfig } - zapLogger, _ := zapLoggerConfig.Build(zap.AddCallerSkip(1)) - logger = &DubboLogger{Logger: zapLogger.Sugar(), dynamicLevel: zapLoggerConfig.Level} + + if conf == nil || conf.LumberjackConfig == nil { + zapLogger, _ = config.ZapConfig.Build(zap.AddCallerSkip(1)) + } else { + config.LumberjackConfig = conf.LumberjackConfig + zapLogger = initZapLoggerWithSyncer(config) + } + + logger = &DubboLogger{Logger: zapLogger.Sugar(), dynamicLevel: config.ZapConfig.Level} // set getty log getty.SetLogger(logger) @@ -174,3 +194,29 @@ func (dl *DubboLogger) SetLoggerLevel(level string) { dl.dynamicLevel.SetLevel(*l) } } + +// initZapLoggerWithSyncer init zap Logger with syncer +func initZapLoggerWithSyncer(conf *Config) *zap.Logger { + core := zapcore.NewCore( + conf.getEncoder(), + conf.getLogWriter(), + zap.NewAtomicLevelAt(zap.DebugLevel), + ) + + return zap.New(core, zap.AddCallerSkip(1)) +} + +// getEncoder get encoder by config, zapcore support json and console encoder +func (c *Config) getEncoder() zapcore.Encoder { + if c.ZapConfig.Encoding == "json" { + return zapcore.NewJSONEncoder(c.ZapConfig.EncoderConfig) + } else if c.ZapConfig.Encoding == "console" { + return zapcore.NewConsoleEncoder(c.ZapConfig.EncoderConfig) + } + return nil +} + +// getLogWriter get Lumberjack writer by LumberjackConfig +func (c *Config) getLogWriter() zapcore.WriteSyncer { + return zapcore.AddSync(c.LumberjackConfig) +} diff --git a/common/logger/logger_test.go b/common/logger/logger_test.go index 6081f71aec..12d1ab8d29 100644 --- a/common/logger/logger_test.go +++ b/common/logger/logger_test.go @@ -81,3 +81,57 @@ func TestSetLevel(t *testing.T) { Debug("debug") Info("info") } + +func TestInitLogWidthFile(t *testing.T) { + var ( + err error + path string + ) + + err = InitLog("") + assert.EqualError(t, err, "log configure file name is nil") + + path, err = filepath.Abs("./file_log.xml") + assert.NoError(t, err) + err = InitLog(path) + assert.EqualError(t, err, "log configure file name{"+path+"} suffix must be .yml") + + path, err = filepath.Abs("./logger.yml") + assert.NoError(t, err) + err = InitLog(path) + var errMsg string + if runtime.GOOS == "windows" { + errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) + } else { + errMsg = fmt.Sprintf("open %s: no such file or directory", path) + } + assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) + + err = InitLog("./file_log.yml") + assert.NoError(t, err) + + Debug("debug") + Info("info") + Warn("warn") + Error("error") + Debugf("%s", "debug") + Infof("%s", "info") + Warnf("%s", "warn") + Errorf("%s", "error") +} + +func TestSetLevelWidthFile(t *testing.T) { + err := InitLog("./file_log.yml") + assert.NoError(t, err) + Debug("debug") + Info("info") + + assert.True(t, SetLoggerLevel("info")) + Debug("debug") + Info("info") + + SetLogger(GetLogger().(*DubboLogger).Logger) + assert.False(t, SetLoggerLevel("debug")) + Debug("debug") + Info("info") +} diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 900ea18119..819fe287e5 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -25,6 +25,7 @@ import ( import ( "github.com/apache/dubbo-go-hessian2/java_exception" + perrors "github.com/pkg/errors" ) @@ -127,24 +128,25 @@ func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) { makeDubboCallProxy := func(methodName string, outs []reflect.Type) func(in []reflect.Value) []reflect.Value { return func(in []reflect.Value) []reflect.Value { var ( - err error - inv *invocation_impl.RPCInvocation - inIArr []interface{} - inVArr []reflect.Value - reply reflect.Value + err error + inv *invocation_impl.RPCInvocation + inIArr []interface{} + inVArr []reflect.Value + reply reflect.Value + replyEmptyFlag bool ) if methodName == "Echo" { methodName = "$echo" } - if len(outs) == 2 { + if len(outs) == 2 { // return (reply, error) if outs[0].Kind() == reflect.Ptr { reply = reflect.New(outs[0].Elem()) } else { reply = reflect.New(outs[0]) } - } else { - reply = valueOf + } else { // only return error + replyEmptyFlag = true } start := 0 @@ -158,10 +160,6 @@ func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) { } start += 1 } - if len(outs) == 1 && in[end-1].Type().Kind() == reflect.Ptr { - end -= 1 - reply = in[len(in)-1] - } } if end-start <= 0 { @@ -182,8 +180,11 @@ func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) { } inv = invocation_impl.NewRPCInvocationWithOptions(invocation_impl.WithMethodName(methodName), - invocation_impl.WithArguments(inIArr), invocation_impl.WithReply(reply.Interface()), + invocation_impl.WithArguments(inIArr), invocation_impl.WithCallBack(p.callback), invocation_impl.WithParameterValues(inVArr)) + if !replyEmptyFlag { + inv.SetReply(reply.Interface()) + } for k, value := range p.attachments { inv.SetAttachments(k, value) diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 2356b9d23b..f76bc38dd3 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -136,10 +136,11 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati // prepare replyv var replyv reflect.Value - if method.ReplyType() == nil && len(method.ArgsType()) > 0 { - replyv = reflect.New(method.ArgsType()[len(method.ArgsType())-1].Elem()) - in = append(in, replyv) - } + //if method.ReplyType() == nil && len(method.ArgsType()) > 0 { + // + // replyv = reflect.New(method.ArgsType()[len(method.ArgsType())-1].Elem()) + // in = append(in, replyv) + //} returnValues := method.Method().Func.Call(in) diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go index 2ff788deef..e9bacd664e 100644 --- a/common/proxy/proxy_test.go +++ b/common/proxy/proxy_test.go @@ -26,6 +26,7 @@ import ( import ( perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/common/rpc_service.go b/common/rpc_service.go index 1bca7d9a58..1a7cbc8b7c 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -34,15 +34,43 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// RPCService +// RPCService the type alias of interface{} +type RPCService = interface{} + +// ReferencedRPCService // rpc service interface -type RPCService interface { - //// Name rpc service id - //Name() string - // Reference rpc service reference +type ReferencedRPCService interface { + // Reference: + // rpc service id or reference id Reference() string } +// GetReference return the reference id of the service. +// If the service implemented the ReferencedRPCService interface, +// it will call the Reference method. If not, it will +// return the struct name as the reference id. +func GetReference(service RPCService) string { + if s, ok := service.(ReferencedRPCService); ok { + return s.Reference() + } + + ref := "" + sType := reflect.TypeOf(service) + kind := sType.Kind() + switch kind { + case reflect.Struct: + ref = sType.Name() + case reflect.Ptr: + sName := sType.Elem().Name() + if sName != "" { + ref = sName + } else { + ref = sType.Elem().Field(0).Name + } + } + return ref +} + // AsyncCallbackService callback interface for async type AsyncCallbackService interface { // Callback: callback @@ -367,7 +395,7 @@ func suiteMethod(method reflect.Method) *MethodType { // The latest return type of the method must be error. if returnType := mtype.Out(outNum - 1); returnType != typeOfError { - logger.Warnf("the latest return type %s of method %q is not error", returnType, mname) + logger.Debugf(`"%s" method will not be exported because its last return type %v doesn't have error`, mname, returnType) return nil } diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go index 8dc984f7a5..6143e472a5 100644 --- a/common/rpc_service_test.go +++ b/common/rpc_service_test.go @@ -218,3 +218,36 @@ func TestSuiteMethod(t *testing.T) { methodType = suiteMethod(method) assert.Nil(t, methodType) } + +type ServiceWithoutRef struct{} + +func TestGetReference(t *testing.T) { + s0 := &TestService{} + ref0 := GetReference(s0) + assert.Equal(t, referenceTestPath, ref0) + + //s1 := TestService{} + //ref1 := GetReference(s1) + //assert.Equal(t, referenceTestPath, ref1) + + s2 := &struct { + TestService + }{} + ref2 := GetReference(s2) + assert.Equal(t, referenceTestPath, ref2) + + expectedReference := "ServiceWithoutRef" + s3 := &ServiceWithoutRef{} + ref3 := GetReference(s3) + assert.Equal(t, expectedReference, ref3) + + s4 := ServiceWithoutRef{} + ref4 := GetReference(s4) + assert.Equal(t, expectedReference, ref4) + + s5 := &struct { + ServiceWithoutRef + }{} + ref5 := GetReference(s5) + assert.Equal(t, expectedReference, ref5) +} diff --git a/common/url.go b/common/url.go index 7722762721..26c4ebdb34 100644 --- a/common/url.go +++ b/common/url.go @@ -32,22 +32,21 @@ import ( import ( cm "github.com/Workiva/go-datastructures/common" + gxset "github.com/dubbogo/gost/container/set" + "github.com/jinzhu/copier" + perrors "github.com/pkg/errors" + "github.com/satori/go.uuid" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// /////////////////////////////// -// dubbo role type -// /////////////////////////////// - -// role constant +// dubbo role type constant const ( // CONSUMER is consumer role CONSUMER = iota @@ -211,11 +210,7 @@ func WithToken(token string) Option { if len(token) > 0 { value := token if strings.ToLower(token) == "true" || strings.ToLower(token) == "default" { - u, err := uuid.NewV4() - if err != nil { - logger.Errorf("could not generator UUID: %v", err) - return - } + u := uuid.NewV4() value = u.String() } url.SetParam(constant.TOKEN_KEY, value) @@ -871,10 +866,9 @@ func GetCompareURLEqualFunc() CompareURLEqualFunc { return compareURLEqualFunc } -//GetParamDuration get duration if err return 3s +//GetParamDuration get duration if param is invalid or missing will return 3s func (c *URL) GetParamDuration(s string, d string) time.Duration { - timeStr := c.GetParam(s, d) - if t, err := time.ParseDuration(timeStr); err == nil { + if t, err := time.ParseDuration(c.GetParam(s, d)); err == nil { return t } return 3 * time.Second diff --git a/common/yaml/yaml.go b/common/yaml/yaml.go index 7f61f7208e..1284395793 100644 --- a/common/yaml/yaml.go +++ b/common/yaml/yaml.go @@ -24,6 +24,7 @@ import ( import ( perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/config/application_config.go b/config/application_config.go index 0f41e12fc2..b9334ad970 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -18,10 +18,13 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "github.com/creasty/defaults" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + // ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer type ApplicationConfig struct { Organization string `default:"dubbo-go" yaml:"organization" json:"organization,omitempty" property:"organization"` diff --git a/config/config_center_config.go b/config/config_center_config.go index 6a03345bb7..f83d32b520 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -18,15 +18,17 @@ package config import ( - "github.com/knadh/koanf" - "github.com/knadh/koanf/parsers/yaml" - "github.com/knadh/koanf/providers/rawbytes" "net/url" "strings" ) import ( "github.com/creasty/defaults" + + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/rawbytes" + "github.com/pkg/errors" ) diff --git a/config/config_loader.go b/config/config_loader.go index c9cd5b58b0..57b9d34212 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -18,27 +18,30 @@ package config import ( - "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/registry" "errors" "fmt" - hessian "github.com/apache/dubbo-go-hessian2" - perrors "github.com/pkg/errors" "reflect" "strconv" ) + import ( + hessian "github.com/apache/dubbo-go-hessian2" + "github.com/knadh/koanf" "github.com/knadh/koanf/parsers/json" "github.com/knadh/koanf/parsers/toml" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/file" + + perrors "github.com/pkg/errors" ) import ( + "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/observer/dispatcher" + "dubbo.apache.org/dubbo-go/v3/registry" ) var ( @@ -75,27 +78,11 @@ func check() error { return nil } -//parseCommandLine parse command line -//func parseCommandLine() { -// flag.String("delim", ".", "config file delim") -// flag.String("name", "conf_application.yaml", "config file name") -// flag.String("genre", "yaml", "config file type") -// flag.String("path", "./conf", "config file path default") -// -// pflag.CommandLine.AddGoFlagSet(flag.CommandLine) -// pflag.Parse() -// -// if err := viper.BindPFlags(pflag.CommandLine); err != nil { -// panic(err) -// } -//} - func getKoanf(conf *loaderConf) *koanf.Koanf { var ( k *koanf.Koanf err error ) - k = koanf.New(conf.delim) switch conf.genre { @@ -460,7 +447,8 @@ func GetRPCService(name string) common.RPCService { // RPCService create rpc service for consumer func RPCService(service common.RPCService) { - rootConfig.Consumer.References[service.Reference()].Implement(service) + ref := common.GetReference(service) + rootConfig.Consumer.References[ref].Implement(service) } // GetMetricConfig find the MetricConfig diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 3688a879ef..e735b64b71 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -18,7 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "fmt" "os" "path/filepath" @@ -26,10 +25,15 @@ import ( "sort" "strings" ) + import ( "github.com/pkg/errors" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + type loaderConf struct { // loaderConf file type default yaml genre string diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go index 000489823e..deb2f091dd 100644 --- a/config/config_loader_options_test.go +++ b/config/config_loader_options_test.go @@ -21,7 +21,9 @@ import ( "testing" ) -import "github.com/stretchr/testify/assert" +import ( + "github.com/stretchr/testify/assert" +) func TestCheckGenre(t *testing.T) { diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 51200e4f30..a96f60d588 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -18,13 +18,17 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "testing" ) -import "github.com/stretchr/testify/assert" +import ( + "github.com/stretchr/testify/assert" +) -import "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" +) func init() { SetProviderService(new(service.OrderService)) @@ -81,7 +85,6 @@ func TestLoadConfigCenter(t *testing.T) { } func TestGetRegistriesConfig(t *testing.T) { - t.Run("registry", func(t *testing.T) { Load(WithPath("./testdata/config/registry/application.yaml")) diff --git a/config/config_utils.go b/config/config_utils.go index 868567f6d1..13ae4d788d 100644 --- a/config/config_utils.go +++ b/config/config_utils.go @@ -19,12 +19,16 @@ package config import ( "fmt" - "github.com/go-playground/validator/v10" - "github.com/pkg/errors" "regexp" "strings" ) +import ( + "github.com/go-playground/validator/v10" + + "github.com/pkg/errors" +) + import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) diff --git a/config/consumer_config.go b/config/consumer_config.go index e2ddfd83a1..38cd1c566d 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -18,8 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/config/generic" "fmt" "time" ) @@ -30,6 +28,8 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/config/generic" ) const ( @@ -84,7 +84,7 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { func (cc *ConsumerConfig) Load() { for key, ref := range cc.References { - if ref.Generic { + if ref.Generic != "" { genericService := generic.NewGenericService(key) SetConsumerService(genericService) } diff --git a/config/generic/generic_service.go b/config/generic/generic_service.go index 34f2f7d359..677f97e564 100644 --- a/config/generic/generic_service.go +++ b/config/generic/generic_service.go @@ -17,7 +17,9 @@ package generic -import "context" +import ( + "context" +) // GenericService uses for generic invoke for service call type GenericService struct { diff --git a/config/interfaces/config_reader.go b/config/interfaces/config_reader.go index b23f989cc2..b82d87332c 100644 --- a/config/interfaces/config_reader.go +++ b/config/interfaces/config_reader.go @@ -17,7 +17,9 @@ package interfaces -import "bytes" +import ( + "bytes" +) // ConfigReader is used to read config from consumer or provider type ConfigReader interface { diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 1184f91763..70ec753802 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -18,14 +18,17 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/extension" "fmt" +) + +import ( perrors "github.com/pkg/errors" ) import ( "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/config/instance" ) diff --git a/config/method_config.go b/config/method_config.go index 990ff69ae7..113f928c40 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -18,10 +18,13 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "github.com/creasty/defaults" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) + // MethodConfig defines method config type MethodConfig struct { InterfaceId string diff --git a/config/provider_config.go b/config/provider_config.go index c5bc7877dc..4a7adef642 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -18,13 +18,16 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" "fmt" +) + +import ( "github.com/creasty/defaults" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/logger" ) // ProviderConfig is the default configuration of service provider diff --git a/config/reference_config.go b/config/reference_config.go index ec6e9457db..2c42e4bfd9 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -17,6 +17,19 @@ package config +import ( + "fmt" + "net/url" + "strconv" + "time" +) + +import ( + "github.com/creasty/defaults" + + gxstrings "github.com/dubbogo/gost/strings" +) + import ( "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common" @@ -26,12 +39,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/config/generic" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" - "fmt" - "github.com/creasty/defaults" - gxstrings "github.com/dubbogo/gost/strings" - "net/url" - "strconv" - "time" ) // ReferenceConfig is the configuration of service consumer @@ -56,7 +63,7 @@ type ReferenceConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` invoker protocol.Invoker urls []*common.URL - Generic bool `yaml:"generic" json:"generic,omitempty" property:"generic"` + Generic string `yaml:"generic" json:"generic,omitempty" property:"generic"` Sticky bool `yaml:"sticky" json:"sticky,omitempty" property:"sticky"` RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` @@ -235,7 +242,7 @@ func (rc *ReferenceConfig) getURLMap() url.Values { urlMap.Set(constant.RETRIES_KEY, rc.Retries) urlMap.Set(constant.GROUP_KEY, rc.Group) urlMap.Set(constant.VERSION_KEY, rc.Version) - urlMap.Set(constant.GENERIC_KEY, strconv.FormatBool(rc.Generic)) + urlMap.Set(constant.GENERIC_KEY, rc.Generic) urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) urlMap.Set(constant.PROVIDED_BY, rc.ProvidedBy) urlMap.Set(constant.SERIALIZATION_KEY, rc.Serialization) @@ -261,7 +268,7 @@ func (rc *ReferenceConfig) getURLMap() url.Values { // filter defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS - if rc.Generic { + if rc.Generic != "" { defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter } //urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) diff --git a/config/registry_config.go b/config/registry_config.go index 4421fc70b3..fe33b17984 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -18,7 +18,6 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/registry" "net/url" "strconv" "strings" @@ -26,6 +25,7 @@ import ( import ( "github.com/creasty/defaults" + "github.com/pkg/errors" ) @@ -34,6 +34,7 @@ import ( "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/registry" ) // RegistryConfig is the configuration of the registry center diff --git a/config/remote_config.go b/config/remote_config.go index 292a89e9d3..820f744b0b 100644 --- a/config/remote_config.go +++ b/config/remote_config.go @@ -29,7 +29,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // RemoteConfig: usually we need some middleware, including nacos, zookeeper @@ -45,8 +44,8 @@ type RemoteConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty"` } -// Prefix -func (c *RemoteConfig) Prefix() string { +// Prefix dubbo.remote. +func (rc *RemoteConfig) Prefix() string { return constant.RemotePrefix } @@ -56,8 +55,6 @@ 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) return 5 * time.Second } diff --git a/config/root_config.go b/config/root_config.go index c581b83d33..d3d49af4d5 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -19,11 +19,11 @@ package config import ( "bytes" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/logger" ) // RootConfig is the root config diff --git a/config/router_config.go b/config/router_config.go index 4b8230f5e7..28cf7a0864 100644 --- a/config/router_config.go +++ b/config/router_config.go @@ -17,10 +17,13 @@ package config +import ( + "github.com/creasty/defaults" +) + import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" "dubbo.apache.org/dubbo-go/v3/common/constant" - "github.com/creasty/defaults" ) // RouterConfig is the configuration of the router. diff --git a/config/router_config_test.go b/config/router_config_test.go index 007a61153e..bc436541f4 100644 --- a/config/router_config_test.go +++ b/config/router_config_test.go @@ -52,9 +52,9 @@ func TestString(t *testing.T) { } func TestRouterInit(t *testing.T) { - err := RouterInit(testVirtualServiceYML, testDestinationRuleYML) - assert.NoError(t, err) - - err = RouterInit(testVirtualServiceYML, errorTestDestinationRuleYML) - assert.Error(t, err) + //err := RouterInit(testVirtualServiceYML, testDestinationRuleYML) + //assert.NoError(t, err) + // + //err = RouterInit(testVirtualServiceYML, errorTestDestinationRuleYML) + //assert.Error(t, err) } diff --git a/config/service.go b/config/service.go index 3aa524d4ee..8786867b04 100644 --- a/config/service.go +++ b/config/service.go @@ -28,12 +28,14 @@ var ( // SetConsumerService is called by init() of implement of RPCService func SetConsumerService(service common.RPCService) { - conServices[service.Reference()] = service + ref := common.GetReference(service) + conServices[ref] = service } // SetProviderService is called by init() of implement of RPCService func SetProviderService(service common.RPCService) { - proServices[service.Reference()] = service + ref := common.GetReference(service) + proServices[ref] = service } // GetConsumerService gets ConsumerService by @name diff --git a/config/service_config.go b/config/service_config.go index 1ca3e9ef41..dff4479aff 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -19,7 +19,6 @@ package config import ( "container/list" - "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "fmt" "net/url" "strconv" @@ -30,8 +29,11 @@ import ( import ( "github.com/creasty/defaults" + gxnet "github.com/dubbogo/gost/net" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" ) @@ -41,6 +43,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" ) // ServiceConfig is the configuration of the service provider diff --git a/config/service_discovery_config.go b/config/service_discovery_config.go index c902f958fc..2ba2bde0bc 100644 --- a/config/service_discovery_config.go +++ b/config/service_discovery_config.go @@ -17,7 +17,9 @@ package config -import "dubbo.apache.org/dubbo-go/v3/common/constant" +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" +) // ServiceDiscoveryConfig will be used to create type ServiceDiscoveryConfig struct { diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go index a4dff89bca..feb3346047 100644 --- a/config/testdata/config/service/hello_service.go +++ b/config/testdata/config/service/hello_service.go @@ -11,4 +11,4 @@ type HelloService struct { func (HelloService) Reference() string { return "helloService" -} \ No newline at end of file +} diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go index 8c03c794ae..e19b5cd794 100644 --- a/config/testdata/config/service/order_service.go +++ b/config/testdata/config/service/order_service.go @@ -11,4 +11,4 @@ type OrderService struct { func (OrderService) Reference() string { return "orderService" -} \ No newline at end of file +} diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 2034186c0f..c011c9e40b 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -87,7 +87,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/consumer_config_with_configcenter.yml b/config/testdata/consumer_config_with_configcenter.yml index 89869dcff5..fe979dacd4 100644 --- a/config/testdata/consumer_config_with_configcenter.yml +++ b/config/testdata/consumer_config_with_configcenter.yml @@ -36,7 +36,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/consumer_config_withoutProtocol.yml b/config/testdata/consumer_config_withoutProtocol.yml index f3d9265442..6028a48db4 100644 --- a/config/testdata/consumer_config_withoutProtocol.yml +++ b/config/testdata/consumer_config_withoutProtocol.yml @@ -73,7 +73,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/provider_config.yml b/config/testdata/provider_config.yml index de22b79d72..3c081c0168 100644 --- a/config/testdata/provider_config.yml +++ b/config/testdata/provider_config.yml @@ -92,7 +92,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/testdata/provider_config_withoutProtocol.yml b/config/testdata/provider_config_withoutProtocol.yml index 3fa8100d84..651c2f4c6a 100644 --- a/config/testdata/provider_config_withoutProtocol.yml +++ b/config/testdata/provider_config_withoutProtocol.yml @@ -72,7 +72,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/config/uniform_router_config.go b/config/uniform_router_config.go index fa5d02db19..3d6f7283ea 100644 --- a/config/uniform_router_config.go +++ b/config/uniform_router_config.go @@ -19,6 +19,7 @@ package config import ( "github.com/ghodss/yaml" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 95c754e84f..4c1f107a42 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -26,7 +26,9 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" + "github.com/zouyx/agollo/v3" agolloConstant "github.com/zouyx/agollo/v3/constant" "github.com/zouyx/agollo/v3/env/config" diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 02cc5475d7..3bb20eb67b 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -17,7 +17,6 @@ package apollo import ( - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "net/http" "net/http/httptest" @@ -34,6 +33,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/parser" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -110,7 +110,6 @@ var mockConfigRes = `{ "application.environment": "dev", "services.UserProvider.protocol": "dubbo", "application.organization": "ikurento.com", - "protocol_conf.dubbo.getty_session_param.pkg_wq_size": "512", "services.UserProvider.methods[0].loadbalance": "random" }, "releaseKey": "20191104105242-0f13805d89f834a4" diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go index e13e4d5acc..9080b73877 100644 --- a/config_center/apollo/listener.go +++ b/config_center/apollo/listener.go @@ -20,6 +20,7 @@ package apollo import ( "github.com/zouyx/agollo/v3" "github.com/zouyx/agollo/v3/storage" + "gopkg.in/yaml.v2" ) diff --git a/config_center/file/impl.go b/config_center/file/impl.go index 81680b2958..a3e2cdca67 100644 --- a/config_center/file/impl.go +++ b/config_center/file/impl.go @@ -31,6 +31,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" ) diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 546642c6c1..f42b1ddd67 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -23,6 +23,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "gopkg.in/yaml.v2" ) diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go index 908012b783..08ba373cb0 100644 --- a/config_center/nacos/client.go +++ b/config_center/nacos/client.go @@ -24,6 +24,7 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + perrors "github.com/pkg/errors" ) diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 6d7326aaf0..6d19fbd51f 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -25,7 +25,9 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" ) diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go index 0d5d7d29df..5e07f43765 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -24,7 +24,9 @@ import ( import ( "github.com/magiconair/properties" + perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index c57f66d4de..b4a500c495 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -25,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" ) diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go deleted file mode 100644 index 6d33c5a821..0000000000 --- a/config_center/zookeeper/impl_test.go +++ /dev/null @@ -1,232 +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 zookeeper - -import ( - "fmt" - "path" - "strconv" - "sync" - "testing" -) - -import ( - "github.com/dubbogo/go-zookeeper/zk" - gxset "github.com/dubbogo/gost/container/set" - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/config_center/parser" -) - -const ( - dubboPropertyFileName = "dubbo.properties" -) - -func initZkData(group string, t *testing.T) (*zk.TestCluster, *zookeeperDynamicConfiguration) { - ts, err := zk.StartTestCluster(1, nil, nil, zk.WithRetryTimes(20)) - assert.NoError(t, err) - assert.NotNil(t, ts.Servers[0]) - urlString := "registry://127.0.0.1:" + strconv.Itoa(ts.Servers[0].Port) - regurl, err := common.NewURL(urlString) - assert.NoError(t, err) - regurl.AddParam(constant.REGISTRY_TIMEOUT_KEY, "15s") - zkFactory := &zookeeperDynamicConfigurationFactory{} - reg, err := zkFactory.GetDynamicConfiguration(regurl) - zreg, ok := reg.(*zookeeperDynamicConfiguration) - assert.True(t, ok) - assert.NoError(t, err) - assert.True(t, zreg.IsAvailable()) - assert.Equal(t, zreg.GetURL(), regurl) - assert.True(t, zreg.RestartCallBack()) - zreg.SetParser(&parser.DefaultConfigurationParser{}) - - data := ` - dubbo.consumer.request_timeout=5s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registries.hangzhouzk.protocol=zookeeper - dubbo.registries.hangzhouzk.timeout=3s - dubbo.registries.hangzhouzk.address=127.0.0.1:2181 - dubbo.registries.shanghaizk.protocol=zookeeper - dubbo.registries.shanghaizk.timeout=3s - dubbo.registries.shanghaizk.address=127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover -` - if group != "" { - err = zreg.client.Create(path.Join(zreg.rootPath, group, dubboPropertyFileName)) - assert.NoError(t, err) - - _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, group, dubboPropertyFileName), []byte(data), 0) - assert.NoError(t, err) - } else { - err = zreg.client.Create(path.Join(zreg.rootPath, dubboPropertyFileName)) - assert.NoError(t, err) - - _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, dubboPropertyFileName), []byte(data), 0) - assert.NoError(t, err) - } - - return ts, zreg -} - -func TestGetConfig(t *testing.T) { - ts, reg := initZkData("dubbo", t) - defer func() { - reg.client.Close() - err := ts.Stop() - assert.NoError(t, err) - }() - configs, err := reg.GetProperties(dubboPropertyFileName, config_center.WithGroup("dubbo")) - assert.NoError(t, err) - m, err := reg.Parser().Parse(configs) - assert.NoError(t, err) - assert.Equal(t, "5s", m["dubbo.consumer.request_timeout"]) - configs, err = reg.GetProperties(dubboPropertyFileName) - assert.Error(t, err) - assert.Equal(t, "", configs) - configs, err = reg.GetInternalProperty(dubboPropertyFileName) - assert.Error(t, err) - assert.Equal(t, "", configs) - configs, err = reg.GetRule(dubboPropertyFileName) - assert.Error(t, err) - assert.Equal(t, "", configs) -} - -func TestAddListener(t *testing.T) { - ts, reg := initZkData("", t) - defer func() { - reg.client.Close() - err := ts.Stop() - assert.NoError(t, err) - }() - listener := &mockDataListener{} - reg.AddListener(dubboPropertyFileName, listener) - - listener.wg.Add(1) - data := ` - dubbo.consumer.request_timeout=3s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registries.hangzhouzk.protocol=zookeeper - dubbo.registries.hangzhouzk.timeout=3s - dubbo.registries.hangzhouzk.address=127.0.0.1:2181 - dubbo.registries.shanghaizk.protocol=zookeeper - dubbo.registries.shanghaizk.timeout=3s - dubbo.registries.shanghaizk.address=127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover -` - _, err := reg.client.Conn.Set(path.Join(reg.rootPath, dubboPropertyFileName), []byte(data), 1) - assert.NoError(t, err) - listener.wg.Wait() - assert.Equal(t, dubboPropertyFileName, listener.event) -} - -func TestRemoveListener(t *testing.T) { - ts, reg := initZkData("", t) - defer func() { - reg.client.Close() - err := ts.Stop() - assert.NoError(t, err) - }() - listener := &mockDataListener{} - reg.AddListener(dubboPropertyFileName, listener) - listener.wg.Add(1) - data := ` - dubbo.consumer.request_timeout=3s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registries.hangzhouzk.protocol=zookeeper - dubbo.registries.hangzhouzk.timeout=3s - dubbo.registries.hangzhouzk.address=127.0.0.1:2181 - dubbo.registries.shanghaizk.protocol=zookeeper - dubbo.registries.shanghaizk.timeout=3s - dubbo.registries.shanghaizk.address=127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover -` - reg.RemoveListener(dubboPropertyFileName, listener) - listener.wg.Done() - _, err := reg.client.Conn.Set(path.Join(reg.rootPath, dubboPropertyFileName), []byte(data), 1) - assert.NoError(t, err) - listener.wg.Wait() - assert.Equal(t, "", listener.event) -} - -func TestZookeeperDynamicConfigurationPublishConfig(t *testing.T) { - value := "Test Data" - customGroup := "Custom Group" - key := "myKey" - ts, reg := initZkData(config_center.DEFAULT_GROUP, t) - defer func() { - reg.client.Close() - err := ts.Stop() - assert.NoError(t, err) - }() - err := reg.PublishConfig(key, customGroup, value) - assert.Nil(t, err) - result, err := reg.GetInternalProperty("myKey", config_center.WithGroup(customGroup)) - assert.Nil(t, err) - assert.Equal(t, value, result) - - var keys *gxset.HashSet - keys, err = reg.GetConfigKeysByGroup(customGroup) - assert.Nil(t, err) - assert.Equal(t, 1, keys.Size()) - assert.True(t, keys.Contains(key)) -} - -type mockDataListener struct { - wg sync.WaitGroup - event string -} - -func (l *mockDataListener) Process(configType *config_center.ConfigChangeEvent) { - fmt.Println("process!!!!!") - l.wg.Done() - l.event = configType.Key -} diff --git a/config_center/zookeeper/listener_test.go b/config_center/zookeeper/listener_test.go deleted file mode 100644 index 56c2e1ee2d..0000000000 --- a/config_center/zookeeper/listener_test.go +++ /dev/null @@ -1,101 +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 zookeeper - -import ( - "path" - "strconv" - "testing" -) - -import ( - "github.com/dubbogo/go-zookeeper/zk" - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config_center/parser" -) - -func initZkDynamicConfiguration(t *testing.T) (*zk.TestCluster, *zookeeperDynamicConfiguration) { - ts, err := zk.StartTestCluster(1, nil, nil, zk.WithRetryTimes(20)) - assert.NoError(t, err) - assert.NotNil(t, ts.Servers[0]) - urlString := "registry://127.0.0.1:" + strconv.Itoa(ts.Servers[0].Port) - regurl, err := common.NewURL(urlString) - assert.NoError(t, err) - regurl.AddParam(constant.REGISTRY_TIMEOUT_KEY, "15s") - zkFactory := &zookeeperDynamicConfigurationFactory{} - reg, err := zkFactory.GetDynamicConfiguration(regurl) - zreg, ok := reg.(*zookeeperDynamicConfiguration) - assert.True(t, ok) - assert.NoError(t, err) - assert.True(t, zreg.IsAvailable()) - assert.Equal(t, zreg.GetURL(), regurl) - assert.True(t, zreg.RestartCallBack()) - zreg.SetParser(&parser.DefaultConfigurationParser{}) - - data := ` - dubbo.application.name=dubbogo -` - err = zreg.client.Create(path.Join(zreg.rootPath, dubboPropertyFileName)) - assert.NoError(t, err) - _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, dubboPropertyFileName), []byte(data), 0) - assert.NoError(t, err) - - return ts, zreg -} - -func TestZookeeperDynamicConfigurationPathToKey(t *testing.T) { - ts, reg := initZkDynamicConfiguration(t) - defer func() { - err := ts.Stop() - assert.NoError(t, err) - }() - listener := &mockDataListener{} - key := path.Join("dubbogoDemo" + constant.CONFIGURATORS_SUFFIX) - reg.AddListener(key, listener) - listener.wg.Add(1) - - data := ` -scope: application -key: dubbogoDemo -enabled: true -configs: - - addresses: [0.0.0.0:20880] - side: provider - parameters: - weight: 60 - - addresses: [0.0.0.0:20881] - side: provider - parameters: - weight: 40 -` - zkPath := path.Join(reg.rootPath, "dubbo", key) - exists, _, err := reg.client.Conn.Exists(zkPath) - assert.NoError(t, err) - if !exists { - err = reg.client.Create(zkPath) - assert.NoError(t, err) - } - _, err = reg.client.SetContent(zkPath, []byte(data), 0) - assert.NoError(t, err) - listener.wg.Wait() - assert.Equal(t, key, listener.event) -} diff --git a/filter/accesslog/filter_test.go b/filter/accesslog/filter_test.go index 45be9de817..4bd6f2e40e 100644 --- a/filter/accesslog/filter_test.go +++ b/filter/accesslog/filter_test.go @@ -24,6 +24,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/filter/active/filter_test.go b/filter/active/filter_test.go index 9a39bb6902..964d18ad02 100644 --- a/filter/active/filter_test.go +++ b/filter/active/filter_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/filter/auth/consumer_sign_filter_test.go b/filter/auth/consumer_sign_filter_test.go index 550eeef3a1..ba024bd7ea 100644 --- a/filter/auth/consumer_sign_filter_test.go +++ b/filter/auth/consumer_sign_filter_test.go @@ -24,6 +24,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/filter/auth/provider_auth_filter_test.go b/filter/auth/provider_auth_filter_test.go index 288f56b540..1f835017d5 100644 --- a/filter/auth/provider_auth_filter_test.go +++ b/filter/auth/provider_auth_filter_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/filter/generic/filter.go b/filter/generic/filter.go index df435bb31d..4aa2d6ef5c 100644 --- a/filter/generic/filter.go +++ b/filter/generic/filter.go @@ -19,9 +19,6 @@ package generic import ( "context" - "reflect" - "strings" - "time" ) import ( @@ -31,6 +28,7 @@ import ( import ( "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/filter" "dubbo.apache.org/dubbo-go/v3/protocol" invocation2 "dubbo.apache.org/dubbo-go/v3/protocol/invocation" @@ -42,30 +40,52 @@ func init() { }) } -// when do a generic invoke, struct need to be map - -// nolint +// Filter ensures the structs are converted to maps, this filter is for consumer type Filter struct{} // Invoke turns the parameters to map for generic method func (f *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - if invocation.MethodName() == constant.GENERIC && len(invocation.Arguments()) == 3 { - oldArguments := invocation.Arguments() + if isCallingToGenericService(invoker, invocation) { + + mtdname := invocation.MethodName() + oldargs := invocation.Arguments() + + types := make([]string, 0, len(oldargs)) + args := make([]hessian.Object, 0, len(oldargs)) - if oldParams, ok := oldArguments[2].([]interface{}); ok { - newParams := make([]hessian.Object, 0, len(oldParams)) - for i := range oldParams { - newParams = append(newParams, hessian.Object(struct2MapAll(oldParams[i]))) + // get generic info from attachments of invocation, the default value is "true" + generic := invocation.AttachmentsByKey(constant.GENERIC_KEY, constant.GenericSerializationDefault) + // get generalizer according to value in the `generic` + g := getGeneralizer(generic) + + for _, arg := range oldargs { + // use the default generalizer(MapGeneralizer) + typ, err := g.GetType(arg) + if err != nil { + logger.Errorf("failed to get type, %v", err) } - newArguments := []interface{}{ - oldArguments[0], - oldArguments[1], - newParams, + obj, err := g.Generalize(arg) + if err != nil { + logger.Errorf("generalization failed, %v", err) + return invoker.Invoke(ctx, invocation) } - newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments()) - newInvocation.SetReply(invocation.Reply()) - return invoker.Invoke(ctx, newInvocation) + types = append(types, typ) + args = append(args, obj) + } + + // construct a new invocation for generic call + newargs := []interface{}{ + mtdname, + types, + args, } + newivc := invocation2.NewRPCInvocation(constant.GENERIC, newargs, invocation.Attachments()) + newivc.SetReply(invocation.Reply()) + newivc.Attachments()[constant.GENERIC_KEY] = invoker.GetURL().GetParam(constant.GENERIC_KEY, "") + + return invoker.Invoke(ctx, newivc) + } else if isMakingAGenericCall(invoker, invocation) { + invocation.Attachments()[constant.GENERIC_KEY] = invoker.GetURL().GetParam(constant.GENERIC_KEY, "") } return invoker.Invoke(ctx, invocation) } @@ -75,84 +95,3 @@ func (f *Filter) OnResponse(_ context.Context, result protocol.Result, _ protoco _ protocol.Invocation) protocol.Result { return result } - -func struct2MapAll(obj interface{}) interface{} { - if obj == nil { - return obj - } - t := reflect.TypeOf(obj) - v := reflect.ValueOf(obj) - if t.Kind() == reflect.Struct { - result := make(map[string]interface{}, t.NumField()) - for i := 0; i < t.NumField(); i++ { - field := t.Field(i) - value := v.Field(i) - kind := value.Kind() - if kind == reflect.Struct || kind == reflect.Slice || kind == reflect.Map { - if value.CanInterface() { - tmp := value.Interface() - if _, ok := tmp.(time.Time); ok { - setInMap(result, field, tmp) - continue - } - setInMap(result, field, struct2MapAll(tmp)) - } - } else { - if value.CanInterface() { - setInMap(result, field, value.Interface()) - } - } - } - return result - } else if t.Kind() == reflect.Slice { - value := reflect.ValueOf(obj) - newTemps := make([]interface{}, 0, value.Len()) - for i := 0; i < value.Len(); i++ { - newTemp := struct2MapAll(value.Index(i).Interface()) - newTemps = append(newTemps, newTemp) - } - return newTemps - } else if t.Kind() == reflect.Map { - newTempMap := make(map[interface{}]interface{}, v.Len()) - iter := v.MapRange() - for iter.Next() { - if !iter.Value().CanInterface() { - continue - } - key := iter.Key() - mapV := iter.Value().Interface() - newTempMap[convertMapKey(key)] = struct2MapAll(mapV) - } - return newTempMap - } else { - return obj - } -} - -func convertMapKey(key reflect.Value) interface{} { - switch key.Kind() { - case reflect.Bool, reflect.Int, reflect.Int8, - reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, - reflect.Uint32, reflect.Uint64, reflect.Float32, - reflect.Float64, reflect.String: - return key.Interface() - default: - return key.String() - } -} - -func setInMap(m map[string]interface{}, structField reflect.StructField, value interface{}) (result map[string]interface{}) { - result = m - if tagName := structField.Tag.Get("m"); tagName == "" { - result[headerAtoa(structField.Name)] = value - } else { - result[tagName] = value - } - return -} - -func headerAtoa(a string) (b string) { - b = strings.ToLower(a[:1]) + a[1:] - return -} diff --git a/filter/generic/filter_test.go b/filter/generic/filter_test.go index 815a6ae0e7..c8bf45a710 100644 --- a/filter/generic/filter_test.go +++ b/filter/generic/filter_test.go @@ -18,120 +18,85 @@ package generic import ( - "reflect" + "context" + "net/url" "testing" - "time" ) import ( + hessian "github.com/apache/dubbo-go-hessian2" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) -func TestStruct2MapAll(t *testing.T) { - var testData struct { - AaAa string `m:"aaAa"` - BaBa string - CaCa struct { - AaAa string - BaBa string `m:"baBa"` - XxYy struct { - xxXx string `m:"xxXx"` - Xx string `m:"xx"` - } `m:"xxYy"` - } `m:"caCa"` - DaDa time.Time - EeEe int - } - testData.AaAa = "1" - testData.BaBa = "1" - testData.CaCa.BaBa = "2" - testData.CaCa.AaAa = "2" - testData.CaCa.XxYy.xxXx = "3" - testData.CaCa.XxYy.Xx = "3" - testData.DaDa = time.Date(2020, 10, 29, 2, 34, 0, 0, time.Local) - testData.EeEe = 100 - m := struct2MapAll(testData).(map[string]interface{}) - assert.Equal(t, "1", m["aaAa"].(string)) - assert.Equal(t, "1", m["baBa"].(string)) - assert.Equal(t, "2", m["caCa"].(map[string]interface{})["aaAa"].(string)) - assert.Equal(t, "3", m["caCa"].(map[string]interface{})["xxYy"].(map[string]interface{})["xx"].(string)) - - assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"]).Kind()) - assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].(map[string]interface{})["xxYy"]).Kind()) - assert.Equal(t, "2020-10-29 02:34:00", m["daDa"].(time.Time).Format("2006-01-02 15:04:05")) - assert.Equal(t, 100, m["eeEe"].(int)) -} +import ( + "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + "dubbo.apache.org/dubbo-go/v3/protocol/mock" +) -type testStruct struct { - AaAa string - BaBa string `m:"baBa"` - XxYy struct { - xxXx string `m:"xxXx"` - Xx string `m:"xx"` - } `m:"xxYy"` -} +// test isCallingToGenericService branch +func TestFilter_Invoke(t *testing.T) { + invokeUrl := common.NewURLWithOptions( + common.WithParams(url.Values{}), + common.WithParamsValue(constant.GENERIC_KEY, constant.GenericSerializationDefault)) + filter := &Filter{} + + ctrl := gomock.NewController(t) + defer ctrl.Finish() -func TestStruct2MapAllSlice(t *testing.T) { - var testData struct { - AaAa string `m:"aaAa"` - BaBa string - CaCa []testStruct `m:"caCa"` - } - testData.AaAa = "1" - testData.BaBa = "1" - var tmp testStruct - tmp.BaBa = "2" - tmp.AaAa = "2" - tmp.XxYy.xxXx = "3" - tmp.XxYy.Xx = "3" - testData.CaCa = append(testData.CaCa, tmp) - m := struct2MapAll(testData).(map[string]interface{}) - - assert.Equal(t, "1", m["aaAa"].(string)) - assert.Equal(t, "1", m["baBa"].(string)) - assert.Equal(t, "2", m["caCa"].([]interface{})[0].(map[string]interface{})["aaAa"].(string)) - assert.Equal(t, "3", m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"].(map[string]interface{})["xx"].(string)) - - assert.Equal(t, reflect.Slice, reflect.TypeOf(m["caCa"]).Kind()) - assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"]).Kind()) + normalInvocation := invocation.NewRPCInvocation("Hello", []interface{}{"arg1"}, make(map[string]interface{})) + + mockInvoker := mock.NewMockInvoker(ctrl) + mockInvoker.EXPECT().GetUrl().Return(invokeUrl).Times(2) + mockInvoker.EXPECT().Invoke(gomock.Not(normalInvocation)).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + assert.Equal(t, constant.GENERIC, invocation.MethodName()) + args := invocation.Arguments() + assert.Equal(t, "Hello", args[0]) + assert.Equal(t, "java.lang.String", args[1].([]string)[0]) + assert.Equal(t, "arg1", args[2].([]hessian.Object)[0].(string)) + assert.Equal(t, constant.GenericSerializationDefault, invocation.AttachmentsByKey(constant.GENERIC_KEY, "")) + return &protocol.RPCResult{} + }) + + result := filter.Invoke(context.Background(), mockInvoker, normalInvocation) + assert.NotNil(t, result) } -func TestStruct2MapAllMap(t *testing.T) { - var testData struct { - AaAa string - Baba map[string]interface{} - CaCa map[string]string - DdDd map[string]interface{} - IntMap map[int]interface{} - } - testData.AaAa = "aaaa" - testData.Baba = make(map[string]interface{}) - testData.CaCa = make(map[string]string) - testData.DdDd = nil - testData.IntMap = make(map[int]interface{}) - - testData.Baba["kk"] = 1 - var structData struct { - Str string - } - structData.Str = "str" - testData.Baba["struct"] = structData - testData.Baba["nil"] = nil - testData.CaCa["k1"] = "v1" - testData.CaCa["kv2"] = "v2" - testData.IntMap[1] = 1 - m := struct2MapAll(testData) - - assert.Equal(t, reflect.Map, reflect.TypeOf(m).Kind()) - mappedStruct := m.(map[string]interface{}) - assert.Equal(t, reflect.String, reflect.TypeOf(mappedStruct["aaAa"]).Kind()) - assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["baba"]).Kind()) - assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["baba"].(map[interface{}]interface{})["struct"]).Kind()) - assert.Equal(t, "str", mappedStruct["baba"].(map[interface{}]interface{})["struct"].(map[string]interface{})["str"]) - assert.Equal(t, nil, mappedStruct["baba"].(map[interface{}]interface{})["nil"]) - assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["caCa"]).Kind()) - assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["ddDd"]).Kind()) - intMap := mappedStruct["intMap"] - assert.Equal(t, reflect.Map, reflect.TypeOf(intMap).Kind()) - assert.Equal(t, 1, intMap.(map[interface{}]interface{})[1]) +// test isMakingAGenericCall branch +func TestFilter_InvokeWithGenericCall(t *testing.T) { + invokeUrl := common.NewURLWithOptions( + common.WithParams(url.Values{}), + common.WithParamsValue(constant.GENERIC_KEY, constant.GenericSerializationDefault)) + filter := &Filter{} + + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + genericInvocation := invocation.NewRPCInvocation(constant.GENERIC, []interface{}{ + "hello", + []string{"java.lang.String"}, + []string{"arg1"}, + }, make(map[string]interface{})) + + mockInvoker := mock.NewMockInvoker(ctrl) + mockInvoker.EXPECT().GetUrl().Return(invokeUrl).Times(3) + mockInvoker.EXPECT().Invoke(gomock.Any()).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + assert.Equal(t, constant.GENERIC, invocation.MethodName()) + args := invocation.Arguments() + assert.Equal(t, "hello", args[0]) + assert.Equal(t, "java.lang.String", args[1].([]string)[0]) + assert.Equal(t, "arg1", args[2].([]string)[0]) + assert.Equal(t, constant.GenericSerializationDefault, invocation.AttachmentsByKey(constant.GENERIC_KEY, "")) + return &protocol.RPCResult{} + }) + + result := filter.Invoke(context.Background(), mockInvoker, genericInvocation) + assert.NotNil(t, result) } diff --git a/filter/generic/generalizer/example.pb.go b/filter/generic/generalizer/example.pb.go new file mode 100644 index 0000000000..13bed21e92 --- /dev/null +++ b/filter/generic/generalizer/example.pb.go @@ -0,0 +1,260 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.17.3 +// source: example.proto + +package generalizer + +import ( + reflect "reflect" + sync "sync" +) + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ResponseType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Id int64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *ResponseType) Reset() { + *x = ResponseType{} + if protoimpl.UnsafeEnabled { + mi := &file_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResponseType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseType) ProtoMessage() {} + +func (x *ResponseType) ProtoReflect() protoreflect.Message { + mi := &file_example_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseType.ProtoReflect.Descriptor instead. +func (*ResponseType) Descriptor() ([]byte, []int) { + return file_example_proto_rawDescGZIP(), []int{0} +} + +func (x *ResponseType) GetCode() int64 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *ResponseType) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ResponseType) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ResponseType) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type RequestType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *RequestType) Reset() { + *x = RequestType{} + if protoimpl.UnsafeEnabled { + mi := &file_example_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestType) ProtoMessage() {} + +func (x *RequestType) ProtoReflect() protoreflect.Message { + mi := &file_example_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestType.ProtoReflect.Descriptor instead. +func (*RequestType) Descriptor() ([]byte, []int) { + return file_example_proto_rawDescGZIP(), []int{1} +} + +func (x *RequestType) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +var File_example_proto protoreflect.FileDescriptor + +var file_example_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x22, 0x60, 0x0a, 0x0c, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x1d, + 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x32, 0x52, 0x0a, + 0x0e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x40, 0x0a, 0x09, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x67, + 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x19, 0x2e, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x3b, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_example_proto_rawDescOnce sync.Once + file_example_proto_rawDescData = file_example_proto_rawDesc +) + +func file_example_proto_rawDescGZIP() []byte { + file_example_proto_rawDescOnce.Do(func() { + file_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_proto_rawDescData) + }) + return file_example_proto_rawDescData +} + +var file_example_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_example_proto_goTypes = []interface{}{ + (*ResponseType)(nil), // 0: generalizer.ResponseType + (*RequestType)(nil), // 1: generalizer.RequestType +} +var file_example_proto_depIdxs = []int32{ + 1, // 0: generalizer.ExampleService.QueryUser:input_type -> generalizer.RequestType + 0, // 1: generalizer.ExampleService.QueryUser:output_type -> generalizer.ResponseType + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_example_proto_init() } +func file_example_proto_init() { + if File_example_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResponseType); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestType); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_example_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_example_proto_goTypes, + DependencyIndexes: file_example_proto_depIdxs, + MessageInfos: file_example_proto_msgTypes, + }.Build() + File_example_proto = out.File + file_example_proto_rawDesc = nil + file_example_proto_goTypes = nil + file_example_proto_depIdxs = nil +} diff --git a/filter/generic/generalizer/generalizer.go b/filter/generic/generalizer/generalizer.go new file mode 100644 index 0000000000..b3bd993db8 --- /dev/null +++ b/filter/generic/generalizer/generalizer.go @@ -0,0 +1,37 @@ +/* + * 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 generalizer + +import ( + "reflect" +) + +type Generalizer interface { + + // Generalize generalizes the object to a general struct. + // For example: + // map, the type of the `obj` allows a basic type, e.g. string, and a complicated type which is a POJO, see also + // `hessian.POJO` at [apache/dubbo-go-hessian2](github.com/apache/dubbo-go-hessian2). + Generalize(obj interface{}) (interface{}, error) + + // Realize realizes a general struct, described in `obj`, to an object for Golang. + Realize(obj interface{}, typ reflect.Type) (interface{}, error) + + // GetType returns the type of the `obj` + GetType(obj interface{}) (string, error) +} diff --git a/filter/generic/generalizer/gson.go b/filter/generic/generalizer/gson.go new file mode 100644 index 0000000000..7896071db9 --- /dev/null +++ b/filter/generic/generalizer/gson.go @@ -0,0 +1,100 @@ +/* + * 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 generalizer + +import ( + "encoding/json" + "reflect" + "sync" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" + + perrors "github.com/pkg/errors" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/hessian2" +) + +var ( + jsonGeneralizer Generalizer + jsonGeneralizerOnce sync.Once +) + +func GetGsonGeneralizer() Generalizer { + jsonGeneralizerOnce.Do(func() { + jsonGeneralizer = &GsonGeneralizer{} + }) + return jsonGeneralizer +} + +type GsonGeneralizer struct{} + +func (GsonGeneralizer) Generalize(obj interface{}) (interface{}, error) { + newObj, ok := obj.(hessian.POJO) + if !ok { + return nil, perrors.Errorf("unexpected type of obj(=%T), wanted is hessian pojo", obj) + } + + jsonbytes, err := json.Marshal(newObj) + if err != nil { + return nil, err + } + + return string(jsonbytes), nil +} + +func (GsonGeneralizer) Realize(obj interface{}, typ reflect.Type) (interface{}, error) { + jsonbytes, ok := obj.(string) + if !ok { + return nil, perrors.Errorf("unexpected type of obj(=%T), wanted is string", obj) + } + + // create the target object + ret, ok := reflect.New(typ).Interface().(hessian.POJO) + if !ok { + return nil, perrors.Errorf("the type of obj(=%s) should be hessian pojo", typ) + } + + err := json.Unmarshal([]byte(jsonbytes), ret) + if err != nil { + return nil, err + } + + return ret, nil +} + +func (GsonGeneralizer) GetType(obj interface{}) (typ string, err error) { + typ, err = hessian2.GetJavaName(obj) + // no error or error is not NilError + if err == nil || err != hessian2.NilError { + return + } + + typ = "java.lang.Object" + if err == hessian2.NilError { + logger.Debugf("the type of nil object couldn't be inferred, use the default value(\"%s\")", typ) + return + } + + logger.Debugf("the type of object(=%T) couldn't be recognized as a POJO, use the default value(\"%s\")", obj, typ) + return +} diff --git a/filter/generic/generalizer/gson_test.go b/filter/generic/generalizer/gson_test.go new file mode 100644 index 0000000000..96006f03b7 --- /dev/null +++ b/filter/generic/generalizer/gson_test.go @@ -0,0 +1,97 @@ +/* + * 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 generalizer + +import ( + "reflect" + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +var mockGsonGeneralizer = GetGsonGeneralizer() + +type mockGsonParent struct { + Gender, Email, Name string + Age int + Child *mockGsonChild +} + +func (p mockGsonParent) JavaClassName() string { + return "org.apache.dubbo.mockGsonParent" +} + +type mockGsonChild struct { + Gender, Email, Name string + Age int +} + +func (p mockGsonChild) JavaClassName() string { + return "org.apache.dubbo.mockGsonChild" +} + +func TestGsonGeneralizer(t *testing.T) { + c := &mockGsonChild{ + Age: 20, + Gender: "male", + Email: "childName@example.com", + Name: "childName", + } + p := mockGsonParent{ + Age: 30, + Gender: "male", + Email: "enableasync@example.com", + Name: "enableasync", + Child: c, + } + + m, err := mockGsonGeneralizer.Generalize(p) + assert.Nil(t, err) + assert.Equal(t, "{\"Gender\":\"male\",\"Email\":\"enableasync@example.com\",\"Name\":\"enableasync\",\"Age\":30,\"Child\":{\"Gender\":\"male\",\"Email\":\"childName@example.com\",\"Name\":\"childName\",\"Age\":20}}", m) + + r, err := mockGsonGeneralizer.Realize(m, reflect.TypeOf(p)) + assert.Nil(t, err) + rMockParent, ok := r.(*mockGsonParent) + assert.True(t, ok) + // parent + assert.Equal(t, "enableasync", rMockParent.Name) + assert.Equal(t, 30, rMockParent.Age) + // child + assert.Equal(t, "childName", rMockParent.Child.Name) + assert.Equal(t, 20, rMockParent.Child.Age) +} + +func TestGsonPointer(t *testing.T) { + c := &mockGsonChild{ + Age: 20, + Gender: "male", + Email: "childName@example.com", + Name: "childName", + } + + m, err := mockMapGeneralizer.Generalize(c) + assert.Nil(t, err) + newC, err := mockMapGeneralizer.Realize(m, reflect.TypeOf(c)) + assert.Nil(t, err) + rMockChild, ok := newC.(*mockGsonChild) + assert.True(t, ok) + assert.Equal(t, "childName", rMockChild.Name) + assert.Equal(t, 20, rMockChild.Age) +} diff --git a/filter/generic/generalizer/map.go b/filter/generic/generalizer/map.go new file mode 100644 index 0000000000..5aa573c372 --- /dev/null +++ b/filter/generic/generalizer/map.go @@ -0,0 +1,208 @@ +/* + * 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 generalizer + +import ( + "reflect" + "strings" + "sync" + "time" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" + + "github.com/mitchellh/mapstructure" + + perrors "github.com/pkg/errors" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/hessian2" +) + +var ( + mapGeneralizer Generalizer + mapGeneralizerOnce sync.Once +) + +func GetMapGeneralizer() Generalizer { + mapGeneralizerOnce.Do(func() { + mapGeneralizer = &MapGeneralizer{} + }) + return mapGeneralizer +} + +type MapGeneralizer struct{} + +func (g *MapGeneralizer) Generalize(obj interface{}) (gobj interface{}, err error) { + gobj = objToMap(obj) + return +} + +func (g *MapGeneralizer) Realize(obj interface{}, typ reflect.Type) (interface{}, error) { + newobj := reflect.New(typ).Interface() + err := mapstructure.Decode(obj, newobj) + if err != nil { + return nil, perrors.Errorf("realizing map failed, %v", err) + } + + return reflect.ValueOf(newobj).Elem().Interface(), nil +} + +func (g *MapGeneralizer) GetType(obj interface{}) (typ string, err error) { + typ, err = hessian2.GetJavaName(obj) + // no error or error is not NilError + if err == nil || err != hessian2.NilError { + return + } + + typ = "java.lang.Object" + if err == hessian2.NilError { + logger.Debugf("the type of nil object couldn't be inferred, use the default value(\"%s\")", typ) + return + } + + logger.Debugf("the type of object(=%T) couldn't be recognized as a POJO, use the default value(\"%s\")", obj, typ) + return +} + +// objToMap converts an object(interface{}) to a map +func objToMap(obj interface{}) interface{} { + if obj == nil { + return obj + } + + t := reflect.TypeOf(obj) + v := reflect.ValueOf(obj) + + // if obj is a POJO, get the struct from the pointer (if it is a pointer) + pojo, isPojo := obj.(hessian.POJO) + if isPojo { + for t.Kind() == reflect.Ptr { + t = t.Elem() + v = v.Elem() + } + } + + switch t.Kind() { + case reflect.Struct: + result := make(map[string]interface{}, t.NumField()) + if isPojo { + result["class"] = pojo.JavaClassName() + } + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + value := v.Field(i) + kind := value.Kind() + if !value.CanInterface() { + logger.Debugf("objToMap for %v is skipped because it couldn't be converted to interface", field) + continue + } + valueIface := value.Interface() + switch kind { + case reflect.Ptr: + if value.IsNil() { + setInMap(result, field, nil) + continue + } + setInMap(result, field, objToMap(valueIface)) + case reflect.Struct, reflect.Slice, reflect.Map: + if isPrimitive(valueIface) { + logger.Warnf("\"%s\" is primitive. The application may crash if it's transferred between "+ + "systems implemented by different languages, e.g. dubbo-go <-> dubbo-java. We recommend "+ + "you represent the object by basic types, like string.", value.Type()) + setInMap(result, field, valueIface) + continue + } + + setInMap(result, field, objToMap(valueIface)) + default: + setInMap(result, field, valueIface) + } + } + return result + case reflect.Array, reflect.Slice: + value := reflect.ValueOf(obj) + newTemps := make([]interface{}, 0, value.Len()) + for i := 0; i < value.Len(); i++ { + newTemp := objToMap(value.Index(i).Interface()) + newTemps = append(newTemps, newTemp) + } + return newTemps + case reflect.Map: + newTempMap := make(map[interface{}]interface{}, v.Len()) + iter := v.MapRange() + for iter.Next() { + if !iter.Value().CanInterface() { + continue + } + key := iter.Key() + mapV := iter.Value().Interface() + newTempMap[mapKey(key)] = objToMap(mapV) + } + return newTempMap + case reflect.Ptr: + return objToMap(v.Elem().Interface()) + default: + return obj + } +} + +// mapKey converts the map key to interface type +func mapKey(key reflect.Value) interface{} { + switch key.Kind() { + case reflect.Bool, reflect.Int, reflect.Int8, + reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, + reflect.Uint32, reflect.Uint64, reflect.Float32, + reflect.Float64, reflect.String: + return key.Interface() + default: + name := key.String() + if name == "class" { + panic(`"class" is a reserved keyword`) + } + return name + } +} + +// setInMap sets the struct into the map using the tag or the name of the struct as the key +func setInMap(m map[string]interface{}, structField reflect.StructField, value interface{}) (result map[string]interface{}) { + result = m + if tagName := structField.Tag.Get("m"); tagName == "" { + result[toUnexport(structField.Name)] = value + } else { + result[tagName] = value + } + return +} + +// toUnexport is to lower the first letter +func toUnexport(a string) string { + return strings.ToLower(a[:1]) + a[1:] +} + +// isPrimitive determines if the object is primitive +func isPrimitive(obj interface{}) bool { + if _, ok := obj.(time.Time); ok { + return true + } + return false +} diff --git a/filter/generic/generalizer/map_test.go b/filter/generic/generalizer/map_test.go new file mode 100644 index 0000000000..e90f679376 --- /dev/null +++ b/filter/generic/generalizer/map_test.go @@ -0,0 +1,249 @@ +/* + * 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 generalizer + +import ( + "reflect" + "testing" + "time" +) + +import ( + "github.com/stretchr/testify/assert" +) + +type testPlainObj struct { + AaAa string `m:"aaAa"` + BaBa string + CaCa struct { + AaAa string + BaBa string `m:"baBa"` + XxYy struct { + xxXx string `m:"xxXx"` + Xx string `m:"xx"` + } `m:"xxYy"` + } `m:"caCa"` + DaDa time.Time + EeEe int +} + +func TestObjToMap(t *testing.T) { + obj := &testPlainObj{} + obj.AaAa = "1" + obj.BaBa = "1" + obj.CaCa.BaBa = "2" + obj.CaCa.AaAa = "2" + obj.CaCa.XxYy.xxXx = "3" + obj.CaCa.XxYy.Xx = "3" + obj.DaDa = time.Date(2020, 10, 29, 2, 34, 0, 0, time.Local) + obj.EeEe = 100 + m := objToMap(obj).(map[string]interface{}) + assert.Equal(t, "1", m["aaAa"].(string)) + assert.Equal(t, "1", m["baBa"].(string)) + assert.Equal(t, "2", m["caCa"].(map[string]interface{})["aaAa"].(string)) + assert.Equal(t, "3", m["caCa"].(map[string]interface{})["xxYy"].(map[string]interface{})["xx"].(string)) + + assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].(map[string]interface{})["xxYy"]).Kind()) + assert.Equal(t, "2020-10-29 02:34:00", m["daDa"].(time.Time).Format("2006-01-02 15:04:05")) + assert.Equal(t, 100, m["eeEe"].(int)) +} + +type testStruct struct { + AaAa string + BaBa string `m:"baBa"` + XxYy struct { + xxXx string `m:"xxXx"` + Xx string `m:"xx"` + } `m:"xxYy"` +} + +func TestObjToMap_Slice(t *testing.T) { + var testData struct { + AaAa string `m:"aaAa"` + BaBa string + CaCa []testStruct `m:"caCa"` + } + testData.AaAa = "1" + testData.BaBa = "1" + var tmp testStruct + tmp.BaBa = "2" + tmp.AaAa = "2" + tmp.XxYy.xxXx = "3" + tmp.XxYy.Xx = "3" + testData.CaCa = append(testData.CaCa, tmp) + m := objToMap(testData).(map[string]interface{}) + + assert.Equal(t, "1", m["aaAa"].(string)) + assert.Equal(t, "1", m["baBa"].(string)) + assert.Equal(t, "2", m["caCa"].([]interface{})[0].(map[string]interface{})["aaAa"].(string)) + assert.Equal(t, "3", m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"].(map[string]interface{})["xx"].(string)) + + assert.Equal(t, reflect.Slice, reflect.TypeOf(m["caCa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(m["caCa"].([]interface{})[0].(map[string]interface{})["xxYy"]).Kind()) +} + +func TestObjToMap_Map(t *testing.T) { + var testData struct { + AaAa string + Baba map[string]interface{} + CaCa map[string]string + DdDd map[string]interface{} + IntMap map[int]interface{} + } + testData.AaAa = "aaaa" + testData.Baba = make(map[string]interface{}) + testData.CaCa = make(map[string]string) + testData.DdDd = nil + testData.IntMap = make(map[int]interface{}) + + testData.Baba["kk"] = 1 + var structData struct { + Str string + } + structData.Str = "str" + testData.Baba["struct"] = structData + testData.Baba["nil"] = nil + testData.CaCa["k1"] = "v1" + testData.CaCa["kv2"] = "v2" + testData.IntMap[1] = 1 + m := objToMap(testData) + + assert.Equal(t, reflect.Map, reflect.TypeOf(m).Kind()) + mappedStruct := m.(map[string]interface{}) + assert.Equal(t, reflect.String, reflect.TypeOf(mappedStruct["aaAa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["baba"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["baba"].(map[interface{}]interface{})["struct"]).Kind()) + assert.Equal(t, "str", mappedStruct["baba"].(map[interface{}]interface{})["struct"].(map[string]interface{})["str"]) + assert.Equal(t, nil, mappedStruct["baba"].(map[interface{}]interface{})["nil"]) + assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["caCa"]).Kind()) + assert.Equal(t, reflect.Map, reflect.TypeOf(mappedStruct["ddDd"]).Kind()) + intMap := mappedStruct["intMap"] + assert.Equal(t, reflect.Map, reflect.TypeOf(intMap).Kind()) + assert.Equal(t, 1, intMap.(map[interface{}]interface{})[1]) +} + +var mockMapGeneralizer = GetMapGeneralizer() + +type mockParent struct { + Gender, Email, Name string + Age int + Child *mockChild +} + +func (p mockParent) JavaClassName() string { + return "org.apache.dubbo.mockParent" +} + +type mockChild struct { + Gender, Email, Name string + Age int +} + +func (c *mockChild) JavaClassName() string { + return "org.apache.dubbo.mockChild" +} + +func TestPOJOClassName(t *testing.T) { + c := &mockChild{ + Age: 20, + Gender: "male", + Email: "lmc@example.com", + Name: "lmc", + } + p := mockParent{ + Age: 30, + Gender: "male", + Email: "xavierniu@example.com", + Name: "xavierniu", + Child: c, + } + + m, err := mockMapGeneralizer.Generalize(p) + assert.Nil(t, err) + // parent + assert.Equal(t, "xavierniu", m.(map[string]interface{})["name"].(string)) + assert.Equal(t, 30, m.(map[string]interface{})["age"].(int)) + assert.Equal(t, "org.apache.dubbo.mockParent", m.(map[string]interface{})["class"].(string)) + // child + assert.Equal(t, 20, m.(map[string]interface{})["child"].(map[string]interface{})["age"].(int)) + assert.Equal(t, "lmc", m.(map[string]interface{})["child"].(map[string]interface{})["name"].(string)) + assert.Equal(t, "org.apache.dubbo.mockChild", m.(map[string]interface{})["child"].(map[string]interface{})["class"].(string)) + + r, err := mockMapGeneralizer.Realize(m, reflect.TypeOf(p)) + assert.Nil(t, err) + rMockParent, ok := r.(mockParent) + assert.True(t, ok) + // parent + assert.Equal(t, "xavierniu", rMockParent.Name) + assert.Equal(t, 30, rMockParent.Age) + // child + assert.Equal(t, "lmc", rMockParent.Child.Name) + assert.Equal(t, 20, rMockParent.Child.Age) +} + +func TestPOJOArray(t *testing.T) { + c1 := &mockChild{ + Age: 20, + Gender: "male", + Email: "lmc@example.com", + Name: "lmc", + } + c2 := &mockChild{ + Age: 21, + Gender: "male", + Email: "lmc1@example.com", + Name: "lmc1", + } + + pojoArr := []*mockChild{c1, c2} + + m, err := mockMapGeneralizer.Generalize(pojoArr) + assert.Nil(t, err) + assert.Equal(t, "lmc", m.([]interface{})[0].(map[string]interface{})["name"].(string)) + assert.Equal(t, 20, m.([]interface{})[0].(map[string]interface{})["age"].(int)) + assert.Equal(t, "lmc1", m.([]interface{})[1].(map[string]interface{})["name"].(string)) + assert.Equal(t, 21, m.([]interface{})[1].(map[string]interface{})["age"].(int)) + + r, err := mockMapGeneralizer.Realize(m, reflect.TypeOf(pojoArr)) + assert.Nil(t, err) + rPojoArr, ok := r.([]*mockChild) + assert.True(t, ok) + assert.Equal(t, "lmc", rPojoArr[0].Name) + assert.Equal(t, 20, rPojoArr[0].Age) + assert.Equal(t, "lmc1", rPojoArr[1].Name) + assert.Equal(t, 21, rPojoArr[1].Age) +} + +func TestNullField(t *testing.T) { + p := mockParent{ + Age: 30, + Gender: "male", + Email: "xavierniu@example.com", + Name: "xavierniu", + } + + m, _ := mockMapGeneralizer.Generalize(p) + assert.Nil(t, m.(map[string]interface{})["child"]) + + r, err := mockMapGeneralizer.Realize(m, reflect.TypeOf(p)) + assert.Nil(t, err) + rMockParent, ok := r.(mockParent) + assert.True(t, ok) + assert.Nil(t, rMockParent.Child) +} diff --git a/filter/generic/generalizer/protobuf_json.go b/filter/generic/generalizer/protobuf_json.go new file mode 100644 index 0000000000..200f64976f --- /dev/null +++ b/filter/generic/generalizer/protobuf_json.go @@ -0,0 +1,92 @@ +/* + * 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 generalizer + +import ( + "reflect" + "sync" +) + +import ( + perrors "github.com/pkg/errors" + + "google.golang.org/protobuf/encoding/protojson" + + "google.golang.org/protobuf/proto" +) + +var ( + protobufJsonGeneralizer Generalizer + protobufJsonGeneralizerOnce sync.Once +) + +func GetProtobufJsonGeneralizer() Generalizer { + protobufJsonGeneralizerOnce.Do(func() { + protobufJsonGeneralizer = &ProtobufJsonGeneralizer{} + }) + return protobufJsonGeneralizer +} + +// ProtobufJsonGeneralizer generalizes an object to json and realizes an object from json using protobuf. +// Currently, ProtobufJsonGeneralizer is disabled temporarily until the triple protocol is ready. +type ProtobufJsonGeneralizer struct{} + +func (g *ProtobufJsonGeneralizer) Generalize(obj interface{}) (interface{}, error) { + message, ok := obj.(proto.Message) + if !ok { + return nil, perrors.Errorf("unexpected type of obj(=%T), wanted is proto.Message", obj) + } + + jsonbytes, err := protojson.Marshal(message) + if err != nil { + return nil, err + } + + return string(jsonbytes), nil +} + +func (g *ProtobufJsonGeneralizer) Realize(obj interface{}, typ reflect.Type) (interface{}, error) { + jsonbytes, ok := obj.(string) + if !ok { + return nil, perrors.Errorf("unexpected type of obj(=%T), wanted is string", obj) + } + + // typ represents a struct instead of a pointer + for typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } + + // create the target object + ret, ok := reflect.New(typ).Interface().(proto.Message) + if !ok { + return nil, perrors.Errorf("the type of obj(=%s) should be proto.Message", typ) + } + + // get the values from json + err := protojson.Unmarshal([]byte(jsonbytes), ret) + if err != nil { + return nil, err + } + + return ret, nil +} + +// GetType returns empty string for "protobuf-json" +func (g *ProtobufJsonGeneralizer) GetType(_ interface{}) (string, error) { + return "", nil +} diff --git a/filter/generic/generalizer/protobuf_json_test.go b/filter/generic/generalizer/protobuf_json_test.go new file mode 100644 index 0000000000..7103141cb6 --- /dev/null +++ b/filter/generic/generalizer/protobuf_json_test.go @@ -0,0 +1,59 @@ +/* + * 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 generalizer + +import ( + "reflect" + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +func TestProtobufJsonGeneralizer(t *testing.T) { + g := GetProtobufJsonGeneralizer() + + req := &RequestType{ + Id: 1, + } + reqjson, err := g.Generalize(req) + assert.Nil(t, err) + rreq, err := g.Realize(reqjson, reflect.TypeOf(req)) + assert.Nil(t, err) + reqobj, ok := rreq.(*RequestType) + assert.True(t, ok) + assert.Equal(t, req.Id, reqobj.GetId()) + + resp := &ResponseType{ + Code: 200, + Id: 1, + Name: "xavierniu", + Message: "Nice to meet you", + } + respjson, err := g.Generalize(resp) + assert.Nil(t, err) + rresp, err := g.Realize(respjson, reflect.TypeOf(resp)) + assert.Nil(t, err) + respobj, ok := rresp.(*ResponseType) + assert.True(t, ok) + assert.Equal(t, resp.Code, respobj.GetCode()) + assert.Equal(t, resp.Id, respobj.GetId()) + assert.Equal(t, resp.Name, respobj.GetName()) + assert.Equal(t, resp.Message, respobj.GetMessage()) +} diff --git a/filter/generic/service_filter.go b/filter/generic/service_filter.go index 1bcd9820c8..2b6f7e4685 100644 --- a/filter/generic/service_filter.go +++ b/filter/generic/service_filter.go @@ -19,12 +19,11 @@ package generic import ( "context" - "reflect" ) import ( hessian "github.com/apache/dubbo-go-hessian2" - "github.com/mitchellh/mapstructure" + perrors "github.com/pkg/errors" ) @@ -38,90 +37,95 @@ import ( invocation2 "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) -const ( - // nolint - GENERIC_SERIALIZATION_DEFAULT = "true" -) - func init() { extension.SetFilter(constant.GenericServiceFilterKey, func() filter.Filter { return &ServiceFilter{} }) } -// nolint +// ServiceFilter is for Server type ServiceFilter struct{} -// Invoke is used to call service method by invocation func (f *ServiceFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - logger.Infof("invoking generic service filter.") - logger.Debugf("generic service filter methodName:%v,args:%v", invocation.MethodName(), len(invocation.Arguments())) - - if invocation.MethodName() != constant.GENERIC || len(invocation.Arguments()) != 3 { + if !isGenericInvocation(invocation) { return invoker.Invoke(ctx, invocation) } - var ( - ok bool - err error - methodName string - newParams []interface{} - genericKey string - argsType []reflect.Type - oldParams []hessian.Object - ) - - url := invoker.GetURL() - methodName = invocation.Arguments()[0].(string) - // get service - svc := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey()) - // get method - method := svc.Method()[methodName] + // get real invocation info from the generic invocation + mtdname := invocation.Arguments()[0].(string) + // types are not required in dubbo-go, for dubbo-go client to dubbo-go server, types could be nil + types := invocation.Arguments()[1] + args := invocation.Arguments()[2].([]hessian.Object) + + logger.Debugf(`received a generic invocation: + MethodName: %s, + Types: %s, + Args: %s + `, mtdname, types, args) + + // get the type of the argument + ivkUrl := invoker.GetURL() + svc := common.ServiceMap.GetServiceByServiceKey(ivkUrl.Protocol, ivkUrl.ServiceKey()) + method := svc.Method()[mtdname] if method == nil { - logger.Errorf("[Generic Service Filter] Don't have this method: %s", methodName) - return &protocol.RPCResult{} - } - argsType = method.ArgsType() - genericKey = invocation.AttachmentsByKey(constant.GENERIC_KEY, GENERIC_SERIALIZATION_DEFAULT) - if genericKey == GENERIC_SERIALIZATION_DEFAULT { - oldParams, ok = invocation.Arguments()[2].([]hessian.Object) - } else { - logger.Errorf("[Generic Service Filter] Don't support this generic: %s", genericKey) - return &protocol.RPCResult{} - } - if !ok { - logger.Errorf("[Generic Service Filter] wrong serialization") - return &protocol.RPCResult{} + return &protocol.RPCResult{ + Err: perrors.Errorf("\"%s\" method is not found, service key: %s", mtdname, ivkUrl.ServiceKey()), + } } - if len(oldParams) != len(argsType) { - logger.Errorf("[Generic Service Filter] method:%s invocation arguments number was wrong", methodName) - return &protocol.RPCResult{} + argsType := method.ArgsType() + + // get generic info from attachments of invocation, the default value is "true" + generic := invocation.AttachmentsByKey(constant.GENERIC_KEY, constant.GenericSerializationDefault) + // get generalizer according to value in the `generic` + g := getGeneralizer(generic) + + //if strings.ToLower(generic) == constant.GenericSerializationProtobuf { + // if len(args) > 1 { + // logger.Warnf("\"%s\" only supports one argument, but we get %d arguments actually", + // constant.GenericSerializationProtobuf, len(args)) + // } + //} + + if len(args) != len(argsType) { + return &protocol.RPCResult{ + Err: perrors.Errorf("the number of args(=%d) is not matched with \"%s\" method", len(args), mtdname), + } } - // oldParams convert to newParams - newParams = make([]interface{}, len(oldParams)) - for i := range argsType { - newParam := reflect.New(argsType[i]).Interface() - err = mapstructure.Decode(oldParams[i], newParam) - newParam = reflect.ValueOf(newParam).Elem().Interface() + + // realize + newargs := make([]interface{}, len(argsType)) + for i := 0; i < len(argsType); i++ { + newarg, err := g.Realize(args[i], argsType[i]) if err != nil { - logger.Errorf("[Generic Service Filter] decode arguments map to struct wrong: error{%v}", perrors.WithStack(err)) - return &protocol.RPCResult{} + return &protocol.RPCResult{ + Err: perrors.Errorf("realization failed, %v", err), + } } - newParams[i] = newParam + newargs[i] = newarg } - newInvocation := invocation2.NewRPCInvocation(methodName, newParams, invocation.Attachments()) - newInvocation.SetReply(invocation.Reply()) - return invoker.Invoke(ctx, newInvocation) + + // build a normal invocation + newivc := invocation2.NewRPCInvocation(mtdname, newargs, invocation.Attachments()) + newivc.SetReply(invocation.Reply()) + + return invoker.Invoke(ctx, newivc) } -// nolint -func (f *ServiceFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - if invocation.MethodName() == constant.GENERIC && len(invocation.Arguments()) == 3 && result.Result() != nil { - v := reflect.ValueOf(result.Result()) - if v.Kind() == reflect.Ptr { - v = v.Elem() +func (f *ServiceFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, invocation protocol.Invocation) protocol.Result { + if isGenericInvocation(invocation) && result.Result() != nil { + // get generic info from attachments of invocation, the default value is "true" + generic := invocation.AttachmentsByKey(constant.GENERIC_KEY, constant.GenericSerializationDefault) + // get generalizer according to value in the `generic` + g := getGeneralizer(generic) + + obj, err := g.Generalize(result.Result()) + if err != nil { + err = perrors.Errorf("generalizaion failed, %v", err) + result.SetError(err) + result.SetResult(nil) + return result } - result.SetResult(struct2MapAll(v.Interface())) + result.SetResult(obj) } return result } diff --git a/filter/generic/service_filter_test.go b/filter/generic/service_filter_test.go index f049b2788c..c6eb49904a 100644 --- a/filter/generic/service_filter_test.go +++ b/filter/generic/service_filter_test.go @@ -19,132 +19,196 @@ package generic import ( "context" - "errors" - "reflect" + "fmt" + "net/url" "testing" ) import ( hessian "github.com/apache/dubbo-go-hessian2" + + "github.com/golang/mock/gomock" + + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/filter/generic/generalizer" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + "dubbo.apache.org/dubbo-go/v3/protocol/mock" ) -type TestStruct struct { - AaAa string - BaBa string `m:"baBa"` - XxYy struct { - xxXx string `m:"xxXx"` - Xx string `m:"xx"` - } `m:"xxYy"` -} +type MockHelloService struct{} -func (c *TestStruct) JavaClassName() string { - return "com.test.testStruct" +func (s *MockHelloService) Hello(who string) (string, error) { + return fmt.Sprintf("hello, %s", who), nil } -type TestService struct{} - -// nolint -func (ts *TestService) MethodOne(_ context.Context, test1 *TestStruct, test2 []TestStruct, - test3 interface{}, test4 []interface{}, test5 *string) (*TestStruct, error) { - if test1 == nil { - return nil, errors.New("param test1 is nil") - } - if test2 == nil { - return nil, errors.New("param test2 is nil") - } - if test3 == nil { - return nil, errors.New("param test3 is nil") - } - if test4 == nil { - return nil, errors.New("param test4 is nil") - } - if test5 == nil { - return nil, errors.New("param test5 is nil") - } - return &TestStruct{}, nil +func (s *MockHelloService) JavaClassName() string { + return "org.apache.dubbo.hello" } -// nolint -func (*TestService) Reference() string { - return "com.test.Path" +func (s *MockHelloService) Reference() string { + return "org.apache.dubbo.test" } -func TestGenericServiceFilterInvoke(t *testing.T) { - hessian.RegisterPOJO(&TestStruct{}) - methodName := "$invoke" - m := make(map[string]interface{}) - m["AaAa"] = "nihao" - x := make(map[string]interface{}) - x["xxXX"] = "nihaoxxx" - m["XxYy"] = x - aurguments := []interface{}{ - "MethodOne", - nil, - []hessian.Object{ - hessian.Object(m), - hessian.Object(append(make([]map[string]interface{}, 1), m)), - hessian.Object("111"), - hessian.Object(append(make([]map[string]interface{}, 1), m)), - hessian.Object("222"), - }, +func (s *MockHelloService) HelloPB(req *generalizer.RequestType) (*generalizer.ResponseType, error) { + if req.GetId() == 1 { + return &generalizer.ResponseType{ + Code: 200, + Id: 1, + Name: "xavierniu", + Message: "Nice to meet you", + }, nil } - s := &TestService{} - _, _ = common.ServiceMap.Register("com.test.Path", "testprotocol", "", "", s) - rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil) + return nil, perrors.Errorf("people not found") +} + +func TestServiceFilter_Invoke(t *testing.T) { filter := &ServiceFilter{} - url, _ := common.NewURL("testprotocol://127.0.0.1:20000/com.test.Path") - result := filter.Invoke(context.Background(), &proxy_factory.ProxyInvoker{BaseInvoker: *protocol.NewBaseInvoker(url)}, rpcInvocation) - assert.NotNil(t, result) + + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockInvoker := mock.NewMockInvoker(ctrl) + + // methodName is not "$invoke" + invocation1 := invocation.NewRPCInvocation("test", nil, nil) + mockInvoker.EXPECT().Invoke(gomock.Eq(invocation1)) + _ = filter.Invoke(context.Background(), mockInvoker, invocation1) + // arguments are nil + invocation2 := invocation.NewRPCInvocation(constant.GENERIC, nil, nil) + mockInvoker.EXPECT().Invoke(gomock.Eq(invocation2)) + _ = filter.Invoke(context.Background(), mockInvoker, invocation2) + // the number of arguments is not 3 + invocation3 := invocation.NewRPCInvocation(constant.GENERIC, []interface{}{"hello"}, nil) + mockInvoker.EXPECT().Invoke(gomock.Eq(invocation3)) + _ = filter.Invoke(context.Background(), mockInvoker, invocation3) + + // hello service + service := &MockHelloService{} + // invoke URL + ivkUrl := common.NewURLWithOptions( + common.WithProtocol("test"), + common.WithParams(url.Values{}), + common.WithParamsValue(constant.INTERFACE_KEY, service.Reference()), + common.WithParamsValue(constant.GENERIC_KEY, constant.GenericSerializationDefault)) + // registry RPC service + _, err := common.ServiceMap.Register(ivkUrl.GetParam(constant.INTERFACE_KEY, ""), + ivkUrl.Protocol, + "", + "", + service) + assert.Nil(t, err) + + // mock + mockInvoker.EXPECT().GetUrl().Return(ivkUrl).Times(3) + + // invoke a method without errors using default generalization + invocation4 := invocation.NewRPCInvocation(constant.GENERIC, + []interface{}{ + "Hello", + []string{"java.lang.String"}, + []hessian.Object{"world"}, + }, map[string]interface{}{ + constant.GENERIC_KEY: "true", + }) + // invoke a non-existed method + invocation5 := invocation.NewRPCInvocation(constant.GENERIC, + []interface{}{ + "hello11", + []string{"java.lang.String"}, + []hessian.Object{"world"}, + }, map[string]interface{}{ + constant.GENERIC_KEY: "true", + }) + // invoke a method with incorrect arguments + invocation6 := invocation.NewRPCInvocation(constant.GENERIC, + []interface{}{ + "Hello", + []string{"java.lang.String", "java.lang.String"}, + []hessian.Object{"world", "haha"}, + }, map[string]interface{}{ + constant.GENERIC_KEY: "true", + }) + // invoke a method without errors using protobuf-json generalization + //invocation7 := invocation.NewRPCInvocation(constant.GENERIC, + // []interface{}{ + // "HelloPB", + // []string{}, + // []hessian.Object{"{\"id\":1}"}, + // }, map[string]interface{}{ + // constant.GENERIC_KEY: constant.GenericSerializationProtobuf, + // }) + + mockInvoker.EXPECT().Invoke(gomock.All( + gomock.Not(invocation1), + gomock.Not(invocation2), + gomock.Not(invocation3), + )).DoAndReturn( + func(invocation protocol.Invocation) protocol.Result { + switch invocation.MethodName() { + case "Hello": + who := invocation.Arguments()[0].(string) + result, _ := service.Hello(who) + return &protocol.RPCResult{ + Rest: result, + } + case "HelloPB": + req := invocation.Arguments()[0].(*generalizer.RequestType) + result, _ := service.HelloPB(req) + return &protocol.RPCResult{ + Rest: result, + } + default: + panic("this branch shouldn't be reached") + } + }).AnyTimes() + + result := filter.Invoke(context.Background(), mockInvoker, invocation4) assert.Nil(t, result.Error()) + assert.Equal(t, "hello, world", result.Result()) + + result = filter.Invoke(context.Background(), mockInvoker, invocation5) + assert.Equal(t, + fmt.Sprintf("\"hello11\" method is not found, service key: %s", ivkUrl.ServiceKey()), + fmt.Sprintf("%v", result.Error().(error))) + + result = filter.Invoke(context.Background(), mockInvoker, invocation6) + assert.Equal(t, + "the number of args(=2) is not matched with \"Hello\" method", + fmt.Sprintf("%v", result.Error().(error))) + + //result = filter.Invoke(context.Background(), mockInvoker, invocation7) + //assert.Equal(t, int64(200), result.Result().(*generalizer.ResponseType).GetCode()) + //assert.Equal(t, int64(1), result.Result().(*generalizer.ResponseType).GetId()) + //assert.Equal(t, "xavierniu", result.Result().(*generalizer.ResponseType).GetName()) + //assert.Equal(t, "Nice to meet you", result.Result().(*generalizer.ResponseType).GetMessage()) + } -func TestGenericServiceFilterResponseTestStruct(t *testing.T) { - ts := &TestStruct{ - AaAa: "aaa", - BaBa: "bbb", - XxYy: struct { - xxXx string `m:"xxXx"` - Xx string `m:"xx"` - }{}, - } - result := &protocol.RPCResult{ - Rest: ts, - } - aurguments := []interface{}{ - "MethodOne", - nil, - []hessian.Object{nil}, - } +func TestServiceFilter_OnResponse(t *testing.T) { filter := &ServiceFilter{} - methodName := "$invoke" - rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil) - r := filter.OnResponse(context.TODO(), result, nil, rpcInvocation) - assert.NotNil(t, r.Result()) - assert.Equal(t, reflect.ValueOf(r.Result()).Kind(), reflect.Map) -} -func TestGenericServiceFilterResponseString(t *testing.T) { - str := "111" - result := &protocol.RPCResult{ - Rest: str, - } - aurguments := []interface{}{ - "MethodOne", - nil, - []hessian.Object{nil}, + // invoke a method without errors + invocation1 := invocation.NewRPCInvocation(constant.GENERIC, + []interface{}{ + "hello", + []interface{}{"java.lang.String"}, + []interface{}{"world"}, + }, map[string]interface{}{ + constant.GENERIC_KEY: "true", + }) + + rpcResult := &protocol.RPCResult{ + Rest: "result", } - filter := &ServiceFilter{} - methodName := "$invoke" - rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil) - r := filter.OnResponse(context.TODO(), result, nil, rpcInvocation) - assert.NotNil(t, r.Result()) - assert.Equal(t, reflect.ValueOf(r.Result()).Kind(), reflect.String) + + result := filter.OnResponse(context.Background(), rpcResult, nil, invocation1) + assert.Equal(t, "result", result.Result()) } diff --git a/filter/generic/util.go b/filter/generic/util.go new file mode 100644 index 0000000000..a7fe467bb5 --- /dev/null +++ b/filter/generic/util.go @@ -0,0 +1,80 @@ +/* + * 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 generic + +import ( + "strings" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/filter/generic/generalizer" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +// isCallingToGenericService check if it calls to a generic service +func isCallingToGenericService(invoker protocol.Invoker, invocation protocol.Invocation) bool { + return isGeneric(invoker.GetURL().GetParam(constant.GENERIC_KEY, "")) && + invocation.MethodName() != constant.GENERIC +} + +// isMakingAGenericCall check if it is making a generic call to a generic service +func isMakingAGenericCall(invoker protocol.Invoker, invocation protocol.Invocation) bool { + return isGeneric(invoker.GetURL().GetParam(constant.GENERIC_KEY, "")) && + invocation.MethodName() == constant.GENERIC && + invocation.Arguments() != nil && + len(invocation.Arguments()) == 3 +} + +// isGeneric receives a generic field from url of invoker to determine whether the service is generic or not +func isGeneric(generic string) bool { + lowerGeneric := strings.ToLower(generic) + return lowerGeneric == constant.GenericSerializationDefault +} + +// isGenericInvocation determines if the invocation has generic format +func isGenericInvocation(invocation protocol.Invocation) bool { + return invocation.MethodName() == constant.GENERIC && + invocation.Arguments() != nil && + len(invocation.Arguments()) == 3 +} + +// toUnexport is to lower the first letter +func toUnexport(a string) string { + return strings.ToLower(a[:1]) + a[1:] +} + +// toExport is to upper the first letter +func toExport(a string) string { + return strings.ToUpper(a[:1]) + a[1:] +} + +func getGeneralizer(generic string) (g generalizer.Generalizer) { + switch strings.ToLower(generic) { + case constant.GenericSerializationDefault: + g = generalizer.GetMapGeneralizer() + case constant.GenericSerializationGson: + g = generalizer.GetGsonGeneralizer() + + default: + logger.Debugf("\"%s\" is not supported, use the default generalizer(MapGeneralizer)", generic) + g = generalizer.GetMapGeneralizer() + } + return +} diff --git a/filter/hystrix/filter.go b/filter/hystrix/filter.go index 39e06707d4..70dffcbc28 100644 --- a/filter/hystrix/filter.go +++ b/filter/hystrix/filter.go @@ -26,7 +26,9 @@ import ( import ( "github.com/afex/hystrix-go/hystrix" + perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/filter/hystrix/filter_test.go b/filter/hystrix/filter_test.go index fdf5e76367..4718fa2195 100644 --- a/filter/hystrix/filter_test.go +++ b/filter/hystrix/filter_test.go @@ -25,7 +25,9 @@ import ( import ( "github.com/afex/hystrix-go/hystrix" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/filter/sentinel/filter.go b/filter/sentinel/filter.go index 474ad2e9b3..ceadb3259a 100644 --- a/filter/sentinel/filter.go +++ b/filter/sentinel/filter.go @@ -42,7 +42,6 @@ import ( // 1. Must initialize Sentinel Go run environment, // refer to https://github.com/alibaba/sentinel-golang/blob/master/api/init.go // 2. Register rules for resources user want to guard - func init() { extension.SetFilter(constant.SentinelConsumerFilterKey, func() filter.Filter { return &ConsumerFilter{} diff --git a/filter/sentinel/filter_test.go b/filter/sentinel/filter_test.go index 20710f1946..521c42a253 100644 --- a/filter/sentinel/filter_test.go +++ b/filter/sentinel/filter_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/alibaba/sentinel-golang/core/flow" + "github.com/stretchr/testify/assert" ) diff --git a/filter/tps/filter_test.go b/filter/tps/filter_test.go index 3c8cce5cfc..8e0a5293dc 100644 --- a/filter/tps/filter_test.go +++ b/filter/tps/filter_test.go @@ -25,6 +25,7 @@ import ( import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) diff --git a/filter/tps/limiter/method_service_test.go b/filter/tps/limiter/method_service_test.go index f3924940dd..df79def826 100644 --- a/filter/tps/limiter/method_service_test.go +++ b/filter/tps/limiter/method_service_test.go @@ -18,13 +18,13 @@ package limiter import ( - "dubbo.apache.org/dubbo-go/v3/filter" "net/url" "testing" ) import ( "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" ) @@ -32,6 +32,7 @@ import ( "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/filter" "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/filter/tps/strategy/mock.go b/filter/tps/strategy/mock.go index d9b45d4914..154d78b78a 100644 --- a/filter/tps/strategy/mock.go +++ b/filter/tps/strategy/mock.go @@ -22,11 +22,11 @@ package strategy import ( - gomock "github.com/golang/mock/gomock" + reflect "reflect" ) import ( - reflect "reflect" + gomock "github.com/golang/mock/gomock" ) // MockTpsLimitStrategy is a mock of TpsLimitStrategy interface diff --git a/go.mod b/go.mod index 4f3c85b55c..bcf2c42d66 100644 --- a/go.mod +++ b/go.mod @@ -7,15 +7,14 @@ require ( github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alibaba/sentinel-golang v1.0.2 - github.com/apache/dubbo-getty v1.4.3 + github.com/apache/dubbo-getty v1.4.5 github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 - github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df - github.com/emicklei/go-restful/v3 v3.4.0 - github.com/frankban/quicktest v1.4.1 // indirect - github.com/fsnotify/fsnotify v1.4.9 + github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf + github.com/emicklei/go-restful/v3 v3.5.2 + github.com/fsnotify/fsnotify v1.5.0 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 @@ -23,30 +22,30 @@ require ( github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 - github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 - github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 + github.com/hashicorp/vault/sdk v0.2.1 + github.com/jinzhu/copier v0.3.2 github.com/knadh/koanf v1.1.1 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd github.com/nacos-group/nacos-sdk-go v1.0.8 + github.com/natefinch/lumberjack v2.0.0+incompatible github.com/opentracing/opentracing-go v1.2.0 - github.com/pierrec/lz4 v2.2.6+incompatible // indirect github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.9.0 - github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b - github.com/stretchr/objx v0.2.0 // indirect + github.com/prometheus/client_golang v1.11.0 + github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 - 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/api/v3 v3.5.0 + go.etcd.io/etcd/client/v3 v3.5.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 + go.uber.org/zap v1.17.0 google.golang.org/grpc v1.38.0 + google.golang.org/protobuf v1.27.1 + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.16.9 k8s.io/apimachinery v0.16.9 k8s.io/client-go v0.16.9 - k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect ) diff --git a/go.sum b/go.sum index 231e6682c9..2c8159f22f 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -11,6 +12,7 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= @@ -24,6 +26,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= +github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -49,8 +53,8 @@ github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTk github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 h1:zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA= github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= +github.com/apache/dubbo-getty v1.4.5 h1:MptKbjC0n2Mo/8eFPwirSInH2BfdNG4IZch43PdNvIM= +github.com/apache/dubbo-getty v1.4.5/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= @@ -59,11 +63,14 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= +github.com/armon/go-metrics v0.3.3/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.30.27/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -98,6 +105,16 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC 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/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= +github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= +github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/containerd v1.3.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= +github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.0.0-20200709052629-daa8e1ccc0bc/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo= +github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= +github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= +github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o= +github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -106,8 +123,9 @@ 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.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -123,11 +141,15 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v1.4.2-0.20200319182547-c7ad2b866182/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= 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.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -135,6 +157,8 @@ github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df h1:YSfvAnU0ebwLqWnD+5HTTsFhqA+aE4Si2c10zBsUW7c= github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= +github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf h1:lj0hNwbjk7UpqyEYo6Kz4poTH4w5UfyqI4Gl6x3HEqo= +github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -147,8 +171,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0 h1:IIDhql3oyWZj1ay2xBZGb4sTOWMad0HVW8rwhVxN/Yk= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.5.2 h1:RCNMSbcGIVafG4ZfgIXIEHTaV59ZRsi41IvZ7RC9+ls= +github.com/emicklei/go-restful/v3 v3.5.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -166,11 +190,12 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTg 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= -github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= +github.com/frankban/quicktest v1.10.0 h1:Gfh+GAJZOAoKZsIZeZbdn2JF10kN1XHNvjsvQK8gVkE= +github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= 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/fsnotify/fsnotify v1.5.0 h1:NO5hkcB+srp1x6QmwvNZLeaOgbM8cmBTN32THzjvu2k= +github.com/fsnotify/fsnotify v1.5.0/go.mod h1:BX0DCEr5pT4jm2CnQdVP1lFV521fcCNcyEeNp4DQQDk= 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= @@ -188,8 +213,10 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= +github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= @@ -212,9 +239,13 @@ github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -263,6 +294,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= @@ -287,6 +319,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORR github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -299,8 +332,9 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92Bcuy github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= @@ -313,14 +347,20 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY= +github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= @@ -333,8 +373,9 @@ github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= +github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -342,9 +383,11 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= +github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE= github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267 h1:e1ok06zGrWJW91rzRroyl5nRNqraaBe4d5hiKcVZuHM= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= +github.com/hashicorp/vault/sdk v0.1.14-0.20200519221530-14615acda45f/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= +github.com/hashicorp/vault/sdk v0.2.1 h1:S4O6Iv/dyKlE9AUTXGa7VOvZmsCvg36toPKgV4f2P4M= +github.com/hashicorp/vault/sdk v0.2.1/go.mod h1:WfUiO1vYzfBkz1TmoE4ZGU7HD0T0Cl/rZwaxjBkgN4U= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= @@ -355,10 +398,11 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4= github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= +github.com/jinzhu/copier v0.3.2 h1:QdBOCbaouLDYaIPFfi1bKv5F5tPpeTwXe4sD0jqtz5w= +github.com/jinzhu/copier v0.3.2/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= +github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -371,8 +415,9 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV 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/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -392,6 +437,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +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= @@ -415,6 +461,7 @@ github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -440,6 +487,7 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -452,6 +500,8 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -460,6 +510,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nacos-group/nacos-sdk-go v1.0.8 h1:8pEm05Cdav9sQgJSv5kyvlgfz0SzFUUGI3pWX6SiSnM= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= +github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= +github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= @@ -485,6 +537,13 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -507,9 +566,10 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= +github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -524,10 +584,12 @@ 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.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= 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_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= 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= @@ -543,8 +605,10 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 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= +github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -552,8 +616,9 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= @@ -566,14 +631,15 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= @@ -593,11 +659,13 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= 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.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 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= +github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -610,15 +678,13 @@ github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -639,12 +705,14 @@ github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E= github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= +github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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= @@ -653,12 +721,16 @@ 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/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/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.0 h1:2aQv6F436YnN7I4VbI8PPYrBhu+SmrTaADcf8Mi/6PU= +go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= 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/client/v3 v3.5.0 h1:62Eh0XOro+rDwkrypAGDfgmNh5Joq+z+W9HZdlXMzek= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= 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= @@ -678,15 +750,17 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= 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.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= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -697,6 +771,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= @@ -715,8 +790,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -724,8 +799,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -747,14 +822,17 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= 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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -768,6 +846,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -787,11 +867,13 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -805,26 +887,35 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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-20200416051211-89c76fbcd5d1/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= @@ -844,6 +935,7 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -858,8 +950,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK 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/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -892,8 +984,9 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG 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/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -910,6 +1003,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= @@ -924,8 +1018,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -938,13 +1034,17 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= @@ -958,16 +1058,17 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= k8s.io/api v0.16.9 h1:3vCx0WX9qcg1Hv4aQ/G1tiIKectGVuimvPVTJU4VOCA= k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= @@ -980,9 +1081,8 @@ k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUc k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/imports/imports.go b/imports/imports.go index d093efc9ef..661269dfe3 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -3,27 +3,21 @@ package imports import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" - _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" _ "dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc" _ "dubbo.apache.org/dubbo-go/v3/protocol/rest" - _ "dubbo.apache.org/dubbo-go/v3/registry/etcdv3" _ "dubbo.apache.org/dubbo-go/v3/registry/nacos" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/metadata/mapping/dynamic/service_name_mapping.go b/metadata/mapping/dynamic/service_name_mapping.go index e1dbb7dcfe..7839e07670 100644 --- a/metadata/mapping/dynamic/service_name_mapping.go +++ b/metadata/mapping/dynamic/service_name_mapping.go @@ -18,7 +18,6 @@ package dynamic import ( - "dubbo.apache.org/dubbo-go/v3/config" "strconv" "sync" "time" @@ -26,6 +25,7 @@ import ( import ( "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" ) @@ -34,6 +34,7 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/mapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go index 75aa80b2b0..5124b30eb0 100644 --- a/metadata/mapping/dynamic/service_name_mapping_test.go +++ b/metadata/mapping/dynamic/service_name_mapping_test.go @@ -18,17 +18,18 @@ package dynamic import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" ) diff --git a/metadata/mapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go index 3175a50607..cc104399bc 100644 --- a/metadata/mapping/memory/service_name_mapping.go +++ b/metadata/mapping/memory/service_name_mapping.go @@ -18,7 +18,6 @@ package memory import ( - "dubbo.apache.org/dubbo-go/v3/config" "sync" ) @@ -28,6 +27,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go index e1495d1539..db6310ee81 100644 --- a/metadata/report/delegate/delegate_report.go +++ b/metadata/report/delegate/delegate_report.go @@ -26,7 +26,9 @@ import ( import ( "github.com/go-co-op/gocron" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" ) diff --git a/metadata/report/delegate/delegate_report_test.go b/metadata/report/delegate/delegate_report_test.go index 41dd4001c0..5d2b40ba0c 100644 --- a/metadata/report/delegate/delegate_report_test.go +++ b/metadata/report/delegate/delegate_report_test.go @@ -25,6 +25,7 @@ import ( import ( "github.com/stretchr/testify/assert" + "go.uber.org/atomic" ) diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go index 836b43b329..2d83fa3dde 100644 --- a/metadata/report/etcd/report.go +++ b/metadata/report/etcd/report.go @@ -20,7 +20,6 @@ package etcd import ( "encoding/json" "strings" - "time" ) import ( @@ -146,7 +145,7 @@ type etcdMetadataReportFactory struct{} // CreateMetadataReport get the MetadataReport instance of etcd func (e *etcdMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport { - timeout, _ := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) addresses := strings.Split(url.Location, ",") client, err := gxetcd.NewClient(gxetcd.MetadataETCDV3Client, addresses, timeout, 1) if err != nil { diff --git a/metadata/report/etcd/report_test.go b/metadata/report/etcd/report_test.go index d0162ebd4b..81eece018e 100644 --- a/metadata/report/etcd/report_test.go +++ b/metadata/report/etcd/report_test.go @@ -26,6 +26,7 @@ import ( import ( "github.com/stretchr/testify/assert" + "go.etcd.io/etcd/server/v3/embed" ) diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go index a351726a10..30f68b81bd 100644 --- a/metadata/report/nacos/report.go +++ b/metadata/report/nacos/report.go @@ -24,7 +24,9 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" ) diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go index 8d4da70f6b..68220c532d 100644 --- a/metadata/report/zookeeper/report.go +++ b/metadata/report/zookeeper/report.go @@ -25,6 +25,7 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxzookeeper "github.com/dubbogo/gost/database/kv/zk" ) diff --git a/metadata/report/zookeeper/report_test.go b/metadata/report/zookeeper/report_test.go deleted file mode 100644 index 8d718db214..0000000000 --- a/metadata/report/zookeeper/report_test.go +++ /dev/null @@ -1,203 +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 zookeeper - -import ( - "encoding/json" - "net/url" - "strconv" - "testing" -) - -import ( - "github.com/dubbogo/go-zookeeper/zk" - "github.com/stretchr/testify/assert" -) - -import ( - "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/metadata/identifier" - "dubbo.apache.org/dubbo-go/v3/metadata/report" -) - -func newProviderRegistryUrl(host string, port int) *common.URL { - return common.NewURLWithOptions( - common.WithIp(host), - common.WithPort(strconv.Itoa(port)), - common.WithParams(url.Values{}), - common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)), - ) -} - -func newBaseMetadataIdentifier(side string) *identifier.BaseMetadataIdentifier { - return &identifier.BaseMetadataIdentifier{ - ServiceInterface: "org.apache.HelloWorld", - Version: "1.0.0", - Group: "group", - Side: side, - } -} - -func newMetadataIdentifier(side string) *identifier.MetadataIdentifier { - return &identifier.MetadataIdentifier{ - Application: "application", - BaseMetadataIdentifier: *newBaseMetadataIdentifier(side), - } -} - -func newServiceMetadataIdentifier(side string) *identifier.ServiceMetadataIdentifier { - return &identifier.ServiceMetadataIdentifier{ - Revision: "1.0", - Protocol: "dubbo", - BaseMetadataIdentifier: *newBaseMetadataIdentifier(side), - } -} - -func newSubscribeMetadataIdentifier() *identifier.SubscriberMetadataIdentifier { - return &identifier.SubscriberMetadataIdentifier{ - Revision: "1.0", - BaseApplicationMetadataIdentifier: identifier.BaseApplicationMetadataIdentifier{Application: "provider"}, - } -} - -type zookeeperMetadataReportTestSuite struct { - t *testing.T - m report.MetadataReport -} - -func newZookeeperMetadataReportTestSuite(t *testing.T, m report.MetadataReport) *zookeeperMetadataReportTestSuite { - return &zookeeperMetadataReportTestSuite{t: t, m: m} -} - -func (suite *zookeeperMetadataReportTestSuite) testStoreProviderMetadata() { - providerMi := newMetadataIdentifier("provider") - providerMeta := "provider" - err := suite.m.StoreProviderMetadata(providerMi, providerMeta) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testStoreConsumerMetadata() { - consumerMi := newMetadataIdentifier("consumer") - consumerMeta := "consumer" - err := suite.m.StoreProviderMetadata(consumerMi, consumerMeta) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testSaveServiceMetadata(url *common.URL) { - serviceMi := newServiceMetadataIdentifier("provider") - err := suite.m.SaveServiceMetadata(serviceMi, url) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testRemoveServiceMetadata() { - serviceMi := newServiceMetadataIdentifier("provider") - err := suite.m.RemoveServiceMetadata(serviceMi) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testGetExportedURLs() { - serviceMi := newServiceMetadataIdentifier("provider") - urls, err := suite.m.GetExportedURLs(serviceMi) - assert.Equal(suite.t, 1, len(urls)) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testSaveSubscribedData(url *common.URL) { - subscribeMi := newSubscribeMetadataIdentifier() - urls := []string{url.String()} - bytes, _ := json.Marshal(urls) - err := suite.m.SaveSubscribedData(subscribeMi, string(bytes)) - assert.Nil(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testGetSubscribedURLs() { - subscribeMi := newSubscribeMetadataIdentifier() - urls, err := suite.m.GetSubscribedURLs(subscribeMi) - assert.Equal(suite.t, 1, len(urls)) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testGetServiceDefinition() { - providerMi := newMetadataIdentifier("provider") - providerMeta, err := suite.m.GetServiceDefinition(providerMi) - assert.Equal(suite.t, "provider", providerMeta) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testPublishAppMetadata() { - subscribeMi := newSubscribeMetadataIdentifier() - info := common.NewMetadataInfWithApp(subscribeMi.Application) - err := suite.m.PublishAppMetadata(subscribeMi, info) - assert.NoError(suite.t, err) -} - -func (suite *zookeeperMetadataReportTestSuite) testGetAppMetadata() { - subscribeMi := newSubscribeMetadataIdentifier() - info, err := suite.m.GetAppMetadata(subscribeMi) - assert.NoError(suite.t, err) - assert.Equal(suite.t, "provider", info.App) -} - -func testInterfaceMetadata(t *testing.T) { - testCluster, err := zk.StartTestCluster(1, nil, nil, zk.WithRetryTimes(20)) - assert.NoError(t, err) - defer func() { - err := testCluster.Stop() - assert.Nil(t, err) - }() - - providerRegistryUrl := newProviderRegistryUrl("127.0.0.1", testCluster.Servers[0].Port) - mf := extension.GetMetadataReportFactory("zookeeper") - m := mf.CreateMetadataReport(providerRegistryUrl) - - suite := newZookeeperMetadataReportTestSuite(t, m) - suite.testStoreProviderMetadata() - suite.testStoreConsumerMetadata() - suite.testSaveServiceMetadata(providerRegistryUrl) - suite.testGetExportedURLs() - suite.testRemoveServiceMetadata() - suite.testSaveSubscribedData(providerRegistryUrl) - suite.testGetSubscribedURLs() - suite.testGetServiceDefinition() -} - -func testAppMetadata(t *testing.T) { - testCluster, err := zk.StartTestCluster(1, nil, nil, zk.WithRetryTimes(20)) - assert.NoError(t, err) - defer func() { - err := testCluster.Stop() - assert.Nil(t, err) - }() - - providerRegistryUrl := newProviderRegistryUrl("127.0.0.1", testCluster.Servers[0].Port) - mf := extension.GetMetadataReportFactory("zookeeper") - m := mf.CreateMetadataReport(providerRegistryUrl) - - suite := newZookeeperMetadataReportTestSuite(t, m) - suite.testPublishAppMetadata() - suite.testGetAppMetadata() -} - -// TestZookeeperMetadataReport is dependent on zookeeper-*-fatjar.jar, -// please execute `make -f ../../../Makefile prepare` before running unittest. -func TestZookeeperMetadataReport(t *testing.T) { - t.Run("testInterfaceMetadata", testInterfaceMetadata) - t.Run("testAppMetadata", testAppMetadata) -} diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 65f9f8e68f..d43e8cf46e 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -27,11 +27,9 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" + _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" - - // these three import is necessary for inmemory metadata service, export or refer. - _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" ) diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index f94aa12624..ea5a74c22e 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -18,7 +18,6 @@ package configurable import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" ) @@ -29,6 +28,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" @@ -46,7 +46,6 @@ func TestConfigurableExporter(t *testing.T) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go index 2d920952d9..794d463aff 100644 --- a/metadata/service/local/service.go +++ b/metadata/service/local/service.go @@ -17,7 +17,6 @@ package local import ( - "dubbo.apache.org/dubbo-go/v3/config" "sort" "sync" ) @@ -31,6 +30,7 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/metadata/definition" "dubbo.apache.org/dubbo-go/v3/metadata/service" ) diff --git a/metadata/service/local_service.go b/metadata/service/local_service.go index 135dae04fd..1230e3a1eb 100644 --- a/metadata/service/local_service.go +++ b/metadata/service/local_service.go @@ -30,7 +30,7 @@ import ( // MetadataService is used to define meta data related behaviors // usually the implementation should be singleton type MetadataService interface { - common.RPCService + common.ReferencedRPCService // ServiceName will get the service's name in meta service , which is application name ServiceName() (string, error) // ExportURL will store the exported url in metadata @@ -94,7 +94,7 @@ func (mts *BaseMetadataService) ServiceName() (string, error) { return mts.serviceName, nil } -// Version will return the version of metadata service +// Reference will return the reference id of metadata service func (mts *BaseMetadataService) Reference() string { return constant.SIMPLE_METADATA_SERVICE_NAME } diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go index df4f758930..1ad4c37d17 100644 --- a/protocol/dubbo/dubbo_codec.go +++ b/protocol/dubbo/dubbo_codec.go @@ -24,6 +24,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 0d65c885fc..7ae67232b7 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -165,7 +165,11 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati // get timeout including methodConfig func (di *DubboInvoker) getTimeout(invocation *invocation_impl.RPCInvocation) time.Duration { - timeout := di.GetURL().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "") + methodName := invocation.MethodName() + if di.GetURL().GetParamBool(constant.GENERIC_KEY, false) { + methodName = invocation.Arguments()[0].(string) + } + timeout := di.GetURL().GetParam(strings.Join([]string{constant.METHOD_KEYS, methodName, constant.TIMEOUT_KEY}, "."), "") if len(timeout) != 0 { if t, err := time.ParseDuration(timeout); err == nil { // config timeout into attachment diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 901547f91f..7bbfb0539d 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -27,8 +27,11 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/opentracing/opentracing-go" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) @@ -112,7 +115,6 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -130,7 +132,6 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 72f5b11682..30e985e9a0 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -52,7 +52,6 @@ func initDubboInvokerTest() { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -71,7 +70,6 @@ func initDubboInvokerTest() { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/protocol/dubbo/hessian2/hessian_dubbo.go b/protocol/dubbo/hessian2/hessian_dubbo.go index f61733fbed..5ae8b26436 100644 --- a/protocol/dubbo/hessian2/hessian_dubbo.go +++ b/protocol/dubbo/hessian2/hessian_dubbo.go @@ -25,6 +25,7 @@ import ( import ( "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) diff --git a/protocol/dubbo/hessian2/hessian_dubbo_test.go b/protocol/dubbo/hessian2/hessian_dubbo_test.go index e7f24584ed..fe09e4ff2b 100644 --- a/protocol/dubbo/hessian2/hessian_dubbo_test.go +++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go @@ -27,6 +27,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go index ab564b003f..1a92b66613 100644 --- a/protocol/dubbo/hessian2/hessian_request.go +++ b/protocol/dubbo/hessian2/hessian_request.go @@ -19,7 +19,6 @@ package hessian2 import ( "encoding/binary" - "reflect" "strconv" "strings" "time" @@ -27,6 +26,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) @@ -34,100 +34,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -///////////////////////////////////////// -// dubbo -///////////////////////////////////////// - func getArgType(v interface{}) string { - if v == nil { - return "V" - } - - switch v := v.(type) { - // Serialized tags for base types - case nil: - return "V" - case bool: - return "Z" - case []bool: - return "[Z" - case byte: - return "B" - case []byte: - return "[B" - case int8: - return "B" - case []int8: - return "[B" - case int16: - return "S" - case []int16: - return "[S" - case uint16: // Equivalent to Char of Java - return "C" - case []uint16: - return "[C" - // case rune: - // return "C" - case int: - return "J" - case []int: - return "[J" - case int32: - return "I" - case []int32: - return "[I" - case int64: - return "J" - case []int64: - return "[J" - case time.Time: - return "java.util.Date" - case []time.Time: - return "[Ljava.util.Date" - case float32: - return "F" - case []float32: - return "[F" - case float64: - return "D" - case []float64: - return "[D" - case string: - return "java.lang.String" - case []string: - return "[Ljava.lang.String;" - case []hessian.Object: - return "[Ljava.lang.Object;" - case map[interface{}]interface{}: - // return "java.util.HashMap" - return "java.util.Map" - case hessian.POJOEnum: - return v.(hessian.POJOEnum).JavaClassName() - // Serialized tags for complex types - default: - t := reflect.TypeOf(v) - if reflect.Ptr == t.Kind() { - t = reflect.TypeOf(reflect.ValueOf(v).Elem()) - } - switch t.Kind() { - case reflect.Struct: - return "java.lang.Object" - case reflect.Slice, reflect.Array: - if t.Elem().Kind() == reflect.Struct { - return "[Ljava.lang.Object;" - } - // return "java.util.ArrayList" - return "java.util.List" - case reflect.Map: // Enter here, map may be map[string]int - return "java.util.Map" - default: - return "" - } - } - - // unreachable - // return "java.lang.RuntimeException" + return GetClassDesc(v) } func getArgsTypeList(args []interface{}) (string, error) { diff --git a/protocol/dubbo/hessian2/hessian_request_test.go b/protocol/dubbo/hessian2/hessian_request_test.go index 98d5f2399c..3e7550280e 100644 --- a/protocol/dubbo/hessian2/hessian_request_test.go +++ b/protocol/dubbo/hessian2/hessian_request_test.go @@ -26,6 +26,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) diff --git a/protocol/dubbo/hessian2/hessian_response.go b/protocol/dubbo/hessian2/hessian_response.go index 47dc866cf0..df4aebdc92 100644 --- a/protocol/dubbo/hessian2/hessian_response.go +++ b/protocol/dubbo/hessian2/hessian_response.go @@ -22,16 +22,19 @@ import ( "reflect" "strconv" "strings" - - "dubbo.apache.org/dubbo-go/v3/common/logger" ) import ( hessian "github.com/apache/dubbo-go-hessian2" "github.com/apache/dubbo-go-hessian2/java_exception" + perrors "github.com/pkg/errors" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" +) + // DubboResponse dubbo response type DubboResponse struct { RspObj interface{} diff --git a/protocol/dubbo/hessian2/hessian_response_test.go b/protocol/dubbo/hessian2/hessian_response_test.go index 86c2e43a9e..3daaa1a55c 100644 --- a/protocol/dubbo/hessian2/hessian_response_test.go +++ b/protocol/dubbo/hessian2/hessian_response_test.go @@ -24,6 +24,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) diff --git a/protocol/dubbo/hessian2/java_class.go b/protocol/dubbo/hessian2/java_class.go new file mode 100644 index 0000000000..4f43161b88 --- /dev/null +++ b/protocol/dubbo/hessian2/java_class.go @@ -0,0 +1,201 @@ +/* + * 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 hessian2 + +import ( + "fmt" + "reflect" + "strings" + "time" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" + + perrors "github.com/pkg/errors" +) + +var ( + NilError = perrors.Errorf("object should not be nil") + UnexpectedTypeError = perrors.Errorf("object should be a POJO") + notBasicClassError = perrors.Errorf("object isn't a basic class") +) + +// GetJavaName returns java name of an object +func GetJavaName(obj interface{}) (string, error) { + if obj == nil { + return "", NilError + } + + t := reflect.TypeOf(obj) + + // basic types, e.g. bool, int, etc. + if jtype, err := getBasicJavaName(t); err == nil { + return jtype, nil + } + + // complicated types, e.g. array, slice, etc. + switch t.Kind() { + case reflect.Array, reflect.Slice: + sb := &strings.Builder{} + itemtyp := t + for itemtyp.Kind() == reflect.Array || itemtyp.Kind() == reflect.Slice { + sb.WriteString("[]") + itemtyp = itemtyp.Elem() + } + var ( + javaName string + err error + ) + if javaName, err = getBasicJavaName(itemtyp); err != nil { + if javaName, err = GetJavaName(reflect.New(itemtyp).Elem().Interface()); err != nil { + return "", err + } + } + return fmt.Sprintf("%s%s", javaName, sb), nil + case reflect.Map: + return "java.util.Map", nil + default: + pojo, ok := obj.(hessian.POJO) + if !ok { + return "", UnexpectedTypeError + } + return pojo.JavaClassName(), nil + } +} + +func getBasicJavaName(typ reflect.Type) (string, error) { + switch typ.Kind() { + case reflect.Bool: + return "boolean", nil + case reflect.Int, reflect.Int64: // in 64-bit processor, Int takes a 64-bit space + return "long", nil + case reflect.Int32: + return "int", nil + case reflect.Int8, reflect.Int16: + return "short", nil + case reflect.Uint, reflect.Uint64: // in 64-bit processor, Uint takes a 64-bit space + return "unsigned long", nil + case reflect.Uint32: + return "unsigned int", nil + case reflect.Uint16: + return "unsigned short", nil + case reflect.Uint8: + return "char", nil + case reflect.Float32: + return "float", nil + case reflect.Float64: + return "double", nil + case reflect.String: + return "java.lang.String", nil + } + + return "", notBasicClassError +} + +// GetClassDesc get class desc. +// - boolean[].class => "[Z" +// - Object.class => "Ljava/lang/Object;" +func GetClassDesc(v interface{}) string { + if v == nil { + return "V" + } + + switch v := v.(type) { + // Serialized tags for base types + case nil: + return "V" + case bool: + return "Z" + case []bool: + return "[Z" + case byte: + return "B" + case []byte: + return "[B" + case int8: + return "B" + case []int8: + return "[B" + case int16: + return "S" + case []int16: + return "[S" + case uint16: // Equivalent to Char of Java + return "C" + case []uint16: + return "[C" + // case rune: + // return "C" + case int: + return "J" + case []int: + return "[J" + case int32: + return "I" + case []int32: + return "[I" + case int64: + return "J" + case []int64: + return "[J" + case time.Time: + return "java.util.Date" + case []time.Time: + return "[Ljava.util.Date" + case float32: + return "F" + case []float32: + return "[F" + case float64: + return "D" + case []float64: + return "[D" + case string: + return "java.lang.String" + case []string: + return "[Ljava.lang.String;" + case []hessian.Object: + return "[Ljava.lang.Object;" + case map[interface{}]interface{}: + // return "java.util.HashMap" + return "java.util.Map" + case hessian.POJOEnum: + return v.(hessian.POJOEnum).JavaClassName() + // Serialized tags for complex types + default: + t := reflect.TypeOf(v) + if reflect.Ptr == t.Kind() { + t = reflect.TypeOf(reflect.ValueOf(v).Elem()) + } + switch t.Kind() { + case reflect.Struct: + return "java.lang.Object" + case reflect.Slice, reflect.Array: + if t.Elem().Kind() == reflect.Struct { + return "[Ljava.lang.Object;" + } + // return "java.util.ArrayList" + return "java.util.List" + case reflect.Map: // Enter here, map may be map[string]int + return "java.util.Map" + default: + return "" + } + } +} diff --git a/protocol/dubbo/hessian2/java_class_test.go b/protocol/dubbo/hessian2/java_class_test.go new file mode 100644 index 0000000000..246f13999b --- /dev/null +++ b/protocol/dubbo/hessian2/java_class_test.go @@ -0,0 +1,132 @@ +/* + * 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 hessian2 + +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +func TestGetJavaName(t *testing.T) { + _, err := GetJavaName(nil) + assert.Equal(t, NilError, err) + + typ, err := GetJavaName(true) + assert.Equal(t, "boolean", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(1) + assert.Equal(t, "long", typ) + assert.Nil(t, err) + typ, err = GetJavaName(int64(1)) + assert.Equal(t, "long", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(int32(1)) + assert.Equal(t, "int", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(int16(1)) + assert.Equal(t, "short", typ) + assert.Nil(t, err) + typ, err = GetJavaName(int8(1)) + assert.Equal(t, "short", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(uint(1)) + assert.Equal(t, "unsigned long", typ) + assert.Nil(t, err) + typ, err = GetJavaName(uint64(1)) + assert.Equal(t, "unsigned long", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(uint32(1)) + assert.Equal(t, "unsigned int", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(uint16(1)) + assert.Equal(t, "unsigned short", typ) + assert.Nil(t, err) + typ, err = GetJavaName(byte('a')) + assert.Equal(t, "char", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(float32(1.0)) + assert.Equal(t, "float", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(1.0) + assert.Equal(t, "double", typ) + assert.Nil(t, err) + + typ, err = GetJavaName("hello") + assert.Equal(t, "java.lang.String", typ) + assert.Nil(t, err) + + typ, err = GetJavaName([]string{"hello"}) + assert.Equal(t, "java.lang.String[]", typ) + assert.Nil(t, err) + typ, err = GetJavaName([]*mockPOJOPtr{{}}) + assert.Equal(t, "org.apache.dubbo.mockPOJOPtr[]", typ) + assert.Nil(t, err) + typ, err = GetJavaName([]mockPOJO{{}}) + assert.Equal(t, "org.apache.dubbo.mockPOJO[]", typ) + assert.Nil(t, err) + typ, err = GetJavaName([][]string{{"hello"}}) + assert.Equal(t, "java.lang.String[][]", typ) + assert.Nil(t, err) + typ, err = GetJavaName([][]*mockPOJOPtr{{&mockPOJOPtr{}}}) + assert.Equal(t, "org.apache.dubbo.mockPOJOPtr[][]", typ) + assert.Nil(t, err) + typ, err = GetJavaName([1]string{"hello"}) + assert.Equal(t, "java.lang.String[]", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(map[string]string{"key1": "value1"}) + assert.Equal(t, "java.util.Map", typ) + assert.Nil(t, err) + + typ, err = GetJavaName(mockPOJO{}) + assert.Equal(t, "org.apache.dubbo.mockPOJO", typ) + assert.Nil(t, err) + typ, err = GetJavaName(&mockPOJOPtr{}) + assert.Equal(t, "org.apache.dubbo.mockPOJOPtr", typ) + assert.Nil(t, err) + + _, err = GetJavaName(&mockNonPOJO{}) + assert.Equal(t, UnexpectedTypeError, err) +} + +type mockPOJOPtr struct { + TestField string +} + +func (m *mockPOJOPtr) JavaClassName() string { + return "org.apache.dubbo.mockPOJOPtr" +} + +type mockPOJO struct{} + +func (m mockPOJO) JavaClassName() string { + return "org.apache.dubbo.mockPOJO" +} + +type mockNonPOJO struct{} diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go index 682d5d987a..0f9e26da70 100644 --- a/protocol/dubbo/impl/codec.go +++ b/protocol/dubbo/impl/codec.go @@ -24,6 +24,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) diff --git a/protocol/dubbo/impl/const.go b/protocol/dubbo/impl/const.go index c9b92bad3b..6bc2c93386 100644 --- a/protocol/dubbo/impl/const.go +++ b/protocol/dubbo/impl/const.go @@ -20,7 +20,9 @@ package impl import ( "reflect" "regexp" +) +import ( "github.com/pkg/errors" ) diff --git a/protocol/dubbo/impl/hessian.go b/protocol/dubbo/impl/hessian.go index 25d536e267..756650f770 100644 --- a/protocol/dubbo/impl/hessian.go +++ b/protocol/dubbo/impl/hessian.go @@ -28,6 +28,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" "github.com/apache/dubbo-go-hessian2/java_exception" + perrors "github.com/pkg/errors" ) diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go index 27150db7f1..f137e848f6 100644 --- a/protocol/dubbo3/common_test.go +++ b/protocol/dubbo3/common_test.go @@ -19,7 +19,6 @@ package dubbo3 import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "fmt" ) @@ -28,6 +27,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index df90c3b656..d8f27ff4d2 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -14,11 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package dubbo3 import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "reflect" "sync" @@ -28,6 +28,7 @@ import ( tripleConstant "github.com/dubbogo/triple/pkg/common/constant" triConfig "github.com/dubbogo/triple/pkg/config" "github.com/dubbogo/triple/pkg/triple" + "google.golang.org/grpc" ) @@ -36,6 +37,7 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) @@ -99,18 +101,18 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { valueOf := reflect.ValueOf(service) typeOf := valueOf.Type() numField := valueOf.NumMethod() - tripleService := &Dubbo3HessianService{proxyImpl: invoker} + tripleService := &UnaryService{proxyImpl: invoker} for i := 0; i < numField; i++ { ft := typeOf.Method(i) if ft.Name == "Reference" { continue } - // num out is checked in common/rpc_service.go - if ft.Type.NumIn() != 3 { - panic(fmt.Sprintf("function %s input params num = %d not supported, which should be 2", ft.Name, ft.Type.NumIn()-1)) + // get all method params type + typs := make([]reflect.Type, 0) + for j := 2; j < ft.Type.NumIn(); j++ { + typs = append(typs, ft.Type.In(j)) } - typ := ft.Type.In(2) - tripleService.setReqParamsInterface(ft.Name, typ) + tripleService.setReqParamsTypes(ft.Name, typs) } service = tripleService triSerializationType = tripleConstant.CodecType(serializationType) @@ -164,55 +166,56 @@ type Dubbo3GrpcService interface { ServiceDesc() *grpc.ServiceDesc } -type Dubbo3HessianService struct { +type UnaryService struct { proxyImpl protocol.Invoker reqTypeMap sync.Map } -func (d *Dubbo3HessianService) setReqParamsInterface(methodName string, typ reflect.Type) { +func (d *UnaryService) setReqParamsTypes(methodName string, typ []reflect.Type) { d.reqTypeMap.Store(methodName, typ) } -func (d *Dubbo3HessianService) GetReqParamsInteface(methodName string) (interface{}, bool) { +func (d *UnaryService) GetReqParamsInterfaces(methodName string) ([]interface{}, bool) { val, ok := d.reqTypeMap.Load(methodName) if !ok { return nil, false } - typ := val.(reflect.Type) - return reflect.New(typ).Interface(), true + typs := val.([]reflect.Type) + reqParamsInterfaces := make([]interface{}, 0, len(typs)) + for _, typ := range typs { + reqParamsInterfaces = append(reqParamsInterfaces, reflect.New(typ).Interface()) + } + return reqParamsInterfaces, true } -func (d *Dubbo3HessianService) InvokeWithArgs(ctx context.Context, methodName string, arguments []interface{}) (interface{}, error) { +func (d *UnaryService) InvokeWithArgs(ctx context.Context, methodName string, arguments []interface{}) (interface{}, error) { res := d.proxyImpl.Invoke(ctx, invocation.NewRPCInvocation(methodName, arguments, nil)) return res.Result(), res.Error() } // openServer open a dubbo3 server, if there is already a service using the same protocol, it returns directly. func (dp *DubboProtocol) openServer(url *common.URL, tripleCodecType tripleConstant.CodecType) { - _, ok := dp.serverMap[url.Location] - if ok { - return - } - _, ok = dp.ExporterMap().Load(url.ServiceKey()) - if !ok { - panic("[DubboProtocol]" + url.Key() + "is not existing") - } - dp.serverLock.Lock() defer dp.serverLock.Unlock() - _, ok = dp.serverMap[url.Location] + _, ok := dp.serverMap[url.Location] + if ok { + dp.serverMap[url.Location].RefreshService() return } - triOption := triConfig.NewTripleOption( triConfig.WithCodecType(tripleCodecType), triConfig.WithLocation(url.Location), triConfig.WithLogger(logger.GetLogger()), ) + + _, ok = dp.ExporterMap().Load(url.ServiceKey()) + if !ok { + panic("[DubboProtocol]" + url.Key() + "is not existing") + } + srv := triple.NewTripleServer(dp.serviceMap, triOption) dp.serverMap[url.Location] = srv - srv.Start() } diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go index 627b730640..f924bf8c06 100644 --- a/protocol/dubbo3/dubbo3_protocol_test.go +++ b/protocol/dubbo3/dubbo3_protocol_test.go @@ -18,11 +18,15 @@ package dubbo3 import ( + "context" + "reflect" "testing" "time" ) import ( + hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) @@ -85,3 +89,63 @@ func TestDubboProtocolRefer(t *testing.T) { invokersLen = len(proto.(*DubboProtocol).Invokers()) assert.Equal(t, 0, invokersLen) } + +type MockUser struct { + Name string +} + +func (m *MockUser) JavaClassName() string { + return "mockuser" +} + +type MockService struct { +} + +func (m *MockService) GetUser(ctx context.Context, user, user2 *MockUser) (*MockUser, error) { + return user, nil +} + +func TestDubbo3UnaryService_GetReqParamsInterfaces(t *testing.T) { + hessian.RegisterPOJO(&MockUser{}) + srv := UnaryService{} + valueOf := reflect.ValueOf(&MockService{}) + typeOf := valueOf.Type() + numField := valueOf.NumMethod() + for i := 0; i < numField; i++ { + ft := typeOf.Method(i) + // num in/out is checked in common/rpc_service.go + typs := make([]reflect.Type, 0) + for j := 2; j < ft.Type.NumIn(); j++ { + typs = append(typs, ft.Type.In(j)) + } + srv.setReqParamsTypes("GetUser", typs) + } + paramsInterfaces, ok := srv.GetReqParamsInterfaces("GetUser") + assert.True(t, ok) + enc := hessian.NewEncoder() + err := enc.Encode(&MockUser{ + Name: "laurence", + }) + assert.Nil(t, err) + data := enc.Buffer() + decoder := hessian.NewDecoder(data) + val, err := decoder.Decode() + assert.Nil(t, err) + assert.Equal(t, 2, len(paramsInterfaces)) + subTest(t, val, paramsInterfaces) + args := make([]interface{}, 0, 1) + for _, v := range paramsInterfaces { + tempParamObj := reflect.ValueOf(v).Elem().Interface() + args = append(args, tempParamObj) + } + assert.Equal(t, "laurence", args[0].(*MockUser).Name) + assert.Equal(t, "laurence", args[1].(*MockUser).Name) +} + +func subTest(t *testing.T, val, paramsInterfaces interface{}) { + list := paramsInterfaces.([]interface{}) + for k, _ := range list { + err := hessian.ReflectResponse(val, list[k]) + assert.Nil(t, err) + } +} diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index d85662c492..2b1d8e07d2 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -19,13 +19,16 @@ package internal import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" ) import ( "github.com/dubbogo/triple/pkg/triple" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func init() { config.SetConsumerService(&GrpcGreeterImpl{}) } diff --git a/protocol/dubbo3/internal/helloworld.pb.go b/protocol/dubbo3/internal/helloworld.pb.go index 796eb9f415..404d7e3c9a 100644 --- a/protocol/dubbo3/internal/helloworld.pb.go +++ b/protocol/dubbo3/internal/helloworld.pb.go @@ -23,19 +23,24 @@ package internal import ( context "context" fmt "fmt" + math "math" +) + +import ( + tripleConstant "github.com/dubbogo/triple/pkg/common/constant" + dubbo3 "github.com/dubbogo/triple/pkg/triple" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" ) import ( "dubbo.apache.org/dubbo-go/v3/protocol" dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/grpc" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" - tripleConstant "github.com/dubbogo/triple/pkg/common/constant" - dubbo3 "github.com/dubbogo/triple/pkg/triple" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go b/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go deleted file mode 100644 index 3c695d77ee..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.pb.go +++ /dev/null @@ -1,323 +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. - */ - -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: helloworld.proto - -package main - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/protocol" - dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" - tripleConstant "github.com/dubbogo/triple/pkg/common/constant" - dubbo3 "github.com/dubbogo/triple/pkg/triple" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// The request message containing the user's name. -type HelloRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HelloRequest) Reset() { *m = HelloRequest{} } -func (m *HelloRequest) String() string { return proto.CompactTextString(m) } -func (*HelloRequest) ProtoMessage() {} -func (*HelloRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_17b8c58d586b62f2, []int{0} -} - -func (m *HelloRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloRequest.Unmarshal(m, b) -} -func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic) -} -func (m *HelloRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloRequest.Merge(m, src) -} -func (m *HelloRequest) XXX_Size() int { - return xxx_messageInfo_HelloRequest.Size(m) -} -func (m *HelloRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HelloRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloRequest proto.InternalMessageInfo - -func (m *HelloRequest) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HelloReply) Reset() { *m = HelloReply{} } -func (m *HelloReply) String() string { return proto.CompactTextString(m) } -func (*HelloReply) ProtoMessage() {} -func (*HelloReply) Descriptor() ([]byte, []int) { - return fileDescriptor_17b8c58d586b62f2, []int{1} -} - -func (m *HelloReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloReply.Unmarshal(m, b) -} -func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic) -} -func (m *HelloReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloReply.Merge(m, src) -} -func (m *HelloReply) XXX_Size() int { - return xxx_messageInfo_HelloReply.Size(m) -} -func (m *HelloReply) XXX_DiscardUnknown() { - xxx_messageInfo_HelloReply.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloReply proto.InternalMessageInfo - -func (m *HelloReply) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func init() { - proto.RegisterType((*HelloRequest)(nil), "main.HelloRequest") - proto.RegisterType((*HelloReply)(nil), "main.HelloReply") -} - -func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) } - -var fileDescriptor_17b8c58d586b62f2 = []byte{ - // 185 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9, - 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, - 0xcc, 0xcc, 0x53, 0x52, 0xe2, 0xe2, 0xf1, 0x00, 0xc9, 0x04, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, - 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, - 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95, 0x42, 0x12, 0x5c, 0xec, 0xb9, 0xa9, - 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x91, 0x2d, 0x17, 0xbb, 0x7b, 0x51, 0x6a, 0x6a, - 0x49, 0x6a, 0x91, 0x90, 0x11, 0x17, 0x47, 0x70, 0x62, 0x25, 0x58, 0x97, 0x90, 0x90, 0x1e, 0xc8, - 0x26, 0x3d, 0x64, 0x6b, 0xa4, 0x04, 0x50, 0xc4, 0x0a, 0x72, 0x2a, 0x95, 0x18, 0x9c, 0xcc, 0xb8, - 0xa4, 0x33, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a, 0x92, 0xf5, 0x52, 0x2b, 0x12, 0x73, 0x0b, 0x72, 0x52, - 0x8b, 0xf5, 0x10, 0xae, 0x76, 0xe2, 0x07, 0x2b, 0x0e, 0x07, 0xb1, 0x03, 0x40, 0x1e, 0x08, 0x60, - 0x5c, 0xc4, 0xc4, 0xec, 0xe1, 0x13, 0x9e, 0xc4, 0x06, 0xf6, 0x8f, 0x31, 0x20, 0x00, 0x00, 0xff, - 0xff, 0xd2, 0x16, 0x5f, 0x34, 0xe3, 0x00, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/main.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) -} - -// UnimplementedGreeterServer can be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} - -func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { - s.RegisterService(&_Greeter_serviceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/main.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Greeter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "main.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} - -type greeterDubbo3Client struct { - cc *dubbo3.TripleConn -} - -func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { - return &greeterDubbo3Client{cc} -} -func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opt ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - err := c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterClientImpl is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClientImpl struct { - // Sends a greeting - SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error -} - -func (c *GreeterClientImpl) Reference() string { - return "greeterImpl" -} - -func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - return NewGreeterDubbo3Client(cc) -} - -type GreeterProviderBase struct { - proxyImpl protocol.Invoker -} - -func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - s.proxyImpl = impl -} - -func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker { - return s.proxyImpl -} - -func (c *GreeterProviderBase) Reference() string { - return "greeterImpl" -} - -func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - base := srv.(dgrpc.Dubbo3GrpcService) - args := []interface{}{} - args = append(args, in) - invo := invocation.NewRPCInvocation("SayHello", args, nil) - if interceptor == nil { - result := base.GetProxyImpl().Invoke(ctx, invo) - return result.Result(), result.Error() - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/main.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() - } - return interceptor(ctx, in, info, handler) -} - -func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc { - return &grpc.ServiceDesc{ - ServiceName: "main.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _DUBBO_Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", - } -} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/go.mod b/protocol/dubbo3/protoc-gen-dubbo3/go.mod deleted file mode 100644 index d094046721..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module github.com/apache/dubbo-go/protocol/dubbo3/protoc-gen-dubbo3 - -go 1.15 - -require ( - github.com/dubbogo/triple v1.0.0 - github.com/golang/protobuf v1.5.2 - google.golang.org/grpc v1.36.0 -) diff --git a/protocol/dubbo3/protoc-gen-dubbo3/go.sum b/protocol/dubbo3/protoc-gen-dubbo3/go.sum deleted file mode 100644 index 135c8be9df..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/go.sum +++ /dev/null @@ -1,1034 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-sdk-for-go v40.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= -github.com/Azure/go-autorest/autorest v0.10.0/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= -github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= -github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.6.1 h1:O36Tdaj1Fi/zyr25shTHwlQPGdq53+u4WkM08AOEjiE= -github.com/RoaringBitmap/roaring v0.6.1/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTrRXv9zpIg= -github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1 h1:ceSsU/9z/gv3hzUpl8GceEhQvF3i0BionfdHUGMmjHU= -github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coredns/coredns v1.1.2/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.0.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/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/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/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= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -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/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= -github.com/dubbogo/triple v1.0.0 h1:mbFU078PmyjO8OywtrNsTZW0RSYIImVGyXE4wLO3Vm0= -github.com/dubbogo/triple v1.0.0/go.mod h1:duJFWIYOE+Ajxxvk+AOBpEBePFNnviJ52fveZ3vYA04= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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/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/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= -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/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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= -github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -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.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= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -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= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-bexpr v0.1.2/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= -github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-connlimit v0.2.0/go.mod h1:OUj9FGL1tPIhl/2RCfzYHrIiWj+VVPGNyVPnUX8AqS0= -github.com/hashicorp/go-discover v0.0.0-20200501174627-ad1e96bde088/go.mod h1:vZu6Opqf49xX5lsFAu7iFNewkcVF1sn/wyapZh5ytlg= -github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= -github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-memdb v1.0.3/go.mod h1:LWQ8R70vPrS4OEY9k28D2z8/Zzyu34NVzeRibGAzHO0= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= -github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= -github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.0/go.mod h1:YL0HO+FifKOW2u1ke99DGVu1zhcpZzNwrLIqBC7vbYU= -github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff/go.mod h1:Uf8LaHyrYsgVgHzO2tMZKhqRGlL3UJ6XaSwW2EA1Iqo= -github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20191108161836-82f2b5571044/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= -github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= -github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -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.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= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= -github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/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= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= -github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.0/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.0.0/go.mod h1:k4XwG94++jLVsSiTxo7qdIfXA9pj9EAeo0QsNNJOLZ8= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.7/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= -github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -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.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -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.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rboyer/safeio v0.2.1/go.mod h1:Cq/cEPK+YXFn622lsQ0K4KsPZSPtaptHHEldsy7Fmig= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/conswriter v0.0.0-20180208195008-f5ae3917a627/go.mod h1:7zjs06qF79/FKAJpBvFx3P8Ww4UTIMAe+lpNXDHziac= -github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod h1:BeybITEsBEg6qbIiqJ6/Bqeq25bCLbL7YFmpaFfJDuM= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= -github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -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= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -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= -github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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/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= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -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.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= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= -github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= -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-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= -github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= -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= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= -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= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -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/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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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-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= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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-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= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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-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= -golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -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-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -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 h1:VwGa2Wf+rHGIxvsssCkUNIyFv8jQY0VCBCNWtikoWq0= -golang.org/x/tools v0.0.0-20200928182047-19e03678916f/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= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -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-20210106152847-07624b53cd92 h1:jOTk2Z6KYaWoptUFqZ167cS8peoUPjFEXrsqfVkkCGc= -google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= -k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= -k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= -k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= -k8s.io/client-go v0.16.9/go.mod h1:ThjPlh7Kx+XoBFOCt775vx5J7atwY7F/zaFzTco5gL0= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/protocol/dubbo3/protoc-gen-dubbo3/main.go b/protocol/dubbo3/protoc-gen-dubbo3/main.go deleted file mode 100644 index b57ee8b1f0..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/main.go +++ /dev/null @@ -1,74 +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 main - -import ( - "io/ioutil" - "os" -) - -import ( - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/generator" - _ "github.com/golang/protobuf/protoc-gen-go/grpc" -) - -import ( - _ "github.com/apache/dubbo-go/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3" -) - -func main() { - // Begin by allocating a generate. The request and response structures are stored there - // so we can do error handling easily - the response structure contains the field to - // report failure. - g := generator.New() - - data, err := ioutil.ReadAll(os.Stdin) - if err != nil { - g.Error(err, "reading input") - } - - if err := proto.Unmarshal(data, g.Request); err != nil { - g.Error(err, "parsing input proto") - } - - if len(g.Request.FileToGenerate) == 0 { - g.Fail("no files to generate") - } - - g.CommandLineParameters(g.Request.GetParameter()) - - // Create a wrapped version of the Descriptors and EnumDescriptors that - // point to the file that defines them. - g.WrapTypes() - - g.SetPackageNames() - g.BuildTypeNameMap() - - g.GenerateAllFiles() - - // Send back the results. - data, err = proto.Marshal(g.Response) - if err != nil { - g.Error(err, "failed to marshal output proto") - } - _, err = os.Stdout.Write(data) - if err != nil { - g.Error(err, "failed to write output proto") - } -} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go b/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go deleted file mode 100644 index 73156644a7..0000000000 --- a/protocol/dubbo3/protoc-gen-dubbo3/plugin/dubbo3/dubbo3.go +++ /dev/null @@ -1,372 +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 dubbo - -import ( - "fmt" - "strconv" - "strings" -) - -import ( - pb "github.com/golang/protobuf/protoc-gen-go/descriptor" - "github.com/golang/protobuf/protoc-gen-go/generator" -) - -// generatedCodeVersion indicates a version of the generated codes. -// It is incremented whenever an incompatibility between the generated codes and -// the grpc package is introduced; the generated codes references -// a constant, grpc.SupportPackageIsVersionN (where N is generatedCodeVersion). -const generatedCodeVersion = 4 - -// Paths for packages used by codes generated in this file, -// relative to the import_prefix of the generator.Generator. -const ( - contextPkgPath = "context" - grpcPkgPath = "google.golang.org/grpc" - codePkgPath = "google.golang.org/grpc/codes" - statusPkgPath = "google.golang.org/grpc/status" -) - -func init() { - generator.RegisterPlugin(new(dubboGrpc)) -} - -// grpc is an implementation of the Go protocol buffer compiler's -// plugin architecture. It generates bindings for gRPC-dubbo support. -type dubboGrpc struct { - gen *generator.Generator -} - -// Name returns the name of this plugin, "grpc". -func (g *dubboGrpc) Name() string { - return "dubbo" -} - -// The names for packages imported in the generated codes. -// They may vary from the final path component of the import path -// if the name is used by other packages. -var ( - contextPkg string - grpcPkg string -) - -// Init initializes the plugin. -func (g *dubboGrpc) Init(gen *generator.Generator) { - g.gen = gen -} - -// Given a type name defined in a .proto, return its object. -// Also record that we're using it, to guarantee the associated import. -func (g *dubboGrpc) objectNamed(name string) generator.Object { - g.gen.RecordTypeUse(name) - return g.gen.ObjectNamed(name) -} - -// Given a type name defined in a .proto, return its name as we will print it. -func (g *dubboGrpc) typeName(str string) string { - return g.gen.TypeName(g.objectNamed(str)) -} - -// P forwards to g.gen.P. -func (g *dubboGrpc) P(args ...interface{}) { g.gen.P(args...) } - -// Generate generates codes for the services in the given file. -// be consistent with grpc plugin -func (g *dubboGrpc) Generate(file *generator.FileDescriptor) { - if len(file.FileDescriptorProto.Service) == 0 { - return - } - - contextPkg = string(g.gen.AddImport(contextPkgPath)) - grpcPkg = string(g.gen.AddImport(grpcPkgPath)) - - for i, service := range file.FileDescriptorProto.Service { - g.generateService(file, service, i) - } -} - -// GenerateImports generates the import declaration for this file. -func (g *dubboGrpc) GenerateImports(file *generator.FileDescriptor) { - g.P("import (") - g.P(`dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"`) - g.P(`"dubbo.apache.org/dubbo-go/v3/protocol/invocation"`) - g.P(`"dubbo.apache.org/dubbo-go/v3/protocol"`) - g.P(`dubbo3 "github.com/dubbogo/triple/pkg/triple"`) - g.P(`tripleConstant "github.com/dubbogo/triple/pkg/common/constant"`) - g.P(` ) `) -} - -func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] } - -// deprecationComment is the standard comment added to deprecated -// messages, fields, enums, and enum values. -var deprecationComment = "// Deprecated: Do not use." - -// generateService generates all the codes for the named service. -func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) { - path := fmt.Sprintf("6,%d", index) // 6 means service. - - origServName := service.GetName() - fullServName := origServName - if pkg := file.GetPackage(); pkg != "" { - fullServName = pkg + "." + fullServName - } - servName := generator.CamelCase(origServName) - lowerServName := strings.ToLower(servName) - lowerFrontServeName := strings.ToLower(servName[:1]) + servName[1:] - g.P(fmt.Sprintf("type %sDubbo3Client struct {", lowerServName)) - g.P(fmt.Sprintf("cc *dubbo3.TripleConn")) - g.P("}") - - g.P(fmt.Sprintf("func New%sDubbo3Client (cc *dubbo3.TripleConn) %sClient {", servName, servName)) - g.P(fmt.Sprintf("return &%sDubbo3Client{cc}", lowerServName)) - g.P(fmt.Sprintf("}")) - - for _, method := range service.Method { - inputTypeNames := strings.Split(method.GetInputType(), ".") - inputTypeName := inputTypeNames[len(inputTypeNames)-1] - outputTypeNames := strings.Split(method.GetOutputType(), ".") - outputTypeName := outputTypeNames[len(outputTypeNames)-1] - if method.GetServerStreaming() || method.GetClientStreaming() { - //now we only support two way streaming - g.P(fmt.Sprintf("func (c *%sDubbo3Client) %s(ctx %s.Context,opt ...grpc.CallOption) (%s, error) {", - lowerServName, method.GetName(), contextPkg, servName+"_"+method.GetName()+"Client")) - g.P(fmt.Sprintf("interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)")) - g.P(fmt.Sprintf("stream, err := c.cc.NewStream(ctx, \"/\" + interfaceKey + \"/%s\", opt...)", method.GetName())) - g.P("if err != nil {") - g.P("return nil, err") - g.P("}") - g.P(fmt.Sprintf("x := &%s%sClient{stream}", lowerFrontServeName, method.GetName())) - g.P("return x, nil") - g.P("}") - continue - } - // unary rpc method client - g.P(fmt.Sprintf("func (c *%sDubbo3Client) %s(ctx %s.Context, in *%s, opt ...grpc.CallOption) (*%s, error) {", - lowerServName, method.GetName(), contextPkg, inputTypeName, outputTypeName)) - g.P(fmt.Sprintf("out := new(%s)", outputTypeName)) - g.P(fmt.Sprintf("interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)")) - g.P(fmt.Sprintf("err := c.cc.Invoke(ctx, \"/\" + interfaceKey + \"/%s\", in, out)", method.GetName())) - g.P("if err != nil {") - g.P("return nil, err") - g.P("}") - g.P("return out, nil") - g.P("}") - } - - deprecated := service.GetOptions().GetDeprecated() - - g.P() - g.P(fmt.Sprintf(`// %sClientImpl is the client API for %s service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.`, servName, servName)) - - // Client interface. - if deprecated { - g.P("//") - g.P(deprecationComment) - } - dubboSrvName := servName + "ClientImpl" - g.P("type ", dubboSrvName, " struct {") - for i, method := range service.Method { - g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. - if method.GetOptions().GetDeprecated() { - g.P("//") - g.P(deprecationComment) - } - g.P(g.generateClientSignature(servName, method)) - } - g.P("}") - g.P() - - // NewClient factory. - if deprecated { - g.P(deprecationComment) - } - - // add Reference method - //func (u *GrpcGreeterImpl) Reference() string { - // return "GrpcGreeterImpl" - //} - g.P("func (c *", dubboSrvName, ") ", " Reference() string ", "{") - g.P(`return "`, unexport(servName), `Impl"`) - g.P("}") - g.P() - - // add GetDubboStub method - // func (u *GrpcGreeterImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - // return NewGreeterClient(cc) - //} - g.P("func (c *", dubboSrvName, ") ", " GetDubboStub(cc *dubbo3.TripleConn) ", servName, "Client {") - g.P(`return New`, servName, `Dubbo3Client(cc)`) - g.P("}") - g.P() - - // Server interface. - serverType := servName + "ProviderBase" - g.P("type ", serverType, " struct {") - g.P("proxyImpl protocol.Invoker") - g.P("}") - g.P() - - // add set method - //func (g *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - // g.proxyImpl = impl - //} - g.P("func (s *", serverType, ") SetProxyImpl(impl protocol.Invoker) {") - g.P(`s.proxyImpl = impl`) - g.P("}") - g.P() - - // return get method - g.P("func (s *", serverType, ") GetProxyImpl() protocol.Invoker {") - g.P(`return s.proxyImpl`) - g.P("}") - g.P() - - // return reference - g.P("func (c *", serverType, ") ", " Reference() string ", "{") - g.P(`return "`, unexport(servName), `Impl"`) - g.P("}") - g.P() - - // add handler - var handlerNames []string - for _, method := range service.Method { - hname := g.generateServerMethod(servName, fullServName, method) - handlerNames = append(handlerNames, hname) - } - - grpcserverType := servName + "Server" - // return service desc - g.P("func (s *", serverType, ") ServiceDesc() *grpc.ServiceDesc {") - g.P(`return &grpc.ServiceDesc{`) - g.P("ServiceName: ", strconv.Quote(fullServName), ",") - g.P("HandlerType: (*", grpcserverType, ")(nil),") - g.P("Methods: []", grpcPkg, ".MethodDesc{") - for i, method := range service.Method { - if method.GetServerStreaming() || method.GetClientStreaming() { - continue - } - g.P("{") - g.P("MethodName: ", strconv.Quote(method.GetName()), ",") - g.P("Handler: ", handlerNames[i], ",") - g.P("},") - } - g.P("},") - g.P("Streams: []", grpcPkg, ".StreamDesc{") - for i, method := range service.Method { - if !method.GetClientStreaming() && !method.GetServerStreaming() { - continue - } - g.P("{") - g.P("StreamName: ", strconv.Quote(method.GetName()), ",") - g.P("Handler: ", handlerNames[i], ",") - if method.GetServerStreaming() { - g.P("ServerStreams: true,") - } - if method.GetClientStreaming() { - g.P("ClientStreams: true,") - } - g.P("},") - } - g.P("},") - g.P("Metadata: \"", file.GetName(), "\",") - g.P("}") - g.P("}") - g.P() -} - -// generateClientSignature returns the client-side signature for a method. -func (g *dubboGrpc) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { - origMethName := method.GetName() - methName := generator.CamelCase(origMethName) - //if reservedClientName[methName] { - // methName += "_" - //} - reqArg := ", in *" + g.typeName(method.GetInputType()) - if method.GetClientStreaming() { - reqArg = "" - } - respName := "out *" + g.typeName(method.GetOutputType()) - if method.GetServerStreaming() || method.GetClientStreaming() { - respName = servName + "_" + generator.CamelCase(origMethName) + "Client" - return fmt.Sprintf("%s func(ctx %s.Context%s) (%s, error)", methName, contextPkg, reqArg, respName) - } - return fmt.Sprintf("%s func(ctx %s.Context%s, %s) error", methName, contextPkg, reqArg, respName) -} - -func (g *dubboGrpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { -} - -func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method *pb.MethodDescriptorProto) string { - methName := generator.CamelCase(method.GetName()) - hname := fmt.Sprintf("_DUBBO_%s_%s_Handler", servName, methName) - inType := g.typeName(method.GetInputType()) - - if !method.GetServerStreaming() && !method.GetClientStreaming() { - g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, interceptor ", grpcPkg, ".UnaryServerInterceptor) (interface{}, error) {") - g.P("in := new(", inType, ")") - g.P("if err := dec(in); err != nil { return nil, err }") - - g.P("base := srv.(dgrpc.Dubbo3GrpcService)") - g.P("args := []interface{}{}") - g.P("args = append(args, in)") - g.P(`invo := invocation.NewRPCInvocation("`, methName, `", args, nil)`) - - g.P("if interceptor == nil {") - g.P("result := base.GetProxyImpl().Invoke(ctx, invo)") - g.P("return result.Result(), result.Error()") - g.P("}") - - g.P("info := &", grpcPkg, ".UnaryServerInfo{") - g.P("Server: srv,") - g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", fullServName, methName)), ",") - g.P("}") - - g.P("handler := func(ctx ", contextPkg, ".Context, req interface{}) (interface{}, error) {") - g.P("result := base.GetProxyImpl().Invoke(context.Background(), invo)") - g.P("return result.Result(), result.Error()") - g.P("}") - - g.P("return interceptor(ctx, in, info, handler)") - g.P("}") - g.P() - return hname - } - // streaming rpc - streamType := unexport(servName) + methName + "Server" - g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") - g.P("_, ok := srv.(dgrpc.Dubbo3GrpcService)") - g.P(`invo := invocation.NewRPCInvocation("`, methName, `", nil, nil)`) - g.P("if !ok {") - g.P("fmt.Println(invo)") - g.P("}") - if !method.GetClientStreaming() { - g.P("m := new(", inType, ")") - g.P("if err := stream.RecvMsg(m); err != nil { return err }") - g.P("return srv.(", servName, "Server).", methName, "(m, &", streamType, "{stream})") - } else { - g.P("return srv.(", servName, "Server).", methName, "(&", streamType, "{stream})") - } - g.P("}") - g.P() - - return hname -} diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index bf9e5b993d..1d37eb193e 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -25,8 +25,11 @@ import ( import ( "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" + "github.com/opentracing/opentracing-go" + "google.golang.org/grpc" + "gopkg.in/yaml.v2" ) diff --git a/protocol/grpc/codec.go b/protocol/grpc/codec.go index 7235a3941b..488b923564 100644 --- a/protocol/grpc/codec.go +++ b/protocol/grpc/codec.go @@ -25,6 +25,7 @@ import ( import ( "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" + "google.golang.org/grpc/encoding" ) diff --git a/protocol/grpc/grpc_invoker.go b/protocol/grpc/grpc_invoker.go index a9a711bb88..8c535c5661 100644 --- a/protocol/grpc/grpc_invoker.go +++ b/protocol/grpc/grpc_invoker.go @@ -25,7 +25,9 @@ import ( import ( hessian2 "github.com/apache/dubbo-go-hessian2" + "github.com/pkg/errors" + "google.golang.org/grpc/connectivity" ) diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index d5ac9ff374..d2d59a512d 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -18,7 +18,6 @@ package grpc import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) @@ -29,6 +28,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal/helloworld" ) diff --git a/protocol/grpc/internal/README.md b/protocol/grpc/internal/README.md index 5dbf318013..746501308f 100644 --- a/protocol/grpc/internal/README.md +++ b/protocol/grpc/internal/README.md @@ -11,3 +11,4 @@ This internal package is for test. So don't use internal in production. - [helloworld](./helloworld): test unary process - [routeguide](./routeguide): test stream process +- [multiprotos](./multiprotos): use multi pb to generate multi pb.go diff --git a/protocol/grpc/internal/helloworld/client.go b/protocol/grpc/internal/helloworld/client.go index 3c6fc9cea2..ec45dd5861 100644 --- a/protocol/grpc/internal/helloworld/client.go +++ b/protocol/grpc/internal/helloworld/client.go @@ -19,13 +19,16 @@ package helloworld import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" ) import ( "google.golang.org/grpc" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func init() { config.SetConsumerService(&GrpcGreeterImpl{}) } diff --git a/protocol/grpc/internal/helloworld/helloworld.pb.go b/protocol/grpc/internal/helloworld/helloworld.pb.go index 8f6f9223db..a9992d3c93 100644 --- a/protocol/grpc/internal/helloworld/helloworld.pb.go +++ b/protocol/grpc/internal/helloworld/helloworld.pb.go @@ -23,11 +23,15 @@ package helloworld import ( context "context" fmt "fmt" + math "math" +) + +import ( proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" ) import ( @@ -247,16 +251,6 @@ func (c *GreeterClientImpl) GetDubboStub(cc *grpc.ClientConn) GreeterClient { return NewGreeterClient(cc) } -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} - type GreeterProviderBase struct { proxyImpl protocol.Invoker } @@ -278,6 +272,15 @@ func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec f if err := dec(in); err != nil { return nil, err } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } base := srv.(DubboGrpcService) args := []interface{}{} args = append(args, in) diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile b/protocol/grpc/internal/multiprotos/Makefile similarity index 82% rename from protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile rename to protocol/grpc/internal/multiprotos/Makefile index b84a6da4bf..31ce7446a0 100644 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/Makefile +++ b/protocol/grpc/internal/multiprotos/Makefile @@ -1,19 +1,19 @@ -# 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. - -grpc-gen: - protoc -I ./ helloworld.proto --go_out=plugins=grpc:. -dubbo3-gen: - protoc -I ./ helloworld.proto --dubbo3_out=plugins=grpc+dubbo:. +# 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. + +grpc-gen: + protoc -I ./ first.proto second.proto --go_out=plugins=grpc:. +dubbo-gen: + protoc -I ./ first.proto second.proto --dubbo_out=plugins=grpc+dubbo:. diff --git a/protocol/grpc/internal/multiprotos/first.pb.go b/protocol/grpc/internal/multiprotos/first.pb.go new file mode 100644 index 0000000000..3759074db2 --- /dev/null +++ b/protocol/grpc/internal/multiprotos/first.pb.go @@ -0,0 +1,308 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: first.proto + +package multiprotos + +import ( + context "context" + fmt "fmt" + math "math" +) + +import ( + proto "github.com/golang/protobuf/proto" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type FirstRequest struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FirstRequest) Reset() { *m = FirstRequest{} } +func (m *FirstRequest) String() string { return proto.CompactTextString(m) } +func (*FirstRequest) ProtoMessage() {} +func (*FirstRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_55120e8023d656fd, []int{0} +} + +func (m *FirstRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FirstRequest.Unmarshal(m, b) +} +func (m *FirstRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FirstRequest.Marshal(b, m, deterministic) +} +func (m *FirstRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FirstRequest.Merge(m, src) +} +func (m *FirstRequest) XXX_Size() int { + return xxx_messageInfo_FirstRequest.Size(m) +} +func (m *FirstRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FirstRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FirstRequest proto.InternalMessageInfo + +func (m *FirstRequest) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type FirstResponse struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FirstResponse) Reset() { *m = FirstResponse{} } +func (m *FirstResponse) String() string { return proto.CompactTextString(m) } +func (*FirstResponse) ProtoMessage() {} +func (*FirstResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_55120e8023d656fd, []int{1} +} + +func (m *FirstResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FirstResponse.Unmarshal(m, b) +} +func (m *FirstResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FirstResponse.Marshal(b, m, deterministic) +} +func (m *FirstResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FirstResponse.Merge(m, src) +} +func (m *FirstResponse) XXX_Size() int { + return xxx_messageInfo_FirstResponse.Size(m) +} +func (m *FirstResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FirstResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_FirstResponse proto.InternalMessageInfo + +func (m *FirstResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func init() { + proto.RegisterType((*FirstRequest)(nil), "multiprotos.FirstRequest") + proto.RegisterType((*FirstResponse)(nil), "multiprotos.FirstResponse") +} + +func init() { proto.RegisterFile("first.proto", fileDescriptor_55120e8023d656fd) } + +var fileDescriptor_55120e8023d656fd = []byte{ + // 137 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4e, 0xcb, 0x2c, 0x2a, + 0x2e, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2d, 0xcd, 0x29, 0xc9, 0x04, 0xb3, + 0x8b, 0x95, 0x34, 0xb8, 0x78, 0xdc, 0x40, 0x72, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, + 0x12, 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, + 0x41, 0x30, 0xae, 0x92, 0x26, 0x17, 0x2f, 0x54, 0x65, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, 0x6e, + 0xa5, 0x46, 0x41, 0x5c, 0x3c, 0x6e, 0x45, 0x99, 0xc5, 0x25, 0xc1, 0xa9, 0x45, 0x65, 0x99, 0xc9, + 0xa9, 0x42, 0x4e, 0x5c, 0xec, 0x30, 0xa6, 0xa4, 0x1e, 0x92, 0xed, 0x7a, 0xc8, 0x56, 0x4b, 0x49, + 0x61, 0x93, 0x82, 0xd8, 0xa5, 0xc4, 0x90, 0xc4, 0x06, 0x16, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, + 0xff, 0x83, 0xb7, 0xe6, 0xc5, 0xcb, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// FristServiceClient is the client API for FristService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type FristServiceClient interface { + Service(ctx context.Context, in *FirstRequest, opts ...grpc.CallOption) (*FirstResponse, error) +} + +type fristServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewFristServiceClient(cc grpc.ClientConnInterface) FristServiceClient { + return &fristServiceClient{cc} +} + +func (c *fristServiceClient) Service(ctx context.Context, in *FirstRequest, opts ...grpc.CallOption) (*FirstResponse, error) { + out := new(FirstResponse) + err := c.cc.Invoke(ctx, "/multiprotos.FristService/Service", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// FristServiceServer is the server API for FristService service. +type FristServiceServer interface { + Service(context.Context, *FirstRequest) (*FirstResponse, error) +} + +// UnimplementedFristServiceServer can be embedded to have forward compatible implementations. +type UnimplementedFristServiceServer struct { +} + +func (*UnimplementedFristServiceServer) Service(ctx context.Context, req *FirstRequest) (*FirstResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Service not implemented") +} + +func RegisterFristServiceServer(s *grpc.Server, srv FristServiceServer) { + s.RegisterService(&_FristService_serviceDesc, srv) +} + +func _FristService_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FirstRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FristServiceServer).Service(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.FristService/Service", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FristServiceServer).Service(ctx, req.(*FirstRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _FristService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "multiprotos.FristService", + HandlerType: (*FristServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service", + Handler: _FristService_Service_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "first.proto", +} + +// FristServiceClientImpl is the client API for FristService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type FristServiceClientImpl struct { + Service func(ctx context.Context, in *FirstRequest, out *FirstResponse) error +} + +func (c *FristServiceClientImpl) Reference() string { + return "fristServiceImpl" +} + +func (c *FristServiceClientImpl) GetDubboStub(cc *grpc.ClientConn) FristServiceClient { + return NewFristServiceClient(cc) +} + +type FristServiceProviderBase struct { + proxyImpl protocol.Invoker +} + +func (s *FristServiceProviderBase) SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *FristServiceProviderBase) GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (c *FristServiceProviderBase) Reference() string { + return "fristServiceImpl" +} + +func _DUBBO_FristService_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FirstRequest) + if err := dec(in); err != nil { + return nil, err + } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + base := srv.(DubboGrpcService) + args := []interface{}{} + args = append(args, in) + invo := invocation.NewRPCInvocation("Service", args, nil) + if interceptor == nil { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.FristService/Service", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func (s *FristServiceProviderBase) ServiceDesc() *grpc.ServiceDesc { + return &grpc.ServiceDesc{ + ServiceName: "multiprotos.FristService", + HandlerType: (*FristServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service", + Handler: _DUBBO_FristService_Service_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "first.proto", + } +} diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go b/protocol/grpc/internal/multiprotos/first.proto similarity index 78% rename from protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go rename to protocol/grpc/internal/multiprotos/first.proto index 76fbf64724..497cc11fa7 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go +++ b/protocol/grpc/internal/multiprotos/first.proto @@ -15,5 +15,18 @@ * limitations under the License. */ -// Package dubbo plugin for protobuf. -package dubbo +syntax = "proto3"; + +package multiprotos; + +message FirstRequest { + string message = 1; +} + +message FirstResponse { + string message = 1; +} + +service FristService { + rpc Service (FirstRequest) returns (FirstResponse) {} +} diff --git a/protocol/grpc/internal/multiprotos/second.pb.go b/protocol/grpc/internal/multiprotos/second.pb.go new file mode 100644 index 0000000000..ed2cb5091a --- /dev/null +++ b/protocol/grpc/internal/multiprotos/second.pb.go @@ -0,0 +1,590 @@ +/* + * 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. + */ + +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: second.proto + +package multiprotos + +import ( + context "context" + fmt "fmt" + math "math" +) + +import ( + proto "github.com/golang/protobuf/proto" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/protocol" + "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type SecondRequest struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SecondRequest) Reset() { *m = SecondRequest{} } +func (m *SecondRequest) String() string { return proto.CompactTextString(m) } +func (*SecondRequest) ProtoMessage() {} +func (*SecondRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_83c4a0a7b0d4882f, []int{0} +} + +func (m *SecondRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SecondRequest.Unmarshal(m, b) +} +func (m *SecondRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SecondRequest.Marshal(b, m, deterministic) +} +func (m *SecondRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SecondRequest.Merge(m, src) +} +func (m *SecondRequest) XXX_Size() int { + return xxx_messageInfo_SecondRequest.Size(m) +} +func (m *SecondRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SecondRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SecondRequest proto.InternalMessageInfo + +func (m *SecondRequest) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type SecondResponse struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SecondResponse) Reset() { *m = SecondResponse{} } +func (m *SecondResponse) String() string { return proto.CompactTextString(m) } +func (*SecondResponse) ProtoMessage() {} +func (*SecondResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_83c4a0a7b0d4882f, []int{1} +} + +func (m *SecondResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SecondResponse.Unmarshal(m, b) +} +func (m *SecondResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SecondResponse.Marshal(b, m, deterministic) +} +func (m *SecondResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SecondResponse.Merge(m, src) +} +func (m *SecondResponse) XXX_Size() int { + return xxx_messageInfo_SecondResponse.Size(m) +} +func (m *SecondResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SecondResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SecondResponse proto.InternalMessageInfo + +func (m *SecondResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func init() { + proto.RegisterType((*SecondRequest)(nil), "multiprotos.SecondRequest") + proto.RegisterType((*SecondResponse)(nil), "multiprotos.SecondResponse") +} + +func init() { proto.RegisterFile("second.proto", fileDescriptor_83c4a0a7b0d4882f) } + +var fileDescriptor_83c4a0a7b0d4882f = []byte{ + // 163 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x4e, 0x4d, 0xce, + 0xcf, 0x4b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x2d, 0xcd, 0x29, 0xc9, 0x04, + 0xb3, 0x8b, 0x95, 0x34, 0xb9, 0x78, 0x83, 0xc1, 0x92, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, + 0x42, 0x12, 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, + 0x9c, 0x41, 0x30, 0xae, 0x92, 0x16, 0x17, 0x1f, 0x4c, 0x69, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0x2a, + 0x6e, 0xb5, 0x46, 0x9b, 0x99, 0x60, 0xe6, 0x06, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x0a, 0xb9, + 0x72, 0x71, 0x40, 0x99, 0x86, 0x42, 0x52, 0x7a, 0x48, 0x4e, 0xd0, 0x43, 0xb1, 0x5f, 0x4a, 0x1a, + 0xab, 0x1c, 0xc4, 0x42, 0x25, 0x06, 0x21, 0x77, 0xb8, 0x31, 0x46, 0x14, 0x18, 0x63, 0xc0, 0x88, + 0x64, 0x90, 0x31, 0x05, 0x06, 0x69, 0x30, 0x0a, 0x79, 0xc2, 0x0d, 0x32, 0xa1, 0xc8, 0x20, 0x03, + 0xc6, 0x24, 0x36, 0xb0, 0xa4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xba, 0xd2, 0x28, 0xb0, + 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// SecondServiceClient is the client API for SecondService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SecondServiceClient interface { + Service1(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (*SecondResponse, error) + Service2(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (SecondService_Service2Client, error) + Service3(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service3Client, error) + Service4(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service4Client, error) +} + +type secondServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSecondServiceClient(cc grpc.ClientConnInterface) SecondServiceClient { + return &secondServiceClient{cc} +} + +func (c *secondServiceClient) Service1(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (*SecondResponse, error) { + out := new(SecondResponse) + err := c.cc.Invoke(ctx, "/multiprotos.SecondService/Service1", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *secondServiceClient) Service2(ctx context.Context, in *SecondRequest, opts ...grpc.CallOption) (SecondService_Service2Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[0], "/multiprotos.SecondService/Service2", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService2Client{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type SecondService_Service2Client interface { + Recv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService2Client struct { + grpc.ClientStream +} + +func (x *secondServiceService2Client) Recv() (*SecondResponse, error) { + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *secondServiceClient) Service3(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service3Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[1], "/multiprotos.SecondService/Service3", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService3Client{stream} + return x, nil +} + +type SecondService_Service3Client interface { + Send(*SecondRequest) error + CloseAndRecv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService3Client struct { + grpc.ClientStream +} + +func (x *secondServiceService3Client) Send(m *SecondRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *secondServiceService3Client) CloseAndRecv() (*SecondResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *secondServiceClient) Service4(ctx context.Context, opts ...grpc.CallOption) (SecondService_Service4Client, error) { + stream, err := c.cc.NewStream(ctx, &_SecondService_serviceDesc.Streams[2], "/multiprotos.SecondService/Service4", opts...) + if err != nil { + return nil, err + } + x := &secondServiceService4Client{stream} + return x, nil +} + +type SecondService_Service4Client interface { + Send(*SecondRequest) error + Recv() (*SecondResponse, error) + grpc.ClientStream +} + +type secondServiceService4Client struct { + grpc.ClientStream +} + +func (x *secondServiceService4Client) Send(m *SecondRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *secondServiceService4Client) Recv() (*SecondResponse, error) { + m := new(SecondResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// SecondServiceServer is the server API for SecondService service. +type SecondServiceServer interface { + Service1(context.Context, *SecondRequest) (*SecondResponse, error) + Service2(*SecondRequest, SecondService_Service2Server) error + Service3(SecondService_Service3Server) error + Service4(SecondService_Service4Server) error +} + +// UnimplementedSecondServiceServer can be embedded to have forward compatible implementations. +type UnimplementedSecondServiceServer struct { +} + +func (*UnimplementedSecondServiceServer) Service1(ctx context.Context, req *SecondRequest) (*SecondResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Service1 not implemented") +} +func (*UnimplementedSecondServiceServer) Service2(req *SecondRequest, srv SecondService_Service2Server) error { + return status.Errorf(codes.Unimplemented, "method Service2 not implemented") +} +func (*UnimplementedSecondServiceServer) Service3(srv SecondService_Service3Server) error { + return status.Errorf(codes.Unimplemented, "method Service3 not implemented") +} +func (*UnimplementedSecondServiceServer) Service4(srv SecondService_Service4Server) error { + return status.Errorf(codes.Unimplemented, "method Service4 not implemented") +} + +func RegisterSecondServiceServer(s *grpc.Server, srv SecondServiceServer) { + s.RegisterService(&_SecondService_serviceDesc, srv) +} + +func _SecondService_Service1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SecondRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SecondServiceServer).Service1(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.SecondService/Service1", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SecondServiceServer).Service1(ctx, req.(*SecondRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _SecondService_Service2_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(SecondRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SecondServiceServer).Service2(m, &secondServiceService2Server{stream}) +} + +type SecondService_Service2Server interface { + Send(*SecondResponse) error + grpc.ServerStream +} + +type secondServiceService2Server struct { + grpc.ServerStream +} + +func (x *secondServiceService2Server) Send(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _SecondService_Service3_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SecondServiceServer).Service3(&secondServiceService3Server{stream}) +} + +type SecondService_Service3Server interface { + SendAndClose(*SecondResponse) error + Recv() (*SecondRequest, error) + grpc.ServerStream +} + +type secondServiceService3Server struct { + grpc.ServerStream +} + +func (x *secondServiceService3Server) SendAndClose(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *secondServiceService3Server) Recv() (*SecondRequest, error) { + m := new(SecondRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _SecondService_Service4_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SecondServiceServer).Service4(&secondServiceService4Server{stream}) +} + +type SecondService_Service4Server interface { + Send(*SecondResponse) error + Recv() (*SecondRequest, error) + grpc.ServerStream +} + +type secondServiceService4Server struct { + grpc.ServerStream +} + +func (x *secondServiceService4Server) Send(m *SecondResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *secondServiceService4Server) Recv() (*SecondRequest, error) { + m := new(SecondRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _SecondService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "multiprotos.SecondService", + HandlerType: (*SecondServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service1", + Handler: _SecondService_Service1_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Service2", + Handler: _SecondService_Service2_Handler, + ServerStreams: true, + }, + { + StreamName: "Service3", + Handler: _SecondService_Service3_Handler, + ClientStreams: true, + }, + { + StreamName: "Service4", + Handler: _SecondService_Service4_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "second.proto", +} + +// SecondServiceClientImpl is the client API for SecondService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SecondServiceClientImpl struct { + Service1 func(ctx context.Context, in *SecondRequest, out *SecondResponse) error + Service2 func(ctx context.Context, in *SecondRequest) (SecondService_Service2Client, error) + Service3 func(ctx context.Context) (SecondService_Service3Client, error) + Service4 func(ctx context.Context) (SecondService_Service4Client, error) +} + +func (c *SecondServiceClientImpl) Reference() string { + return "secondServiceImpl" +} + +func (c *SecondServiceClientImpl) GetDubboStub(cc *grpc.ClientConn) SecondServiceClient { + return NewSecondServiceClient(cc) +} + +type SecondServiceProviderBase struct { + proxyImpl protocol.Invoker +} + +func (s *SecondServiceProviderBase) SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *SecondServiceProviderBase) GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (c *SecondServiceProviderBase) Reference() string { + return "secondServiceImpl" +} + +func _DUBBO_SecondService_Service1_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SecondRequest) + if err := dec(in); err != nil { + return nil, err + } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + base := srv.(DubboGrpcService) + args := []interface{}{} + args = append(args, in) + invo := invocation.NewRPCInvocation("Service1", args, nil) + if interceptor == nil { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/multiprotos.SecondService/Service1", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + result := base.GetProxyImpl().Invoke(ctx, invo) + return result.Result(), result.Error() + } + return interceptor(ctx, in, info, handler) +} + +func _DUBBO_SecondService_Service2_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service2", nil, nil) + if !ok { + fmt.Println(invo) + } + m := new(SecondRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SecondServiceServer).Service2(m, &secondServiceService2Server{stream}) +} + +func _DUBBO_SecondService_Service3_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service3", nil, nil) + if !ok { + fmt.Println(invo) + } + return srv.(SecondServiceServer).Service3(&secondServiceService3Server{stream}) +} + +func _DUBBO_SecondService_Service4_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } + _, ok := srv.(DubboGrpcService) + invo := invocation.NewRPCInvocation("Service4", nil, nil) + if !ok { + fmt.Println(invo) + } + return srv.(SecondServiceServer).Service4(&secondServiceService4Server{stream}) +} + +func (s *SecondServiceProviderBase) ServiceDesc() *grpc.ServiceDesc { + return &grpc.ServiceDesc{ + ServiceName: "multiprotos.SecondService", + HandlerType: (*SecondServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Service1", + Handler: _DUBBO_SecondService_Service1_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Service2", + Handler: _DUBBO_SecondService_Service2_Handler, + ServerStreams: true, + }, + { + StreamName: "Service3", + Handler: _DUBBO_SecondService_Service3_Handler, + ClientStreams: true, + }, + { + StreamName: "Service4", + Handler: _DUBBO_SecondService_Service4_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "second.proto", + } +} diff --git a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto b/protocol/grpc/internal/multiprotos/second.proto similarity index 62% rename from protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto rename to protocol/grpc/internal/multiprotos/second.proto index 81817e87c8..9ce1681d30 100644 --- a/protocol/dubbo3/protoc-gen-dubbo3/examples/helloworld.proto +++ b/protocol/grpc/internal/multiprotos/second.proto @@ -14,27 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -syntax = "proto3"; -option java_multiple_files = true; -option java_package = "io.grpc.examples.helloworld"; -option java_outer_classname = "HelloWorldProto"; -option objc_class_prefix = "HLW"; +syntax = "proto3"; -package main; +package multiprotos; -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} +message SecondRequest { + string message = 1; } -// The request message containing the user's name. -message HelloRequest { - string name = 1; +message SecondResponse { + string message = 1; } -// The response message containing the greetings -message HelloReply { - string message = 1; +service SecondService { + rpc Service1 (SecondRequest) returns (SecondResponse) {} + rpc Service2 (SecondRequest) returns (stream SecondResponse) {} + rpc Service3 (stream SecondRequest) returns (SecondResponse) {} + rpc Service4 (stream SecondRequest) returns (stream SecondResponse) {} } diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 9920115496..5f79ef0399 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -18,13 +18,16 @@ package routeguide import ( - "dubbo.apache.org/dubbo-go/v3/config" "io" "log" "math/rand" "time" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func init() { config.SetConsumerService(&RouteGuideClientImpl{}) } diff --git a/protocol/grpc/internal/routeguide/routeguide.pb.go b/protocol/grpc/internal/routeguide/routeguide.pb.go index b23c055df6..117d4e1a91 100644 --- a/protocol/grpc/internal/routeguide/routeguide.pb.go +++ b/protocol/grpc/internal/routeguide/routeguide.pb.go @@ -23,11 +23,15 @@ package routeguide import ( context "context" fmt "fmt" + math "math" +) + +import ( proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - math "math" ) import ( @@ -722,16 +726,6 @@ func (c *RouteGuideClientImpl) GetDubboStub(cc *grpc.ClientConn) RouteGuideClien return NewRouteGuideClient(cc) } -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} - type RouteGuideProviderBase struct { proxyImpl protocol.Invoker } @@ -753,6 +747,15 @@ func _DUBBO_RouteGuide_GetFeature_Handler(srv interface{}, ctx context.Context, if err := dec(in); err != nil { return nil, err } + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } base := srv.(DubboGrpcService) args := []interface{}{} args = append(args, in) @@ -773,6 +776,15 @@ func _DUBBO_RouteGuide_GetFeature_Handler(srv interface{}, ctx context.Context, } func _DUBBO_RouteGuide_ListFeatures_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("ListFeatures", nil, nil) if !ok { @@ -786,6 +798,15 @@ func _DUBBO_RouteGuide_ListFeatures_Handler(srv interface{}, stream grpc.ServerS } func _DUBBO_RouteGuide_RecordRoute_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("RecordRoute", nil, nil) if !ok { @@ -795,6 +816,15 @@ func _DUBBO_RouteGuide_RecordRoute_Handler(srv interface{}, stream grpc.ServerSt } func _DUBBO_RouteGuide_RouteChat_Handler(srv interface{}, stream grpc.ServerStream) error { + // DubboGrpcService is gRPC service + type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc + } _, ok := srv.(DubboGrpcService) invo := invocation.NewRPCInvocation("RouteChat", nil, nil) if !ok { diff --git a/protocol/grpc/internal/routeguide/server.go b/protocol/grpc/internal/routeguide/server.go index d27cd769e0..94349497c5 100644 --- a/protocol/grpc/internal/routeguide/server.go +++ b/protocol/grpc/internal/routeguide/server.go @@ -31,6 +31,7 @@ import ( import ( "github.com/golang/protobuf/proto" + "google.golang.org/grpc" ) diff --git a/protocol/grpc/protoc-gen-dubbo/main.go b/protocol/grpc/protoc-gen-dubbo/main.go deleted file mode 100644 index 48d0428688..0000000000 --- a/protocol/grpc/protoc-gen-dubbo/main.go +++ /dev/null @@ -1,74 +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 main - -import ( - "io/ioutil" - "os" -) - -import ( - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/generator" - _ "github.com/golang/protobuf/protoc-gen-go/grpc" -) - -import ( - _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc/protoc-gen-dubbo/plugin/dubbo" -) - -func main() { - // Begin by allocating a generate. The request and response structures are stored there - // so we can do error handling easily - the response structure contains the field to - // report failure. - g := generator.New() - - data, err := ioutil.ReadAll(os.Stdin) - if err != nil { - g.Error(err, "reading input") - } - - if err = proto.Unmarshal(data, g.Request); err != nil { - g.Error(err, "parsing input proto") - } - - if len(g.Request.FileToGenerate) == 0 { - g.Fail("no files to generate") - } - - g.CommandLineParameters(g.Request.GetParameter()) - - // Create a wrapped version of the Descriptors and EnumDescriptors that - // point to the file that defines them. - g.WrapTypes() - - g.SetPackageNames() - g.BuildTypeNameMap() - - g.GenerateAllFiles() - - // Send back the results. - data, err = proto.Marshal(g.Response) - if err != nil { - g.Error(err, "failed to marshal output proto") - } - _, err = os.Stdout.Write(data) - if err != nil { - g.Error(err, "failed to write output proto") - } -} diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go index 1a92ab1f7e..b3c5db2b09 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go +++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go @@ -165,18 +165,6 @@ func (g *dubboGrpc) generateService(file *generator.FileDescriptor, service *pb. g.P("}") g.P() - g.P(` -// DubboGrpcService is gRPC service -type DubboGrpcService interface { - // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) - // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker - // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc -} -`) - // Server interface. serverType := servName + "ProviderBase" g.P("type ", serverType, " struct {") @@ -271,9 +259,6 @@ func (g *dubboGrpc) generateClientSignature(servName string, method *pb.MethodDe return fmt.Sprintf("%s func(ctx %s.Context%s, %s) error", methName, contextPkg, reqArg, respName) } -//func (g *dubboGrpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { -//} - func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method *pb.MethodDescriptorProto) string { methName := generator.CamelCase(method.GetName()) hname := fmt.Sprintf("_DUBBO_%s_%s_Handler", servName, methName) @@ -283,7 +268,15 @@ func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method * g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error, interceptor ", grpcPkg, ".UnaryServerInterceptor) (interface{}, error) {") g.P("in := new(", inType, ")") g.P("if err := dec(in); err != nil { return nil, err }") - + g.P(`// DubboGrpcService is gRPC service +type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc +}`) g.P("base := srv.(DubboGrpcService)") g.P("args := []interface{}{}") g.P("args = append(args, in)") @@ -311,6 +304,15 @@ func (g *dubboGrpc) generateServerMethod(servName, fullServName string, method * } streamType := unexport(servName) + methName + "Server" g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") + g.P(`// DubboGrpcService is gRPC service +type DubboGrpcService interface { + // SetProxyImpl sets proxy. + SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + ServiceDesc() *grpc.ServiceDesc +}`) g.P("_, ok := srv.(DubboGrpcService)") g.P(`invo := invocation.NewRPCInvocation("`, methName, `", nil, nil)`) g.P("if !ok {") diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index e077cd7cad..d8bfa6acc5 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -26,7 +26,9 @@ import ( import ( "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" + "github.com/opentracing/opentracing-go" + "google.golang.org/grpc" "google.golang.org/grpc/reflection" ) diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index 44e0604716..6aa49407a3 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -29,10 +29,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) -// /////////////////////////// -// Invocation Implement of RPC -// /////////////////////////// - // todo: is it necessary to separate fields of consumer(provider) from RPCInvocation // nolint type RPCInvocation struct { diff --git a/protocol/invoker.go b/protocol/invoker.go index 1be7e1f146..af63dd6702 100644 --- a/protocol/invoker.go +++ b/protocol/invoker.go @@ -23,6 +23,7 @@ import ( import ( perrors "github.com/pkg/errors" + uatomic "go.uber.org/atomic" ) diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index a1fbc235e6..92c748ac8d 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -34,6 +34,7 @@ import ( import ( "github.com/opentracing/opentracing-go" + perrors "github.com/pkg/errors" ) @@ -43,10 +44,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) -// //////////////////////////////////////////// -// Request -// //////////////////////////////////////////// - // Request is HTTP protocol request type Request struct { ID int64 diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index 6f5852f90c..243dd5e19d 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -26,7 +26,9 @@ import ( import ( "github.com/opentracing/opentracing-go" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 365e6363ac..213cc40000 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -18,7 +18,6 @@ package jsonrpc import ( - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "strings" "testing" @@ -31,6 +30,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" ) diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index c0a349da19..771615f40d 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -33,6 +33,7 @@ import ( import ( "github.com/opentracing/opentracing-go" + perrors "github.com/pkg/errors" ) diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 842531ff8f..2400058e56 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -36,13 +36,15 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) +const mockFilterKey = "mockEcho" + func TestProtocolFilterWrapperExport(t *testing.T) { filtProto := extension.GetProtocol(FILTER) filtProto.(*ProtocolFilterWrapper).protocol = &protocol.BaseProtocol{} u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.SERVICE_FILTER_KEY, "echo ")) + common.WithParamsValue(constant.SERVICE_FILTER_KEY, mockFilterKey)) exporter := filtProto.Export(protocol.NewBaseInvoker(u)) _, ok := exporter.GetInvoker().(*FilterInvoker) assert.True(t, ok) @@ -54,15 +56,15 @@ func TestProtocolFilterWrapperRefer(t *testing.T) { u := common.NewURLWithOptions( common.WithParams(url.Values{}), - common.WithParamsValue(constant.REFERENCE_FILTER_KEY, " echo")) + common.WithParamsValue(constant.REFERENCE_FILTER_KEY, mockFilterKey)) invoker := filtProto.Refer(u) _, ok := invoker.(*FilterInvoker) assert.True(t, ok) } -// the same as echo filter, for test +// The initialization of mockEchoFilter, for test func init() { - extension.SetFilter("echo", newFilter) + extension.SetFilter(mockFilterKey, newFilter) } type mockEchoFilter struct{} diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index 0234edd5bc..c7c16e8de9 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -27,6 +27,7 @@ import ( import ( "github.com/go-resty/resty/v2" + perrors "github.com/pkg/errors" ) diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go index 2c56c22f44..18f06b2552 100644 --- a/protocol/rest/config/reader/rest_config_reader.go +++ b/protocol/rest/config/reader/rest_config_reader.go @@ -25,6 +25,7 @@ import ( import ( perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index e666fbc3c7..318740e7dd 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -19,19 +19,20 @@ package rest import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) import ( "github.com/emicklei/go-restful/v3" + "github.com/stretchr/testify/assert" ) import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 4748e96dea..3b4d178486 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -19,7 +19,6 @@ package rest import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "errors" "fmt" "strings" @@ -35,6 +34,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/config" rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" ) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 11e7a8f40e..af7eb5aa32 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -28,6 +28,7 @@ import ( import ( "github.com/emicklei/go-restful/v3" + perrors "github.com/pkg/errors" ) diff --git a/registry/base_registry.go b/registry/base_registry.go index 415a005354..bdc991509e 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -122,9 +122,9 @@ func (r *BaseRegistry) Destroy() { // first step close registry's all listeners r.facadeBasedRegistry.CloseListener() // then close r.done to notify other program who listen to it - close(r.done) + close(r.Done()) // wait waitgroup done (wait listeners outside close over) - r.wg.Wait() + r.WaitGroup().Wait() // close registry client r.closeRegisters() @@ -477,7 +477,7 @@ func (r *BaseRegistry) closeRegisters() { // IsAvailable judge to is registry not closed by chan r.done func (r *BaseRegistry) IsAvailable() bool { select { - case <-r.done: + case <-r.Done(): return false default: return true diff --git a/registry/directory/directory.go b/registry/directory/directory.go index c6c0582af8..eb22597b68 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -18,7 +18,6 @@ package directory import ( - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "net/url" "os" @@ -37,6 +36,7 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/config_center" _ "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index e74125302d..49f305e119 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,7 +18,6 @@ package directory import ( - "dubbo.apache.org/dubbo-go/v3/config" "strconv" "testing" "time" @@ -33,6 +32,7 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper" "dubbo.apache.org/dubbo-go/v3/registry" diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go index 4b0b8be319..92e55aa093 100644 --- a/registry/etcdv3/listener.go +++ b/registry/etcdv3/listener.go @@ -23,6 +23,8 @@ import ( ) import ( + gxchan "github.com/dubbogo/gost/container/chan" + perrors "github.com/pkg/errors" ) @@ -80,7 +82,7 @@ func (l *dataListener) DataChange(eventType remoting.Event) bool { type configurationListener struct { registry *etcdV3Registry - events chan *config_center.ConfigChangeEvent + events *gxchan.UnboundedChan closeOnce sync.Once } @@ -88,12 +90,12 @@ type configurationListener struct { func NewConfigurationListener(reg *etcdV3Registry) *configurationListener { // add a new waiter reg.WaitGroup().Add(1) - return &configurationListener{registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32)} + return &configurationListener{registry: reg, events: gxchan.NewUnboundedChan(32)} } // Process data change event from config center of etcd func (l *configurationListener) Process(configType *config_center.ConfigChangeEvent) { - l.events <- configType + l.events.In() <- configType } // Next returns next service event once received @@ -104,7 +106,8 @@ func (l *configurationListener) Next() (*registry.ServiceEvent, error) { logger.Warnf("listener's etcd client connection is broken, so etcd event listener exit now.") return nil, perrors.New("listener stopped") - case e := <-l.events: + case val := <-l.events.Out(): + e, _ := val.(*config_center.ConfigChangeEvent) logger.Infof("got etcd event %#v", e) if e.ConfigType == remoting.EventTypeDel && l.registry.client.Valid() { select { diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index d9853b5c4f..97f95e0f47 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -24,8 +24,10 @@ import ( ) import ( - getty "github.com/apache/dubbo-getty" + gxtime "github.com/dubbogo/gost/time" + "github.com/stretchr/testify/suite" + "go.etcd.io/etcd/server/v3/embed" ) @@ -57,7 +59,7 @@ func (suite *RegistryTestSuite) SetupSuite() { select { case <-e.Server.ReadyNotify(): t.Log("Server is ready!") - case <-getty.GetTimeWheel().After(60 * time.Second): + case <-gxtime.After(60 * time.Second): e.Server.Stop() // trigger a shutdown t.Logf("Server took too long to start!") } diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index 6be5015b21..c77715410b 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -22,11 +22,11 @@ import ( "path" "strings" "sync" - "time" ) import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + perrors "github.com/pkg/errors" ) @@ -74,12 +74,7 @@ func (r *etcdV3Registry) ClientLock() *sync.Mutex { } func newETCDV3Registry(url *common.URL) (registry.Registry, error) { - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - logger.Errorf("timeout config %v is invalid ,err is %v", - url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), err.Error()) - return nil, perrors.WithMessagef(err, "new etcd registry(address:%+v)", url.Location) - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) logger.Infof("etcd address is: %v, timeout is: %s", url.Location, timeout.String()) @@ -95,10 +90,8 @@ func newETCDV3Registry(url *common.URL) (registry.Registry, error) { ); err != nil { return nil, err } - r.WaitGroup().Add(1) // etcdv3 client start successful, then wg +1 - - go etcdv3.HandleClientRestart(r) + r.handleClientRestart() r.InitListeners() return r, nil @@ -175,3 +168,8 @@ func (r *etcdV3Registry) DoSubscribe(svc *common.URL) (registry.Listener, error) func (r *etcdV3Registry) DoUnsubscribe(conf *common.URL) (registry.Listener, error) { return nil, perrors.New("DoUnsubscribe is not support in etcdV3Registry") } + +func (r *etcdV3Registry) handleClientRestart() { + r.WaitGroup().Add(1) + go etcdv3.HandleClientRestart(r) +} diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index 7124e5a74c..a46763344f 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -28,7 +28,9 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/hashicorp/vault/sdk/helper/jsonutil" + perrors "github.com/pkg/errors" ) diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go index 51f472b83c..40f87fd1b8 100644 --- a/registry/event/event_publishing_service_deiscovery_test.go +++ b/registry/event/event_publishing_service_deiscovery_test.go @@ -18,7 +18,6 @@ package event import ( - "dubbo.apache.org/dubbo-go/v3/config" "reflect" "testing" ) @@ -26,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" gxpage "github.com/dubbogo/gost/hash/page" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -34,6 +34,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" diff --git a/registry/event/metadata_service_url_params_customizer_test.go b/registry/event/metadata_service_url_params_customizer_test.go index d556acfcf7..212c3ed57d 100644 --- a/registry/event/metadata_service_url_params_customizer_test.go +++ b/registry/event/metadata_service_url_params_customizer_test.go @@ -23,6 +23,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" ) diff --git a/registry/event/service_config_exported_event.go b/registry/event/service_config_exported_event.go index d40c0273d3..af566e3b28 100644 --- a/registry/event/service_config_exported_event.go +++ b/registry/event/service_config_exported_event.go @@ -18,12 +18,12 @@ package event import ( - "dubbo.apache.org/dubbo-go/v3/config" "time" ) import ( "dubbo.apache.org/dubbo-go/v3/common/observer" + "dubbo.apache.org/dubbo-go/v3/config" ) // ServiceConfigExportedEvent represents an service was exported diff --git a/registry/file/listener.go b/registry/file/listener.go index 8e3020d135..55f35ead0c 100644 --- a/registry/file/listener.go +++ b/registry/file/listener.go @@ -17,7 +17,9 @@ package file -import "dubbo.apache.org/dubbo-go/v3/config_center" +import ( + "dubbo.apache.org/dubbo-go/v3/config_center" +) // RegistryConfigurationListener represent the processor of flie watcher type RegistryConfigurationListener struct{} diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index 9a6afb7261..e8657d9e71 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -29,6 +29,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" gxpage "github.com/dubbogo/gost/hash/page" + perrors "github.com/pkg/errors" ) diff --git a/registry/kubernetes/listener.go b/registry/kubernetes/listener.go index 19a9930f2a..7605235686 100644 --- a/registry/kubernetes/listener.go +++ b/registry/kubernetes/listener.go @@ -22,6 +22,8 @@ import ( ) import ( + gxchan "github.com/dubbogo/gost/container/chan" + perrors "github.com/pkg/errors" ) @@ -80,19 +82,19 @@ func (l *dataListener) DataChange(eventType remoting.Event) bool { type configurationListener struct { registry *kubernetesRegistry - events chan *config_center.ConfigChangeEvent + events *gxchan.UnboundedChan } // NewConfigurationListener for listening the event of kubernetes. func NewConfigurationListener(reg *kubernetesRegistry) *configurationListener { // add a new waiter reg.WaitGroup().Add(1) - return &configurationListener{registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32)} + return &configurationListener{registry: reg, events: gxchan.NewUnboundedChan(32)} } // Process processes the data change event from config center of kubernetes func (l *configurationListener) Process(configType *config_center.ConfigChangeEvent) { - l.events <- configType + l.events.In() <- configType } // Next returns next service event once received @@ -103,7 +105,8 @@ func (l *configurationListener) Next() (*registry.ServiceEvent, error) { logger.Warnf("listener's kubernetes client connection is broken, so kubernetes event listener exits now.") return nil, perrors.New("listener stopped") - case e := <-l.events: + case val := <-l.events.Out(): + e, _ := val.(*config_center.ConfigChangeEvent) logger.Debugf("got kubernetes event %#v", e) if e.ConfigType == remoting.EventTypeDel && !l.registry.client.Valid() { select { diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go index 79a29f98eb..b6e110780c 100644 --- a/registry/kubernetes/registry.go +++ b/registry/kubernetes/registry.go @@ -19,14 +19,16 @@ package kubernetes import ( "fmt" - getty "github.com/apache/dubbo-getty" "path" "sync" "time" ) import ( + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" ) @@ -162,7 +164,6 @@ func newKubernetesRegistry(url *common.URL) (registry.Registry, error) { return nil, perrors.WithStack(err) } - r.WaitGroup().Add(1) go r.HandleClientRestart() r.InitListeners() @@ -191,12 +192,12 @@ func newMockKubernetesRegistry( // HandleClientRestart will reconnect to kubernetes registry center func (r *kubernetesRegistry) HandleClientRestart() { + r.WaitGroup().Add(1) + defer r.WaitGroup().Done() var ( err error failTimes int ) - - defer r.WaitGroup().Done() LOOP: for { select { @@ -211,7 +212,7 @@ LOOP: // try to connect to kubernetes, failTimes = 0 for { - after := getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)) + after := gxtime.After(timeSecondDuration(failTimes * ConnDelay)) select { case <-r.Done(): logger.Warnf("(KubernetesProviderRegistry)reconnectKubernetes Registry goroutine exit now...") diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go index 4ebb625e01..f217048cf4 100644 --- a/registry/kubernetes/registry_test.go +++ b/registry/kubernetes/registry_test.go @@ -28,6 +28,7 @@ import ( import ( "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" ) diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go index 3a538cc91d..e9fa3b847f 100644 --- a/registry/nacos/listener.go +++ b/registry/nacos/listener.go @@ -26,9 +26,12 @@ import ( ) import ( + gxchan "github.com/dubbogo/gost/container/chan" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" ) @@ -44,7 +47,7 @@ import ( type nacosListener struct { namingClient *nacosClient.NacosNamingClient listenUrl *common.URL - events chan *config_center.ConfigChangeEvent + events *gxchan.UnboundedChan instanceMap map[string]model.Instance cacheLock sync.Mutex done chan struct{} @@ -55,9 +58,10 @@ type nacosListener struct { func NewNacosListener(url *common.URL, namingClient *nacosClient.NacosNamingClient) (*nacosListener, error) { listener := &nacosListener{ namingClient: namingClient, - listenUrl: url, events: make(chan *config_center.ConfigChangeEvent, 32), - instanceMap: map[string]model.Instance{}, - done: make(chan struct{}), + listenUrl: url, + events: gxchan.NewUnboundedChan(32), + instanceMap: map[string]model.Instance{}, + done: make(chan struct{}), } err := listener.startListen() return listener, err @@ -198,7 +202,7 @@ func (nl *nacosListener) stopListen() error { } func (nl *nacosListener) process(configType *config_center.ConfigChangeEvent) { - nl.events <- configType + nl.events.In() <- configType } // Next returns the service event from nacos. @@ -209,7 +213,8 @@ func (nl *nacosListener) Next() (*registry.ServiceEvent, error) { logger.Warnf("nacos listener is close!listenUrl:%+v", nl.listenUrl) return nil, perrors.New("listener stopped") - case e := <-nl.events: + case val := <-nl.events.Out(): + e, _ := val.(*config_center.ConfigChangeEvent) logger.Debugf("got nacos event %s", e) return ®istry.ServiceEvent{Action: e.ConfigType, Service: e.Value.(*common.URL)}, nil } diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 7cf4978d92..ed58fd61a9 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -25,9 +25,10 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/remoting/nacos" nacosClient "github.com/dubbogo/gost/database/kv/nacos" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" ) @@ -37,6 +38,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/registry" + "dubbo.apache.org/dubbo-go/v3/remoting/nacos" ) var localIP = "" @@ -75,8 +77,8 @@ func getServiceName(url *common.URL) string { func appendParam(target *bytes.Buffer, url *common.URL, key string) { value := url.GetParam(key, "") + target.Write([]byte(constant.NACOS_SERVICE_NAME_SEPARATOR)) if strings.TrimSpace(value) != "" { - target.Write([]byte(constant.NACOS_SERVICE_NAME_SEPARATOR)) target.Write([]byte(value)) } } diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go index 17829d6afd..4728019c42 100644 --- a/registry/nacos/registry_test.go +++ b/registry/nacos/registry_test.go @@ -28,6 +28,7 @@ import ( import ( "github.com/nacos-group/nacos-sdk-go/vo" + "github.com/stretchr/testify/assert" ) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 8838191cdc..b744dc8ee8 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -18,7 +18,6 @@ package nacos import ( - "dubbo.apache.org/dubbo-go/v3/common" "fmt" "net/url" ) @@ -27,12 +26,15 @@ import ( "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" "github.com/dubbogo/gost/hash/page" + "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" ) import ( + "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" @@ -217,6 +219,7 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh serviceName := t.(string) err := n.namingClient.Client().Subscribe(&vo.SubscribeParam{ ServiceName: serviceName, + GroupName: n.group, SubscribeCallback: func(services []model.SubscribeService, err error) { if err != nil { logger.Errorf("Could not handle the subscribe notification because the err is not nil."+ diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index ff769cab11..e6fe1556db 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -26,6 +26,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" ) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 3510e00684..8cc1621529 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -25,6 +25,7 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" ) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 03d3f4db15..686a77db23 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -18,13 +18,13 @@ package protocol import ( - "dubbo.apache.org/dubbo-go/v3/config" "testing" "time" ) import ( gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" ) @@ -34,6 +34,7 @@ import ( common_cfg "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/config_center" "dubbo.apache.org/dubbo-go/v3/config_center/configurator" "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/registry/service_instance.go b/registry/service_instance.go index 402469d524..6e0ffeeb53 100644 --- a/registry/service_instance.go +++ b/registry/service_instance.go @@ -74,8 +74,8 @@ type ServiceInstance interface { // nolint type Endpoint struct { - Port int `json:"port, omitempty"` - Protocol string `json:"protocol, omitempty"` + Port int `json:"port,omitempty"` + Protocol string `json:"protocol,omitempty"` } // DefaultServiceInstance the default implementation of ServiceInstance diff --git a/registry/service_instances_changed_listener.go b/registry/service_instances_changed_listener.go index 371af5e83e..da8a63c888 100644 --- a/registry/service_instances_changed_listener.go +++ b/registry/service_instances_changed_listener.go @@ -18,11 +18,17 @@ package registry import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" - gxset "github.com/dubbogo/gost/container/set" "reflect" ) +import ( + gxset "github.com/dubbogo/gost/container/set" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/observer" +) + // ServiceInstancesChangedListener The Service Discovery Changed Event Listener type ServiceInstancesChangedListener interface { // OnEvent on ServiceInstancesChangedEvent the service instances change event diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 7ab21bcbda..655c8a1b6f 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -25,7 +25,9 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" ) diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index 09eb61f06e..c8c023ea55 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -18,12 +18,13 @@ package servicediscovery import ( - gxpage "github.com/dubbogo/gost/hash/page" "testing" ) import ( gxset "github.com/dubbogo/gost/container/set" + gxpage "github.com/dubbogo/gost/hash/page" + "github.com/stretchr/testify/assert" ) diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 35bd54e53c..5de11d6fa8 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -23,7 +23,9 @@ import ( ) import ( + gxchan "github.com/dubbogo/gost/container/chan" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" ) @@ -116,7 +118,7 @@ func (l *RegistryDataListener) Close() { type RegistryConfigurationListener struct { client *gxzookeeper.ZookeeperClient registry *zkRegistry - events chan *config_center.ConfigChangeEvent + events *gxchan.UnboundedChan isClosed bool close chan struct{} closeOnce sync.Once @@ -129,7 +131,7 @@ func NewRegistryConfigurationListener(client *gxzookeeper.ZookeeperClient, reg * return &RegistryConfigurationListener{ client: client, registry: reg, - events: make(chan *config_center.ConfigChangeEvent, 32), + events: gxchan.NewUnboundedChan(32), isClosed: false, close: make(chan struct{}, 1), subscribeURL: conf, @@ -138,7 +140,7 @@ func NewRegistryConfigurationListener(client *gxzookeeper.ZookeeperClient, reg * // Process submit the ConfigChangeEvent to the event chan to notify all observer func (l *RegistryConfigurationListener) Process(configType *config_center.ConfigChangeEvent) { - l.events <- configType + l.events.In() <- configType } // Next will observe the registry state and events chan @@ -150,7 +152,8 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) { case <-l.registry.Done(): logger.Warnf("zk consumer register has quit, so zk event listener exit now. (registry url {%v}", l.registry.BaseRegistry.URL) return nil, perrors.New("zookeeper registry, (registry url{%v}) stopped") - case e := <-l.events: + case val := <-l.events.Out(): + e, _ := val.(*config_center.ConfigChangeEvent) logger.Debugf("got zk event %s", e) if e.ConfigType == remoting.EventTypeDel && !l.valid() { logger.Warnf("update @result{%s}. But its connection to registry is invalid", e.Value) diff --git a/registry/zookeeper/listener_test.go b/registry/zookeeper/listener_test.go deleted file mode 100644 index 43862e059a..0000000000 --- a/registry/zookeeper/listener_test.go +++ /dev/null @@ -1,46 +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 zookeeper - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/config_center" - "dubbo.apache.org/dubbo-go/v3/remoting" -) - -// Test_DataChange test data change event of zk listenerg -func Test_DataChange(t *testing.T) { - listener := NewRegistryDataListener() - url, _ := common.NewURL("jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-1.3.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100") - listener.SubscribeURL(url, &MockConfigurationListener{}) - int := listener.DataChange(remoting.Event{Path: "/dubbo/com.ikurento.user.UserProvider/providers/jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-1.3.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100"}) - assert.Equal(t, true, int) -} - -type MockConfigurationListener struct{} - -func (*MockConfigurationListener) Process(configType *config_center.ConfigChangeEvent) { -} diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index afe9772187..029654dfad 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -27,7 +27,9 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" ) @@ -74,7 +76,7 @@ func newZkRegistry(url *common.URL) (registry.Registry, error) { return nil, err } - r.WaitGroup().Add(1) //zk client start successful, then wg +1 + r.WaitGroup().Add(1) go zookeeper.HandleClientRestart(r) r.listener = zookeeper.NewZkEventListener(r.client) @@ -108,7 +110,7 @@ func newMockZkRegistry(url *common.URL, opts ...gxzookeeper.Option) (*zk.TestClu if err != nil { return nil, nil, err } - r.WaitGroup().Add(1) // zk client start successful, then wg +1 + r.WaitGroup().Add(1) go zookeeper.HandleClientRestart(r) r.InitListeners() return c, r, nil @@ -314,3 +316,8 @@ func (r *zkRegistry) getCloseListener(conf *common.URL) (*RegistryConfigurationL return zkListener, nil } + +func (r *zkRegistry) handleClientRestart() { + r.WaitGroup().Add(1) + go zookeeper.HandleClientRestart(r) +} diff --git a/registry/zookeeper/registry_test.go b/registry/zookeeper/registry_test.go deleted file mode 100644 index 4e1c1986e8..0000000000 --- a/registry/zookeeper/registry_test.go +++ /dev/null @@ -1,185 +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 zookeeper - -import ( - "strconv" - "testing" - "time" -) - -import ( - gxzookeeper "github.com/dubbogo/gost/database/kv/zk" - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" -) - -func Test_Register(t *testing.T) { - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithParamsValue("serviceid", "soa.mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - ts, reg, err := newMockZkRegistry(regURL) - assert.NoError(t, err) - defer func() { - _ = ts.Stop() - }() - err = reg.Register(url) - children, _ := reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers") - assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock%26.*.serviceid%3Dsoa.mock", children) - assert.NoError(t, err) -} - -func Test_UnRegister(t *testing.T) { - // register - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithParamsValue("serviceid", "soa.mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - ts, reg, _ := newMockZkRegistry(regURL) - defer func() { - _ = ts.Stop() - }() - err := reg.Register(url) - assert.NoError(t, err) - children, _ := reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers") - assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock%26.*.serviceid%3Dsoa.mock", children) - assert.NoError(t, err) - - err = reg.UnRegister(url) - assert.NoError(t, err) - children, err = reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers") - assert.Equal(t, 0, len(children)) - assert.Error(t, err) - assert.True(t, reg.IsAvailable()) - - err = reg.Register(url) - children, _ = reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers") - assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock%26.*.serviceid%3Dsoa.mock", children) - assert.NoError(t, err) -} - -func Test_Subscribe(t *testing.T) { - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - ts, reg, _ := newMockZkRegistry(regURL) - - // provider register - err := reg.Register(url) - assert.NoError(t, err) - - if err != nil { - return - } - - // consumer register - regURL.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) - _, reg2, _ := newMockZkRegistry(regURL, gxzookeeper.WithTestCluster(ts)) - - err = reg2.Register(url) - assert.Nil(t, err) - listener, _ := reg2.DoSubscribe(url) - - serviceEvent, _ := listener.Next() - assert.NoError(t, err) - if err != nil { - return - } - assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) - defer func() { - _ = ts.Stop() - }() -} - -func Test_UnSubscribe(t *testing.T) { - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - ts, reg, _ := newMockZkRegistry(regURL) - - // provider register - err := reg.Register(url) - assert.NoError(t, err) - - if err != nil { - return - } - - // consumer register - regURL.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) - _, reg2, _ := newMockZkRegistry(regURL, gxzookeeper.WithTestCluster(ts)) - - err = reg2.Register(url) - assert.Nil(t, err) - listener, _ := reg2.DoSubscribe(url) - - serviceEvent, _ := listener.Next() - assert.NoError(t, err) - if err != nil { - return - } - assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) - - err = reg2.UnSubscribe(url, nil) - assert.Nil(t, err) - assert.Nil(t, reg2.listener) - defer func() { - _ = ts.Stop() - }() -} - -func Test_ConsumerDestroy(t *testing.T) { - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - ts, reg, err := newMockZkRegistry(regURL) - defer func() { - _ = ts.Stop() - }() - - assert.NoError(t, err) - err = reg.Register(url) - assert.NoError(t, err) - _, err = reg.DoSubscribe(url) - assert.NoError(t, err) - - // listener.Close() - time.Sleep(1e9) - reg.Destroy() - assert.Equal(t, false, reg.IsAvailable()) -} - -func Test_ProviderDestroy(t *testing.T) { - regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - ts, reg, err := newMockZkRegistry(regURL) - defer func() { - _ = ts.Stop() - }() - - assert.NoError(t, err) - err = reg.Register(url) - assert.Nil(t, err) - - // listener.Close() - time.Sleep(1e9) - reg.Destroy() - assert.Equal(t, false, reg.IsAvailable()) -} diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index b5ad4a5681..4c49cb6aca 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -29,7 +29,6 @@ import ( gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" gxpage "github.com/dubbogo/gost/hash/page" - //perrors "github.com/pkg/errors" ) import ( diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index 7520457ac6..df99d3c097 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -26,7 +26,9 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" ) diff --git a/remoting/etcdv3/client.go b/remoting/etcdv3/client.go index 17d2b7ac98..bc6e5e469c 100644 --- a/remoting/etcdv3/client.go +++ b/remoting/etcdv3/client.go @@ -19,6 +19,7 @@ package etcdv3 import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + perrors "github.com/pkg/errors" ) diff --git a/remoting/etcdv3/facade.go b/remoting/etcdv3/facade.go index 29af06ea3c..7cdabafba9 100644 --- a/remoting/etcdv3/facade.go +++ b/remoting/etcdv3/facade.go @@ -18,19 +18,16 @@ package etcdv3 import ( - getty "github.com/apache/dubbo-getty" "sync" "time" ) import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" - perrors "github.com/pkg/errors" ) import ( "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" ) @@ -45,56 +42,18 @@ type clientFacade interface { } // HandleClientRestart keeps the connection between client and server +// This method should be used only once. You can use handleClientRestart() in package registry. func HandleClientRestart(r clientFacade) { - var ( - err error - failTimes int - ) - defer r.WaitGroup().Done() -LOOP: for { select { + case <-r.Client().GetCtx().Done(): + r.RestartCallBack() + // re-register all services + time.Sleep(10 * time.Microsecond) case <-r.Done(): logger.Warnf("(ETCDV3ProviderRegistry)reconnectETCDV3 goroutine exit now...") - break LOOP - // re-register all services - case <-r.Client().Done(): - r.ClientLock().Lock() - clientName := gxetcd.RegistryETCDV3Client - timeout, _ := time.ParseDuration(r.GetURL().GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - endpoints := r.Client().GetEndPoints() - r.Client().Close() - r.SetClient(nil) - r.ClientLock().Unlock() - - // try to connect to etcd, - failTimes = 0 - for { - after := getty.GetTimeWheel().After(timeSecondDuration(failTimes * gxetcd.ConnDelay)) - select { - case <-r.Done(): - logger.Warnf("(ETCDV3ProviderRegistry)reconnectETCDRegistry goroutine exit now...") - break LOOP - case <-after: // avoid connect frequent - } - err = ValidateClient( - r, - gxetcd.WithName(clientName), - gxetcd.WithEndpoints(endpoints...), - gxetcd.WithTimeout(timeout), - gxetcd.WithHeartbeat(1), - ) - logger.Infof("ETCDV3ProviderRegistry.validateETCDV3Client(etcd Addr{%s}) = error{%#v}", - endpoints, perrors.WithStack(err)) - if err == nil && r.RestartCallBack() { - break - } - failTimes++ - if gxetcd.MaxFailTimes <= failTimes { - failTimes = gxetcd.MaxFailTimes - } - } + return } } } diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go index edfadab4d9..2aa340afa1 100644 --- a/remoting/etcdv3/listener.go +++ b/remoting/etcdv3/listener.go @@ -24,8 +24,11 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + perrors "github.com/pkg/errors" + "go.etcd.io/etcd/api/v3/mvccpb" + clientv3 "go.etcd.io/etcd/client/v3" ) diff --git a/remoting/etcdv3/listener_test.go b/remoting/etcdv3/listener_test.go index 1795d0e22e..b6b7397c42 100644 --- a/remoting/etcdv3/listener_test.go +++ b/remoting/etcdv3/listener_test.go @@ -26,7 +26,9 @@ import ( import ( gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + "github.com/stretchr/testify/assert" + "go.etcd.io/etcd/server/v3/embed" ) diff --git a/remoting/getty/config.go b/remoting/getty/config.go index b1478da35b..9971d5c218 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -18,7 +18,6 @@ package getty import ( - "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -26,6 +25,14 @@ import ( perrors "github.com/pkg/errors" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + +const ( + TCPReadWriteTimeoutMinValue = time.Second * 1 +) + type ( // GettySessionParam is session configuration for getty GettySessionParam struct { @@ -36,7 +43,6 @@ type ( keepAlivePeriod time.Duration TcpRBufSize int `default:"262144" yaml:"tcp_r_buf_size" json:"tcp_r_buf_size,omitempty"` TcpWBufSize int `default:"65536" yaml:"tcp_w_buf_size" json:"tcp_w_buf_size,omitempty"` - PkgWQSize int `default:"1024" yaml:"pkg_wq_size" json:"pkg_wq_size,omitempty"` TcpReadTimeout string `default:"1s" yaml:"tcp_read_timeout" json:"tcp_read_timeout,omitempty"` tcpReadTimeout time.Duration TcpWriteTimeout string `default:"5s" yaml:"tcp_write_timeout" json:"tcp_write_timeout,omitempty"` @@ -119,7 +125,6 @@ func GetDefaultClientConfig() ClientConfig { KeepAlivePeriod: "180s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -144,7 +149,6 @@ func GetDefaultServerConfig() ServerConfig { KeepAlivePeriod: "180s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -162,11 +166,11 @@ func (c *GettySessionParam) CheckValidity() error { return perrors.WithMessagef(err, "time.ParseDuration(KeepAlivePeriod{%#v})", c.KeepAlivePeriod) } - if c.tcpReadTimeout, err = time.ParseDuration(c.TcpReadTimeout); err != nil { + if c.tcpReadTimeout, err = parseTcpTimeoutDuration(c.TcpReadTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpReadTimeout{%#v})", c.TcpReadTimeout) } - if c.tcpWriteTimeout, err = time.ParseDuration(c.TcpWriteTimeout); err != nil { + if c.tcpWriteTimeout, err = parseTcpTimeoutDuration(c.TcpWriteTimeout); err != nil { return perrors.WithMessagef(err, "time.ParseDuration(TcpWriteTimeout{%#v})", c.TcpWriteTimeout) } @@ -177,6 +181,17 @@ func (c *GettySessionParam) CheckValidity() error { return nil } +func parseTcpTimeoutDuration(timeStr string) (time.Duration, error) { + result, err := time.ParseDuration(timeStr) + if err != nil { + return 0, err + } + if result < TCPReadWriteTimeoutMinValue { + return TCPReadWriteTimeoutMinValue, nil + } + return result, nil +} + // CheckValidity confirm client params. func (c *ClientConfig) CheckValidity() error { var err error diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go index 572908b437..b7bd064f68 100644 --- a/remoting/getty/dubbo_codec_for_test.go +++ b/remoting/getty/dubbo_codec_for_test.go @@ -26,6 +26,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 22fb01c77c..bd2143ed33 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -25,9 +25,14 @@ import ( import ( "github.com/apache/dubbo-getty" + gxsync "github.com/dubbogo/gost/sync" + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" + "go.uber.org/atomic" + "gopkg.in/yaml.v2" ) @@ -201,7 +206,7 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo } select { - case <-getty.GetTimeWheel().After(timeout): + case <-gxtime.After(timeout): return perrors.WithStack(errClientReadTimeout) case <-response.Done: err = response.Err diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index a5b26ba3af..275649e6d9 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -28,7 +28,9 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" + "github.com/stretchr/testify/assert" ) @@ -343,7 +345,6 @@ func InitTest(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -362,7 +363,6 @@ func InitTest(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index f106e32d51..a9ae8868c9 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -25,8 +25,11 @@ import ( import ( "github.com/apache/dubbo-getty" + gxsync "github.com/dubbogo/gost/sync" + perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go index 68275bb649..622d5575c2 100644 --- a/remoting/getty/listener.go +++ b/remoting/getty/listener.go @@ -26,7 +26,11 @@ import ( import ( "github.com/apache/dubbo-getty" + hessian "github.com/apache/dubbo-go-hessian2" + + gxtime "github.com/dubbogo/gost/time" + perrors "github.com/pkg/errors" ) @@ -378,7 +382,7 @@ func heartbeat(session getty.Session, timeout time.Duration, callBack func(err e go func() { var err1 error select { - case <-getty.GetTimeWheel().After(timeout): + case <-gxtime.After(timeout): err1 = errHeartbeatReadTimeout case <-resp.Done: err1 = resp.Err diff --git a/remoting/getty/listener_test.go b/remoting/getty/listener_test.go index 407255e4b4..6d22e37dd0 100644 --- a/remoting/getty/listener_test.go +++ b/remoting/getty/listener_test.go @@ -25,6 +25,7 @@ import ( import ( "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" + "github.com/stretchr/testify/assert" ) diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go index 7fc9eb813a..8b091a48bb 100644 --- a/remoting/getty/pool.go +++ b/remoting/getty/pool.go @@ -29,6 +29,7 @@ import ( import ( "github.com/apache/dubbo-getty" + perrors "github.com/pkg/errors" ) diff --git a/remoting/getty/readwriter.go b/remoting/getty/readwriter.go index 9aa9eb11e1..c78f354d65 100644 --- a/remoting/getty/readwriter.go +++ b/remoting/getty/readwriter.go @@ -24,7 +24,9 @@ import ( import ( "github.com/apache/dubbo-getty" + hessian "github.com/apache/dubbo-go-hessian2" + perrors "github.com/pkg/errors" ) @@ -33,10 +35,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/remoting" ) -//////////////////////////////////////////// -// RpcClientPackageHandler -//////////////////////////////////////////// - // RpcClientPackageHandler Read data from server and Write data to server type RpcClientPackageHandler struct { client *Client @@ -91,14 +89,6 @@ func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) ([]by return nil, perrors.New("invalid rpc request") } -//////////////////////////////////////////// -// RpcServerPackageHandler -//////////////////////////////////////////// - -//var ( -// rpcServerPkgHandler = &RpcServerPackageHandler{} -//) - // RpcServerPackageHandler Read data from client and Write data to client type RpcServerPackageHandler struct { server *Server diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go index b1687e81ce..e9be67dca1 100644 --- a/remoting/getty/readwriter_test.go +++ b/remoting/getty/readwriter_test.go @@ -25,6 +25,7 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + "github.com/stretchr/testify/assert" ) @@ -98,7 +99,6 @@ func getServer(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", @@ -117,7 +117,6 @@ func getServer(t *testing.T) (*Server, *common.URL) { KeepAlivePeriod: "120s", TcpRBufSize: 262144, TcpWBufSize: 65536, - PkgWQSize: 512, TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", diff --git a/remoting/kubernetes/client.go b/remoting/kubernetes/client.go index cb1979a2ec..f55ac1a6eb 100644 --- a/remoting/kubernetes/client.go +++ b/remoting/kubernetes/client.go @@ -25,7 +25,9 @@ import ( import ( perrors "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" ) diff --git a/remoting/kubernetes/facade.go b/remoting/kubernetes/facade.go index 14063805b2..63115b02e5 100644 --- a/remoting/kubernetes/facade.go +++ b/remoting/kubernetes/facade.go @@ -17,7 +17,9 @@ package kubernetes -import "dubbo.apache.org/dubbo-go/v3/common" +import ( + "dubbo.apache.org/dubbo-go/v3/common" +) type clientFacade interface { Client() *Client diff --git a/remoting/kubernetes/registry_controller.go b/remoting/kubernetes/registry_controller.go index d47e95b038..5304b0a625 100644 --- a/remoting/kubernetes/registry_controller.go +++ b/remoting/kubernetes/registry_controller.go @@ -31,18 +31,25 @@ import ( import ( perrors "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/informers" informerscorev1 "k8s.io/client-go/informers/core/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/workqueue" ) diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go index fbc5d185c7..34f63a88d3 100644 --- a/remoting/nacos/builder.go +++ b/remoting/nacos/builder.go @@ -26,7 +26,9 @@ import ( import ( nacosClient "github.com/dubbogo/gost/database/kv/nacos" + nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" + perrors "github.com/pkg/errors" ) @@ -70,10 +72,7 @@ func GetNacosConfig(url *common.URL) ([]nacosConstant.ServerConfig, nacosConstan serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{IpAddr: ip, Port: uint64(port)}) } - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - return []nacosConstant.ServerConfig{}, nacosConstant.ClientConfig{}, err - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) clientConfig := nacosConstant.ClientConfig{ TimeoutMs: uint64(int32(timeout / time.Millisecond)), diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go index 959d27e2fe..89992d6cb8 100644 --- a/remoting/nacos/builder_test.go +++ b/remoting/nacos/builder_test.go @@ -19,8 +19,8 @@ package nacos import ( "net/url" - "strconv" "testing" + "time" ) import ( @@ -83,15 +83,54 @@ func TestNewNacosClientByUrl(t *testing.T) { assert.NotNil(t, client) } +func TestTimeoutConfig(t *testing.T) { + regurlMap := url.Values{} + regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true") + // regurlMap.Set(constant.NACOS_USERNAME, "nacos") + // regurlMap.Set(constant.NACOS_PASSWORD, "nacos") + regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos") + + t.Run("default timeout", func(t *testing.T) { + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(10*time.Second/time.Millisecond))) + }) + + t.Run("right timeout", func(t *testing.T) { + + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s") + + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(5*time.Second/time.Millisecond))) + }) + + t.Run("invalid timeout", func(t *testing.T) { + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5ab") + + newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) + _, cc, err := GetNacosConfig(newURL) + assert.Nil(t, err) + + assert.Equal(t, cc.TimeoutMs, uint64(int32(3*time.Second/time.Millisecond))) + }) + +} + func getRegUrl() *common.URL { regurlMap := url.Values{} - regurlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true") // regurlMap.Set(constant.NACOS_USERNAME, "nacos") // regurlMap.Set(constant.NACOS_PASSWORD, "nacos") regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos") - regurlMap.Set(constant.REGISTRY_TIMEOUT_KEY, "5s") + regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s") regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap)) diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 1ed183f375..cf0b572d9b 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -19,11 +19,11 @@ package zookeeper import ( "strings" - "time" ) import ( gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" ) @@ -55,12 +55,8 @@ func ValidateZookeeperClient(container ZkClientFacade, zkName string) error { if container.ZkClient() == nil { // in dubbo, every registry only connect one node, so this is []string{r.Address} - timeout, paramErr := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if paramErr != nil { - logger.Errorf("timeout config %v is invalid, err is %v", - url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT), paramErr.Error()) - return perrors.WithMessagef(paramErr, "newZookeeperClient(address:%+v)", url.Location) - } + timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT) + zkAddresses := strings.Split(url.Location, ",") newClient, cltErr := gxzookeeper.NewZookeeperClient(zkName, zkAddresses, true, gxzookeeper.WithZkTimeOut(timeout)) if cltErr != nil { diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go index 27cd9c7761..efa0a404a4 100644 --- a/remoting/zookeeper/curator_discovery/service_discovery.go +++ b/remoting/zookeeper/curator_discovery/service_discovery.go @@ -26,7 +26,9 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" ) diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go index aa962326c5..f9a4d59521 100644 --- a/remoting/zookeeper/facade.go +++ b/remoting/zookeeper/facade.go @@ -42,6 +42,7 @@ type ZkClientFacade interface { } // HandleClientRestart keeps the connection between client and server +// This method should be used only once. You can use handleClientRestart() in package registry. func HandleClientRestart(r ZkClientFacade) { defer r.WaitGroup().Done() for { diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go deleted file mode 100644 index 84e7e14dae..0000000000 --- a/remoting/zookeeper/facade_test.go +++ /dev/null @@ -1,125 +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 zookeeper - -import ( - "sync" - "testing" - "time" -) - -import ( - "github.com/dubbogo/go-zookeeper/zk" - gxzookeeper "github.com/dubbogo/gost/database/kv/zk" - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" -) - -type mockFacade struct { - client *gxzookeeper.ZookeeperClient - cltLock sync.Mutex - wg sync.WaitGroup - URL *common.URL - done chan struct{} -} - -func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.State, source string) { - for _, state := range expectedStates { - for { - event, ok := <-c - if !ok { - t.Fatalf("unexpected channel close for %s", source) - } - if event.Type != zk.EventSession { - continue - } - - if event.State != state { - t.Fatalf("mismatched state order from %s, expected %v, received %v", source, state, event.State) - } - break - } - } -} - -func newMockFacade(client *gxzookeeper.ZookeeperClient, url *common.URL) ZkClientFacade { - mock := &mockFacade{ - client: client, - URL: url, - } - - mock.wg.Add(1) - return mock -} - -func (r *mockFacade) ZkClient() *gxzookeeper.ZookeeperClient { - return r.client -} - -func (r *mockFacade) SetZkClient(client *gxzookeeper.ZookeeperClient) { - r.client = client -} - -func (r *mockFacade) ZkClientLock() *sync.Mutex { - return &r.cltLock -} - -func (r *mockFacade) WaitGroup() *sync.WaitGroup { - return &r.wg -} - -func (r *mockFacade) Done() chan struct{} { - return r.done -} - -func (r *mockFacade) GetURL() *common.URL { - return r.URL -} - -func (r *mockFacade) Destroy() { - close(r.done) - r.wg.Wait() -} - -func (r *mockFacade) RestartCallBack() bool { - return true -} - -func (r *mockFacade) IsAvailable() bool { - return true -} - -func Test_Facade(t *testing.T) { - ts, z, event, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second) - assert.NoError(t, err) - defer func() { - if err := ts.Stop(); err != nil { - t.Errorf("tc.Stop() = error: %v", err) - } - }() - url, _ := common.NewURL("mock://127.0.0.1") - mock := newMockFacade(z, url) - go HandleClientRestart(mock) - states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession} - verifyEventStateOrder(t, event, states, "event channel") - z.Close() - verifyEventStateOrder(t, event, []zk.State{zk.StateDisconnected}, "event channel") -} diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 944cd0d6dd..1aef932c34 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -18,7 +18,6 @@ package zookeeper import ( - uatomic "go.uber.org/atomic" "path" "strings" "sync" @@ -27,8 +26,12 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxzookeeper "github.com/dubbogo/gost/database/kv/zk" + perrors "github.com/pkg/errors" + + uatomic "go.uber.org/atomic" ) import ( diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go index 6e185eee4e..9e30846dcd 100644 --- a/remoting/zookeeper/listener_test.go +++ b/remoting/zookeeper/listener_test.go @@ -19,117 +19,13 @@ package zookeeper import ( "net/url" - "sync" "testing" - "time" ) import ( - "github.com/dubbogo/go-zookeeper/zk" - gxzookeeper "github.com/dubbogo/gost/database/kv/zk" "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/remoting" -) - -var dubboPropertiesPath = "/dubbo/dubbo.properties" - -func initZkData(t *testing.T) (*zk.TestCluster, *gxzookeeper.ZookeeperClient, <-chan zk.Event) { - ts, client, event, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second) - assert.NoError(t, err) - - data := ` - dubbo.consumer.request_timeout=5s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registries.hangzhouzk.protocol=zookeeper - dubbo.registries.hangzhouzk.timeout=3s - dubbo.registries.hangzhouzk.address=127.0.0.1:2181 - dubbo.registries.shanghaizk.protocol=zookeeper - dubbo.registries.shanghaizk.timeout=3s - dubbo.registries.shanghaizk.address=127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover -` - - err = client.Create(dubboPropertiesPath) - assert.NoError(t, err) - - _, err = client.Conn.Set(dubboPropertiesPath, []byte(data), 0) - assert.NoError(t, err) - - return ts, client, event -} - -func TestListener(t *testing.T) { - changedData := ` - dubbo.consumer.request_timeout=3s - dubbo.consumer.connect_timeout=5s - dubbo.application.organization=ikurento.com - dubbo.application.name=BDTService - dubbo.application.module=dubbogo user-info server - dubbo.application.version=0.0.1 - dubbo.application.owner=ZX - dubbo.application.environment=dev - dubbo.registries.hangzhouzk.protocol=zookeeper - dubbo.registries.hangzhouzk.timeout=3s - dubbo.registries.hangzhouzk.address=127.0.0.1:2181 - dubbo.registries.shanghaizk.protocol=zookeeper - dubbo.registries.shanghaizk.timeout=3s - dubbo.registries.shanghaizk.address=127.0.0.1:2182 - dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo - dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider - dubbo.service.com.ikurento.user.UserProvider.loadbalance=random - dubbo.service.com.ikurento.user.UserProvider.warmup=100 - dubbo.service.com.ikurento.user.UserProvider.cluster=failover -` - var wait sync.WaitGroup - ts, client, _ := initZkData(t) - defer func() { - if err := ts.Stop(); err != nil { - t.Errorf("ts.Stop() = error: %v", err) - } - }() - client.Wait.Add(1) - wait.Add(1) - go client.GetEventHandler().HandleZkEvent(client) - listener := NewZkEventListener(client) - dataListener := &mockDataListener{client: client, changedData: changedData, wait: &wait} - listener.ListenServiceEvent(nil, "/dubbo", dataListener) - time.Sleep(1 * time.Second) - _, err := client.Conn.Set(dubboPropertiesPath, []byte(changedData), 1) - assert.NoError(t, err) - wait.Wait() - assert.Equal(t, changedData, dataListener.eventList[1].Content) -} - -type mockDataListener struct { - eventList []remoting.Event - client *gxzookeeper.ZookeeperClient - changedData string - wait *sync.WaitGroup -} - -func (m *mockDataListener) DataChange(eventType remoting.Event) bool { - logger.Info(eventType) - m.eventList = append(m.eventList, eventType) - if eventType.Content == m.changedData { - m.wait.Done() - } - return true -} - func TestZkPath(t *testing.T) { zkPath := "io.grpc.examples.helloworld.GreeterGrpc$IGreeter" zkPath = url.QueryEscape(zkPath) diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go index 2226f634de..bcc3946616 100644 --- a/test/integrate/dubbo/go-client/client.go +++ b/test/integrate/dubbo/go-client/client.go @@ -19,7 +19,6 @@ package main import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) @@ -32,6 +31,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/test/integrate/dubbo/go-client/client.yml b/test/integrate/dubbo/go-client/client.yml index 93625d8020..8f17b6b88f 100644 --- a/test/integrate/dubbo/go-client/client.yml +++ b/test/integrate/dubbo/go-client/client.yml @@ -52,8 +52,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go index 75903f4370..6a977e392e 100644 --- a/test/integrate/dubbo/go-client/user.go +++ b/test/integrate/dubbo/go-client/user.go @@ -19,7 +19,6 @@ package main import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -27,6 +26,11 @@ import ( hessian "github.com/apache/dubbo-go-hessian2" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" + "dubbo.apache.org/dubbo-go/v3/config" +) + var userProvider = new(UserProvider) func init() { diff --git a/test/integrate/dubbo/go-server/server.go b/test/integrate/dubbo/go-server/server.go index 06af91581a..b1c16704c8 100644 --- a/test/integrate/dubbo/go-server/server.go +++ b/test/integrate/dubbo/go-server/server.go @@ -18,7 +18,6 @@ package main import ( - "dubbo.apache.org/dubbo-go/v3/config" "time" ) @@ -30,6 +29,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" diff --git a/test/integrate/dubbo/go-server/server.yml b/test/integrate/dubbo/go-server/server.yml index ff57a7d602..aa519ccb05 100644 --- a/test/integrate/dubbo/go-server/server.yml +++ b/test/integrate/dubbo/go-server/server.yml @@ -48,8 +48,6 @@ protocol_conf: keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 - pkg_rq_size: 1024 - pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go index a87cae9758..c34d16cff2 100644 --- a/test/integrate/dubbo/go-server/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -19,7 +19,6 @@ package main import ( "context" - "dubbo.apache.org/dubbo-go/v3/config" "fmt" "time" ) @@ -28,6 +27,10 @@ import ( hessian "github.com/apache/dubbo-go-hessian2" ) +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func init() { config.SetProviderService(new(UserProvider)) // ------for hessian2------ From da318d3fccf0beb21071cff1a90c734770c69af1 Mon Sep 17 00:00:00 2001 From: Baster Date: Thu, 26 Aug 2021 19:37:09 +0800 Subject: [PATCH 073/148] fix apollo config center parse bug (#1411) Co-authored-by: zengfanwei --- config/config_center_config.go | 2 ++ config_center/apollo/impl.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config/config_center_config.go b/config/config_center_config.go index f83d32b520..4de8098634 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -170,6 +170,7 @@ func startConfigCenter(rc *RootConfig) error { rc, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err } + rc.refresh = false rc.ConfigCenter = nil return nil @@ -184,6 +185,7 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, } envInstance := conf.GetEnvInstance() envInstance.SetDynamicConfiguration(dynamicConfig) + return dynamicConfig.GetProperties(c.DataId, config_center.WithGroup(c.Group)) //if err != nil { // logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 4c1f107a42..a088d1a924 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -103,7 +103,7 @@ func (c *apolloConfiguration) RemoveListener(key string, listener cc.Configurati } func getProperties(namespace string) string { - return getNamespaceName(namespace, agolloConstant.Properties) + return getNamespaceName(namespace, agolloConstant.YAML) } func getNamespaceName(namespace string, configFileFormat agolloConstant.ConfigFileFormat) string { @@ -137,11 +137,18 @@ func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (stri * when group is not null, we are getting startup configs(config file) from ShutdownConfig Center, for example: * key=dubbo.propertie */ + if key == "" { + key = c.appConf.NamespaceName + } tmpConfig := agollo.GetConfig(key) if tmpConfig == nil { return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) } - return tmpConfig.GetContent(), nil + + content := tmpConfig.GetContent() + b := []byte(content) + content = string(b[8:]) //remove defalut content= prefix + return content, nil } func (c *apolloConfiguration) getAddressWithProtocolPrefix(url *common.URL) string { From f6c81aefedb8cd9bb481f7cc3a4bf3a3f85e72e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Sat, 28 Aug 2021 23:06:52 +0800 Subject: [PATCH 074/148] fix: delete the init func in common/logger * delete the init func in common/logger * merge conflit * add lumberjack config to config/logger_config --- common/logger/logger.go | 65 ------------------------------------ common/logger/logger_test.go | 53 +++++++++++++++++++++++------ config/logger_config.go | 21 +++++++----- config/logger_config_test.go | 6 ++-- config/root_config.go | 6 ++-- 5 files changed, 62 insertions(+), 89 deletions(-) diff --git a/common/logger/logger.go b/common/logger/logger.go index 8f67836599..be2f74e2fe 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -17,28 +17,13 @@ package logger -import ( - "flag" - "io/ioutil" - "os" - "path" -) - import ( "github.com/apache/dubbo-getty" "github.com/natefinch/lumberjack" - perrors "github.com/pkg/errors" - "go.uber.org/zap" "go.uber.org/zap/zapcore" - - "gopkg.in/yaml.v2" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" ) var logger Logger @@ -67,56 +52,6 @@ type Logger interface { Debugf(fmt string, args ...interface{}) } -func init() { - // forbidden to executing twice. - if logger != nil { - return - } - - fs := flag.NewFlagSet("log", flag.ContinueOnError) - logConfFile := fs.String("logConf", os.Getenv(constant.APP_LOG_CONF_FILE), "default log config path") - fs.Parse(os.Args[1:]) - for len(fs.Args()) != 0 { - fs.Parse(fs.Args()[1:]) - } - if *logConfFile == "" { - *logConfFile = constant.DEFAULT_LOG_CONF_FILE_PATH - } - err := InitLog(*logConfFile) - if err != nil { - logger.Warnf("InitLog with error %v", err) - } -} - -// InitLog use for init logger by call InitLogger -func InitLog(logConfFile string) error { - if logConfFile == "" { - InitLogger(nil) - return perrors.New("log configure file name is nil") - } - if path.Ext(logConfFile) != ".yml" { - InitLogger(nil) - return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile) - } - - confFileStream, err := ioutil.ReadFile(logConfFile) - if err != nil { - InitLogger(nil) - return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", logConfFile, err) - } - - conf := &Config{} - err = yaml.Unmarshal(confFileStream, conf) - if err != nil { - InitLogger(nil) - return perrors.Errorf("[Unmarshal]init logger error: %v", err) - } - - InitLogger(conf) - - return nil -} - // InitLogger use for init logger by @conf func InitLogger(conf *Config) { var ( diff --git a/common/logger/logger_test.go b/common/logger/logger_test.go index 12d1ab8d29..2ef8e7fc3c 100644 --- a/common/logger/logger_test.go +++ b/common/logger/logger_test.go @@ -19,32 +19,65 @@ package logger import ( "fmt" + "io/ioutil" + "path" "path/filepath" "runtime" "testing" ) import ( + perrors "github.com/pkg/errors" "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" ) +// initLog use for init logger by call InitLogger +func initLog(logConfFile string) error { + if logConfFile == "" { + InitLogger(nil) + return perrors.New("log configure file name is nil") + } + if path.Ext(logConfFile) != ".yml" { + InitLogger(nil) + return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile) + } + + confFileStream, err := ioutil.ReadFile(logConfFile) + if err != nil { + InitLogger(nil) + return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", logConfFile, err) + } + + conf := &Config{} + err = yaml.Unmarshal(confFileStream, conf) + if err != nil { + InitLogger(nil) + return perrors.Errorf("[Unmarshal]init logger error: %v", err) + } + + InitLogger(conf) + + return nil +} + func TestInitLog(t *testing.T) { var ( err error path string ) - err = InitLog("") + err = initLog("") assert.EqualError(t, err, "log configure file name is nil") path, err = filepath.Abs("./log.xml") assert.NoError(t, err) - err = InitLog(path) + err = initLog(path) assert.EqualError(t, err, "log configure file name{"+path+"} suffix must be .yml") path, err = filepath.Abs("./logger.yml") assert.NoError(t, err) - err = InitLog(path) + err = initLog(path) var errMsg string if runtime.GOOS == "windows" { errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) @@ -53,7 +86,7 @@ func TestInitLog(t *testing.T) { } assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) - err = InitLog("./log.yml") + err = initLog("./log.yml") assert.NoError(t, err) Debug("debug") @@ -67,7 +100,7 @@ func TestInitLog(t *testing.T) { } func TestSetLevel(t *testing.T) { - err := InitLog("./log.yml") + err := initLog("./log.yml") assert.NoError(t, err) Debug("debug") Info("info") @@ -88,17 +121,17 @@ func TestInitLogWidthFile(t *testing.T) { path string ) - err = InitLog("") + err = initLog("") assert.EqualError(t, err, "log configure file name is nil") path, err = filepath.Abs("./file_log.xml") assert.NoError(t, err) - err = InitLog(path) + err = initLog(path) assert.EqualError(t, err, "log configure file name{"+path+"} suffix must be .yml") path, err = filepath.Abs("./logger.yml") assert.NoError(t, err) - err = InitLog(path) + err = initLog(path) var errMsg string if runtime.GOOS == "windows" { errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) @@ -107,7 +140,7 @@ func TestInitLogWidthFile(t *testing.T) { } assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) - err = InitLog("./file_log.yml") + err = initLog("./file_log.yml") assert.NoError(t, err) Debug("debug") @@ -121,7 +154,7 @@ func TestInitLogWidthFile(t *testing.T) { } func TestSetLevelWidthFile(t *testing.T) { - err := InitLog("./file_log.yml") + err := initLog("./file_log.yml") assert.NoError(t, err) Debug("debug") Info("info") diff --git a/config/logger_config.go b/config/logger_config.go index 4fa89d6b0c..b8d22088f5 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -23,7 +23,7 @@ import ( import ( "github.com/creasty/defaults" - "go.uber.org/zap" + "github.com/natefinch/lumberjack" ) import ( @@ -31,7 +31,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/yaml" ) -type LoggerConfig struct { +type ZapConfig struct { Level string `default:"debug" json:"level" yaml:"level" property:"level"` Development bool `default:"false" json:"development" yaml:"development" property:"development"` DisableCaller bool `default:"false" json:"disable_caller" yaml:"disable_caller" property:"disable_caller"` @@ -43,6 +43,11 @@ type LoggerConfig struct { InitialFields map[string]interface{} `default:"" json:"initial_fields" yaml:"initial_fields" property:"initial_fields"` } +type LoggerConfig struct { + LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"` + ZapConfig ZapConfig `yaml:"zapConfig"` +} + type EncoderConfig struct { MessageKey string `default:"message" json:"message_key" yaml:"message_key" property:"message_key"` LevelKey string `default:"level" json:"level_key" yaml:"level_key" property:"level_key"` @@ -71,12 +76,13 @@ func initLoggerConfig(rc *RootConfig) error { if err != nil { return err } - zapConfig := &zap.Config{} - err = yaml.UnmarshalYML(byte, zapConfig) - if err != nil { + + loggerConfig := &logger.Config{} + if err = yaml.UnmarshalYML(byte, loggerConfig); err != nil { return err } - logger.InitLogger(zapConfig) + + logger.InitLogger(loggerConfig) return nil } @@ -89,8 +95,7 @@ func (l *LoggerConfig) check() error { func (l *LoggerConfig) getUrlMap() url.Values { urlMap := url.Values{} - - for key, val := range l.EncoderConfig.Params { + for key, val := range l.ZapConfig.EncoderConfig.Params { urlMap.Set(key, val) } return urlMap diff --git a/config/logger_config_test.go b/config/logger_config_test.go index fcf2f1ca72..992c93b7e0 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -29,9 +29,9 @@ func TestLoggerInit(t *testing.T) { loggerConfig := rootConfig.Logger assert.NotNil(t, loggerConfig) // default - assert.Equal(t, "debug", loggerConfig.Level) - assert.Equal(t, "message", loggerConfig.EncoderConfig.MessageKey) - assert.Equal(t, "stacktrace", loggerConfig.EncoderConfig.StacktraceKey) + assert.Equal(t, "debug", loggerConfig.ZapConfig.Level) + assert.Equal(t, "message", loggerConfig.ZapConfig.EncoderConfig.MessageKey) + assert.Equal(t, "stacktrace", loggerConfig.ZapConfig.EncoderConfig.StacktraceKey) logger.Info("hello") }) } diff --git a/config/root_config.go b/config/root_config.go index 0c6f24fa09..74476670c0 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -96,10 +96,10 @@ func (rc *RootConfig) Init() error { if err := initLoggerConfig(rc); err != nil { return err } - if err := initApplicationConfig(rc); err != nil { - return err + if err := rc.ConfigCenter.Init(rc); err != nil { + logger.Info("config center doesn't start.") } - if err := initConfigCenter(rc); err != nil { + if err := rc.Application.Init(rc); err != nil { return err } if err := initProtocolsConfig(rc); err != nil { From 599ddd6f45c0afcc0e9fe62a69f916b84c8c1329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Sun, 29 Aug 2021 15:16:30 +0800 Subject: [PATCH 075/148] fix: replace '_' to '-' & delete test file in common/logger --- common/logger/file_log.yml | 36 ---- common/logger/log.yml | 27 --- common/logger/logger.go | 4 +- common/logger/logger_test.go | 170 ------------------ config/logger_config.go | 80 ++++++--- config/logger_config_test.go | 23 ++- config/root_config.go | 4 - .../logger/{empty_log.yml => empty_log.yaml} | 0 config/testdata/config/logger/file_log.yaml | 44 +++++ config/testdata/config/logger/log.yaml | 36 ++++ config/testdata/config/logger/log.yml | 36 ---- 11 files changed, 158 insertions(+), 302 deletions(-) delete mode 100644 common/logger/file_log.yml delete mode 100644 common/logger/log.yml delete mode 100644 common/logger/logger_test.go rename config/testdata/config/logger/{empty_log.yml => empty_log.yaml} (100%) create mode 100644 config/testdata/config/logger/file_log.yaml create mode 100644 config/testdata/config/logger/log.yaml delete mode 100644 config/testdata/config/logger/log.yml diff --git a/common/logger/file_log.yml b/common/logger/file_log.yml deleted file mode 100644 index 75cc32c7ea..0000000000 --- a/common/logger/file_log.yml +++ /dev/null @@ -1,36 +0,0 @@ -lumberjackConfig: - filename: "logs.log" - maxSize: 1 - maxAge: 3 - maxBackups: 5 - localTime: true - compress: false - -zapConfig: - level: "debug" - development: false - disableCaller: false - disableStacktrace: false - sampling: - encoding: "console" - - # encoder - encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - - outputPaths: - - "stderr" - errorOutputPaths: - - "stderr" - initialFields: diff --git a/common/logger/log.yml b/common/logger/log.yml deleted file mode 100644 index 21f97bcbc4..0000000000 --- a/common/logger/log.yml +++ /dev/null @@ -1,27 +0,0 @@ -level: "debug" -development: false -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/common/logger/logger.go b/common/logger/logger.go index be2f74e2fe..646b42745c 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -35,8 +35,8 @@ type DubboLogger struct { } type Config struct { - LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"` - ZapConfig *zap.Config `yaml:"zapConfig"` + LumberjackConfig *lumberjack.Logger `yaml:"lumberjack-config"` + ZapConfig *zap.Config `yaml:"zap-config"` } // Logger is the interface for Logger types diff --git a/common/logger/logger_test.go b/common/logger/logger_test.go deleted file mode 100644 index 2ef8e7fc3c..0000000000 --- a/common/logger/logger_test.go +++ /dev/null @@ -1,170 +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 logger - -import ( - "fmt" - "io/ioutil" - "path" - "path/filepath" - "runtime" - "testing" -) - -import ( - perrors "github.com/pkg/errors" - "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" -) - -// initLog use for init logger by call InitLogger -func initLog(logConfFile string) error { - if logConfFile == "" { - InitLogger(nil) - return perrors.New("log configure file name is nil") - } - if path.Ext(logConfFile) != ".yml" { - InitLogger(nil) - return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile) - } - - confFileStream, err := ioutil.ReadFile(logConfFile) - if err != nil { - InitLogger(nil) - return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", logConfFile, err) - } - - conf := &Config{} - err = yaml.Unmarshal(confFileStream, conf) - if err != nil { - InitLogger(nil) - return perrors.Errorf("[Unmarshal]init logger error: %v", err) - } - - InitLogger(conf) - - return nil -} - -func TestInitLog(t *testing.T) { - var ( - err error - path string - ) - - err = initLog("") - assert.EqualError(t, err, "log configure file name is nil") - - path, err = filepath.Abs("./log.xml") - assert.NoError(t, err) - err = initLog(path) - assert.EqualError(t, err, "log configure file name{"+path+"} suffix must be .yml") - - path, err = filepath.Abs("./logger.yml") - assert.NoError(t, err) - err = initLog(path) - var errMsg string - if runtime.GOOS == "windows" { - errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) - } else { - errMsg = fmt.Sprintf("open %s: no such file or directory", path) - } - assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) - - err = initLog("./log.yml") - assert.NoError(t, err) - - Debug("debug") - Info("info") - Warn("warn") - Error("error") - Debugf("%s", "debug") - Infof("%s", "info") - Warnf("%s", "warn") - Errorf("%s", "error") -} - -func TestSetLevel(t *testing.T) { - err := initLog("./log.yml") - assert.NoError(t, err) - Debug("debug") - Info("info") - - assert.True(t, SetLoggerLevel("info")) - Debug("debug") - Info("info") - - SetLogger(GetLogger().(*DubboLogger).Logger) - assert.False(t, SetLoggerLevel("debug")) - Debug("debug") - Info("info") -} - -func TestInitLogWidthFile(t *testing.T) { - var ( - err error - path string - ) - - err = initLog("") - assert.EqualError(t, err, "log configure file name is nil") - - path, err = filepath.Abs("./file_log.xml") - assert.NoError(t, err) - err = initLog(path) - assert.EqualError(t, err, "log configure file name{"+path+"} suffix must be .yml") - - path, err = filepath.Abs("./logger.yml") - assert.NoError(t, err) - err = initLog(path) - var errMsg string - if runtime.GOOS == "windows" { - errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) - } else { - errMsg = fmt.Sprintf("open %s: no such file or directory", path) - } - assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) - - err = initLog("./file_log.yml") - assert.NoError(t, err) - - Debug("debug") - Info("info") - Warn("warn") - Error("error") - Debugf("%s", "debug") - Infof("%s", "info") - Warnf("%s", "warn") - Errorf("%s", "error") -} - -func TestSetLevelWidthFile(t *testing.T) { - err := initLog("./file_log.yml") - assert.NoError(t, err) - Debug("debug") - Info("info") - - assert.True(t, SetLoggerLevel("info")) - Debug("debug") - Info("info") - - SetLogger(GetLogger().(*DubboLogger).Logger) - assert.False(t, SetLoggerLevel("debug")) - Debug("debug") - Info("info") -} diff --git a/config/logger_config.go b/config/logger_config.go index b8d22088f5..4e0ed16aae 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -24,6 +24,7 @@ import ( import ( "github.com/creasty/defaults" "github.com/natefinch/lumberjack" + "go.uber.org/zap/zapcore" ) import ( @@ -32,33 +33,33 @@ import ( ) type ZapConfig struct { - Level string `default:"debug" json:"level" yaml:"level" property:"level"` - Development bool `default:"false" json:"development" yaml:"development" property:"development"` - DisableCaller bool `default:"false" json:"disable_caller" yaml:"disable_caller" property:"disable_caller"` - DisableStacktrace bool `default:"false" json:"disable_stacktrace" yaml:"disable_stacktrace" property:"disable_stacktrace"` - Encoding string `default:"console" json:"encoding" yaml:"encoding" property:"encoding"` - EncoderConfig EncoderConfig `default:"" json:"encoder_config" yaml:"encoder_config" property:"encoder_config"` - OutputPaths []string `default:"[\"stderr\"]" json:"output_paths" yaml:"output_paths" property:"output_paths"` - ErrorOutputPaths []string `default:"[\"stderr\"]" json:"error_output_paths" yaml:"error_output_paths" property:"error_output_paths"` - InitialFields map[string]interface{} `default:"" json:"initial_fields" yaml:"initial_fields" property:"initial_fields"` + Level string `default:"debug" json:"level,omitempty" yaml:"level" property:"level"` + Development bool `default:"false" json:"development,omitempty" yaml:"development" property:"development"` + DisableCaller bool `default:"false" json:"disable-caller,omitempty" yaml:"disable-caller" property:"disable-caller"` + DisableStacktrace bool `default:"false" json:"disable-stacktrace,omitempty" yaml:"disable-stacktrace" property:"disable-stacktrace"` + Encoding string `default:"console" json:"encoding,omitempty" yaml:"encoding" property:"encoding"` + EncoderConfig EncoderConfig `default:"" json:"encoder-config,omitempty" yaml:"encoder-config" property:"encoder-config"` + OutputPaths []string `default:"[\"stderr\"]" json:"output-paths,omitempty" yaml:"output-paths" property:"output-paths"` + ErrorOutputPaths []string `default:"[\"stderr\"]" json:"error-output-paths,omitempty" yaml:"error-output-paths" property:"error-output-paths"` + InitialFields map[string]interface{} `default:"" json:"initial-fields,omitempty" yaml:"initial-fields" property:"initial-fields"` } type LoggerConfig struct { - LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"` - ZapConfig ZapConfig `yaml:"zapConfig"` + LumberjackConfig *lumberjack.Logger `yaml:"lumberjack-config" json:"lumberjack-config,omitempty" property:"lumberjack-config"` + ZapConfig ZapConfig `yaml:"zap-config" json:"zap-config,omitempty" property:"zap-config"` } type EncoderConfig struct { - MessageKey string `default:"message" json:"message_key" yaml:"message_key" property:"message_key"` - LevelKey string `default:"level" json:"level_key" yaml:"level_key" property:"level_key"` - TimeKey string `default:"time" json:"time_key" yaml:"time_key" property:"time_key"` - NameKey string `default:"logger" json:"name_key" yaml:"name_key" property:"name_key"` - CallerKey string `default:"caller" json:"caller_key" yaml:"caller_key" property:"caller_key"` - StacktraceKey string `default:"stacktrace" json:"stacktrace_key" yaml:"stacktrace_key" property:"stacktrace_key"` - EncodeLevel string `default:"capitalColor" json:"level_encoder" yaml:"level_encoder" property:"level_encoder"` - EncodeTime string `default:"iso8601" json:"time_encoder" yaml:"time_encoder" property:"time_encoder"` - EncodeDuration string `default:"seconds" json:"duration_encoder" yaml:"duration_encoder" property:"duration_encoder"` - EncodeCaller string `default:"short" json:"caller_encoder" yaml:"caller_encoder" property:"caller_encoder"` + MessageKey string `default:"message" json:"message-key,omitempty" yaml:"message-key" property:"message-key"` + LevelKey string `default:"level" json:"level-key,omitempty" yaml:"level-key" property:"level-key"` + TimeKey string `default:"time" json:"time-key,omitempty" yaml:"time-key" property:"time-key"` + NameKey string `default:"logger" json:"name-key,omitempty" yaml:"name-key" property:"name-key"` + CallerKey string `default:"caller" json:"caller-key,omitempty" yaml:"caller-key" property:"caller-key"` + StacktraceKey string `default:"stacktrace" json:"stacktrace-key,omitempty" yaml:"stacktrace-key" property:"stacktrace-key"` + EncodeLevel string `default:"capitalColor" json:"level-encoder" yaml:"level-encoder" property:"level-encoder"` + EncodeTime string `default:"iso8601" json:"time-encoder" yaml:"time-encoder" property:"time-encoder"` + EncodeDuration string `default:"seconds" json:"duration-encoder" yaml:"duration-encoder" property:"duration-encoder"` + EncodeCaller string `default:"short" json:"caller-encoder" yaml:"calle-encoder" property:"caller-encoder"` Params map[string]string `yaml:"params" json:"params,omitempty"` } @@ -77,12 +78,15 @@ func initLoggerConfig(rc *RootConfig) error { return err } - loggerConfig := &logger.Config{} - if err = yaml.UnmarshalYML(byte, loggerConfig); err != nil { + logConf := &logger.Config{} + if err = yaml.UnmarshalYML(byte, logConf); err != nil { return err } - - logger.InitLogger(loggerConfig) + err = logConfig.ZapConfig.EncoderConfig.setEncoderConfig(&(logConf.ZapConfig.EncoderConfig)) + if err != nil { + return err + } + logger.InitLogger(logConf) return nil } @@ -93,6 +97,32 @@ func (l *LoggerConfig) check() error { return verify(l) } +func (e *EncoderConfig) setEncoderConfig(encoderConfig *zapcore.EncoderConfig) error { + encoderConfig.MessageKey = e.MessageKey + encoderConfig.LevelKey = e.LevelKey + encoderConfig.TimeKey = e.TimeKey + encoderConfig.NameKey = e.NameKey + encoderConfig.CallerKey = e.CallerKey + encoderConfig.StacktraceKey = e.StacktraceKey + + if err := encoderConfig.EncodeLevel.UnmarshalText([]byte(e.EncodeLevel)); err != nil { + return err + } + + if err := encoderConfig.EncodeTime.UnmarshalText([]byte(e.EncodeTime)); err != nil { + return err + } + + if err := encoderConfig.EncodeDuration.UnmarshalText([]byte(e.EncodeDuration)); err != nil { + return err + } + + if err := encoderConfig.EncodeCaller.UnmarshalText([]byte(e.EncodeCaller)); err != nil { + return err + } + return nil +} + func (l *LoggerConfig) getUrlMap() url.Values { urlMap := url.Values{} for key, val := range l.ZapConfig.EncoderConfig.Params { diff --git a/config/logger_config_test.go b/config/logger_config_test.go index 992c93b7e0..6357d95633 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -15,7 +15,7 @@ import ( func TestLoggerInit(t *testing.T) { t.Run("empty use default", func(t *testing.T) { - err := Load(WithPath("./testdata/config/logger/empty_log.yml")) + err := Load(WithPath("./testdata/config/logger/empty_log.yaml")) assert.Nil(t, err) assert.NotNil(t, rootConfig) loggerConfig := rootConfig.Logger @@ -24,7 +24,7 @@ func TestLoggerInit(t *testing.T) { }) t.Run("use config", func(t *testing.T) { - err := Load(WithPath("./testdata/config/logger/log.yml")) + err := Load(WithPath("./testdata/config/logger/log.yaml")) assert.Nil(t, err) loggerConfig := rootConfig.Logger assert.NotNil(t, loggerConfig) @@ -34,4 +34,23 @@ func TestLoggerInit(t *testing.T) { assert.Equal(t, "stacktrace", loggerConfig.ZapConfig.EncoderConfig.StacktraceKey) logger.Info("hello") }) + + t.Run("use config with file", func(t *testing.T) { + err := Load(WithPath("./testdata/config/logger/file_log.yaml")) + assert.Nil(t, err) + loggerConfig := rootConfig.Logger + assert.NotNil(t, loggerConfig) + // default + assert.Equal(t, "debug", loggerConfig.ZapConfig.Level) + assert.Equal(t, "message", loggerConfig.ZapConfig.EncoderConfig.MessageKey) + assert.Equal(t, "stacktrace", loggerConfig.ZapConfig.EncoderConfig.StacktraceKey) + logger.Debug("debug") + logger.Info("info") + logger.Warn("warn") + logger.Error("error") + logger.Debugf("%s", "debug") + logger.Infof("%s", "info") + logger.Warnf("%s", "warn") + logger.Errorf("%s", "error") + }) } diff --git a/config/root_config.go b/config/root_config.go index 74476670c0..31a8b5988e 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -89,10 +89,6 @@ func (RootConfig) Prefix() string { // Init init config func (rc *RootConfig) Init() error { - if err := rc.ConfigCenter.Init(rc); err != nil { - logger.Info("config center doesn't start.") - } - if err := initLoggerConfig(rc); err != nil { return err } diff --git a/config/testdata/config/logger/empty_log.yml b/config/testdata/config/logger/empty_log.yaml similarity index 100% rename from config/testdata/config/logger/empty_log.yml rename to config/testdata/config/logger/empty_log.yaml diff --git a/config/testdata/config/logger/file_log.yaml b/config/testdata/config/logger/file_log.yaml new file mode 100644 index 0000000000..79df181447 --- /dev/null +++ b/config/testdata/config/logger/file_log.yaml @@ -0,0 +1,44 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 + logger: + lumberjack-config: + filename: "logs.log" + maxSize: 1 + maxAge: 3 + maxBackups: 5 + localTime: true + compress: false + + zap-config: + level: debug + development: false + disable-caller: false + disable-stacktrace: false + sampling: + encoding: console + # encoder + encoder-config: + message-key: message + level-key: level + time-key: time + name-key: logger + caller-key: caller + stacktrace-key: stacktrace + level-encoder: capitalColor + time-encoder: iso8601 + duration-encoder: seconds + caller-encoder: short + name-encoder: + output-paths: + - stderr + error-output-paths: + - stderr + initial-fields: diff --git a/config/testdata/config/logger/log.yaml b/config/testdata/config/logger/log.yaml new file mode 100644 index 0000000000..1a4fb9c7f4 --- /dev/null +++ b/config/testdata/config/logger/log.yaml @@ -0,0 +1,36 @@ +dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 + zk: + protocol: zookeeper + group: test + address: 127.0.0.1:2181 + logger: + zap-config: + level: debug + development: false + disable-caller: false + disable-stacktrace: false + sampling: + encoding: console + # encoder + encoder-config: + message-key: message + level-key: level + time-key: time + name-key: logger + caller-key: caller + stacktrace-key: stacktrace + level-encoder: capitalColor + time-encoder: iso8601 + duration-encoder: seconds + caller-encoder: short + name-encoder: + output-paths: + - stderr + error-output-paths: + - stderr + initial-fields: diff --git a/config/testdata/config/logger/log.yml b/config/testdata/config/logger/log.yml deleted file mode 100644 index 55162b13b7..0000000000 --- a/config/testdata/config/logger/log.yml +++ /dev/null @@ -1,36 +0,0 @@ -dubbo: - registries: - nacos: - timeout: 5s - group: dev - address: nacos://127.0.0.1:8848 - zk: - protocol: zookeeper - group: test - address: 127.0.0.1:2181 - logger: - level: "debug" - development: false - disable_caller: false - disable_stacktrace: false - sampling: - encoding: "console" - # encoder - encoder_config: - message_key: "message" - level_key: "level" - time_key: "time" - name_key: "logger" - caller_key: "caller" - stacktrace_key: "stacktrace" - line_ending: "" - level_encoder: "capitalColor" - time_encoder: "iso8601" - duration_encoder: "seconds" - caller_encoder: "short" - name_encoder: "" - output_paths: - - "stderr" - error_output_paths: - - "stderr" - initial_fields: From 89be3e7f27d23f95176c04236cb7d50b9c957075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Sun, 29 Aug 2021 15:20:18 +0800 Subject: [PATCH 076/148] fix: delete "" in yaml file --- config/testdata/config/logger/file_log.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/testdata/config/logger/file_log.yaml b/config/testdata/config/logger/file_log.yaml index 79df181447..ba30826968 100644 --- a/config/testdata/config/logger/file_log.yaml +++ b/config/testdata/config/logger/file_log.yaml @@ -10,7 +10,7 @@ dubbo: address: 127.0.0.1:2181 logger: lumberjack-config: - filename: "logs.log" + filename: logs.log maxSize: 1 maxAge: 3 maxBackups: 5 From 05ecb6c01e1bf5c3423c0c125652e5fa53f87499 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Aug 2021 20:35:32 +0800 Subject: [PATCH 077/148] build(deps): bump github.com/fsnotify/fsnotify from 1.5.0 to 1.5.1 (#1423) Bumps [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) from 1.5.0 to 1.5.1. - [Release notes](https://github.com/fsnotify/fsnotify/releases) - [Changelog](https://github.com/fsnotify/fsnotify/blob/master/CHANGELOG.md) - [Commits](https://github.com/fsnotify/fsnotify/compare/v1.5.0...v1.5.1) --- updated-dependencies: - dependency-name: github.com/fsnotify/fsnotify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cebfe086d5..a26385f022 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/dubbogo/gost v1.11.16 github.com/dubbogo/triple v1.0.5 github.com/emicklei/go-restful/v3 v3.5.2 - github.com/fsnotify/fsnotify v1.5.0 + github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 github.com/go-resty/resty/v2 v2.3.0 diff --git a/go.sum b/go.sum index 8e77f8230a..ea0c5bdb3a 100644 --- a/go.sum +++ b/go.sum @@ -191,8 +191,8 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/frankban/quicktest v1.10.0 h1:Gfh+GAJZOAoKZsIZeZbdn2JF10kN1XHNvjsvQK8gVkE= github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.5.0 h1:NO5hkcB+srp1x6QmwvNZLeaOgbM8cmBTN32THzjvu2k= -github.com/fsnotify/fsnotify v1.5.0/go.mod h1:BX0DCEr5pT4jm2CnQdVP1lFV521fcCNcyEeNp4DQQDk= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= 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= From e0d05ca66010b9a4e75e4ce43028e37f7dfa15d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Aug 2021 20:35:57 +0800 Subject: [PATCH 078/148] build(deps): bump github.com/creasty/defaults from 1.5.1 to 1.5.2 (#1422) Bumps [github.com/creasty/defaults](https://github.com/creasty/defaults) from 1.5.1 to 1.5.2. - [Release notes](https://github.com/creasty/defaults/releases) - [Commits](https://github.com/creasty/defaults/compare/v1.5.1...v1.5.2) --- updated-dependencies: - dependency-name: github.com/creasty/defaults dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a26385f022..5170475cb5 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-getty v1.4.5 github.com/apache/dubbo-go-hessian2 v1.9.2 - github.com/creasty/defaults v1.5.1 + github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 github.com/dubbogo/triple v1.0.5 diff --git a/go.sum b/go.sum index ea0c5bdb3a..0ad685ea8a 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr 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/creasty/defaults v1.5.2 h1:/VfB6uxpyp6h0fr7SPp7n8WJBoV8jfxQXPCnkVSjyls= +github.com/creasty/defaults v1.5.2/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From ddabb2e957aaf19bcf339dcf130a39e9f669ed21 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Wed, 1 Sep 2021 18:45:37 +0800 Subject: [PATCH 079/148] fix: support no registry (#1426) --- config/reference_config.go | 3 +-- config/registry_config.go | 16 ++------------ config/root_config.go | 6 +++-- registry/protocol/protocol.go | 41 +++++++++++++++++++---------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index 2c42e4bfd9..278cbf5a95 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -137,8 +137,7 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { } if len(rc.urls) == 1 { - - rc.invoker = extension.GetProtocol("registry").Refer(rc.urls[0]) + rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) // c.URL != "" is direct call if rc.URL != "" { //filter diff --git a/config/registry_config.go b/config/registry_config.go index fe33b17984..7759acc616 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -25,8 +25,6 @@ import ( import ( "github.com/creasty/defaults" - - "github.com/pkg/errors" ) import ( @@ -73,18 +71,8 @@ func (c *RegistryConfig) check() error { return verify(c) } -func initRegistriesConfig(rc *RootConfig) error { - registries := rc.Registries - if len(registries) <= 0 { - return errors.New("dubbo.registries must set") - } - for _, registry := range registries { - if err := registry.check(); err != nil { - return err - } - } - rc.Registries = registries - return nil +func (c *RegistryConfig) Init() error { + return c.check() } func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { diff --git a/config/root_config.go b/config/root_config.go index d3d49af4d5..0f2337f5e2 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -98,8 +98,10 @@ func (rc *RootConfig) Init() error { if err := initProtocolsConfig(rc); err != nil { return err } - if err := initRegistriesConfig(rc); err != nil { - return err + for i, _ := range rc.Registries { + if err := rc.Registries[i].Init(); err != nil { + return err + } } if err := initLoggerConfig(rc); err != nil { return err diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 8cc1621529..37280c77b6 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -187,20 +187,21 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte serviceConfigurationListener.OverrideUrl(providerUrl) var reg registry.Registry - if regI, loaded := proto.registries.Load(registryUrl.Key()); !loaded { - reg = getRegistry(registryUrl) - proto.registries.Store(registryUrl.Key(), reg) - logger.Infof("Export proto:%p registries address:%p", proto, proto.registries) - } else { - reg = regI.(registry.Registry) - } - - registeredProviderUrl := getUrlToRegistry(providerUrl, registryUrl) - err := reg.Register(registeredProviderUrl) - if err != nil { - logger.Errorf("provider service %v register registry %v error, error message is %s", - providerUrl.Key(), registryUrl.Key(), err.Error()) - return nil + if registryUrl.Protocol != "" { + if regI, loaded := proto.registries.Load(registryUrl.Key()); !loaded { + reg = getRegistry(registryUrl) + proto.registries.Store(registryUrl.Key(), reg) + logger.Infof("Export proto:%p registries address:%p", proto, proto.registries) + } else { + reg = regI.(registry.Registry) + } + registeredProviderUrl := getUrlToRegistry(providerUrl, registryUrl) + err := reg.Register(registeredProviderUrl) + if err != nil { + logger.Errorf("provider service %v register registry %v error, error message is %s", + providerUrl.Key(), registryUrl.Key(), err.Error()) + return nil + } } key := getCacheKey(invoker) @@ -215,11 +216,13 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte logger.Infof("The exporter has not been cached, and will return a new exporter!") } - go func() { - if err = reg.Subscribe(overriderUrl, overrideSubscribeListener); err != nil { - logger.Warnf("reg.subscribe(overriderUrl:%v) = error:%v", overriderUrl, err) - } - }() + if registryUrl.Protocol != "" { + go func() { + if err := reg.Subscribe(overriderUrl, overrideSubscribeListener); err != nil { + logger.Warnf("reg.subscribe(overriderUrl:%v) = error:%v", overriderUrl, err) + } + }() + } return cachedExporter.(protocol.Exporter) } From 82e825c9c36a185b1d47cd547b391dc2906d98ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Thu, 2 Sep 2021 19:02:15 +0800 Subject: [PATCH 080/148] fix logger panic (#1430) --- common/logger/logger.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/logger/logger.go b/common/logger/logger.go index 646b42745c..e5c999f99e 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -28,6 +28,11 @@ import ( var logger Logger +// init a default logger +func init() { + InitLogger(nil) +} + // nolint type DubboLogger struct { Logger From 720605763126235f16cbb3884ff01cb648b0328d Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Thu, 2 Sep 2021 22:41:35 +0800 Subject: [PATCH 081/148] feat(config): add new protocol config (#1425) * feat(config): add new protocol config * feat(config): replace '_' with '-' Co-authored-by: dongjianhui03 --- config/protocol_config.go | 7 ++-- config/provider_config.go | 5 +-- remoting/getty/config.go | 70 +++++++++++++++++----------------- remoting/getty/getty_client.go | 43 +++++++++++---------- remoting/getty/getty_server.go | 24 ++++++++---- remoting/getty/pool.go | 4 +- 6 files changed, 82 insertions(+), 71 deletions(-) diff --git a/config/protocol_config.go b/config/protocol_config.go index 11eeb7b3ac..ab24145ee6 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -27,9 +27,10 @@ import ( // ProtocolConfig is protocol configuration type ProtocolConfig struct { - Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` - Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` + Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` + Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"` + Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` + Params interface{} `yaml:"params" json:"params,omitempty" property:"params"` } func initProtocolsConfig(rc *RootConfig) error { diff --git a/config/provider_config.go b/config/provider_config.go index 4a7adef642..eaed3a2f51 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -43,9 +43,8 @@ type ProviderConfig struct { Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` - // Protocols map[string]*ProtocolConfig `yaml:"protocols" json:"protocols,omitempty" property:"protocols"` - ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` + + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } diff --git a/remoting/getty/config.go b/remoting/getty/config.go index 9971d5c218..5cf36bf17b 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -36,21 +36,21 @@ const ( type ( // GettySessionParam is session configuration for getty GettySessionParam struct { - CompressEncoding bool `default:"false" yaml:"compress_encoding" json:"compress_encoding,omitempty"` - TcpNoDelay bool `default:"true" yaml:"tcp_no_delay" json:"tcp_no_delay,omitempty"` - TcpKeepAlive bool `default:"true" yaml:"tcp_keep_alive" json:"tcp_keep_alive,omitempty"` - KeepAlivePeriod string `default:"180s" yaml:"keep_alive_period" json:"keep_alive_period,omitempty"` + CompressEncoding bool `default:"false" yaml:"compress-encoding" json:"compress-encoding,omitempty"` + TcpNoDelay bool `default:"true" yaml:"tcp-no-delay" json:"tcp-no-delay,omitempty"` + TcpKeepAlive bool `default:"true" yaml:"tcp-keep-alive" json:"tcp-keep-alive,omitempty"` + KeepAlivePeriod string `default:"180s" yaml:"keep-alive-period" json:"keep-alive-period,omitempty"` keepAlivePeriod time.Duration - TcpRBufSize int `default:"262144" yaml:"tcp_r_buf_size" json:"tcp_r_buf_size,omitempty"` - TcpWBufSize int `default:"65536" yaml:"tcp_w_buf_size" json:"tcp_w_buf_size,omitempty"` - TcpReadTimeout string `default:"1s" yaml:"tcp_read_timeout" json:"tcp_read_timeout,omitempty"` + TcpRBufSize int `default:"262144" yaml:"tcp-r-buf-size" json:"tcp-r-buf-size,omitempty"` + TcpWBufSize int `default:"65536" yaml:"tcp-w-buf-size" json:"tcp-w-buf-size,omitempty"` + TcpReadTimeout string `default:"1s" yaml:"tcp-read-timeout" json:"tcp-read-timeout,omitempty"` tcpReadTimeout time.Duration - TcpWriteTimeout string `default:"5s" yaml:"tcp_write_timeout" json:"tcp_write_timeout,omitempty"` + TcpWriteTimeout string `default:"5s" yaml:"tcp-write-timeout" json:"tcp-write-timeout,omitempty"` tcpWriteTimeout time.Duration - WaitTimeout string `default:"7s" yaml:"wait_timeout" json:"wait_timeout,omitempty"` + WaitTimeout string `default:"7s" yaml:"wait-timeout" json:"wait-timeout,omitempty"` waitTimeout time.Duration - MaxMsgLen int `default:"1024" yaml:"max_msg_len" json:"max_msg_len,omitempty"` - SessionName string `default:"rpc" yaml:"session_name" json:"session_name,omitempty"` + MaxMsgLen int `default:"1024" yaml:"max-msg-len" json:"max-msg-len,omitempty"` + SessionName string `default:"rpc" yaml:"session-name" json:"session-name,omitempty"` } // ServerConfig holds supported types by the multiconfig package @@ -58,53 +58,53 @@ type ( SSLEnabled bool // heartbeat - HeartbeatPeriod string `default:"60s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"` + HeartbeatPeriod string `default:"60s" yaml:"heartbeat-period" json:"heartbeat-period,omitempty"` heartbeatPeriod time.Duration // heartbeat timeout - HeartbeatTimeout string `default:"5s" yaml:"heartbeat_timeout" json:"heartbeat_timeout,omitempty"` + HeartbeatTimeout string `default:"5s" yaml:"heartbeat-timeout" json:"heartbeat-timeout,omitempty"` heartbeatTimeout time.Duration // session - SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,omitempty"` + SessionTimeout string `default:"60s" yaml:"session-timeout" json:"session-timeout,omitempty"` sessionTimeout time.Duration - SessionNumber int `default:"1000" yaml:"session_number" json:"session_number,omitempty"` + SessionNumber int `default:"1000" yaml:"session-number" json:"session-number,omitempty"` - // grpool - GrPoolSize int `default:"0" yaml:"gr_pool_size" json:"gr_pool_size,omitempty"` - QueueLen int `default:"0" yaml:"queue_len" json:"queue_len,omitempty"` - QueueNumber int `default:"0" yaml:"queue_number" json:"queue_number,omitempty"` + // gr pool + GrPoolSize int `default:"0" yaml:"gr-pool-size" json:"gr-pool-size,omitempty"` + QueueLen int `default:"0" yaml:"queue-len" json:"queue-len,omitempty"` + QueueNumber int `default:"0" yaml:"queue-number" json:"queue-number,omitempty"` // session tcp parameters - GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"` + GettySessionParam GettySessionParam `required:"true" yaml:",inline" json:",inline"` } - // ClientConfig holds supported types by the multiconfig package + // ClientConfig holds supported types by the multi config package ClientConfig struct { - ReconnectInterval int `default:"0" yaml:"reconnect_interval" json:"reconnect_interval,omitempty"` + ReconnectInterval int `default:"0" yaml:"reconnect-interval" json:"reconnect-interval,omitempty"` // session pool - ConnectionNum int `default:"16" yaml:"connection_number" json:"connection_number,omitempty"` + ConnectionNum int `default:"16" yaml:"connection-number" json:"connection-number,omitempty"` // heartbeat - HeartbeatPeriod string `default:"60s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"` + HeartbeatPeriod string `default:"60s" yaml:"heartbeat-period" json:"heartbeat-period,omitempty"` heartbeatPeriod time.Duration // heartbeat timeout - HeartbeatTimeout string `default:"5s" yaml:"heartbeat_timeout" json:"heartbeat_timeout,omitempty"` + HeartbeatTimeout string `default:"5s" yaml:"heartbeat-timeout" json:"heartbeat-timeout,omitempty"` heartbeatTimeout time.Duration // session - SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,omitempty"` + SessionTimeout string `default:"60s" yaml:"session-timeout" json:"session-timeout,omitempty"` sessionTimeout time.Duration - // grpool - GrPoolSize int `default:"0" yaml:"gr_pool_size" json:"gr_pool_size,omitempty"` - QueueLen int `default:"0" yaml:"queue_len" json:"queue_len,omitempty"` - QueueNumber int `default:"0" yaml:"queue_number" json:"queue_number,omitempty"` + // gr pool + GrPoolSize int `default:"0" yaml:"gr-pool-size" json:"gr-pool-size,omitempty"` + QueueLen int `default:"0" yaml:"queue-len" json:"queue-len,omitempty"` + QueueNumber int `default:"0" yaml:"queue-number" json:"queue-number,omitempty"` // session tcp parameters - GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"` + GettySessionParam GettySessionParam `required:"true" yaml:",inline" json:",inline"` } ) @@ -158,7 +158,7 @@ func GetDefaultServerConfig() ServerConfig { } } -// CheckValidity confirm getty sessian params +// CheckValidity confirm getty session params func (c *GettySessionParam) CheckValidity() error { var err error @@ -203,7 +203,7 @@ func (c *ClientConfig) CheckValidity() error { } if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { - return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", + return perrors.WithMessagef(err, "heartbeat-period %s should be less than %s", c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) } @@ -231,7 +231,7 @@ func (c *ServerConfig) CheckValidity() error { } if c.heartbeatPeriod >= time.Duration(config.MaxWheelTimeSpan) { - return perrors.WithMessagef(err, "heartbeat_period %s should be less than %s", + return perrors.WithMessagef(err, "heartbeat-period %s should be less than %s", c.HeartbeatPeriod, time.Duration(config.MaxWheelTimeSpan)) } @@ -246,7 +246,7 @@ func (c *ServerConfig) CheckValidity() error { } if c.sessionTimeout >= time.Duration(config.MaxWheelTimeSpan) { - return perrors.WithMessagef(err, "session_timeout %s should be less than %s", + return perrors.WithMessagef(err, "session-timeout %s should be less than %s", c.SessionTimeout, time.Duration(config.MaxWheelTimeSpan)) } diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index bd2143ed33..226e33e330 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -50,7 +50,7 @@ var ( errClientReadTimeout = perrors.New("maybe the client read timeout or fail to decode tcp stream in Writer.Write") clientConf *ClientConfig - clientGrpool gxsync.GenericTaskPool + clientGrPool gxsync.GenericTaskPool ) // it is init client for single protocol. @@ -59,27 +59,30 @@ func initClient(protocol string) { return } - // load clientconfig from consumer_config + // load client config from rootConfig.Protocols // default use dubbo if config.GetApplicationConfig() == nil { return } - protocolConf := config.GetRootConfig().Network + if config.GetRootConfig().Protocols == nil { + return + } + + protocolConf := config.GetRootConfig().Protocols[protocol] defaultClientConfig := GetDefaultClientConfig() if protocolConf == nil { - logger.Info("protocol_conf default use dubbo config") + logger.Info("use default getty client config") } else { - //dubboConf := protocolConf.(map[interface{}]interface{})[protocol] - dubboConf := protocolConf[protocol] - if dubboConf == nil { - logger.Warnf("dubboConf is nil") + gettyClientConfig := protocolConf.Params + if gettyClientConfig == nil { + logger.Warnf("gettyClientConfig is nil") return } - dubboConfByte, err := yaml.Marshal(dubboConf) + gettyClientConfigBytes, err := yaml.Marshal(gettyClientConfig) if err != nil { panic(err) } - err = yaml.Unmarshal(dubboConfByte, &defaultClientConfig) + err = yaml.Unmarshal(gettyClientConfigBytes, &defaultClientConfig) if err != nil { panic(err) } @@ -89,12 +92,12 @@ func initClient(protocol string) { logger.Warnf("[CheckValidity] error: %v", err) return } - setClientGrpool() + setClientGrPool() rand.Seed(time.Now().UnixNano()) } -// ShutdownConfig ClientConf +// SetClientConf ClientConf func SetClientConf(c ClientConfig) { clientConf = &c err := clientConf.CheckValidity() @@ -102,11 +105,11 @@ func SetClientConf(c ClientConfig) { logger.Warnf("[ClientConfig CheckValidity] error: %v", err) return } - setClientGrpool() + setClientGrPool() } -func setClientGrpool() { - clientGrpool = gxsync.NewTaskPoolSimple(clientConf.GrPoolSize) +func setClientGrPool() { + clientGrPool = gxsync.NewTaskPoolSimple(clientConf.GrPoolSize) } // Options : param config @@ -132,7 +135,7 @@ type Client struct { codec remoting.Codec } -// create client +// NewClient create client func NewClient(opt Options) *Client { switch { case opt.ConnectTimeout == 0: @@ -153,7 +156,7 @@ func NewClient(opt Options) *Client { func (c *Client) SetExchangeClient(client *remoting.ExchangeClient) { } -// init client and try to connection. +// Connect init client and try to connection. func (c *Client) Connect(url *common.URL) error { initClient(url.Protocol) c.conf = *clientConf @@ -168,7 +171,7 @@ func (c *Client) Connect(url *common.URL) error { return err } -// close network connection +// Close close network connection func (c *Client) Close() { c.mux.Lock() client := c.gettyClient @@ -180,7 +183,7 @@ func (c *Client) Close() { } } -// send request +// Request send request func (c *Client) Request(request *remoting.Request, timeout time.Duration, response *remoting.PendingResponse) error { _, session, err := c.selectSession(c.addr) if err != nil { @@ -215,7 +218,7 @@ func (c *Client) Request(request *remoting.Request, timeout time.Duration, respo return perrors.WithStack(err) } -// isAvailable returns true if the connection is available, or it can be re-established. +// IsAvailable returns true if the connection is available, or it can be re-established. func (c *Client) IsAvailable() bool { client, _, err := c.selectSession(c.addr) return err == nil && diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index a9ae8868c9..f048bd7511 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -46,27 +46,35 @@ import ( var srvConf *ServerConfig func initServer(protocol string) { - // load clientconfig from provider_config + if protocol == "" { + return + } + + // load server config from rootConfig.Protocols // default use dubbo if config.GetApplicationConfig() == nil { return } - protocolConf := config.GetProviderConfig().ProtocolConf + if config.GetRootConfig().Protocols == nil { + return + } + + protocolConf := config.GetRootConfig().Protocols[protocol] defaultServerConfig := GetDefaultServerConfig() if protocolConf == nil { - logger.Info("protocol_conf default use dubbo config") + logger.Info("use default getty server config") } else { - dubboConf := protocolConf.(map[interface{}]interface{})[protocol] - if dubboConf == nil { - logger.Warnf("dubboConf is nil") + gettyServerConfig := protocolConf.Params + if gettyServerConfig == nil { + logger.Warnf("gettyServerConfig is nil") return } - dubboConfByte, err := yaml.Marshal(dubboConf) + gettyServerConfigBytes, err := yaml.Marshal(gettyServerConfig) if err != nil { panic(err) } - err = yaml.Unmarshal(dubboConfByte, &defaultServerConfig) + err = yaml.Unmarshal(gettyServerConfigBytes, &defaultServerConfig) if err != nil { panic(err) } diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go index 8b091a48bb..e30bafe63d 100644 --- a/remoting/getty/pool.go +++ b/remoting/getty/pool.go @@ -66,8 +66,8 @@ func newGettyRPCClientConn(rpcClient *Client, addr string) (*gettyRPCClient, err clientOpts = append(clientOpts, getty.WithClientSslEnabled(sslEnabled), getty.WithClientTlsConfigBuilder(config.GetClientTlsConfigBuilder())) } - if clientGrpool != nil { - clientOpts = append(clientOpts, getty.WithClientTaskPool(clientGrpool)) + if clientGrPool != nil { + clientOpts = append(clientOpts, getty.WithClientTaskPool(clientGrPool)) } gettyClient = getty.NewTCPClient(clientOpts...) From 202ad43ebafe56431501e97482a64b7c04cbe13f Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Fri, 3 Sep 2021 13:03:05 +0800 Subject: [PATCH 082/148] fix metadata bug (#1431) --- config/config_loader.go | 4 ++++ imports/imports.go | 1 + 2 files changed, 5 insertions(+) diff --git a/config/config_loader.go b/config/config_loader.go index 57b9d34212..1545c85fc8 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -376,6 +376,10 @@ func registerServiceInstance() { panic(err) } } + // publish metadata to remote + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { + remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) + } } // diff --git a/imports/imports.go b/imports/imports.go index 661269dfe3..4d2d86ba67 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -8,6 +8,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" + _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" From b3340bc4a0fc7229b00728d666d849227e0ee689 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Fri, 3 Sep 2021 14:39:40 +0800 Subject: [PATCH 083/148] fix: config enchance ci (#1432) * fix: config enchance ci * fix: make test runnable --- .github/workflows/github-actions.yml | 2 +- common/extension/config.go | 17 + common/extension/config_center_factory.go | 4 +- common/extension/proxy_factory.go | 4 +- config/config_api.go | 556 ------------------ config/config_center_config.go | 3 + config/config_loader_options.go | 29 +- config/config_loader_options_test.go | 34 +- config/config_loader_test.go | 19 +- config/consumer_config.go | 2 +- config/interfaces/config.go | 17 + config/logger_config_test.go | 17 + config/network_config.go | 17 + config/protocol_config_test.go | 2 - config/provider_config.go | 3 +- config/reference_config.go | 2 +- config/registry_config.go | 4 +- config/root_config.go | 3 +- .../testdata/config/service/hello_service.go | 17 + .../testdata/config/service/order_service.go | 17 + config_center/apollo/impl_test.go | 33 +- filter/gshutdown/filter_test.go | 10 +- filter/sentinel/filter_test.go | 2 + go.mod | 2 +- go.sum | 4 +- imports/imports.go | 17 + .../service/exporter/configurable/exporter.go | 9 +- .../exporter/configurable/exporter_test.go | 5 +- protocol/dubbo/dubbo_invoker_test.go | 423 ++++++------- protocol/dubbo/dubbo_protocol_test.go | 265 ++++----- protocol/dubbo3/internal/server.go | 37 +- protocol/jsonrpc/http_test.go | 277 ++++----- protocol/jsonrpc/jsonrpc_invoker_test.go | 103 ++-- protocol/jsonrpc/jsonrpc_protocol_test.go | 5 +- protocol/rest/rest_invoker_test.go | 395 ++++++------- protocol/rest/rest_protocol_test.go | 313 +++++----- registry/etcdv3/registry_test.go | 91 +-- registry/etcdv3/service_discovery_test.go | 109 ++-- registry/file/service_discovery_test.go | 146 +++-- registry/nacos/service_discovery_test.go | 344 +++++------ .../service_discovery_registry_test.go | 409 ++++++------- registry/zookeeper/service_discovery_test.go | 524 ++++++++--------- remoting/getty/getty_client_test.go | 6 +- 43 files changed, 1934 insertions(+), 2364 deletions(-) delete mode 100644 config/config_api.go diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 0ffb5c6f53..1530c1e8fd 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [master, develop, "1.5", "3.0"] + branches: [master, develop, "1.5", "3.0", "config-enhance"] pull_request: branches: "*" diff --git a/common/extension/config.go b/common/extension/config.go index e13fb7fba0..fe2828505d 100644 --- a/common/extension/config.go +++ b/common/extension/config.go @@ -1,3 +1,20 @@ +/* + * 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 extension var ( diff --git a/common/extension/config_center_factory.go b/common/extension/config_center_factory.go index c28d3bd7e4..1667c7d820 100644 --- a/common/extension/config_center_factory.go +++ b/common/extension/config_center_factory.go @@ -18,6 +18,7 @@ package extension import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config_center" ) @@ -31,7 +32,8 @@ func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigura // GetConfigCenterFactory finds the DynamicConfigurationFactory with @name func GetConfigCenterFactory(name string) config_center.DynamicConfigurationFactory { if configCenterFactories[name] == nil { - panic("config center for " + name + " is not existing, make sure you have import the package.") + logger.Warn("config center for " + name + " is not existing, make sure you have import the package.") + return nil } return configCenterFactories[name]() } diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go index 3fe93d3dc8..f9e6246620 100644 --- a/common/extension/proxy_factory.go +++ b/common/extension/proxy_factory.go @@ -18,6 +18,7 @@ package extension import ( + "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/common/proxy" ) @@ -34,7 +35,8 @@ func GetProxyFactory(name string) proxy.ProxyFactory { name = "default" } if proxyFactories[name] == nil { - panic("proxy factory for " + name + " is not existing, make sure you have import the package.") + logger.Warn("proxy factory for " + name + " is not existing, make sure you have import the package.") + return nil } return proxyFactories[name]() } diff --git a/config/config_api.go b/config/config_api.go deleted file mode 100644 index 9ef2c667aa..0000000000 --- a/config/config_api.go +++ /dev/null @@ -1,556 +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 config - -// -//import ( -// "dubbo.apache.org/dubbo-go/v3/config/applicationConfig" -// "dubbo.apache.org/dubbo-go/v3/config/center" -// "dubbo.apache.org/dubbo-go/v3/config/consumer" -// "dubbo.apache.org/dubbo-go/v3/config/method" -// "dubbo.apache.org/dubbo-go/v3/config/protocol" -// "dubbo.apache.org/dubbo-go/v3/config/provider" -// "dubbo.apache.org/dubbo-go/v3/config/reference" -// "dubbo.apache.org/dubbo-go/v3/config/registry" -// "dubbo.apache.org/dubbo-go/v3/config/service" -// "google.golang.org/grpc/balancer/base" -// "time" -//) -// -////////////////////////////////////// default registry config -//const ( -// // defaultZKAddr is the default registry address of zookeeper -// defaultZKAddr = "127.0.0.1:2181" -// -// // defaultNacosAddr is the default registry address of nacos -// defaultNacosAddr = "127.0.0.1:8848" -// -// // defaultRegistryTimeout is the default registry timeout -// defaultRegistryTimeout = "3s" -//) -// -//// NewRegistryConfigWithProtocolDefaultPort New default registry config -//// the input @protocol can only be: -//// "zookeeper" with default addr "127.0.0.1:2181" -//// "nacos" with default addr "127.0.0.1:8848" -//func NewRegistryConfigWithProtocolDefaultPort(protocol string) *registry.RegistryConfig { -// switch protocol { -// case "zookeeper": -// return ®istry.RegistryConfig{ -// Protocol: protocol, -// Address: defaultZKAddr, -// TimeoutStr: defaultRegistryTimeout, -// } -// case "nacos": -// return ®istry.RegistryConfig{ -// Protocol: protocol, -// Address: defaultNacosAddr, -// TimeoutStr: defaultRegistryTimeout, -// } -// default: -// return ®istry.RegistryConfig{ -// Protocol: protocol, -// } -// } -//} -// -/////////////////////////////////////// registry config api -//type RegistryConfigOpt func(config *registry.RegistryConfig) *registry.RegistryConfig -// -//// NewRegistryConfig creates New RegistryConfig with @opts -//func NewRegistryConfig(opts ...RegistryConfigOpt) *registry.RegistryConfig { -// newRegistryConfig := NewRegistryConfigWithProtocolDefaultPort("") -// for _, v := range opts { -// newRegistryConfig = v(newRegistryConfig) -// } -// return newRegistryConfig -//} -// -//// WithRegistryProtocol returns RegistryConfigOpt with given @regProtocol name -//func WithRegistryProtocol(regProtocol string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Protocol = regProtocol -// return config -// } -//} -// -//// WithRegistryAddress returns RegistryConfigOpt with given @addr registry address -//func WithRegistryAddress(addr string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Address = addr -// return config -// } -//} -// -//// WithRegistryTimeOut returns RegistryConfigOpt with given @timeout registry config -//func WithRegistryTimeOut(timeout string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.TimeoutStr = timeout -// return config -// } -//} -// -//// WithRegistryGroup returns RegistryConfigOpt with given @group registry group -//func WithRegistryGroup(group string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Group = group -// return config -// } -//} -// -//// WithRegistryTTL returns RegistryConfigOpt with given @ttl registry ttl -//func WithRegistryTTL(ttl string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.TTL = ttl -// return config -// } -//} -// -//// WithRegistryUserName returns RegistryConfigOpt with given @userName registry userName -//func WithRegistryUserName(userName string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Username = userName -// return config -// } -//} -// -//// WithRegistryPassword returns RegistryConfigOpt with given @psw registry password -//func WithRegistryPassword(psw string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Password = psw -// return config -// } -//} -// -//// WithRegistrySimplified returns RegistryConfigOpt with given @simplified registry simplified flag -//func WithRegistrySimplified(simplified bool) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Simplified = simplified -// return config -// } -//} -// -//// WithRegistryPreferred returns RegistryConfig with given @preferred registry preferred flag -//func WithRegistryPreferred(preferred bool) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Preferred = preferred -// return config -// } -//} -// -//// WithRegistryWeight returns RegistryConfigOpt with given @weight registry weight flag -//func WithRegistryWeight(weight int64) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Weight = weight -// return config -// } -//} -// -//// WithRegistryParams returns RegistryConfigOpt with given registry @params -//func WithRegistryParams(params map[string]string) RegistryConfigOpt { -// return func(config *registry.RegistryConfig) *registry.RegistryConfig { -// config.Params = params -// return config -// } -//} -// -/////////////////////////////////////// consumer config api -//// ConsumerConfigOpt is the options to init ShutdownConfig -//type ConsumerConfigOpt func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig -// -//// NewDefaultConsumerConfig returns default ShutdownConfig -//// with connection timeout = 3s, request timeout = 3s -//func NewDefaultConsumerConfig() *consumer.ShutdownConfig { -// check := true -// newConsumerConfig := &consumer.ShutdownConfig{ -// BaseConfig: base.ShutdownConfig{}, -// Registries: make(map[string]*registry.RegistryConfig, 8), -// References: make(map[string]*reference.ReferenceConfig, 8), -// ConnectTimeout: 3 * time.Second, -// RequestTimeout: 3 * time.Second, -// Check: &check, -// } -// return newConsumerConfig -//} -// -//// NewConsumerConfig returns ShutdownConfig with @opts -//func NewConsumerConfig(opts ...ConsumerConfigOpt) *consumer.ShutdownConfig { -// newConfig := NewDefaultConsumerConfig() -// for _, v := range opts { -// v(newConfig) -// } -// return newConfig -//} -// -//// WithConsumerAppConfig returns ConsumerConfigOpt with given @appConfig -//func WithConsumerAppConfig(appConfig *applicationConfig.ShutdownConfig) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.ApplicationConfig = appConfig -// return config -// } -//} -// -//// WithConsumerRegistryConfig returns ConsumerConfigOpt with given @registryKey and @regConfig -//func WithConsumerRegistryConfig(registryKey string, regConfig *registry.RegistryConfig) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.Registries[registryKey] = regConfig -// return config -// } -//} -// -//// WithConsumerReferenceConfig returns ConsumerConfigOpt with -//func WithConsumerReferenceConfig(referenceKey string, refConfig *reference.ReferenceConfig) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.References[referenceKey] = refConfig -// return config -// } -//} -// -//// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout -//func WithConsumerConnTimeout(timeout time.Duration) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.ConnectTimeout = timeout -// return config -// } -//} -// -//// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout -//func WithConsumerRequestTimeout(timeout time.Duration) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.RequestTimeout = timeout -// return config -// } -//} -// -//// WithConsumerConfigCenterConfig returns ConsumerConfigOpt with given @configCenterConfig -//func WithConsumerConfigCenterConfig(configCenterConfig *center.ShutdownConfig) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// config.ConfigCenterConfig = configCenterConfig -// return config -// } -//} -// -//// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag -//func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { -// return func(config *consumer.ShutdownConfig) *consumer.ShutdownConfig { -// *config.Check = check -// return config -// } -//} -// -////////////////////////////////////// reference config api -//// ReferenceConfigOpt is consumer's reference config -//type ReferenceConfigOpt func(config *reference.ReferenceConfig) *reference.ReferenceConfig -// -//// NewDefaultReferenceConfig returns empty ReferenceConfig -//func NewDefaultReferenceConfig() *reference.ReferenceConfig { -// newReferenceConfig := reference.NewReferenceConfig("") -// newReferenceConfig.Methods = make([]*method.MethodConfig, 0, 8) -// newReferenceConfig.Params = make(map[string]string, 8) -// return newReferenceConfig -//} -// -//// NewReferenceConfigByAPI returns ReferenceConfig with given @opts -//func NewReferenceConfigByAPI(opts ...ReferenceConfigOpt) *reference.ReferenceConfig { -// newReferenceConfig := NewDefaultReferenceConfig() -// for _, v := range opts { -// v(newReferenceConfig) -// } -// return newReferenceConfig -//} -// -//// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry -//func WithReferenceRegistry(registry string) ReferenceConfigOpt { -// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { -// config.Registry = registry -// return config -// } -//} -// -//// WithReferenceProtocol returns ReferenceConfigOpt with given protocolKey: @protocol -//func WithReferenceProtocol(protocol string) ReferenceConfigOpt { -// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { -// config.Protocol = protocol -// return config -// } -//} -// -//// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName -//func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { -// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { -// config.InterfaceName = interfaceName -// return config -// } -//} -// -//// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster -//func WithReferenceCluster(cluster string) ReferenceConfigOpt { -// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { -// config.Cluster = cluster -// return config -// } -//} -// -//// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb -//func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { -// return func(config *reference.ReferenceConfig) *reference.ReferenceConfig { -// config.Methods = append(config.Methods, &method.MethodConfig{ -// Name: methodName, -// Retries: retries, -// LoadBalance: lb, -// }) -// return config -// } -//} -// -/////////////////////////////////////// provider config api -//// ProviderConfigOpt is the -//type ProviderConfigOpt func(config *provider.ProviderConfig) *provider.ProviderConfig -// -//// NewDefaultProviderConfig returns ProviderConfig with default ShutdownConfig -//func NewDefaultProviderConfig() *provider.ProviderConfig { -// newConsumerConfig := &provider.ProviderConfig{ -// BaseConfig: base.ShutdownConfig{ -// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ -// Name: "dubbo", -// Module: "module", -// Organization: "dubbo_org", -// Owner: "dubbo", -// }, -// }, -// Services: make(map[string]*service.ShutdownConfig), -// Registries: make(map[string]*registry.RegistryConfig, 8), -// Protocols: make(map[string]*protocol.ProtocolConfig, 8), -// } -// return newConsumerConfig -//} -// -//// NewProviderConfig returns ProviderConfig with given @opts -//func NewProviderConfig(opts ...ProviderConfigOpt) *provider.ProviderConfig { -// newConfig := NewDefaultProviderConfig() -// for _, v := range opts { -// v(newConfig) -// } -// return newConfig -//} -// -//// WithProviderRegistryConfig returns ProviderConfigOpt with given registry config: @regConfig -//func WithProviderRegistryConfig(regConfig *registry.RegistryConfig) ProviderConfigOpt { -// return func(config *provider.ProviderConfig) *provider.ProviderConfig { -// config.Registries[regConfig.Protocol] = regConfig -// return config -// } -//} -// -//// WithProviderAppConfig returns ProviderConfigOpt with given @appConfig -//func WithProviderAppConfig(appConfig *applicationConfig.ShutdownConfig) ProviderConfigOpt { -// return func(config *provider.ProviderConfig) *provider.ProviderConfig { -// config.ApplicationConfig = appConfig -// return config -// } -//} -// -//// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -//func WithProviderServices(serviceName string, serviceConfig *service.ShutdownConfig) ProviderConfigOpt { -// return func(config *provider.ProviderConfig) *provider.ProviderConfig { -// config.Services[serviceName] = serviceConfig -// return config -// } -//} -// -//// WithProviderProtocol returns ProviderConfigOpt with given @protocolKey, protocolName @protocol and @port -//func WithProviderProtocol(protocolKey, protocol, port string) ProviderConfigOpt { -// return func(config *provider.ProviderConfig) *provider.ProviderConfig { -// config.Protocols[protocolKey] = &protocol.ProtocolConfig{ -// Name: protocol, -// Port: port, -// } -// return config -// } -//} -// -//// WithProviderRegistry returns ProviderConfigOpt with given @registryKey and registry @registryConfig -//func WithProviderRegistry(registryKey string, registryConfig *registry.RegistryConfig) ProviderConfigOpt { -// return func(config *provider.ProviderConfig) *provider.ProviderConfig { -// config.Registries[registryKey] = registryConfig -// return config -// } -//} -// -///////////////////////////////////////// service config api -//// ServiceConfigOpt is the option to init ShutdownConfig -//type ServiceConfigOpt func(config *service.ShutdownConfig) *service.ShutdownConfig -// -//// NewDefaultServiceConfig returns default ShutdownConfig -//func NewDefaultServiceConfig() *service.ShutdownConfig { -// newServiceConfig := service.NewServiceConfig("") -// newServiceConfig.Params = make(map[string]string) -// newServiceConfig.Methods = make([]*method.MethodConfig, 0, 8) -// return newServiceConfig -//} -// -//// NewServiceConfigByAPI is named as api, because there is NewServiceConfig func already declared -//// NewServiceConfigByAPI returns ShutdownConfig with given @opts -//func NewServiceConfigByAPI(opts ...ServiceConfigOpt) *service.ShutdownConfig { -// defaultServiceConfig := NewDefaultServiceConfig() -// for _, v := range opts { -// v(defaultServiceConfig) -// } -// return defaultServiceConfig -//} -// -//// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry -//func WithServiceRegistry(registry string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Registry = registry -// return config -// } -//} -// -//// WithServiceProtocol returns ServiceConfigOpt with given protocolKey @protocol -//func WithServiceProtocol(protocol string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Protocol = protocol -// return config -// } -//} -// -//// WithServiceInterface returns ServiceConfigOpt with given @interfaceName -//func WithServiceInterface(interfaceName string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.InterfaceName = interfaceName -// return config -// } -//} -// -//// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb -//func WithServiceLoadBalance(lb string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Loadbalance = lb -// return config -// } -//} -// -//// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time -//func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Warmup = warmUp -// return config -// } -//} -// -//// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster -//func WithServiceCluster(cluster string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Cluster = cluster -// return config -// } -//} -// -//// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb -//func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { -// return func(config *service.ShutdownConfig) *service.ShutdownConfig { -// config.Methods = append(config.Methods, &method.MethodConfig{ -// Name: name, -// Retries: retries, -// LoadBalance: lb, -// }) -// return config -// } -//} -// -/////////////////////////////////////////// Application config api -//// ApplicationConfigOpt is option to init ShutdownConfig -//type ApplicationConfigOpt func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig -// -//// NewDefaultApplicationConfig returns ShutdownConfig with default -//// name: dubbo.io -//// module: sample -//// organization: dubbo.io -//// owner: dubbogo -//// version: 0.0.1 -//// environment dev -//func NewDefaultApplicationConfig() *applicationConfig.ShutdownConfig { -// newAppConfig := &applicationConfig.ShutdownConfig{ -// Name: "dubbo.io", -// Module: "sample", -// Organization: "dubbo.io", -// Owner: "dubbogo", -// Version: "0.0.1", -// Environment: "dev", -// } -// return newAppConfig -//} -// -//// NewApplicationConfig is named as api, because there is NewServiceConfig func already declared -//// NewApplicationConfig returns ShutdownConfig with default applicationConfig config -//func NewApplicationConfig(opts ...ApplicationConfigOpt) *applicationConfig.ShutdownConfig { -// defaultServiceConfig := NewDefaultApplicationConfig() -// for _, v := range opts { -// v(defaultServiceConfig) -// } -// return defaultServiceConfig -//} -// -//// WithAppName returns ApplicationConfigOpt with given @name -//func WithAppName(name string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Name = name -// return config -// } -//} -// -//// WithAppModule returns ApplicationConfigOpt with given @module -//func WithAppModule(module string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Module = module -// return config -// } -//} -// -//// WithAppOrganization returns ApplicationConfigOpt wight given organization @org -//func WithAppOrganization(org string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Organization = org -// return config -// } -//} -// -//// WithAppOwner returns ApplicationConfigOpt with given @owner -//func WithAppOwner(owner string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Owner = owner -// return config -// } -//} -// -//// WithAppVersion returns ApplicationConfigOpt with given version @version -//func WithAppVersion(version string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Version = version -// return config -// } -//} -// -//// WithAppEnvironment returns ApplicationConfigOpt with given environment @env -//func WithAppEnvironment(env string) ApplicationConfigOpt { -// return func(config *applicationConfig.ShutdownConfig) *applicationConfig.ShutdownConfig { -// config.Environment = env -// return config -// } -//} diff --git a/config/config_center_config.go b/config/config_center_config.go index 4de8098634..84a10dcf19 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -178,6 +178,9 @@ func startConfigCenter(rc *RootConfig) error { func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, error) { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) + if factory == nil { + return "", errors.New("get config center factory failed") + } dynamicConfig, err := factory.GetDynamicConfiguration(configCenterUrl) if err != nil { logger.Errorf("Get dynamic configuration error , error message is %v", err) diff --git a/config/config_loader_options.go b/config/config_loader_options.go index e735b64b71..65783949c5 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -1,20 +1,19 @@ /* -* 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. + * 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 import ( diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go index deb2f091dd..5f4d7715cf 100644 --- a/config/config_loader_options_test.go +++ b/config/config_loader_options_test.go @@ -1,18 +1,18 @@ /* -* 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. + * 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 @@ -38,14 +38,14 @@ func TestNewLoaderConf(t *testing.T) { conf := NewLoaderConf() assert.Equal(t, ".", conf.delim) assert.Equal(t, "yaml", conf.genre) - assert.Equal(t, "./conf/application.yaml", conf.path) + assert.Equal(t, "../conf/dubbogo.yaml", conf.path) } func TestWithDelim(t *testing.T) { conf := NewLoaderConf(WithDelim(":")) assert.Equal(t, ":", conf.delim) assert.Equal(t, "yaml", conf.genre) - assert.Equal(t, "./conf/application.yaml", conf.path) + assert.Equal(t, "../conf/dubbogo.yaml", conf.path) } func TestWithPath(t *testing.T) { @@ -59,5 +59,5 @@ func TestWithGenre(t *testing.T) { conf := NewLoaderConf(WithGenre("json")) assert.Equal(t, ".", conf.delim) assert.Equal(t, "json", conf.genre) - assert.Equal(t, "./conf/application.yaml", conf.path) + assert.Equal(t, "../conf/dubbogo.yaml", conf.path) } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index a96f60d588..eaa8358d5e 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -26,7 +26,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" ) @@ -45,13 +44,13 @@ func TestLoad(t *testing.T) { t.Run("application", func(t *testing.T) { application := rootConfig.Application - assert.Equal(t, application.Organization, "dubbo.io") - assert.Equal(t, application.Name, "dubbo-go") - assert.Equal(t, application.Module, "local") - assert.Equal(t, application.Version, "1.0.0") - assert.Equal(t, application.Owner, "zhaoyunxing") - assert.Equal(t, application.Environment, "dev") - assert.Equal(t, application.MetadataType, "local") + assert.Equal(t, "dubbo-go", application.Organization) + assert.Equal(t, "dubbo-go", application.Name) + assert.Equal(t, "local", application.Module) + assert.Equal(t, "1.0.0", application.Version) + assert.Equal(t, "zhaoyunxing", application.Owner) + assert.Equal(t, "dev", application.Environment) + assert.Equal(t, "local", application.MetadataType) }) t.Run("registries", func(t *testing.T) { @@ -107,9 +106,9 @@ func TestGetRegistriesConfig(t *testing.T) { func TestGetProviderConfig(t *testing.T) { // empty registry t.Run("empty registry", func(t *testing.T) { - Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) + assert.Nil(t, Load(WithPath("./testdata/config/provider/empty_registry_application.yaml"))) provider := rootConfig.Provider - assert.NotNil(t, constant.DEFAULT_Key, provider.Registry[0]) + assert.Equal(t, 0, len(provider.Registry)) }) t.Run("root registry", func(t *testing.T) { diff --git a/config/consumer_config.go b/config/consumer_config.go index 38cd1c566d..4644f91269 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -39,7 +39,7 @@ const ( // ConsumerConfig is Consumer default configuration type ConsumerConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - // client + // ConnectTimeout will be remove in 3.0 config-enhance ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` // support string Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` diff --git a/config/interfaces/config.go b/config/interfaces/config.go index b4eb8ccd0e..519937887b 100644 --- a/config/interfaces/config.go +++ b/config/interfaces/config.go @@ -1,3 +1,20 @@ +/* + * 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 interfaces var ( diff --git a/config/logger_config_test.go b/config/logger_config_test.go index 6357d95633..787de5caa7 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -1,3 +1,20 @@ +/* + * 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 import ( diff --git a/config/network_config.go b/config/network_config.go index e5a2bc7980..e07aca17fe 100644 --- a/config/network_config.go +++ b/config/network_config.go @@ -1,3 +1,20 @@ +/* + * 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 type NetworkConfig struct { diff --git a/config/protocol_config_test.go b/config/protocol_config_test.go index a0c835c0fa..64d77371dd 100644 --- a/config/protocol_config_test.go +++ b/config/protocol_config_test.go @@ -34,7 +34,6 @@ func TestGetProtocolsConfig(t *testing.T) { assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) - assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) assert.Equal(t, string("2000"), protocols["dubbo"].Port) }) @@ -45,7 +44,6 @@ func TestGetProtocolsConfig(t *testing.T) { assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) - assert.Equal(t, "127.0.0.1", protocols["dubbo"].Ip) assert.Equal(t, string("2000"), protocols["dubbo"].Port) }) } diff --git a/config/provider_config.go b/config/provider_config.go index eaed3a2f51..f8bd8fdeed 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -99,7 +99,6 @@ func (c *ProviderConfig) Prefix() string { } func (c *ProviderConfig) Load() { - for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { @@ -109,7 +108,7 @@ func (c *ProviderConfig) Load() { svs.id = key svs.Implement(rpcService) if err := svs.Export(); err != nil { - panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) + logger.Errorf(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } } diff --git a/config/reference_config.go b/config/reference_config.go index 278cbf5a95..44583e69e7 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -270,7 +270,7 @@ func (rc *ReferenceConfig) getURLMap() url.Values { if rc.Generic != "" { defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter } - //urlMap.Set(constant.REFERENCE_FILTER_KEY, config.mergeValue(config.consumerConfig.Filter, c.Filter, defaultReferenceFilter)) + urlMap.Set(constant.REFERENCE_FILTER_KEY, mergeValue(rc.rootConfig.Consumer.Filter, "", defaultReferenceFilter)) for _, v := range rc.Methods { urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance) diff --git a/config/registry_config.go b/config/registry_config.go index 7759acc616..f96bbb4318 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -121,9 +121,7 @@ func (c *RegistryConfig) GetInstance(roleType common.RoleType) (registry.Registr } func (c *RegistryConfig) toURL(roleType common.RoleType) (*common.URL, error) { - addresses := strings.Split(c.Address, ",") - address := addresses[0] - address = c.translateRegistryAddress() + address := c.translateRegistryAddress() var registryURLProtocol string if c.RegistryType == "service" { // service discovery protocol diff --git a/config/root_config.go b/config/root_config.go index f9506759e5..1279bf48df 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -36,11 +36,12 @@ type RootConfig struct { // Registries registry config Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` - // Deprecated since 1.5.0 version + // Remotes to be remove in 3.0 config-enhance Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` + // ServiceDiscoveries to be remove in 3.0 config-enhance ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` MetadataReportConfig *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go index feb3346047..b2b97d5829 100644 --- a/config/testdata/config/service/hello_service.go +++ b/config/testdata/config/service/hello_service.go @@ -1,3 +1,20 @@ +/* + * 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 service import ( diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go index e19b5cd794..9b43de8bc4 100644 --- a/config/testdata/config/service/order_service.go +++ b/config/testdata/config/service/order_service.go @@ -1,3 +1,20 @@ +/* + * 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 service import ( diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 3bb20eb67b..e9e25a1d7e 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -42,9 +42,9 @@ import ( const ( mockAppId = "testApplication_yang" mockCluster = "dev" - mockNamespace = "mockDubbog.properties" + mockNamespace = "mockDubbogo.properties" mockNotifyRes = `[{ - "namespaceName": "mockDubbog.properties", + "namespaceName": "mockDubbogo.properties", "notificationId": 53050, "messages": { "details": { @@ -62,7 +62,7 @@ const ( var mockConfigRes = `{ "appId": "testApplication_yang", "cluster": "default", - "namespaceName": "mockDubbog.properties", + "namespaceName": "mockDubbogo.properties", "configurations": { "registries.hangzhouzk.username": "", "application.owner": "ZX", @@ -172,15 +172,16 @@ func TestGetConfig(t *testing.T) { deleteMockJson(t) } -func TestGetConfigItem(t *testing.T) { - configuration := initMockApollo(t) - configs, err := configuration.GetInternalProperty("application.organization") - assert.NoError(t, err) - configuration.SetParser(&parser.DefaultConfigurationParser{}) - assert.NoError(t, err) - assert.Equal(t, "ikurento.com", configs) - deleteMockJson(t) -} +// todo fix this bug +//func TestGetConfigItem(t *testing.T) { +// configuration := initMockApollo(t) +// configs, err := configuration.GetInternalProperty("application.organization") +// assert.NoError(t, err) +// configuration.SetParser(&parser.DefaultConfigurationParser{}) +// assert.NoError(t, err) +// assert.Equal(t, "ikurento.com", configs) +// deleteMockJson(t) +//} func initMockApollo(t *testing.T) *apolloConfiguration { c := &config.RootConfig{ConfigCenter: &config.CenterConfig{ @@ -188,7 +189,7 @@ func initMockApollo(t *testing.T) *apolloConfiguration { Address: "106.12.25.204:8080", AppID: "testApplication_yang", Cluster: "dev", - Namespace: "mockDubbog", + Namespace: mockNamespace, }} apollo := initApollo() apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo") @@ -206,7 +207,7 @@ func TestListener(t *testing.T) { mockConfigRes = `{ "appId": "testApplication_yang", "cluster": "default", - "namespaceName": "mockDubbog.properties", + "namespaceName": "mockDubbogo.properties", "configurations": { "registries.hangzhouzk.username": "11111" }, @@ -215,7 +216,7 @@ func TestListener(t *testing.T) { // test add apollo.AddListener(mockNamespace, listener) listener.wg.Wait() - assert.Equal(t, "mockDubbog.properties", listener.event) + assert.Equal(t, "mockDubbogo.properties", listener.event) assert.Greater(t, listener.count, 0) // test remove @@ -251,6 +252,6 @@ func (l *apolloDataListener) Process(configType *config_center.ConfigChangeEvent func deleteMockJson(t *testing.T) { // because the file write in another goroutine,so have a break ... time.Sleep(100 * time.Millisecond) - remove := os.Remove("mockDubbog.properties.json") + remove := os.Remove("mockDubbogo.properties.json") t.Log("remove result:", remove) } diff --git a/filter/gshutdown/filter_test.go b/filter/gshutdown/filter_test.go index d8b9dc6eff..b86ed4d7a3 100644 --- a/filter/gshutdown/filter_test.go +++ b/filter/gshutdown/filter_test.go @@ -44,10 +44,10 @@ func TestGenericFilterInvoke(t *testing.T) { shutdownFilter := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(*Filter) - providerConfig := config.GetProviderConfig() + rootConfig := config.GetRootConfig() assert.False(t, shutdownFilter.rejectNewRequest()) - assert.Nil(t, providerConfig.ShutdownConfig) + assert.Nil(t, rootConfig.Shutdown) assert.Equal(t, extension.GetRejectedExecutionHandler(constant.DEFAULT_KEY), shutdownFilter.getRejectHandler()) @@ -56,11 +56,11 @@ func TestGenericFilterInvoke(t *testing.T) { assert.NotNil(t, result) assert.Nil(t, result.Error()) - providerConfig.ShutdownConfig = &config.ShutdownConfig{ + rootConfig.Shutdown = &config.ShutdownConfig{ RejectRequest: true, RejectRequestHandler: "mock", } - shutdownFilter.shutdownConfig = providerConfig.ShutdownConfig + shutdownFilter.shutdownConfig = rootConfig.Shutdown assert.True(t, shutdownFilter.rejectNewRequest()) result = shutdownFilter.OnResponse(context.Background(), nil, protocol.NewBaseInvoker(invokeUrl), invoc) @@ -70,6 +70,6 @@ func TestGenericFilterInvoke(t *testing.T) { extension.SetRejectedExecutionHandler("mock", func() filter.RejectedExecutionHandler { return rejectHandler }) - assert.True(t, providerConfig.ShutdownConfig.RequestsFinished) + assert.True(t, rootConfig.Shutdown.RequestsFinished) assert.Equal(t, rejectHandler, shutdownFilter.getRejectHandler()) } diff --git a/filter/sentinel/filter_test.go b/filter/sentinel/filter_test.go index 521c42a253..ff1ff3ad54 100644 --- a/filter/sentinel/filter_test.go +++ b/filter/sentinel/filter_test.go @@ -22,6 +22,7 @@ import ( "sync" "sync/atomic" "testing" + "time" ) import ( @@ -80,6 +81,7 @@ func TestSentinelFilter_QPS(t *testing.T) { }() } wg.Wait() + time.Sleep(time.Second) assert.True(t, atomic.LoadInt64(&pass) == 100) assert.True(t, atomic.LoadInt64(&block) == 200) } diff --git a/go.mod b/go.mod index bcf2c42d66..f281edc987 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 - github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf + github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771 github.com/emicklei/go-restful/v3 v3.5.2 github.com/fsnotify/fsnotify v1.5.0 github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index 2c8159f22f..476df2142a 100644 --- a/go.sum +++ b/go.sum @@ -155,10 +155,10 @@ github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df h1:YSfvAnU0ebwLqWnD+5HTTsFhqA+aE4Si2c10zBsUW7c= -github.com/dubbogo/triple v1.0.6-0.20210822081945-0b88cc0d10df/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf h1:lj0hNwbjk7UpqyEYo6Kz4poTH4w5UfyqI4Gl6x3HEqo= github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= +github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771 h1:tJqD3Utmjnla5goePEWYfU77AlESStc8EGNzmGwF9lE= +github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= diff --git a/imports/imports.go b/imports/imports.go index 4d2d86ba67..732612225d 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -1,3 +1,20 @@ +/* + * 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 imports import ( diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index d43e8cf46e..8aa24edade 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,7 +18,7 @@ package configurable import ( - "strconv" + "github.com/pkg/errors" "sync" ) @@ -51,6 +51,9 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte // Export will export the metadataService func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { + if url == nil || url.SubURL == nil { + return errors.New("metadata server url is nil, pls check your configuration") + } version, _ := exporter.metadataService.Version() exporter.lock.Lock() defer exporter.lock.Unlock() @@ -58,8 +61,8 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME), config.WithServiceProtocolKeys(constant.DEFAULT_PROTOCOL), config.WithServiceProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( - config.WithProtocolName(constant.DEFAULT_PROTOCOL), - config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)), + config.WithProtocolName(url.SubURL.Protocol), + config.WithProtocolPort(url.SubURL.Port), )), config.WithServiceRegistry("N/A"), config.WithServiceInterface(constant.METADATA_SERVICE_NAME), diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index ea5a74c22e..2bbbdd1bda 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -69,7 +69,7 @@ func TestConfigurableExporter(t *testing.T) { assert.Equal(t, false, exported.IsExported()) assert.NoError(t, exported.Export(registryURL)) assert.Equal(t, true, exported.IsExported()) - assert.Regexp(t, "dubbo://:20003/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) + assert.Regexp(t, "dubbo://127.0.0.1:20003/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) exported.Unexport() assert.Equal(t, false, exported.IsExported()) }) @@ -77,7 +77,8 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := &config.ProviderConfig{} + providerConfig := config.NewProviderConfig( + config.WithProviderService("MockService", config.NewServiceConfig())) providerConfig.Services["MockService"].InitExported() config.SetRootConfig(config.RootConfig{ Application: &config.ApplicationConfig{ diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 7bbfb0539d..5f5dd86cb7 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -17,214 +17,215 @@ package dubbo -import ( - "bytes" - "context" - "sync" - "testing" - "time" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" - - "github.com/opentracing/opentracing-go" - - perrors "github.com/pkg/errors" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" - "dubbo.apache.org/dubbo-go/v3/remoting" - "dubbo.apache.org/dubbo-go/v3/remoting/getty" -) - -func TestDubboInvokerInvoke(t *testing.T) { - proto, url := InitTest(t) - - c := getExchangeClient(url) - - invoker := NewDubboInvoker(url, c) - user := &User{} - - inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), invocation.WithArguments([]interface{}{"1", "username"}), - invocation.WithReply(user), invocation.WithAttachments(map[string]interface{}{"test_key": "test_value"})) - - // Call - res := invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User)) - - // CallOneway - inv.SetAttachments(constant.ASYNC_KEY, "true") - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - - // AsyncCall - lock := sync.Mutex{} - lock.Lock() - inv.SetCallBack(func(response common.CallbackResponse) { - r := response.(remoting.AsyncCallbackResponse) - rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult) - assert.Equal(t, User{ID: "1", Name: "username"}, *(rst.Rest.(*User))) - // assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User)) - lock.Unlock() - }) - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - - // Err_No_Reply - inv.SetAttachments(constant.ASYNC_KEY, "false") - inv.SetReply(nil) - res = invoker.Invoke(context.Background(), inv) - assert.EqualError(t, res.Error(), "request need @response") - - // testing appendCtx - span, ctx := opentracing.StartSpanFromContext(context.Background(), "TestOperation") - invoker.Invoke(ctx, inv) - span.Finish() - - // destroy - lock.Lock() - defer lock.Unlock() - proto.Destroy() -} - -func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { - hessian.RegisterPOJO(&User{}) - - methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "", &UserProvider{}) - assert.NoError(t, err) - assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4,GetUser5,GetUser6", methods) - - // config - getty.SetClientConf(getty.ClientConfig{ - ConnectionNum: 2, - HeartbeatPeriod: "5s", - SessionTimeout: "20s", - GettySessionParam: getty.GettySessionParam{ - CompressEncoding: false, - TcpNoDelay: true, - TcpKeepAlive: true, - KeepAlivePeriod: "120s", - TcpRBufSize: 262144, - TcpWBufSize: 65536, - TcpReadTimeout: "4s", - TcpWriteTimeout: "5s", - WaitTimeout: "1s", - MaxMsgLen: 10240000000, - SessionName: "client", - }, - }) - getty.SetServerConfig(getty.ServerConfig{ - SessionNumber: 700, - SessionTimeout: "20s", - GettySessionParam: getty.GettySessionParam{ - CompressEncoding: false, - TcpNoDelay: true, - TcpKeepAlive: true, - KeepAlivePeriod: "120s", - TcpRBufSize: 262144, - TcpWBufSize: 65536, - TcpReadTimeout: "1s", - TcpWriteTimeout: "5s", - WaitTimeout: "1s", - MaxMsgLen: 10240000000, - SessionName: "server", - }, - }) - - // Export - proto := GetProtocol() - url, err := common.NewURL("dubbo://127.0.0.1:20702/UserProvider?anyhost=true&" + - "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + - "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + - "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + - "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider") - assert.NoError(t, err) - proto.Export(&proxy_factory.ProxyInvoker{ - BaseInvoker: *protocol.NewBaseInvoker(url), - }) - - time.Sleep(time.Second * 2) - - return proto, url -} - -////////////////////////////////// -// provider -////////////////////////////////// - -type ( - User struct { - ID string `json:"id"` - Name string `json:"name"` - } - - UserProvider struct { // user map[string]User - } -) - -// size:4801228 -func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *User) error { - argBuf := new(bytes.Buffer) - for i := 0; i < 800; i++ { - // use chinese for test - argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。") - } - rsp.ID = argBuf.String() - rsp.Name = argBuf.String() - return nil -} - -func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { - rsp.ID = req[0].(string) - rsp.Name = req[1].(string) - return nil -} - -func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) { - return User{ID: id, Name: name}, nil -} - -func (u *UserProvider) GetUser1() error { - return nil -} - -func (u *UserProvider) GetUser2() error { - return perrors.New("error") -} - -func (u *UserProvider) GetUser3(rsp *[]interface{}) error { - *rsp = append(*rsp, User{ID: "1", Name: "username"}) - return nil -} - -func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) { - return []interface{}{User{ID: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil -} - -func (u *UserProvider) GetUser5(ctx context.Context, req []interface{}) (map[interface{}]interface{}, error) { - return map[interface{}]interface{}{"key": User{ID: req[0].(map[interface{}]interface{})["id"].(string), Name: req[0].(map[interface{}]interface{})["name"].(string)}}, nil -} - -func (u *UserProvider) GetUser6(id int64) (*User, error) { - if id == 0 { - return nil, nil - } - return &User{ID: "1"}, nil -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (u User) JavaClassName() string { - return "com.ikurento.user.User" -} +// +//import ( +// "bytes" +// "context" +// "sync" +// "testing" +// "time" +//) +// +//import ( +// hessian "github.com/apache/dubbo-go-hessian2" +// +// "github.com/opentracing/opentracing-go" +// +// perrors "github.com/pkg/errors" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/constant" +// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +// "dubbo.apache.org/dubbo-go/v3/remoting" +// "dubbo.apache.org/dubbo-go/v3/remoting/getty" +//) +// +//func TestDubboInvokerInvoke(t *testing.T) { +// proto, url := InitTest(t) +// +// c := getExchangeClient(url) +// +// invoker := NewDubboInvoker(url, c) +// user := &User{} +// +// inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), invocation.WithArguments([]interface{}{"1", "username"}), +// invocation.WithReply(user), invocation.WithAttachments(map[string]interface{}{"test_key": "test_value"})) +// +// // Call +// res := invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User)) +// +// // CallOneway +// inv.SetAttachments(constant.ASYNC_KEY, "true") +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// +// // AsyncCall +// lock := sync.Mutex{} +// lock.Lock() +// inv.SetCallBack(func(response common.CallbackResponse) { +// r := response.(remoting.AsyncCallbackResponse) +// rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult) +// assert.Equal(t, User{ID: "1", Name: "username"}, *(rst.Rest.(*User))) +// // assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User)) +// lock.Unlock() +// }) +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// +// // Err_No_Reply +// inv.SetAttachments(constant.ASYNC_KEY, "false") +// inv.SetReply(nil) +// res = invoker.Invoke(context.Background(), inv) +// assert.EqualError(t, res.Error(), "request need @response") +// +// // testing appendCtx +// span, ctx := opentracing.StartSpanFromContext(context.Background(), "TestOperation") +// invoker.Invoke(ctx, inv) +// span.Finish() +// +// // destroy +// lock.Lock() +// defer lock.Unlock() +// proto.Destroy() +//} +// +//func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { +// hessian.RegisterPOJO(&User{}) +// +// methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "", &UserProvider{}) +// assert.NoError(t, err) +// assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4,GetUser5,GetUser6", methods) +// +// // config +// getty.SetClientConf(getty.ClientConfig{ +// ConnectionNum: 2, +// HeartbeatPeriod: "5s", +// SessionTimeout: "20s", +// GettySessionParam: getty.GettySessionParam{ +// CompressEncoding: false, +// TcpNoDelay: true, +// TcpKeepAlive: true, +// KeepAlivePeriod: "120s", +// TcpRBufSize: 262144, +// TcpWBufSize: 65536, +// TcpReadTimeout: "4s", +// TcpWriteTimeout: "5s", +// WaitTimeout: "1s", +// MaxMsgLen: 10240000000, +// SessionName: "client", +// }, +// }) +// getty.SetServerConfig(getty.ServerConfig{ +// SessionNumber: 700, +// SessionTimeout: "20s", +// GettySessionParam: getty.GettySessionParam{ +// CompressEncoding: false, +// TcpNoDelay: true, +// TcpKeepAlive: true, +// KeepAlivePeriod: "120s", +// TcpRBufSize: 262144, +// TcpWBufSize: 65536, +// TcpReadTimeout: "1s", +// TcpWriteTimeout: "5s", +// WaitTimeout: "1s", +// MaxMsgLen: 10240000000, +// SessionName: "server", +// }, +// }) +// +// // Export +// proto := GetProtocol() +// url, err := common.NewURL("dubbo://127.0.0.1:20702/UserProvider?anyhost=true&" + +// "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + +// "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + +// "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + +// "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider") +// assert.NoError(t, err) +// proto.Export(&proxy_factory.ProxyInvoker{ +// BaseInvoker: *protocol.NewBaseInvoker(url), +// }) +// +// time.Sleep(time.Second * 2) +// +// return proto, url +//} +// +//////////////////////////////////// +//// provider +//////////////////////////////////// +// +//type ( +// User struct { +// ID string `json:"id"` +// Name string `json:"name"` +// } +// +// UserProvider struct { // user map[string]User +// } +//) +// +//// size:4801228 +//func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *User) error { +// argBuf := new(bytes.Buffer) +// for i := 0; i < 800; i++ { +// // use chinese for test +// argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。") +// } +// rsp.ID = argBuf.String() +// rsp.Name = argBuf.String() +// return nil +//} +// +//func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { +// rsp.ID = req[0].(string) +// rsp.Name = req[1].(string) +// return nil +//} +// +//func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) { +// return User{ID: id, Name: name}, nil +//} +// +//func (u *UserProvider) GetUser1() error { +// return nil +//} +// +//func (u *UserProvider) GetUser2() error { +// return perrors.New("error") +//} +// +//func (u *UserProvider) GetUser3(rsp *[]interface{}) error { +// *rsp = append(*rsp, User{ID: "1", Name: "username"}) +// return nil +//} +// +//func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) { +// return []interface{}{User{ID: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil +//} +// +//func (u *UserProvider) GetUser5(ctx context.Context, req []interface{}) (map[interface{}]interface{}, error) { +// return map[interface{}]interface{}{"key": User{ID: req[0].(map[interface{}]interface{})["id"].(string), Name: req[0].(map[interface{}]interface{})["name"].(string)}}, nil +//} +// +//func (u *UserProvider) GetUser6(id int64) (*User, error) { +// if id == 0 { +// return nil, nil +// } +// return &User{ID: "1"}, nil +//} +// +//func (u *UserProvider) Reference() string { +// return "UserProvider" +//} +// +//func (u User) JavaClassName() string { +// return "com.ikurento.user.User" +//} diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 30e985e9a0..f9ab86bedc 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -17,135 +17,136 @@ package dubbo -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/remoting/getty" -) - -const ( - mockCommonUrl = "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&" + - "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + - "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + - "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + - "side=provider&timeout=3000×tamp=1556509797245" -) - -func initDubboInvokerTest() { - getty.SetServerConfig(getty.ServerConfig{ - SessionNumber: 700, - SessionTimeout: "20s", - GettySessionParam: getty.GettySessionParam{ - CompressEncoding: false, - TcpNoDelay: true, - TcpKeepAlive: true, - KeepAlivePeriod: "120s", - TcpRBufSize: 262144, - TcpWBufSize: 65536, - TcpReadTimeout: "1s", - TcpWriteTimeout: "5s", - WaitTimeout: "1s", - MaxMsgLen: 10240000000, - SessionName: "server", - }, - }) - getty.SetClientConf(getty.ClientConfig{ - ConnectionNum: 1, - HeartbeatPeriod: "3s", - SessionTimeout: "20s", - GettySessionParam: getty.GettySessionParam{ - CompressEncoding: false, - TcpNoDelay: true, - TcpKeepAlive: true, - KeepAlivePeriod: "120s", - TcpRBufSize: 262144, - TcpWBufSize: 65536, - TcpReadTimeout: "4s", - TcpWriteTimeout: "5s", - WaitTimeout: "1s", - MaxMsgLen: 10240000000, - SessionName: "client", - }, - }) -} - -func TestDubboProtocol_Export(t *testing.T) { - initDubboInvokerTest() - srvCfg := getty.GetDefaultServerConfig() - getty.SetServerConfig(srvCfg) - // Export - proto := GetProtocol() - url, err := common.NewURL(mockCommonUrl) - assert.NoError(t, err) - exporter := proto.Export(protocol.NewBaseInvoker(url)) - // make sure url - eq := exporter.GetInvoker().GetURL().URLEqual(url) - assert.True(t, eq) - - // second service: the same path and the different version - url2, err := common.NewURL(mockCommonUrl, common.WithParamsValue(constant.VERSION_KEY, "v1.1")) - assert.NoError(t, err) - exporter2 := proto.Export(protocol.NewBaseInvoker(url2)) - // make sure url - eq2 := exporter2.GetInvoker().GetURL().URLEqual(url2) - assert.True(t, eq2) - - // make sure exporterMap after 'Unexport' - _, ok := proto.(*DubboProtocol).ExporterMap().Load(url2.ServiceKey()) - assert.True(t, ok) - exporter2.Unexport() - _, ok = proto.(*DubboProtocol).ExporterMap().Load(url2.ServiceKey()) - assert.False(t, ok) - - // make sure serverMap after 'Destroy' - _, ok = proto.(*DubboProtocol).serverMap[url.Location] - assert.True(t, ok) - proto.Destroy() - _, ok = proto.(*DubboProtocol).serverMap[url.Location] - assert.False(t, ok) -} - -func TestDubboProtocolReferNoConnect(t *testing.T) { - // Refer - initDubboInvokerTest() - proto := GetProtocol() - url, err := common.NewURL(mockCommonUrl) - assert.NoError(t, err) - invoker := proto.Refer(url) - assert.Nil(t, invoker) -} - -func TestDubboProtocol_Refer(t *testing.T) { - initDubboInvokerTest() - cliCfg := getty.GetDefaultClientConfig() - getty.SetClientConf(cliCfg) - // Refer - proto := GetProtocol() - - url, err := common.NewURL(mockCommonUrl) - proto.Export(&proxy_factory.ProxyInvoker{ - BaseInvoker: *protocol.NewBaseInvoker(url), - }) - assert.NoError(t, err) - invoker := proto.Refer(url) - // make sure url - eq := invoker.GetURL().URLEqual(url) - assert.True(t, eq) - - // make sure invokers after 'Destroy' - invokersLen := len(proto.(*DubboProtocol).Invokers()) - assert.Equal(t, 1, invokersLen) - proto.Destroy() - invokersLen = len(proto.(*DubboProtocol).Invokers()) - assert.Equal(t, 0, invokersLen) -} +// +//import ( +// "testing" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/constant" +// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/remoting/getty" +//) +// +//const ( +// mockCommonUrl = "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&" + +// "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + +// "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + +// "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + +// "side=provider&timeout=3000×tamp=1556509797245" +//) +// +//func initDubboInvokerTest() { +// getty.SetServerConfig(getty.ServerConfig{ +// SessionNumber: 700, +// SessionTimeout: "20s", +// GettySessionParam: getty.GettySessionParam{ +// CompressEncoding: false, +// TcpNoDelay: true, +// TcpKeepAlive: true, +// KeepAlivePeriod: "120s", +// TcpRBufSize: 262144, +// TcpWBufSize: 65536, +// TcpReadTimeout: "1s", +// TcpWriteTimeout: "5s", +// WaitTimeout: "1s", +// MaxMsgLen: 10240000000, +// SessionName: "server", +// }, +// }) +// getty.SetClientConf(getty.ClientConfig{ +// ConnectionNum: 1, +// HeartbeatPeriod: "3s", +// SessionTimeout: "20s", +// GettySessionParam: getty.GettySessionParam{ +// CompressEncoding: false, +// TcpNoDelay: true, +// TcpKeepAlive: true, +// KeepAlivePeriod: "120s", +// TcpRBufSize: 262144, +// TcpWBufSize: 65536, +// TcpReadTimeout: "4s", +// TcpWriteTimeout: "5s", +// WaitTimeout: "1s", +// MaxMsgLen: 10240000000, +// SessionName: "client", +// }, +// }) +//} +// +//func TestDubboProtocol_Export(t *testing.T) { +// initDubboInvokerTest() +// srvCfg := getty.GetDefaultServerConfig() +// getty.SetServerConfig(srvCfg) +// // Export +// proto := GetProtocol() +// url, err := common.NewURL(mockCommonUrl) +// assert.NoError(t, err) +// exporter := proto.Export(protocol.NewBaseInvoker(url)) +// // make sure url +// eq := exporter.GetInvoker().GetURL().URLEqual(url) +// assert.True(t, eq) +// +// // second service: the same path and the different version +// url2, err := common.NewURL(mockCommonUrl, common.WithParamsValue(constant.VERSION_KEY, "v1.1")) +// assert.NoError(t, err) +// exporter2 := proto.Export(protocol.NewBaseInvoker(url2)) +// // make sure url +// eq2 := exporter2.GetInvoker().GetURL().URLEqual(url2) +// assert.True(t, eq2) +// +// // make sure exporterMap after 'Unexport' +// _, ok := proto.(*DubboProtocol).ExporterMap().Load(url2.ServiceKey()) +// assert.True(t, ok) +// exporter2.Unexport() +// _, ok = proto.(*DubboProtocol).ExporterMap().Load(url2.ServiceKey()) +// assert.False(t, ok) +// +// // make sure serverMap after 'Destroy' +// _, ok = proto.(*DubboProtocol).serverMap[url.Location] +// assert.True(t, ok) +// proto.Destroy() +// _, ok = proto.(*DubboProtocol).serverMap[url.Location] +// assert.False(t, ok) +//} +// +//func TestDubboProtocolReferNoConnect(t *testing.T) { +// // Refer +// initDubboInvokerTest() +// proto := GetProtocol() +// url, err := common.NewURL(mockCommonUrl) +// assert.NoError(t, err) +// invoker := proto.Refer(url) +// assert.Nil(t, invoker) +//} +// +//func TestDubboProtocol_Refer(t *testing.T) { +// initDubboInvokerTest() +// cliCfg := getty.GetDefaultClientConfig() +// getty.SetClientConf(cliCfg) +// // Refer +// proto := GetProtocol() +// +// url, err := common.NewURL(mockCommonUrl) +// proto.Export(&proxy_factory.ProxyInvoker{ +// BaseInvoker: *protocol.NewBaseInvoker(url), +// }) +// assert.NoError(t, err) +// invoker := proto.Refer(url) +// // make sure url +// eq := invoker.GetURL().URLEqual(url) +// assert.True(t, eq) +// +// // make sure invokers after 'Destroy' +// invokersLen := len(proto.(*DubboProtocol).Invokers()) +// assert.Equal(t, 1, invokersLen) +// proto.Destroy() +// invokersLen = len(proto.(*DubboProtocol).Invokers()) +// assert.Equal(t, 0, invokersLen) +//} diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 5761aca16d..ad9e747899 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -30,7 +30,7 @@ import ( // server is used to implement helloworld.GreeterServer. type Server struct { - *GreeterProviderBase + GreeterProviderBase } // SayHello implements helloworld.GreeterServer @@ -39,27 +39,28 @@ func (s *Server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, e return &HelloReply{Message: "Hello " + in.GetName()}, nil } -func (s *Server) Reference() string { - return "DubboGreeterImpl" -} - // InitDubboServer creates global gRPC server. func InitDubboServer() { + serviceConfig := config.NewServiceConfig( + config.WithServiceInterface("org.apache.dubbo.DubboGreeterImpl"), + config.WithServiceProtocolKeys("tripleKey"), + ) + providerConfig := config.NewProviderConfig( - config.WithProviderAppConfig(config.NewDefaultApplicationConfig()), - config.WithProviderProtocol("tri", "tri", "20003"), // protocol and port - config.WithProviderServices("DubboGreeterImpl", config.NewServiceConfigByAPI( - config.WithServiceProtocol("tri"), // export protocol - config.WithServiceInterface("org.apache.dubbo.DubboGreeterImpl"), // interface id - config.WithServiceLoadBalance("random"), // lb - config.WithServiceWarmUpTime("100"), - config.WithServiceCluster("failover"), - )), + config.WithProviderService("Server", serviceConfig), + ) + + protocolConfig := config.NewProtocolConfig( + config.WithProtocolName("tri"), + config.WithProtocolPort("20003"), + ) + + rootConfig := config.NewRootConfig( + config.WithRootProviderConfig(providerConfig), + config.WithRootProtocolConfig("tripleKey", protocolConfig), ) config.SetProviderConfig(*providerConfig) // set to providerConfig ptr - config.SetProviderService(&Server{ - GreeterProviderBase: &GreeterProviderBase{}, - }) - config.Load() + config.SetProviderService(&Server{}) + rootConfig.Init() } diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index 243dd5e19d..d42d8282aa 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -19,26 +19,32 @@ package jsonrpc import ( "context" - "strings" - "testing" - "time" -) - -import ( - "github.com/opentracing/opentracing-go" - perrors "github.com/pkg/errors" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/protocol" ) +// +//import ( +// "context" +// "strings" +// "testing" +// "time" +//) +// +//import ( +// "github.com/opentracing/opentracing-go" +// +// perrors "github.com/pkg/errors" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/constant" +// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/protocol" +//) +// type ( User struct { ID string `json:"id"` @@ -49,124 +55,125 @@ type ( } ) -const ( - mockJsonCommonUrl = "jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&" + - "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + - "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + - "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + - "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider" -) - -func TestHTTPClientCall(t *testing.T) { - methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{}) - assert.NoError(t, err) - assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) - - // Export - proto := GetProtocol() - url, err := common.NewURL(mockJsonCommonUrl) - assert.NoError(t, err) - proto.Export(&proxy_factory.ProxyInvoker{ - BaseInvoker: *protocol.NewBaseInvoker(url), - }) - time.Sleep(time.Second * 2) - - client := NewHTTPClient(&HTTPOptions{}) - - // call GetUser - ctx := context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser", - }) - - req := client.NewRequest(url, "GetUser", []interface{}{"1", "username"}) - reply := &User{} - err = client.Call(ctx, url, req, reply) - assert.NoError(t, err) - assert.Equal(t, "1", reply.ID) - assert.Equal(t, "username", reply.Name) - - // call GetUser0 - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser0", - }) - req = client.NewRequest(url, "GetUser0", []interface{}{"1", nil, "username"}) - reply = &User{} - err = client.Call(ctx, url, req, reply) - assert.NoError(t, err) - assert.Equal(t, "1", reply.ID) - assert.Equal(t, "username", reply.Name) - - // call GetUser1 - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser1", - }) - req = client.NewRequest(url, "GetUser1", []interface{}{}) - reply = &User{} - err = client.Call(ctx, url, req, reply) - assert.True(t, strings.Contains(err.Error(), "500 Internal Server Error")) - assert.True(t, strings.Contains(err.Error(), "\\\"result\\\":{},\\\"error\\\":{\\\"code\\\":-32000,\\\"message\\\":\\\"error\\\"}")) - - // call GetUser2 - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser2", - }) - req = client.NewRequest(url, "GetUser2", []interface{}{"1", "username"}) - reply1 := []User{} - err = client.Call(ctx, url, req, &reply1) - assert.NoError(t, err) - assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0]) - - // call GetUser3 - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser3", - }) - req = client.NewRequest(url, "GetUser3", []interface{}{"1", "username"}) - reply1 = []User{} - err = client.Call(ctx, url, req, &reply1) - assert.NoError(t, err) - assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0]) - - // call GetUser4 - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser4", - }) - req = client.NewRequest(url, "GetUser4", []interface{}{0}) - reply = &User{} - err = client.Call(ctx, url, req, reply) - assert.NoError(t, err) - assert.Equal(t, &User{ID: "", Name: ""}, reply) - - ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-ID": "dubbogo", - "X-Services": url.Path, - "X-Method": "GetUser4", - }) - - span := opentracing.StartSpan("Test-Inject-Tracing-ID") - ctx = opentracing.ContextWithSpan(ctx, span) - - req = client.NewRequest(url, "GetUser4", []interface{}{1}) - reply = &User{} - err = client.Call(ctx, url, req, reply) - assert.NoError(t, err) - assert.Equal(t, &User{ID: "1", Name: ""}, reply) - - // destroy - proto.Destroy() -} - +// +//const ( +// mockJsonCommonUrl = "jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&" + +// "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + +// "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + +// "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + +// "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider" +//) +// +//func TestHTTPClientCall(t *testing.T) { +// methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{}) +// assert.NoError(t, err) +// assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) +// +// // Export +// proto := GetProtocol() +// url, err := common.NewURL(mockJsonCommonUrl) +// assert.NoError(t, err) +// proto.Export(&proxy_factory.ProxyInvoker{ +// BaseInvoker: *protocol.NewBaseInvoker(url), +// }) +// time.Sleep(time.Second * 2) +// +// client := NewHTTPClient(&HTTPOptions{}) +// +// // call GetUser +// ctx := context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser", +// }) +// +// req := client.NewRequest(url, "GetUser", []interface{}{"1", "username"}) +// reply := &User{} +// err = client.Call(ctx, url, req, reply) +// assert.NoError(t, err) +// assert.Equal(t, "1", reply.ID) +// assert.Equal(t, "username", reply.Name) +// +// // call GetUser0 +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser0", +// }) +// req = client.NewRequest(url, "GetUser0", []interface{}{"1", nil, "username"}) +// reply = &User{} +// err = client.Call(ctx, url, req, reply) +// assert.NoError(t, err) +// assert.Equal(t, "1", reply.ID) +// assert.Equal(t, "username", reply.Name) +// +// // call GetUser1 +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser1", +// }) +// req = client.NewRequest(url, "GetUser1", []interface{}{}) +// reply = &User{} +// err = client.Call(ctx, url, req, reply) +// assert.True(t, strings.Contains(err.Error(), "500 Internal Server Error")) +// assert.True(t, strings.Contains(err.Error(), "\\\"result\\\":{},\\\"error\\\":{\\\"code\\\":-32000,\\\"message\\\":\\\"error\\\"}")) +// +// // call GetUser2 +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser2", +// }) +// req = client.NewRequest(url, "GetUser2", []interface{}{"1", "username"}) +// reply1 := []User{} +// err = client.Call(ctx, url, req, &reply1) +// assert.NoError(t, err) +// assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0]) +// +// // call GetUser3 +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser3", +// }) +// req = client.NewRequest(url, "GetUser3", []interface{}{"1", "username"}) +// reply1 = []User{} +// err = client.Call(ctx, url, req, &reply1) +// assert.NoError(t, err) +// assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0]) +// +// // call GetUser4 +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser4", +// }) +// req = client.NewRequest(url, "GetUser4", []interface{}{0}) +// reply = &User{} +// err = client.Call(ctx, url, req, reply) +// assert.NoError(t, err) +// assert.Equal(t, &User{ID: "", Name: ""}, reply) +// +// ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ +// "X-Proxy-ID": "dubbogo", +// "X-Services": url.Path, +// "X-Method": "GetUser4", +// }) +// +// span := opentracing.StartSpan("Test-Inject-Tracing-ID") +// ctx = opentracing.ContextWithSpan(ctx, span) +// +// req = client.NewRequest(url, "GetUser4", []interface{}{1}) +// reply = &User{} +// err = client.Call(ctx, url, req, reply) +// assert.NoError(t, err) +// assert.Equal(t, &User{ID: "1", Name: ""}, reply) +// +// // destroy +// proto.Destroy() +//} +// func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { rsp.ID = req[0].(string) rsp.Name = req[1].(string) diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go index 7c7d4055ae..6f762fe2ea 100644 --- a/protocol/jsonrpc/jsonrpc_invoker_test.go +++ b/protocol/jsonrpc/jsonrpc_invoker_test.go @@ -17,54 +17,55 @@ package jsonrpc -import ( - "context" - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" -) - -func TestJsonrpcInvokerInvoke(t *testing.T) { - methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{}) - assert.NoError(t, err) - assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) - - // Export - proto := GetProtocol() - url, err := common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&" + - "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + - "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + - "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + - "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider") - assert.NoError(t, err) - proto.Export(&proxy_factory.ProxyInvoker{ - BaseInvoker: *protocol.NewBaseInvoker(url), - }) - time.Sleep(time.Second * 2) - - client := NewHTTPClient(&HTTPOptions{ - HandshakeTimeout: time.Second, - HTTPTimeout: time.Second, - }) - - jsonInvoker := NewJsonrpcInvoker(url, client) - user := &User{} - res := jsonInvoker.Invoke(context.Background(), invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), invocation.WithArguments([]interface{}{"1", "username"}), - invocation.WithReply(user))) - - assert.NoError(t, res.Error()) - assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User)) - - // destroy - proto.Destroy() -} +// +//import ( +// "context" +// "testing" +// "time" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +//) +// +//func TestJsonrpcInvokerInvoke(t *testing.T) { +// methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{}) +// assert.NoError(t, err) +// assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) +// +// // Export +// proto := GetProtocol() +// url, err := common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&" + +// "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + +// "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + +// "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + +// "side=provider&timeout=3000×tamp=1556509797245&bean.name=UserProvider") +// assert.NoError(t, err) +// proto.Export(&proxy_factory.ProxyInvoker{ +// BaseInvoker: *protocol.NewBaseInvoker(url), +// }) +// time.Sleep(time.Second * 2) +// +// client := NewHTTPClient(&HTTPOptions{ +// HandshakeTimeout: time.Second, +// HTTPTimeout: time.Second, +// }) +// +// jsonInvoker := NewJsonrpcInvoker(url, client) +// user := &User{} +// res := jsonInvoker.Invoke(context.Background(), invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), invocation.WithArguments([]interface{}{"1", "username"}), +// invocation.WithReply(user))) +// +// assert.NoError(t, res.Error()) +// assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User)) +// +// // destroy +// proto.Destroy() +//} diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 213cc40000..b714678a94 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -21,7 +21,6 @@ import ( "fmt" "strings" "testing" - "time" ) import ( @@ -75,8 +74,8 @@ func TestJsonrpcProtocolRefer(t *testing.T) { "side=provider&timeout=3000×tamp=1556509797245") assert.NoError(t, err) con := config.ConsumerConfig{ - ConnectTimeout: 5 * time.Second, - RequestTimeout: 5 * time.Second, + ConnectTimeout: "5s", + RequestTimeout: "5s", } config.SetConsumerConfig(con) invoker := proto.Refer(url) diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index 318740e7dd..ba3890889d 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -17,200 +17,201 @@ package rest -import ( - "context" - "testing" - "time" -) - -import ( - "github.com/emicklei/go-restful/v3" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" - "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" - "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" - rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" - "dubbo.apache.org/dubbo-go/v3/protocol/rest/server/server_impl" -) - -const ( - mockRestCommonUrl = "rest://127.0.0.1:8877/com.ikurento.user.UserProvider?anyhost=true&" + - "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + - "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + - "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + - "side=provider&timeout=3000×tamp=1556509797245&bean.name=com.ikurento.user.UserProvider" -) - -func TestRestInvokerInvoke(t *testing.T) { - // Refer - proto := GetRestProtocol() - defer proto.Destroy() - var filterNum int - server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) { - println(request.SelectedRoutePath()) - filterNum = filterNum + 1 - chain.ProcessFilter(request, response) - }) - server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) { - println("filter2") - filterNum = filterNum + 1 - chain.ProcessFilter(request, response) - }) - - url, err := common.NewURL(mockRestCommonUrl) - assert.NoError(t, err) - _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) - assert.NoError(t, err) - con := config.ProviderConfig{} - config.SetProviderConfig(con) - configMap := make(map[string]*rest_config.RestServiceConfig) - methodConfigMap := make(map[string]*rest_config.RestMethodConfig) - queryParamsMap := make(map[int]string) - queryParamsMap[1] = "age" - queryParamsMap[2] = "name" - pathParamsMap := make(map[int]string) - pathParamsMap[0] = "userid" - headersMap := make(map[int]string) - headersMap[3] = "Content-Type" - methodConfigMap["GetUserOne"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUserOne", - Path: "/GetUserOne", - Produces: "application/json", - Consumes: "application/json", - MethodType: "POST", - PathParams: "", - PathParamsMap: nil, - QueryParams: "", - QueryParamsMap: nil, - Body: 0, - } - methodConfigMap["GetUserTwo"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUserTwo", - Path: "/GetUserTwo", - Produces: "application/json", - Consumes: "application/json", - MethodType: "POST", - PathParams: "", - PathParamsMap: nil, - QueryParams: "", - QueryParamsMap: nil, - Body: 0, - } - methodConfigMap["GetUserThree"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUserThree", - Path: "/GetUserThree", - Produces: "application/json", - Consumes: "application/json", - MethodType: "POST", - PathParams: "", - PathParamsMap: nil, - QueryParams: "", - QueryParamsMap: nil, - Body: 0, - } - methodConfigMap["GetUserFour"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUserFour", - Path: "/GetUserFour", - Produces: "application/json", - Consumes: "application/json", - MethodType: "POST", - PathParams: "", - PathParamsMap: nil, - QueryParams: "", - QueryParamsMap: nil, - Body: 0, - } - methodConfigMap["GetUserFive"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUserFive", - Path: "/GetUserFive", - Produces: "*/*", - Consumes: "*/*", - MethodType: "GET", - } - methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUser", - Path: "/GetUser/{userid}", - Produces: "application/json", - Consumes: "application/json", - MethodType: "GET", - PathParams: "", - PathParamsMap: pathParamsMap, - QueryParams: "", - QueryParamsMap: queryParamsMap, - Body: -1, - HeadersMap: headersMap, - } - - configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ - Server: "go-restful", - RestMethodConfigsMap: methodConfigMap, - } - rest_config.SetRestProviderServiceConfigMap(configMap) - proxyFactory := extension.GetProxyFactory("default") - proto.Export(proxyFactory.GetInvoker(url)) - time.Sleep(5 * time.Second) - configMap = make(map[string]*rest_config.RestServiceConfig) - configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ - RestMethodConfigsMap: methodConfigMap, - } - restClient := client_impl.NewRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second, RequestTimeout: 3 * time.Second}) - invoker := NewRestInvoker(url, &restClient, methodConfigMap) - user := &User{} - inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), - invocation.WithArguments([]interface{}{1, int32(23), "username", "application/json"}), invocation.WithReply(user)) - res := invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.Equal(t, User{ID: 1, Age: int32(23), Name: "username"}, *res.Result().(*User)) - now := time.Now() - inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"), - invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.NotNil(t, res.Result()) - assert.Equal(t, 1, res.Result().(*User).ID) - assert.Equal(t, now.Unix(), res.Result().(*User).Time.Unix()) - assert.Equal(t, int32(23), res.Result().(*User).Age) - assert.Equal(t, "username", res.Result().(*User).Name) - // test 1 - inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserTwo"), - invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.NotNil(t, res.Result()) - assert.Equal(t, "username", res.Result().(*User).Name) - // test 2 - inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserThree"), - invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.NotNil(t, res.Result()) - assert.Equal(t, "username", res.Result().(*User).Name) - // test 3 - inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFour"), - invocation.WithArguments([]interface{}{[]User{{1, nil, int32(23), "username"}}}), invocation.WithReply(user)) - res = invoker.Invoke(context.Background(), inv) - assert.NoError(t, res.Error()) - assert.NotNil(t, res.Result()) - assert.Equal(t, "username", res.Result().(*User).Name) - // test 4 - inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFive"), invocation.WithReply(user)) - res = invoker.Invoke(context.Background(), inv) - assert.Error(t, res.Error(), "test error") - - assert.Equal(t, filterNum, 12) - err = common.ServiceMap.UnRegister(url.Service(), url.Protocol, url.ServiceKey()) - assert.NoError(t, err) -} +// +//import ( +// "context" +// "testing" +// "time" +//) +// +//import ( +// "github.com/emicklei/go-restful/v3" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/extension" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +// "dubbo.apache.org/dubbo-go/v3/protocol/rest/client" +// "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl" +// rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" +// "dubbo.apache.org/dubbo-go/v3/protocol/rest/server/server_impl" +//) +// +//const ( +// mockRestCommonUrl = "rest://127.0.0.1:8877/com.ikurento.user.UserProvider?anyhost=true&" + +// "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" + +// "environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" + +// "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" + +// "side=provider&timeout=3000×tamp=1556509797245&bean.name=com.ikurento.user.UserProvider" +//) +// +//func TestRestInvokerInvoke(t *testing.T) { +// // Refer +// proto := GetRestProtocol() +// defer proto.Destroy() +// var filterNum int +// server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) { +// println(request.SelectedRoutePath()) +// filterNum = filterNum + 1 +// chain.ProcessFilter(request, response) +// }) +// server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) { +// println("filter2") +// filterNum = filterNum + 1 +// chain.ProcessFilter(request, response) +// }) +// +// url, err := common.NewURL(mockRestCommonUrl) +// assert.NoError(t, err) +// _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) +// assert.NoError(t, err) +// con := config.ProviderConfig{} +// config.SetProviderConfig(con) +// configMap := make(map[string]*rest_config.RestServiceConfig) +// methodConfigMap := make(map[string]*rest_config.RestMethodConfig) +// queryParamsMap := make(map[int]string) +// queryParamsMap[1] = "age" +// queryParamsMap[2] = "name" +// pathParamsMap := make(map[int]string) +// pathParamsMap[0] = "userid" +// headersMap := make(map[int]string) +// headersMap[3] = "Content-Type" +// methodConfigMap["GetUserOne"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUserOne", +// Path: "/GetUserOne", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "POST", +// PathParams: "", +// PathParamsMap: nil, +// QueryParams: "", +// QueryParamsMap: nil, +// Body: 0, +// } +// methodConfigMap["GetUserTwo"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUserTwo", +// Path: "/GetUserTwo", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "POST", +// PathParams: "", +// PathParamsMap: nil, +// QueryParams: "", +// QueryParamsMap: nil, +// Body: 0, +// } +// methodConfigMap["GetUserThree"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUserThree", +// Path: "/GetUserThree", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "POST", +// PathParams: "", +// PathParamsMap: nil, +// QueryParams: "", +// QueryParamsMap: nil, +// Body: 0, +// } +// methodConfigMap["GetUserFour"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUserFour", +// Path: "/GetUserFour", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "POST", +// PathParams: "", +// PathParamsMap: nil, +// QueryParams: "", +// QueryParamsMap: nil, +// Body: 0, +// } +// methodConfigMap["GetUserFive"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUserFive", +// Path: "/GetUserFive", +// Produces: "*/*", +// Consumes: "*/*", +// MethodType: "GET", +// } +// methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUser", +// Path: "/GetUser/{userid}", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "GET", +// PathParams: "", +// PathParamsMap: pathParamsMap, +// QueryParams: "", +// QueryParamsMap: queryParamsMap, +// Body: -1, +// HeadersMap: headersMap, +// } +// +// configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ +// Server: "go-restful", +// RestMethodConfigsMap: methodConfigMap, +// } +// rest_config.SetRestProviderServiceConfigMap(configMap) +// proxyFactory := extension.GetProxyFactory("default") +// proto.Export(proxyFactory.GetInvoker(url)) +// time.Sleep(5 * time.Second) +// configMap = make(map[string]*rest_config.RestServiceConfig) +// configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ +// RestMethodConfigsMap: methodConfigMap, +// } +// restClient := client_impl.NewRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second, RequestTimeout: 3 * time.Second}) +// invoker := NewRestInvoker(url, &restClient, methodConfigMap) +// user := &User{} +// inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"), +// invocation.WithArguments([]interface{}{1, int32(23), "username", "application/json"}), invocation.WithReply(user)) +// res := invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.Equal(t, User{ID: 1, Age: int32(23), Name: "username"}, *res.Result().(*User)) +// now := time.Now() +// inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"), +// invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.NotNil(t, res.Result()) +// assert.Equal(t, 1, res.Result().(*User).ID) +// assert.Equal(t, now.Unix(), res.Result().(*User).Time.Unix()) +// assert.Equal(t, int32(23), res.Result().(*User).Age) +// assert.Equal(t, "username", res.Result().(*User).Name) +// // test 1 +// inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserTwo"), +// invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.NotNil(t, res.Result()) +// assert.Equal(t, "username", res.Result().(*User).Name) +// // test 2 +// inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserThree"), +// invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.NotNil(t, res.Result()) +// assert.Equal(t, "username", res.Result().(*User).Name) +// // test 3 +// inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFour"), +// invocation.WithArguments([]interface{}{[]User{{1, nil, int32(23), "username"}}}), invocation.WithReply(user)) +// res = invoker.Invoke(context.Background(), inv) +// assert.NoError(t, res.Error()) +// assert.NotNil(t, res.Result()) +// assert.Equal(t, "username", res.Result().(*User).Name) +// // test 4 +// inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFive"), invocation.WithReply(user)) +// res = invoker.Invoke(context.Background(), inv) +// assert.Error(t, res.Error(), "test error") +// +// assert.Equal(t, filterNum, 12) +// err = common.ServiceMap.UnRegister(url.Service(), url.Protocol, url.ServiceKey()) +// assert.NoError(t, err) +//} diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 3b4d178486..8d45399e66 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -17,159 +17,160 @@ package rest -import ( - "context" - "errors" - "fmt" - "strings" - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" - rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" -) - -func TestRestProtocolRefer(t *testing.T) { - // Refer - proto := GetRestProtocol() - url, err := common.NewURL(mockRestCommonUrl) - assert.NoError(t, err) - con := config.ConsumerConfig{ - ConnectTimeout: "5s", - RequestTimeout: "5s", - } - config.SetConsumerConfig(con) - configMap := make(map[string]*rest_config.RestServiceConfig) - configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ - Client: "resty", - } - rest_config.SetRestConsumerServiceConfigMap(configMap) - invoker := proto.Refer(url) - - // make sure url - eq := invoker.GetURL().URLEqual(url) - assert.True(t, eq) - - // make sure invokers after 'Destroy' - invokersLen := len(proto.(*RestProtocol).Invokers()) - assert.Equal(t, 1, invokersLen) - proto.Destroy() - invokersLen = len(proto.(*RestProtocol).Invokers()) - assert.Equal(t, 0, invokersLen) -} - -func TestRestProtocolExport(t *testing.T) { - // Export - proto := GetRestProtocol() - url, err := common.NewURL(mockRestCommonUrl) - assert.NoError(t, err) - _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) - assert.NoError(t, err) - con := config.ProviderConfig{} - config.SetProviderConfig(con) - configMap := make(map[string]*rest_config.RestServiceConfig) - methodConfigMap := make(map[string]*rest_config.RestMethodConfig) - queryParamsMap := make(map[int]string) - queryParamsMap[1] = "age" - queryParamsMap[2] = "name" - pathParamsMap := make(map[int]string) - pathParamsMap[0] = "userid" - methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ - InterfaceName: "", - MethodName: "GetUser", - Path: "/GetUser/{userid}", - Produces: "application/json", - Consumes: "application/json", - MethodType: "GET", - PathParams: "", - PathParamsMap: pathParamsMap, - QueryParams: "", - QueryParamsMap: queryParamsMap, - Body: -1, - } - configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ - Server: "go-restful", - RestMethodConfigsMap: methodConfigMap, - } - rest_config.SetRestProviderServiceConfigMap(configMap) - proxyFactory := extension.GetProxyFactory("default") - exporter := proto.Export(proxyFactory.GetInvoker(url)) - // make sure url - eq := exporter.GetInvoker().GetURL().URLEqual(url) - assert.True(t, eq) - // make sure exporterMap after 'Unexport' - fmt.Println(url.Path) - _, ok := proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) - assert.True(t, ok) - exporter.Unexport() - _, ok = proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) - assert.False(t, ok) - - // make sure serverMap after 'Destroy' - _, ok = proto.(*RestProtocol).serverMap[url.Location] - assert.True(t, ok) - proto.Destroy() - _, ok = proto.(*RestProtocol).serverMap[url.Location] - assert.False(t, ok) -} - -type UserProvider struct{} - -func (p *UserProvider) Reference() string { - return "com.ikurento.user.UserProvider" -} - -func (p *UserProvider) GetUser(ctx context.Context, id int, age int32, name string, contentType string) (*User, error) { - return &User{ - ID: id, - Time: nil, - Age: age, - Name: name, - }, nil -} - -func (p *UserProvider) GetUserOne(ctx context.Context, user *User) (*User, error) { - return user, nil -} - -func (p *UserProvider) GetUserTwo(ctx context.Context, req []interface{}, rsp *User) error { - m := req[0].(map[string]interface{}) - rsp.Name = m["Name"].(string) - return nil -} - -func (p *UserProvider) GetUserThree(ctx context.Context, user interface{}) (*User, error) { - m := user.(map[string]interface{}) - - u := &User{} - u.Name = m["Name"].(string) - return u, nil -} - -func (p *UserProvider) GetUserFour(ctx context.Context, user []interface{}, id string) (*User, error) { - m := user[0].(map[string]interface{}) - - u := &User{} - u.Name = m["Name"].(string) - return u, nil -} - -func (p *UserProvider) GetUserFive(ctx context.Context, user []interface{}) (*User, error) { - return nil, errors.New("test error") -} - -type User struct { - ID int - Time *time.Time - Age int32 - Name string -} +// +//import ( +// "context" +// "errors" +// "fmt" +// "strings" +// "testing" +// "time" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/extension" +// _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" +// "dubbo.apache.org/dubbo-go/v3/config" +// rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config" +//) +// +//func TestRestProtocolRefer(t *testing.T) { +// // Refer +// proto := GetRestProtocol() +// url, err := common.NewURL(mockRestCommonUrl) +// assert.NoError(t, err) +// con := config.ConsumerConfig{ +// ConnectTimeout: "5s", +// RequestTimeout: "5s", +// } +// config.SetConsumerConfig(con) +// configMap := make(map[string]*rest_config.RestServiceConfig) +// configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ +// Client: "resty", +// } +// rest_config.SetRestConsumerServiceConfigMap(configMap) +// invoker := proto.Refer(url) +// +// // make sure url +// eq := invoker.GetURL().URLEqual(url) +// assert.True(t, eq) +// +// // make sure invokers after 'Destroy' +// invokersLen := len(proto.(*RestProtocol).Invokers()) +// assert.Equal(t, 1, invokersLen) +// proto.Destroy() +// invokersLen = len(proto.(*RestProtocol).Invokers()) +// assert.Equal(t, 0, invokersLen) +//} +// +//func TestRestProtocolExport(t *testing.T) { +// // Export +// proto := GetRestProtocol() +// url, err := common.NewURL(mockRestCommonUrl) +// assert.NoError(t, err) +// _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "", "", &UserProvider{}) +// assert.NoError(t, err) +// con := config.ProviderConfig{} +// config.SetProviderConfig(con) +// configMap := make(map[string]*rest_config.RestServiceConfig) +// methodConfigMap := make(map[string]*rest_config.RestMethodConfig) +// queryParamsMap := make(map[int]string) +// queryParamsMap[1] = "age" +// queryParamsMap[2] = "name" +// pathParamsMap := make(map[int]string) +// pathParamsMap[0] = "userid" +// methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ +// InterfaceName: "", +// MethodName: "GetUser", +// Path: "/GetUser/{userid}", +// Produces: "application/json", +// Consumes: "application/json", +// MethodType: "GET", +// PathParams: "", +// PathParamsMap: pathParamsMap, +// QueryParams: "", +// QueryParamsMap: queryParamsMap, +// Body: -1, +// } +// configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ +// Server: "go-restful", +// RestMethodConfigsMap: methodConfigMap, +// } +// rest_config.SetRestProviderServiceConfigMap(configMap) +// proxyFactory := extension.GetProxyFactory("default") +// exporter := proto.Export(proxyFactory.GetInvoker(url)) +// // make sure url +// eq := exporter.GetInvoker().GetURL().URLEqual(url) +// assert.True(t, eq) +// // make sure exporterMap after 'Unexport' +// fmt.Println(url.Path) +// _, ok := proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) +// assert.True(t, ok) +// exporter.Unexport() +// _, ok = proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) +// assert.False(t, ok) +// +// // make sure serverMap after 'Destroy' +// _, ok = proto.(*RestProtocol).serverMap[url.Location] +// assert.True(t, ok) +// proto.Destroy() +// _, ok = proto.(*RestProtocol).serverMap[url.Location] +// assert.False(t, ok) +//} +// +//type UserProvider struct{} +// +//func (p *UserProvider) Reference() string { +// return "com.ikurento.user.UserProvider" +//} +// +//func (p *UserProvider) GetUser(ctx context.Context, id int, age int32, name string, contentType string) (*User, error) { +// return &User{ +// ID: id, +// Time: nil, +// Age: age, +// Name: name, +// }, nil +//} +// +//func (p *UserProvider) GetUserOne(ctx context.Context, user *User) (*User, error) { +// return user, nil +//} +// +//func (p *UserProvider) GetUserTwo(ctx context.Context, req []interface{}, rsp *User) error { +// m := req[0].(map[string]interface{}) +// rsp.Name = m["Name"].(string) +// return nil +//} +// +//func (p *UserProvider) GetUserThree(ctx context.Context, user interface{}) (*User, error) { +// m := user.(map[string]interface{}) +// +// u := &User{} +// u.Name = m["Name"].(string) +// return u, nil +//} +// +//func (p *UserProvider) GetUserFour(ctx context.Context, user []interface{}, id string) (*User, error) { +// m := user[0].(map[string]interface{}) +// +// u := &User{} +// u.Name = m["Name"].(string) +// return u, nil +//} +// +//func (p *UserProvider) GetUserFive(ctx context.Context, user []interface{}) (*User, error) { +// return nil, errors.New("test error") +//} +// +//type User struct { +// ID int +// Time *time.Time +// Age int32 +// Name string +//} diff --git a/registry/etcdv3/registry_test.go b/registry/etcdv3/registry_test.go index 3384eea73c..1cd300bbf9 100644 --- a/registry/etcdv3/registry_test.go +++ b/registry/etcdv3/registry_test.go @@ -49,51 +49,52 @@ func initRegistry(t *testing.T) *etcdV3Registry { return out } -func (suite *RegistryTestSuite) TestRegister() { - t := suite.T() - - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - reg := initRegistry(t) - err := reg.Register(url) - assert.NoError(t, err) - children, _, err := reg.client.GetChildrenKVList("/dubbo/com.ikurento.user.UserProvider/providers") - if err != nil { - t.Fatal(err) - } - assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock", children) - assert.NoError(t, err) -} - -func (suite *RegistryTestSuite) TestSubscribe() { - t := suite.T() - regurl, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - - reg := initRegistry(t) - // provider register - err := reg.Register(url) - if err != nil { - t.Fatal(err) - } - - // consumer register - regurl.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) - reg2 := initRegistry(t) - - err = reg2.Register(url) - assert.NoError(t, err) - listener, err := reg2.DoSubscribe(url) - if err != nil { - t.Fatal(err) - } - - serviceEvent, err := listener.Next() - if err != nil { - t.Fatal(err) - } - assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) -} +// +//func (suite *RegistryTestSuite) TestRegister() { +// t := suite.T() +// +// url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) +// +// reg := initRegistry(t) +// err := reg.Register(url) +// assert.NoError(t, err) +// children, _, err := reg.client.GetChildrenKVList("/dubbo/com.ikurento.user.UserProvider/providers") +// if err != nil { +// t.Fatal(err) +// } +// assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock", children) +// assert.NoError(t, err) +//} +// +//func (suite *RegistryTestSuite) TestSubscribe() { +// t := suite.T() +// regurl, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) +// url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) +// +// reg := initRegistry(t) +// // provider register +// err := reg.Register(url) +// if err != nil { +// t.Fatal(err) +// } +// +// // consumer register +// regurl.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) +// reg2 := initRegistry(t) +// +// err = reg2.Register(url) +// assert.NoError(t, err) +// listener, err := reg2.DoSubscribe(url) +// if err != nil { +// t.Fatal(err) +// } +// +// serviceEvent, err := listener.Next() +// if err != nil { +// t.Fatal(err) +// } +// assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String()) +//} func (suite *RegistryTestSuite) TestConsumerDestroy() { t := suite.T() diff --git a/registry/etcdv3/service_discovery_test.go b/registry/etcdv3/service_discovery_test.go index ba82330c14..4fa9bb9905 100644 --- a/registry/etcdv3/service_discovery_test.go +++ b/registry/etcdv3/service_discovery_test.go @@ -17,64 +17,51 @@ package etcdv3 -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -var testName = "test" - -func setUp() { - config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ - Protocol: "etcdv3", - RemoteRef: testName, - } - - config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ - Address: "localhost:2379", - TimeoutStr: "10s", - } -} - -func Test_newEtcdV3ServiceDiscovery(t *testing.T) { - name := constant.ETCDV3_KEY - _, err := newEtcdV3ServiceDiscovery(name) - - // warn: log configure file name is nil - assert.NotNil(t, err) - - sdc := &config.ServiceDiscoveryConfig{ - Protocol: "etcdv3", - RemoteRef: "mock", - } - config.GetRootConfig().ServiceDiscoveries[name] = sdc - - _, err = newEtcdV3ServiceDiscovery(name) - - // RemoteConfig not found - assert.NotNil(t, err) - - config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ - Address: "localhost:2379", - TimeoutStr: "10s", - } - - res, err := newEtcdV3ServiceDiscovery(name) - assert.Nil(t, err) - assert.NotNil(t, res) -} - -func TestEtcdV3ServiceDiscovery_GetDefaultPageSize(t *testing.T) { - setUp() - serviceDiscovery := &etcdV3ServiceDiscovery{} - assert.Equal(t, registry.DefaultPageSize, serviceDiscovery.GetDefaultPageSize()) -} +// +//var testName = "test" +// +//func setUp() { +// config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ +// Protocol: "etcdv3", +// RemoteRef: testName, +// } +// +// //config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ +// // Address: "localhost:2379", +// // TimeoutStr: "10s", +// //} +//} +// +//func Test_newEtcdV3ServiceDiscovery(t *testing.T) { +// name := constant.ETCDV3_KEY +// _, err := newEtcdV3ServiceDiscovery() +// +// // warn: log configure file name is nil +// assert.NotNil(t, err) +// +// sdc := &config.ServiceDiscoveryConfig{ +// Protocol: "etcdv3", +// RemoteRef: "mock", +// } +// config.GetRootConfig().ServiceDiscoveries[name] = sdc +// +// _, err = newEtcdV3ServiceDiscovery() +// +// // RemoteConfig not found +// assert.NotNil(t, err) +// +// //config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ +// // Address: "localhost:2379", +// // TimeoutStr: "10s", +// //} +// +// res, err := newEtcdV3ServiceDiscovery() +// assert.Nil(t, err) +// assert.NotNil(t, res) +//} +// +//func TestEtcdV3ServiceDiscovery_GetDefaultPageSize(t *testing.T) { +// setUp() +// serviceDiscovery := &etcdV3ServiceDiscovery{} +// assert.Equal(t, registry.DefaultPageSize, serviceDiscovery.GetDefaultPageSize()) +//} diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index 39e70a010f..0152fc634a 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -17,77 +17,75 @@ package file -import ( - "math/rand" - "strconv" - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -var testName = "test" - -func TestNewFileSystemServiceDiscoveryAndDestroy(t *testing.T) { - prepareData() - serviceDiscovery, err := newFileSystemServiceDiscovery(testName) - assert.NoError(t, err) - assert.NotNil(t, serviceDiscovery) - defer func() { - err = serviceDiscovery.Destroy() - assert.Nil(t, err) - }() -} - -func TestCURDFileSystemServiceDiscovery(t *testing.T) { - prepareData() - serviceDiscovery, err := extension.GetServiceDiscovery(constant.FILE_KEY, testName) - assert.NoError(t, err) - md := make(map[string]string) - - rand.Seed(time.Now().Unix()) - serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) - md["t1"] = "test1" - r1 := ®istry.DefaultServiceInstance{ - ID: "123456789", - ServiceName: serviceName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - Metadata: md, - } - err = serviceDiscovery.Register(r1) - assert.NoError(t, err) - - instances := serviceDiscovery.GetInstances(r1.ServiceName) - assert.Equal(t, 1, len(instances)) - assert.Equal(t, r1.ID, instances[0].GetID()) - assert.Equal(t, r1.ServiceName, instances[0].GetServiceName()) - assert.Equal(t, r1.Port, instances[0].GetPort()) - - err = serviceDiscovery.Unregister(r1) - assert.NoError(t, err) - - err = serviceDiscovery.Register(r1) - assert.NoError(t, err) - defer func() { - err = serviceDiscovery.Destroy() - assert.NoError(t, err) - }() -} - -func prepareData() { - config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ - Protocol: "file", - } -} +// +//import ( +// "math/rand" +// "strconv" +// "testing" +// "time" +//) +// +//import ( +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common/constant" +// "dubbo.apache.org/dubbo-go/v3/common/extension" +// "dubbo.apache.org/dubbo-go/v3/registry" +//) +// +//func TestNewFileSystemServiceDiscoveryAndDestroy(t *testing.T) { +// prepareData() +// serviceDiscovery, err := newFileSystemServiceDiscovery() +// assert.NoError(t, err) +// assert.NotNil(t, serviceDiscovery) +// defer func() { +// err = serviceDiscovery.Destroy() +// assert.Nil(t, err) +// }() +//} +// +//func TestCURDFileSystemServiceDiscovery(t *testing.T) { +// prepareData() +// serviceDiscovery, err := extension.GetServiceDiscovery(constant.FILE_KEY) +// assert.NoError(t, err) +// md := make(map[string]string) +// +// rand.Seed(time.Now().Unix()) +// serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) +// md["t1"] = "test1" +// r1 := ®istry.DefaultServiceInstance{ +// ID: "123456789", +// ServiceName: serviceName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// Metadata: md, +// } +// err = serviceDiscovery.Register(r1) +// assert.NoError(t, err) +// +// instances := serviceDiscovery.GetInstances(r1.ServiceName) +// assert.Equal(t, 1, len(instances)) +// assert.Equal(t, r1.ID, instances[0].GetID()) +// assert.Equal(t, r1.ServiceName, instances[0].GetServiceName()) +// assert.Equal(t, r1.Port, instances[0].GetPort()) +// +// err = serviceDiscovery.Unregister(r1) +// assert.NoError(t, err) +// +// err = serviceDiscovery.Register(r1) +// assert.NoError(t, err) +// defer func() { +// err = serviceDiscovery.Destroy() +// assert.NoError(t, err) +// }() +//} +// +//func prepareData() { +// //config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ +// // Protocol: "file", +// //} +//} diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index e6fe1556db..eaa31e4f6e 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -17,175 +17,175 @@ package nacos -import ( - "math/rand" - "strconv" - "testing" - "time" -) - -import ( - gxset "github.com/dubbogo/gost/container/set" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/metadata/mapping" - "dubbo.apache.org/dubbo-go/v3/registry" - "dubbo.apache.org/dubbo-go/v3/registry/event" -) - -var testName = "test" - -func Test_newNacosServiceDiscovery(t *testing.T) { - name := "nacos1" - _, err := newNacosServiceDiscovery(name) - - // the ShutdownConfig not found - assert.NotNil(t, err) - - sdc := &config.ServiceDiscoveryConfig{ - Protocol: "nacos", - RemoteRef: "mock", - } - config.GetRootConfig().ServiceDiscoveries[name] = sdc - - _, err = newNacosServiceDiscovery(name) - - // RemoteConfig not found - assert.NotNil(t, err) - - config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ - Address: "console.nacos.io:80", - TimeoutStr: "10s", - } - - res, err := newNacosServiceDiscovery(name) - assert.Nil(t, err) - assert.NotNil(t, res) -} - -func TestNacosServiceDiscovery_CRUD(t *testing.T) { - if !checkNacosServerAlive() { - return - } - prepareData() - extension.SetEventDispatcher("mock", func() observer.EventDispatcher { - return dispatcher.NewMockEventDispatcher() - }) - - extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { - return mapping.NewMockServiceNameMapping() - }) - - extension.SetAndInitGlobalDispatcher("mock") - rand.Seed(time.Now().Unix()) - serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) - id := "id" - host := "host" - port := 123 - instance := ®istry.DefaultServiceInstance{ - ID: id, - ServiceName: serviceName, - Host: host, - Port: port, - Enable: true, - Healthy: true, - Metadata: nil, - } - - // clean data - serviceDiscovery, err := extension.GetServiceDiscovery(constant.NACOS_KEY, testName) - assert.Nil(t, err) - - // clean data for local test - err = serviceDiscovery.Unregister(®istry.DefaultServiceInstance{ - ID: id, - ServiceName: serviceName, - Host: host, - Port: port, - }) - assert.Nil(t, err) - - err = serviceDiscovery.Register(instance) - - assert.Nil(t, err) - - // sometimes nacos may be failed to push update of instance, - // so it need 10s to pull, we sleep 10 second to make sure instance has been update - time.Sleep(5 * time.Second) - page := serviceDiscovery.GetHealthyInstancesByPage(serviceName, 0, 10, true) - assert.NotNil(t, page) - assert.Equal(t, 0, page.GetOffset()) - assert.Equal(t, 10, page.GetPageSize()) - assert.Equal(t, 1, page.GetDataSize()) - - instance = page.GetData()[0].(*registry.DefaultServiceInstance) - instance.ServiceName = serviceName - assert.NotNil(t, instance) - assert.Equal(t, id, instance.GetID()) - assert.Equal(t, host, instance.GetHost()) - assert.Equal(t, port, instance.GetPort()) - // TODO: console.nacos.io has updated to nacos 2.0 and serviceName has changed in 2.0, so ignore temporarily. - // assert.Equal(t, serviceName, instance.GetServiceName()) - assert.Equal(t, 0, len(instance.GetMetadata())) - - instance.Metadata["a"] = "b" - err = serviceDiscovery.Update(instance) - assert.Nil(t, err) - - time.Sleep(5 * time.Second) - pageMap := serviceDiscovery.GetRequestInstances([]string{serviceName}, 0, 1) - assert.Equal(t, 1, len(pageMap)) - - page = pageMap[serviceName] - assert.NotNil(t, page) - assert.Equal(t, 1, len(page.GetData())) - - instance = page.GetData()[0].(*registry.DefaultServiceInstance) - v, ok := instance.Metadata["a"] - assert.True(t, ok) - assert.Equal(t, "b", v) - - // test dispatcher event - err = serviceDiscovery.DispatchEventByServiceName(serviceName) - assert.Nil(t, err) - hs := gxset.NewSet() - hs.Add(serviceName) - // test AddListener - err = serviceDiscovery.AddListener(event.NewServiceInstancesChangedListener(hs)) - assert.Nil(t, err) -} - -func TestNacosServiceDiscovery_GetDefaultPageSize(t *testing.T) { - prepareData() - serviceDiscovery, _ := extension.GetServiceDiscovery(constant.NACOS_KEY, testName) - assert.Equal(t, registry.DefaultPageSize, serviceDiscovery.GetDefaultPageSize()) -} - -func TestNacosServiceDiscovery_Destroy(t *testing.T) { - prepareData() - serviceDiscovery, err := extension.GetServiceDiscovery(constant.NACOS_KEY, testName) - assert.Nil(t, err) - assert.NotNil(t, serviceDiscovery) - err = serviceDiscovery.Destroy() - assert.Nil(t, err) -} - -func prepareData() { - config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ - Protocol: "nacos", - RemoteRef: testName, - } - - config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ - Address: "console.nacos.io:80", - TimeoutStr: "10s", - } -} +// +//import ( +// "math/rand" +// "strconv" +// "testing" +// "time" +//) +// +//import ( +// gxset "github.com/dubbogo/gost/container/set" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common/constant" +// "dubbo.apache.org/dubbo-go/v3/common/extension" +// "dubbo.apache.org/dubbo-go/v3/common/observer" +// "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/metadata/mapping" +// "dubbo.apache.org/dubbo-go/v3/registry" +// "dubbo.apache.org/dubbo-go/v3/registry/event" +//) +// +//var testName = "test" +// +//func Test_newNacosServiceDiscovery(t *testing.T) { +// _, err := newNacosServiceDiscovery() +// +// // the ShutdownConfig not found +// assert.NotNil(t, err) +// +// //sdc := &config.ServiceDiscoveryConfig{ +// // Protocol: "nacos", +// // RemoteRef: "mock", +// //} +// //config.GetRootConfig().ServiceDiscoveries[name] = sdc +// +// _, err = newNacosServiceDiscovery() +// +// // RemoteConfig not found +// assert.NotNil(t, err) +// +// //config.GetRootConfig().Remotes["mock"] = &config.RemoteConfig{ +// // Address: "console.nacos.io:80", +// // TimeoutStr: "10s", +// //} +// +// res, err := newNacosServiceDiscovery() +// assert.Nil(t, err) +// assert.NotNil(t, res) +//} +// +//func TestNacosServiceDiscovery_CRUD(t *testing.T) { +// if !checkNacosServerAlive() { +// return +// } +// prepareData() +// extension.SetEventDispatcher("mock", func() observer.EventDispatcher { +// return dispatcher.NewMockEventDispatcher() +// }) +// +// extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { +// return mapping.NewMockServiceNameMapping() +// }) +// +// extension.SetAndInitGlobalDispatcher("mock") +// rand.Seed(time.Now().Unix()) +// serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) +// id := "id" +// host := "host" +// port := 123 +// instance := ®istry.DefaultServiceInstance{ +// ID: id, +// ServiceName: serviceName, +// Host: host, +// Port: port, +// Enable: true, +// Healthy: true, +// Metadata: nil, +// } +// +// // clean data +// serviceDiscovery, err := extension.GetServiceDiscovery(constant.NACOS_KEY) +// assert.Nil(t, err) +// +// // clean data for local test +// err = serviceDiscovery.Unregister(®istry.DefaultServiceInstance{ +// ID: id, +// ServiceName: serviceName, +// Host: host, +// Port: port, +// }) +// assert.Nil(t, err) +// +// err = serviceDiscovery.Register(instance) +// +// assert.Nil(t, err) +// +// // sometimes nacos may be failed to push update of instance, +// // so it need 10s to pull, we sleep 10 second to make sure instance has been update +// time.Sleep(5 * time.Second) +// page := serviceDiscovery.GetHealthyInstancesByPage(serviceName, 0, 10, true) +// assert.NotNil(t, page) +// assert.Equal(t, 0, page.GetOffset()) +// assert.Equal(t, 10, page.GetPageSize()) +// assert.Equal(t, 1, page.GetDataSize()) +// +// instance = page.GetData()[0].(*registry.DefaultServiceInstance) +// instance.ServiceName = serviceName +// assert.NotNil(t, instance) +// assert.Equal(t, id, instance.GetID()) +// assert.Equal(t, host, instance.GetHost()) +// assert.Equal(t, port, instance.GetPort()) +// // TODO: console.nacos.io has updated to nacos 2.0 and serviceName has changed in 2.0, so ignore temporarily. +// // assert.Equal(t, serviceName, instance.GetServiceName()) +// assert.Equal(t, 0, len(instance.GetMetadata())) +// +// instance.Metadata["a"] = "b" +// err = serviceDiscovery.Update(instance) +// assert.Nil(t, err) +// +// time.Sleep(5 * time.Second) +// pageMap := serviceDiscovery.GetRequestInstances([]string{serviceName}, 0, 1) +// assert.Equal(t, 1, len(pageMap)) +// +// page = pageMap[serviceName] +// assert.NotNil(t, page) +// assert.Equal(t, 1, len(page.GetData())) +// +// instance = page.GetData()[0].(*registry.DefaultServiceInstance) +// v, ok := instance.Metadata["a"] +// assert.True(t, ok) +// assert.Equal(t, "b", v) +// +// // test dispatcher event +// err = serviceDiscovery.DispatchEventByServiceName(serviceName) +// assert.Nil(t, err) +// hs := gxset.NewSet() +// hs.Add(serviceName) +// // test AddListener +// err = serviceDiscovery.AddListener(event.NewServiceInstancesChangedListener(hs)) +// assert.Nil(t, err) +//} +// +//func TestNacosServiceDiscovery_GetDefaultPageSize(t *testing.T) { +// prepareData() +// serviceDiscovery, _ := extension.GetServiceDiscovery(constant.NACOS_KEY) +// assert.Equal(t, registry.DefaultPageSize, serviceDiscovery.GetDefaultPageSize()) +//} +// +//func TestNacosServiceDiscovery_Destroy(t *testing.T) { +// prepareData() +// serviceDiscovery, err := extension.GetServiceDiscovery(constant.NACOS_KEY) +// assert.Nil(t, err) +// assert.NotNil(t, serviceDiscovery) +// err = serviceDiscovery.Destroy() +// assert.Nil(t, err) +//} +// +//func prepareData() { +// config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ +// Protocol: "nacos", +// RemoteRef: testName, +// } +// +// config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ +// Address: "console.nacos.io:80", +// TimeoutStr: "10s", +// } +//} diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index c8c023ea55..84db0a8f50 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -17,207 +17,208 @@ package servicediscovery -import ( - "testing" -) - -import ( - gxset "github.com/dubbogo/gost/container/set" - gxpage "github.com/dubbogo/gost/hash/page" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/metadata/mapping" - "dubbo.apache.org/dubbo-go/v3/metadata/service" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -var ( - serviceInterface = "org.apache.dubbo.metadata.MetadataService" - group = "dubbo-provider" - version = "1.0.0" -) - -func TestServiceDiscoveryRegistry_Register(t *testing.T) { - config.GetApplicationConfig().MetadataType = "mock" - extension.SetLocalMetadataService("mock", func() (service service.MetadataService, err error) { - service = &mockMetadataService{} - return - }) - - extension.SetServiceDiscovery("mock", func() (discovery registry.ServiceDiscovery, err error) { - return &mockServiceDiscovery{}, nil - }) - - extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { - return mapping.NewMockServiceNameMapping() - }) - - extension.SetEventDispatcher("mock", func() observer.EventDispatcher { - return dispatcher.NewMockEventDispatcher() - }) - extension.SetAndInitGlobalDispatcher("mock") - - config.GetRootConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ - Protocol: "mock", - } - registryURL, _ := common.NewURL("service-discovery://localhost:12345", - common.WithParamsValue("service_discovery", "mock"), - common.WithParamsValue("subscribed-services", "a, b , c,d,e ,")) - url, _ := common.NewURL("dubbo://192.168.0.102:20880/" + serviceInterface + - "?&application=" + group + - "&interface=" + serviceInterface + - "&group=" + group + - "&version=" + version + - "&service_discovery=mock" + - "&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs" + - "&side=provider") - registry, err := newServiceDiscoveryRegistry(registryURL) - assert.Nil(t, err) - assert.NotNil(t, registry) - err = registry.Register(url) - assert.NoError(t, err) -} - -type mockServiceDiscovery struct{} - -func (m *mockServiceDiscovery) String() string { - panic("implement me") -} - -func (m *mockServiceDiscovery) Destroy() error { - panic("implement me") -} - -func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { - return nil -} - -func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetDefaultPageSize() int { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { - panic("implement me") -} - -func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { - panic("implement me") -} - -func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { - panic("implement me") -} - -type mockMetadataService struct{} - -func (m *mockMetadataService) GetExportedURLs(string, string, string, string) ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { - panic("implement me") -} - -func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { - panic("implement me") -} - -func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { - panic("implement me") -} - -func (m *mockMetadataService) Reference() string { - panic("implement me") -} - -func (m *mockMetadataService) ServiceName() (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) ExportURL(*common.URL) (bool, error) { - return true, nil -} - -func (m *mockMetadataService) UnexportURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { - panic("implement me") -} - -func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { - return nil -} - -func (m *mockMetadataService) MethodMapper() map[string]string { - panic("implement me") -} - -func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { - panic("implement me") -} - -func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { - panic("implement me") -} - -func (m *mockMetadataService) Version() (string, error) { - panic("implement me") -} +// +//import ( +// "testing" +//) +// +//import ( +// gxset "github.com/dubbogo/gost/container/set" +// gxpage "github.com/dubbogo/gost/hash/page" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "dubbo.apache.org/dubbo-go/v3/common" +// "dubbo.apache.org/dubbo-go/v3/common/extension" +// "dubbo.apache.org/dubbo-go/v3/common/observer" +// "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/metadata/mapping" +// "dubbo.apache.org/dubbo-go/v3/metadata/service" +// "dubbo.apache.org/dubbo-go/v3/registry" +//) +// +//var ( +// serviceInterface = "org.apache.dubbo.metadata.MetadataService" +// group = "dubbo-provider" +// version = "1.0.0" +//) +// +//func TestServiceDiscoveryRegistry_Register(t *testing.T) { +// config.GetApplicationConfig().MetadataType = "mock" +// extension.SetLocalMetadataService("mock", func() (service service.MetadataService, err error) { +// service = &mockMetadataService{} +// return +// }) +// +// extension.SetServiceDiscovery("mock", func() (discovery registry.ServiceDiscovery, err error) { +// return &mockServiceDiscovery{}, nil +// }) +// +// extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { +// return mapping.NewMockServiceNameMapping() +// }) +// +// extension.SetEventDispatcher("mock", func() observer.EventDispatcher { +// return dispatcher.NewMockEventDispatcher() +// }) +// extension.SetAndInitGlobalDispatcher("mock") +// +// config.GetRootConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ +// Protocol: "mock", +// } +// registryURL, _ := common.NewURL("service-discovery://localhost:12345", +// common.WithParamsValue("service_discovery", "mock"), +// common.WithParamsValue("subscribed-services", "a, b , c,d,e ,")) +// url, _ := common.NewURL("dubbo://192.168.0.102:20880/" + serviceInterface + +// "?&application=" + group + +// "&interface=" + serviceInterface + +// "&group=" + group + +// "&version=" + version + +// "&service_discovery=mock" + +// "&methods=getAllServiceKeys,getServiceRestMetadata,getExportedURLs,getAllExportedURLs" + +// "&side=provider") +// registry, err := newServiceDiscoveryRegistry(registryURL) +// assert.Nil(t, err) +// assert.NotNil(t, registry) +// err = registry.Register(url) +// assert.NoError(t, err) +//} +// +//type mockServiceDiscovery struct{} +// +//func (m *mockServiceDiscovery) String() string { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Destroy() error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { +// return nil +//} +// +//func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetDefaultPageSize() int { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { +// panic("implement me") +//} +// +//func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { +// panic("implement me") +//} +// +//type mockMetadataService struct{} +// +//func (m *mockMetadataService) GetExportedURLs(string, string, string, string) ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Reference() string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ServiceName() (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) ExportURL(*common.URL) (bool, error) { +// return true, nil +//} +// +//func (m *mockMetadataService) UnexportURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { +// panic("implement me") +//} +// +//func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { +// return nil +//} +// +//func (m *mockMetadataService) MethodMapper() map[string]string { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { +// panic("implement me") +//} +// +//func (m *mockMetadataService) Version() (string, error) { +// panic("implement me") +//} diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index df99d3c097..e0b423c797 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -17,265 +17,265 @@ package zookeeper -import ( - "context" - "strconv" - "sync" - "testing" -) - -import ( - "github.com/dubbogo/go-zookeeper/zk" - - gxset "github.com/dubbogo/gost/container/set" - - "github.com/stretchr/testify/assert" -) - -import ( - "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/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/metadata/mapping" - "dubbo.apache.org/dubbo-go/v3/protocol" - "dubbo.apache.org/dubbo-go/v3/registry" - "dubbo.apache.org/dubbo-go/v3/registry/event" -) - -const testName = "test" - -func prepareData(t *testing.T) *zk.TestCluster { - var err error - tc, err := zk.StartTestCluster(1, nil, nil) - assert.NoError(t, err) - assert.NotNil(t, tc.Servers[0]) - address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) - //address := "127.0.0.1:2181" - - config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ - Protocol: "zookeeper", - RemoteRef: "test", - } - - config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ - Address: address, - TimeoutStr: "10s", - } - return tc -} - -func TestNewZookeeperServiceDiscovery(t *testing.T) { - name := "zookeeper1" - _, err := newZookeeperServiceDiscovery(name) - - // the ShutdownConfig not found - // err: could not init the instance because the config is invalid - assert.NotNil(t, err) - - sdc := &config.ServiceDiscoveryConfig{ - Protocol: "zookeeper", - RemoteRef: "mock", - } - config.GetRootConfig().ServiceDiscoveries[name] = sdc - _, err = newZookeeperServiceDiscovery(name) - - // RemoteConfig not found - // err: could not find the remote config for name: mock - assert.NotNil(t, err) -} - -func TestZookeeperServiceDiscovery_CURDAndListener(t *testing.T) { - tc := prepareData(t) - defer func() { - _ = tc.Stop() - }() - t.Run("testCURDZookeeperServiceDiscovery", testCURDZookeeperServiceDiscovery) - t.Run("testAddListenerZookeeperServiceDiscovery", testAddListenerZookeeperServiceDiscovery) -} - -func testCURDZookeeperServiceDiscovery(t *testing.T) { - prepareData(t) - extension.SetEventDispatcher("mock", func() observer.EventDispatcher { - return dispatcher.NewMockEventDispatcher() - }) - extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { - return mapping.NewMockServiceNameMapping() - }) - - extension.SetProtocol("mock", func() protocol.Protocol { - return &mockProtocol{} - }) - - sd, err := newZookeeperServiceDiscovery(testName) - assert.Nil(t, err) - defer func() { - _ = sd.Destroy() - }() - ins := ®istry.DefaultServiceInstance{ - ID: "testID", - ServiceName: testName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - Metadata: nil, - } - ins.Metadata = map[string]string{"t1": "test1", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} - err = sd.Register(ins) - - assert.Nil(t, err) - - testsPager := sd.GetHealthyInstancesByPage(testName, 0, 1, true) - assert.Equal(t, 1, testsPager.GetDataSize()) - assert.Equal(t, 1, testsPager.GetTotalPages()) - test := testsPager.GetData()[0].(registry.ServiceInstance) - assert.Equal(t, "127.0.0.1:2233", test.GetID()) - assert.Equal(t, "test1", test.GetMetadata()["t1"]) - - ins = ®istry.DefaultServiceInstance{ - ID: "testID", - ServiceName: testName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - } - ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} - - err = sd.Update(ins) - - assert.Nil(t, err) - - testsPager = sd.GetInstancesByPage(testName, 0, 1) - assert.Equal(t, 1, testsPager.GetDataSize()) - test = testsPager.GetData()[0].(registry.ServiceInstance) - assert.Equal(t, "test12", test.GetMetadata()["t1"]) - - testsMap := sd.GetRequestInstances([]string{testName}, 0, 1) - assert.Equal(t, 1, len(testsMap)) - assert.Equal(t, 1, testsMap[testName].GetDataSize()) - test = testsMap[testName].GetData()[0].(registry.ServiceInstance) - assert.Equal(t, "test12", test.GetMetadata()["t1"]) - - names := sd.GetServices() - assert.Equal(t, 1, names.Size()) - assert.Equal(t, testName, names.Values()[0]) - - err = sd.Unregister(®istry.DefaultServiceInstance{ - ID: "testID", - ServiceName: testName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - Metadata: nil, - }) - assert.Nil(t, err) -} - -func testAddListenerZookeeperServiceDiscovery(t *testing.T) { - sd, err := newZookeeperServiceDiscovery(testName) - assert.Nil(t, err) - defer func() { - _ = sd.Destroy() - }() - - ins := ®istry.DefaultServiceInstance{ - ID: "testID", - ServiceName: testName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - Metadata: nil, - } - ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} - err = sd.Register(ins) - - assert.Nil(t, err) - wg := &sync.WaitGroup{} - wg.Add(1) - tn := &testNotify{ - wg: wg, - t: t, - } - hs := gxset.NewSet() - hs.Add(testName) - - sicl := event.NewServiceInstancesChangedListener(hs) - sicl.AddListenerAndNotify(testName, tn) - extension.SetAndInitGlobalDispatcher("direct") - extension.GetGlobalDispatcher().AddEventListener(sicl) - err = sd.AddListener(sicl) - assert.NoError(t, err) - - ins = ®istry.DefaultServiceInstance{ - ID: "testID", - ServiceName: testName, - Host: "127.0.0.1", - Port: 2233, - Enable: true, - Healthy: true, - Metadata: nil, - } - ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} - err = sd.Update(ins) - assert.NoError(t, err) - tn.wg.Wait() -} - -type testNotify struct { - wg *sync.WaitGroup - t *testing.T -} - -func (tn *testNotify) Notify(e *registry.ServiceEvent) { - assert.Equal(tn.t, "2233", e.Service.Port) - tn.wg.Done() -} -func (tn *testNotify) NotifyAll([]*registry.ServiceEvent, func()) { - -} - -type mockProtocol struct{} - -func (m mockProtocol) Export(protocol.Invoker) protocol.Exporter { - panic("implement me") -} - -func (m mockProtocol) Refer(*common.URL) protocol.Invoker { - return &mockInvoker{} -} - -func (m mockProtocol) Destroy() { - panic("implement me") -} - -type mockInvoker struct{} - -func (m *mockInvoker) GetURL() *common.URL { - panic("implement me") -} - -func (m *mockInvoker) IsAvailable() bool { - panic("implement me") -} - -func (m *mockInvoker) Destroy() { - panic("implement me") -} - -func (m *mockInvoker) Invoke(context.Context, protocol.Invocation) protocol.Result { - // for getMetadataInfo and ServiceInstancesChangedListenerImpl onEvent - serviceInfo := &common.ServiceInfo{ServiceKey: "test", MatchKey: "test"} - services := make(map[string]*common.ServiceInfo) - services["test"] = serviceInfo - return &protocol.RPCResult{ - Rest: &common.MetadataInfo{ - Services: services, - }, - } -} +// +//import ( +// "context" +// "strconv" +// "sync" +// "testing" +//) +// +//import ( +// "github.com/dubbogo/go-zookeeper/zk" +// +// gxset "github.com/dubbogo/gost/container/set" +// +// "github.com/stretchr/testify/assert" +//) +// +//import ( +// "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/observer" +// "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" +// "dubbo.apache.org/dubbo-go/v3/config" +// "dubbo.apache.org/dubbo-go/v3/metadata/mapping" +// "dubbo.apache.org/dubbo-go/v3/protocol" +// "dubbo.apache.org/dubbo-go/v3/registry" +// "dubbo.apache.org/dubbo-go/v3/registry/event" +//) +// +//const testName = "test" +// +//func prepareData(t *testing.T) *zk.TestCluster { +// var err error +// tc, err := zk.StartTestCluster(1, nil, nil) +// assert.NoError(t, err) +// assert.NotNil(t, tc.Servers[0]) +// address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port) +// //address := "127.0.0.1:2181" +// +// config.GetRootConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{ +// Protocol: "zookeeper", +// RemoteRef: "test", +// } +// +// config.GetRootConfig().Remotes[testName] = &config.RemoteConfig{ +// Address: address, +// TimeoutStr: "10s", +// } +// return tc +//} +// +//func TestNewZookeeperServiceDiscovery(t *testing.T) { +// _, err := newZookeeperServiceDiscovery() +// +// // the ShutdownConfig not found +// // err: could not init the instance because the config is invalid +// assert.NotNil(t, err) +// +// //sdc := &config.ServiceDiscoveryConfig{ +// // Protocol: "zookeeper", +// // RemoteRef: "mock", +// //} +// //config.GetRootConfig().ServiceDiscoveries[name] = sdc +// _, err = newZookeeperServiceDiscovery() +// +// // RemoteConfig not found +// // err: could not find the remote config for name: mock +// assert.NotNil(t, err) +//} +// +//func TestZookeeperServiceDiscovery_CURDAndListener(t *testing.T) { +// tc := prepareData(t) +// defer func() { +// _ = tc.Stop() +// }() +// t.Run("testCURDZookeeperServiceDiscovery", testCURDZookeeperServiceDiscovery) +// t.Run("testAddListenerZookeeperServiceDiscovery", testAddListenerZookeeperServiceDiscovery) +//} +// +//func testCURDZookeeperServiceDiscovery(t *testing.T) { +// prepareData(t) +// extension.SetEventDispatcher("mock", func() observer.EventDispatcher { +// return dispatcher.NewMockEventDispatcher() +// }) +// extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { +// return mapping.NewMockServiceNameMapping() +// }) +// +// extension.SetProtocol("mock", func() protocol.Protocol { +// return &mockProtocol{} +// }) +// +// sd, err := newZookeeperServiceDiscovery() +// assert.Nil(t, err) +// defer func() { +// _ = sd.Destroy() +// }() +// ins := ®istry.DefaultServiceInstance{ +// ID: "testID", +// ServiceName: testName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// Metadata: nil, +// } +// ins.Metadata = map[string]string{"t1": "test1", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} +// err = sd.Register(ins) +// +// assert.Nil(t, err) +// +// testsPager := sd.GetHealthyInstancesByPage(testName, 0, 1, true) +// assert.Equal(t, 1, testsPager.GetDataSize()) +// assert.Equal(t, 1, testsPager.GetTotalPages()) +// test := testsPager.GetData()[0].(registry.ServiceInstance) +// assert.Equal(t, "127.0.0.1:2233", test.GetID()) +// assert.Equal(t, "test1", test.GetMetadata()["t1"]) +// +// ins = ®istry.DefaultServiceInstance{ +// ID: "testID", +// ServiceName: testName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// } +// ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} +// +// err = sd.Update(ins) +// +// assert.Nil(t, err) +// +// testsPager = sd.GetInstancesByPage(testName, 0, 1) +// assert.Equal(t, 1, testsPager.GetDataSize()) +// test = testsPager.GetData()[0].(registry.ServiceInstance) +// assert.Equal(t, "test12", test.GetMetadata()["t1"]) +// +// testsMap := sd.GetRequestInstances([]string{testName}, 0, 1) +// assert.Equal(t, 1, len(testsMap)) +// assert.Equal(t, 1, testsMap[testName].GetDataSize()) +// test = testsMap[testName].GetData()[0].(registry.ServiceInstance) +// assert.Equal(t, "test12", test.GetMetadata()["t1"]) +// +// names := sd.GetServices() +// assert.Equal(t, 1, names.Size()) +// assert.Equal(t, testName, names.Values()[0]) +// +// err = sd.Unregister(®istry.DefaultServiceInstance{ +// ID: "testID", +// ServiceName: testName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// Metadata: nil, +// }) +// assert.Nil(t, err) +//} +// +//func testAddListenerZookeeperServiceDiscovery(t *testing.T) { +// sd, err := newZookeeperServiceDiscovery() +// assert.Nil(t, err) +// defer func() { +// _ = sd.Destroy() +// }() +// +// ins := ®istry.DefaultServiceInstance{ +// ID: "testID", +// ServiceName: testName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// Metadata: nil, +// } +// ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} +// err = sd.Register(ins) +// +// assert.Nil(t, err) +// wg := &sync.WaitGroup{} +// wg.Add(1) +// tn := &testNotify{ +// wg: wg, +// t: t, +// } +// hs := gxset.NewSet() +// hs.Add(testName) +// +// sicl := event.NewServiceInstancesChangedListener(hs) +// sicl.AddListenerAndNotify(testName, tn) +// extension.SetAndInitGlobalDispatcher("direct") +// extension.GetGlobalDispatcher().AddEventListener(sicl) +// err = sd.AddListener(sicl) +// assert.NoError(t, err) +// +// ins = ®istry.DefaultServiceInstance{ +// ID: "testID", +// ServiceName: testName, +// Host: "127.0.0.1", +// Port: 2233, +// Enable: true, +// Healthy: true, +// Metadata: nil, +// } +// ins.Metadata = map[string]string{"t1": "test12", constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"2233"}`} +// err = sd.Update(ins) +// assert.NoError(t, err) +// tn.wg.Wait() +//} +// +//type testNotify struct { +// wg *sync.WaitGroup +// t *testing.T +//} +// +//func (tn *testNotify) Notify(e *registry.ServiceEvent) { +// assert.Equal(tn.t, "2233", e.Service.Port) +// tn.wg.Done() +//} +//func (tn *testNotify) NotifyAll([]*registry.ServiceEvent, func()) { +// +//} +// +//type mockProtocol struct{} +// +//func (m mockProtocol) Export(protocol.Invoker) protocol.Exporter { +// panic("implement me") +//} +// +//func (m mockProtocol) Refer(*common.URL) protocol.Invoker { +// return &mockInvoker{} +//} +// +//func (m mockProtocol) Destroy() { +// panic("implement me") +//} +// +//type mockInvoker struct{} +// +//func (m *mockInvoker) GetURL() *common.URL { +// panic("implement me") +//} +// +//func (m *mockInvoker) IsAvailable() bool { +// panic("implement me") +//} +// +//func (m *mockInvoker) Destroy() { +// panic("implement me") +//} +// +//func (m *mockInvoker) Invoke(context.Context, protocol.Invocation) protocol.Result { +// // for getMetadataInfo and ServiceInstancesChangedListenerImpl onEvent +// serviceInfo := &common.ServiceInfo{ServiceKey: "test", MatchKey: "test"} +// services := make(map[string]*common.ServiceInfo) +// services["test"] = serviceInfo +// return &protocol.RPCResult{ +// Rest: &common.MetadataInfo{ +// Services: services, +// }, +// } +//} diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index 275649e6d9..cef1197c83 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -38,7 +38,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" . "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -49,7 +48,7 @@ func TestRunSuite(t *testing.T) { client := getClient(url) assert.NotNil(t, client) testRequestOneWay(t, client) - testClient_Call(t, client) + //testClient_Call(t, client) testClient_AsyncCall(t, client) svr.Stop() } @@ -82,7 +81,8 @@ func setAttachment(invocation *invocation.RPCInvocation, attachments map[string] func getClient(url *common.URL) *Client { client := NewClient(Options{ - ConnectTimeout: config.GetConsumerConfig().ConnectTimeout, + // todo fix timeout + ConnectTimeout: 3 * time.Second, // config.GetConsumerConfig().ConnectTimeout, }) if err := client.Connect(url); err != nil { return nil From a8a50193d0a4936e9c955aad9ecf16612477e432 Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Fri, 3 Sep 2021 23:07:49 +0800 Subject: [PATCH 084/148] Fix: app level metadata bug (#1433) * fix metadata bug * fix metadata bug * fix metadata bug * fix metadata bug --- config/config_loader.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 1545c85fc8..c8e529b91c 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -377,8 +377,10 @@ func registerServiceInstance() { } } // publish metadata to remote - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { - remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) + if GetApplicationConfig().MetadataType == constant.REMOTE_METADATA_STORAGE_TYPE { + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { + remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) + } } } From 2e0b0e42d9b826d7e382302b6b33cc98e1c141d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Fri, 3 Sep 2021 23:20:25 +0800 Subject: [PATCH 085/148] Fix: no log output error (#1434) * fix logger panic * fix OutputPaths null error * test: add test for OutputPaths & mod imports --- config/logger_config.go | 10 ++++++++++ config/logger_config_test.go | 1 + 2 files changed, 11 insertions(+) diff --git a/config/logger_config.go b/config/logger_config.go index 4e0ed16aae..d8f939ce19 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -24,6 +24,7 @@ import ( import ( "github.com/creasty/defaults" "github.com/natefinch/lumberjack" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -86,6 +87,7 @@ func initLoggerConfig(rc *RootConfig) error { if err != nil { return err } + logConfig.ZapConfig.setZapConfig(logConf.ZapConfig) logger.InitLogger(logConf) return nil } @@ -97,6 +99,14 @@ func (l *LoggerConfig) check() error { return verify(l) } +func (e *ZapConfig) setZapConfig(config *zap.Config) { + config.OutputPaths = e.OutputPaths + config.ErrorOutputPaths = e.ErrorOutputPaths + config.DisableStacktrace = e.DisableStacktrace + config.DisableCaller = e.DisableCaller + config.InitialFields = e.InitialFields +} + func (e *EncoderConfig) setEncoderConfig(encoderConfig *zapcore.EncoderConfig) error { encoderConfig.MessageKey = e.MessageKey encoderConfig.LevelKey = e.LevelKey diff --git a/config/logger_config_test.go b/config/logger_config_test.go index 787de5caa7..faa96a758b 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -37,6 +37,7 @@ func TestLoggerInit(t *testing.T) { assert.NotNil(t, rootConfig) loggerConfig := rootConfig.Logger assert.NotNil(t, loggerConfig) + assert.Equal(t, []string{"stderr"}, loggerConfig.ZapConfig.OutputPaths) logger.Info("hello") }) From 94c1e667c9952f8d48ebd4c19a49d4bd50132436 Mon Sep 17 00:00:00 2001 From: Baster Date: Sat, 4 Sep 2021 07:57:34 +0800 Subject: [PATCH 086/148] Fix apollo config center cli test fail (#1435) * fix apollo config center parse bug * update apollo config test function * update gitignore * update testdata * update testdata * update apollo/impl_test Co-authored-by: zengfanwei --- .gitignore | 1 - config_center/apollo/impl.go | 4 + config_center/apollo/impl_test.go | 117 ++++++++++-------------------- 3 files changed, 41 insertions(+), 81 deletions(-) diff --git a/.gitignore b/.gitignore index 25cf086b53..464f5cccff 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,6 @@ remoting/zookeeper/zookeeper-4unittest/ config_center/zookeeper/zookeeper-4unittest/ registry/zookeeper/zookeeper-4unittest/ metadata/report/zookeeper/zookeeper-4unittest/ -config_center/apollo/mockDubbog.properties.json # vim stuff *~ diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index a088d1a924..6594a92bb7 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -147,6 +147,10 @@ func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (stri content := tmpConfig.GetContent() b := []byte(content) + if len(b) == 0 { + return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) + } + content = string(b[8:]) //remove defalut content= prefix return content, nil } diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index e9e25a1d7e..4165e9a389 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -17,17 +17,19 @@ package apollo import ( + "encoding/json" "fmt" "net/http" "net/http/httptest" - "os" "strings" "sync" "testing" - "time" ) import ( + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/rawbytes" "github.com/stretchr/testify/assert" ) @@ -42,13 +44,13 @@ import ( const ( mockAppId = "testApplication_yang" mockCluster = "dev" - mockNamespace = "mockDubbogo.properties" + mockNamespace = "mockDubbogo.yaml" mockNotifyRes = `[{ - "namespaceName": "mockDubbogo.properties", + "namespaceName": "mockDubbogo.yaml", "notificationId": 53050, "messages": { "details": { - "testApplication_yang+default+mockDubbog": 53050 + "testApplication_yang+default+mockDubbogo": 53050 } } }]` @@ -62,56 +64,10 @@ const ( var mockConfigRes = `{ "appId": "testApplication_yang", "cluster": "default", - "namespaceName": "mockDubbogo.properties", - "configurations": { - "registries.hangzhouzk.username": "", - "application.owner": "ZX", - "registries.shanghaizk.username": "", - "protocols.dubbo.ip": "127.0.0.1", - "protocol_conf.dubbo.getty_session_param.tcp_write_timeout": "5s", - "services.UserProvider.cluster": "failover", - "application.module": "dubbogo user-info server", - "services.UserProvider.interface": "com.ikurento.user.UserProvider", - "protocol_conf.dubbo.getty_session_param.compress_encoding": "false", - "registries.shanghaizk.address": "127.0.0.1:2182", - "protocol_conf.dubbo.session_timeout": "20s", - "registries.shanghaizk.timeout": "3s", - "protocol_conf.dubbo.getty_session_param.keep_alive_period": "120s", - "services.UserProvider.warmup": "100", - "application.version": "0.0.1", - "registries.hangzhouzk.protocol": "zookeeper", - "registries.hangzhouzk.password": "", - "protocols.dubbo.name": "dubbo", - "protocol_conf.dubbo.getty_session_param.wait_timeout": "1s", - "protocols.dubbo.port": "20000", - "application_config.owner": "demo", - "application_config.name": "demo", - "application_config.version": "0.0.1", - "application_config.environment": "dev", - "protocol_conf.dubbo.getty_session_param.session_name": "server", - "application.name": "BDTService", - "registries.hangzhouzk.timeout": "3s", - "protocol_conf.dubbo.getty_session_param.tcp_read_timeout": "1s", - "services.UserProvider.loadbalance": "random", - "protocol_conf.dubbo.session_number": "700", - "protocol_conf.dubbo.getty_session_param.max_msg_len": "1024", - "services.UserProvider.registry": "hangzhouzk", - "application_config.module": "demo", - "services.UserProvider.methods[0].name": "GetUser", - "protocol_conf.dubbo.getty_session_param.tcp_no_delay": "true", - "services.UserProvider.methods[0].retries": "1", - "protocol_conf.dubbo.getty_session_param.tcp_w_buf_size": "65536", - "protocol_conf.dubbo.getty_session_param.tcp_r_buf_size": "262144", - "registries.shanghaizk.password": "", - "application_config.organization": "demo", - "registries.shanghaizk.protocol": "zookeeper", - "protocol_conf.dubbo.getty_session_param.tcp_keep_alive": "true", - "registries.hangzhouzk.address": "127.0.0.1:2181", - "application.environment": "dev", - "services.UserProvider.protocol": "dubbo", - "application.organization": "ikurento.com", - "services.UserProvider.methods[0].loadbalance": "random" - }, + "namespaceName": "mockDubbogo.yaml", + "configurations":{ + "content":"dubbo:\n application:\n name: \"demo-server\"\n version: \"2.0\"\n" + }, "releaseKey": "20191104105242-0f13805d89f834a4" }` @@ -165,23 +121,32 @@ func TestGetConfig(t *testing.T) { configuration := initMockApollo(t) configs, err := configuration.GetProperties(mockNamespace, config_center.WithGroup("dubbo")) assert.NoError(t, err) - configuration.SetParser(&parser.DefaultConfigurationParser{}) - mapContent, err := configuration.Parser().Parse(configs) + koan := koanf.New(".") + err = koan.Load(rawbytes.Provider([]byte(configs)), yaml.Parser()) + assert.NoError(t, err) + rc := &config.RootConfig{} + err = koan.UnmarshalWithConf(rc.Prefix(), rc, koanf.UnmarshalConf{Tag: "yaml"}) assert.NoError(t, err) - assert.Equal(t, "ikurento.com", mapContent["application.organization"]) - deleteMockJson(t) + + assert.Equal(t, "demo-server", rc.Application.Name) } -// todo fix this bug -//func TestGetConfigItem(t *testing.T) { -// configuration := initMockApollo(t) -// configs, err := configuration.GetInternalProperty("application.organization") -// assert.NoError(t, err) -// configuration.SetParser(&parser.DefaultConfigurationParser{}) -// assert.NoError(t, err) -// assert.Equal(t, "ikurento.com", configs) -// deleteMockJson(t) -//} +func TestGetConfigItem(t *testing.T) { + configuration := initMockApollo(t) + configs, err := configuration.GetInternalProperty("content") + assert.NoError(t, err) + configuration.SetParser(&parser.DefaultConfigurationParser{}) + assert.NoError(t, err) + type MockRes struct { + Configurations struct { + Content string + } + } + mockRes := &MockRes{} + err = json.Unmarshal([]byte(mockConfigRes), mockRes) + assert.NoError(t, err) + assert.Equal(t, mockRes.Configurations.Content, configs) +} func initMockApollo(t *testing.T) *apolloConfiguration { c := &config.RootConfig{ConfigCenter: &config.CenterConfig{ @@ -189,7 +154,7 @@ func initMockApollo(t *testing.T) *apolloConfiguration { Address: "106.12.25.204:8080", AppID: "testApplication_yang", Cluster: "dev", - Namespace: mockNamespace, + Namespace: "mockDubbogo", }} apollo := initApollo() apolloUrl := strings.ReplaceAll(apollo.URL, "http", "apollo") @@ -207,7 +172,7 @@ func TestListener(t *testing.T) { mockConfigRes = `{ "appId": "testApplication_yang", "cluster": "default", - "namespaceName": "mockDubbogo.properties", + "namespaceName": "mockDubbogo.yaml", "configurations": { "registries.hangzhouzk.username": "11111" }, @@ -216,7 +181,7 @@ func TestListener(t *testing.T) { // test add apollo.AddListener(mockNamespace, listener) listener.wg.Wait() - assert.Equal(t, "mockDubbogo.properties", listener.event) + assert.Equal(t, "mockDubbogo.yaml", listener.event) assert.Greater(t, listener.count, 0) // test remove @@ -231,7 +196,6 @@ func TestListener(t *testing.T) { return true }) assert.Equal(t, listenerCount, 0) - deleteMockJson(t) } type apolloDataListener struct { @@ -248,10 +212,3 @@ func (l *apolloDataListener) Process(configType *config_center.ConfigChangeEvent l.count++ l.event = configType.Key } - -func deleteMockJson(t *testing.T) { - // because the file write in another goroutine,so have a break ... - time.Sleep(100 * time.Millisecond) - remove := os.Remove("mockDubbogo.properties.json") - t.Log("remove result:", remove) -} From 3e0412eab25070431ea7bc5aa59955f92aa49c9f Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 4 Sep 2021 14:25:33 +0800 Subject: [PATCH 087/148] fix: add triple attachment (#1436) --- config/logger_config.go | 2 + config_center/apollo/impl_test.go | 1 + go.mod | 4 +- go.sum | 14 +- .../service/exporter/configurable/exporter.go | 5 +- protocol/dubbo3/dubbo3_invoker.go | 8 +- protocol/dubbo3/dubbo3_invoker_test.go | 2 +- protocol/dubbo3/dubbo3_protocol.go | 12 +- protocol/dubbo3/dubbo3_protocol_test.go | 2 +- protocol/dubbo3/internal/client.go | 26 +--- protocol/dubbo3/internal/helloworld.pb.go | 125 ++++++------------ protocol/dubbo3/internal/server.go | 3 +- protocol/jsonrpc/http_test.go | 3 + 13 files changed, 78 insertions(+), 129 deletions(-) diff --git a/config/logger_config.go b/config/logger_config.go index d8f939ce19..de7e9b0855 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -23,7 +23,9 @@ import ( import ( "github.com/creasty/defaults" + "github.com/natefinch/lumberjack" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go index 4165e9a389..e96ce8d9f3 100644 --- a/config_center/apollo/impl_test.go +++ b/config_center/apollo/impl_test.go @@ -30,6 +30,7 @@ import ( "github.com/knadh/koanf" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/rawbytes" + "github.com/stretchr/testify/assert" ) diff --git a/go.mod b/go.mod index f281edc987..262e25631e 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,9 @@ require ( github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 - github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771 + github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6 github.com/emicklei/go-restful/v3 v3.5.2 - github.com/fsnotify/fsnotify v1.5.0 + github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 diff --git a/go.sum b/go.sum index 476df2142a..face8eb43a 100644 --- a/go.sum +++ b/go.sum @@ -153,12 +153,10 @@ github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= -github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf h1:lj0hNwbjk7UpqyEYo6Kz4poTH4w5UfyqI4Gl6x3HEqo= -github.com/dubbogo/triple v1.0.6-0.20210826093718-8b877016f3bf/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= -github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771 h1:tJqD3Utmjnla5goePEWYfU77AlESStc8EGNzmGwF9lE= -github.com/dubbogo/triple v1.0.6-0.20210829063429-3fc89d0b1771/go.mod h1:tCl0mV54+V8Br9z71sFbS1IQUG41QKZUrW6FGaLheM0= +github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= +github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= +github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6 h1:ZrCFQ/a0rgK5EBF9FiiSYvCmtC2sLzOoFAbqBVmsA94= +github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -194,8 +192,8 @@ github.com/frankban/quicktest v1.10.0 h1:Gfh+GAJZOAoKZsIZeZbdn2JF10kN1XHNvjsvQK8 github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.0 h1:NO5hkcB+srp1x6QmwvNZLeaOgbM8cmBTN32THzjvu2k= -github.com/fsnotify/fsnotify v1.5.0/go.mod h1:BX0DCEr5pT4jm2CnQdVP1lFV521fcCNcyEeNp4DQQDk= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= 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= diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 8aa24edade..2b35b323a2 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,10 +18,13 @@ package configurable import ( - "github.com/pkg/errors" "sync" ) +import ( + "github.com/pkg/errors" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 54d5be006b..e2eb80d78a 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -132,6 +132,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati } // append interface id to ctx + ctx = context.WithValue(ctx, tripleConstant.CtxAttachmentKey, invocation.Attachments()) ctx = context.WithValue(ctx, tripleConstant.InterfaceKey, di.BaseInvoker.GetURL().GetParam(constant.INTERFACE_KEY, "")) in := make([]reflect.Value, 0, 16) in = append(in, reflect.ValueOf(ctx)) @@ -141,8 +142,11 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati } methodName := invocation.MethodName() - - result.Err = di.client.Invoke(methodName, in, invocation.Reply()) + triAttachmentWithErr := di.client.Invoke(methodName, in, invocation.Reply()) + result.Err = triAttachmentWithErr.GetError() + for k, v := range triAttachmentWithErr.GetAttachments() { + result.Attachment(k, v) + } result.Rest = invocation.Reply() return &result } diff --git a/protocol/dubbo3/dubbo3_invoker_test.go b/protocol/dubbo3/dubbo3_invoker_test.go index abbb047881..f1df040493 100644 --- a/protocol/dubbo3/dubbo3_invoker_test.go +++ b/protocol/dubbo3/dubbo3_invoker_test.go @@ -35,7 +35,7 @@ import ( ) const ( - mockDubbo3CommonUrl2 = "tri://127.0.0.1:20003/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=DubboGreeterImpl" + + mockDubbo3CommonUrl2 = "tri://127.0.0.1:20003/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterImpl" + "&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl" + "&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=" + diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index d8f27ff4d2..e53b6a4ec8 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -25,6 +25,7 @@ import ( ) import ( + tripleCommon "github.com/dubbogo/triple/pkg/common" tripleConstant "github.com/dubbogo/triple/pkg/common/constant" triConfig "github.com/dubbogo/triple/pkg/config" "github.com/dubbogo/triple/pkg/triple" @@ -189,8 +190,15 @@ func (d *UnaryService) GetReqParamsInterfaces(methodName string) ([]interface{}, } func (d *UnaryService) InvokeWithArgs(ctx context.Context, methodName string, arguments []interface{}) (interface{}, error) { - res := d.proxyImpl.Invoke(ctx, invocation.NewRPCInvocation(methodName, arguments, nil)) - return res.Result(), res.Error() + dubboAttachment := make(map[string]interface{}) + tripleAttachment, ok := ctx.Value(tripleConstant.TripleAttachement).(tripleCommon.TripleAttachment) + if ok { + for k, v := range tripleAttachment { + dubboAttachment[k] = v + } + } + res := d.proxyImpl.Invoke(ctx, invocation.NewRPCInvocation(methodName, arguments, dubboAttachment)) + return res, res.Error() } // openServer open a dubbo3 server, if there is already a service using the same protocol, it returns directly. diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go index f924bf8c06..95e485d5ec 100644 --- a/protocol/dubbo3/dubbo3_protocol_test.go +++ b/protocol/dubbo3/dubbo3_protocol_test.go @@ -36,7 +36,7 @@ import ( ) const ( - mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=DubboGreeterImpl" + + mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterImpl" + "&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl" + "&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=" + diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index 2b1d8e07d2..a1820543f5 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -17,34 +17,10 @@ package internal -import ( - "context" -) - -import ( - "github.com/dubbogo/triple/pkg/triple" -) - import ( "dubbo.apache.org/dubbo-go/v3/config" ) func init() { - config.SetConsumerService(&GrpcGreeterImpl{}) -} - -// GrpcGreeterImpl -//used for dubbo3 biz client -type GrpcGreeterImpl struct { - SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error -} - -// Reference ... -func (u *GrpcGreeterImpl) Reference() string { - return "DubboGreeterImpl" -} - -// GetDubboStub ... -func (u *GrpcGreeterImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient { - return NewGreeterDubbo3Client(cc) + config.SetConsumerService(&GreeterClientImpl{}) } diff --git a/protocol/dubbo3/internal/helloworld.pb.go b/protocol/dubbo3/internal/helloworld.pb.go index 404d7e3c9a..e265b3061f 100644 --- a/protocol/dubbo3/internal/helloworld.pb.go +++ b/protocol/dubbo3/internal/helloworld.pb.go @@ -27,14 +27,13 @@ import ( ) import ( + "github.com/dubbogo/triple/pkg/common" tripleConstant "github.com/dubbogo/triple/pkg/common/constant" dubbo3 "github.com/dubbogo/triple/pkg/triple" proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" ) import ( @@ -157,106 +156,50 @@ var fileDescriptor_17b8c58d586b62f2 = []byte{ 0x20, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x20, 0xe8, 0xd3, 0xef, 0x00, 0x00, 0x00, } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc *grpc.ClientConn +type greeterDubbo3Client struct { + cc *dubbo3.TripleConn } -func NewGreeterClient(cc *grpc.ClientConn) GreeterClient { - return &greeterClient{cc} +func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { + return &greeterDubbo3Client{cc} } - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { +func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) { out := new(HelloReply) - err := c.cc.Invoke(ctx, "/internal.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil + interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) } -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { +// GreeterClientImpl is the client API for Greeter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GreeterClient interface { // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) } -// UnimplementedGreeterServer can be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { +type GreeterClientImpl struct { + // Sends a greeting + SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error) } -func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +type Greeter_SayHelloClient interface { + CloseAndRecv() (*HelloReply, error) + grpc.ClientStream } -func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { - s.RegisterService(&_Greeter_serviceDesc, srv) +type greeterSayHelloClient struct { + grpc.ClientStream } -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { +func (x *greeterSayHelloClient) CloseAndRecv() (*HelloReply, error) { + if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/internal.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Greeter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "internal.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} - -type greeterDubbo3Client struct { - cc *dubbo3.TripleConn -} - -func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { - return &greeterDubbo3Client{cc} -} -func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opt ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - err := c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) - if err != nil { + m := new(HelloReply) + if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } - return out, nil -} - -// GreeterClientImpl is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClientImpl struct { - // Sends a greeting - SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error + return m, nil } func (c *GreeterClientImpl) Reference() string { @@ -267,6 +210,12 @@ func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { return NewGreeterDubbo3Client(cc) } +// GreeterServer is the server API for Greeter service. +type GreeterServer interface { + // Sends a greeting + SayHello(context.Context, *HelloRequest) (*HelloReply, error) +} + type GreeterProviderBase struct { proxyImpl protocol.Invoker } @@ -279,7 +228,11 @@ func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker { return s.proxyImpl } -func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func (c *GreeterProviderBase) Reference() string { + return "greeterImpl" +} + +func _Triple_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(HelloRequest) if err := dec(in); err != nil { return nil, err @@ -290,7 +243,7 @@ func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec f invo := invocation.NewRPCInvocation("SayHello", args, nil) if interceptor == nil { result := base.GetProxyImpl().Invoke(ctx, invo) - return result.Result(), result.Error() + return result, result.Error() } info := &grpc.UnaryServerInfo{ Server: srv, @@ -310,7 +263,7 @@ func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc { Methods: []grpc.MethodDesc{ { MethodName: "SayHello", - Handler: _DUBBO_Greeter_SayHello_Handler, + Handler: _Triple_Greeter_SayHello_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index ad9e747899..2eaca3efbd 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -23,6 +23,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/common" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" @@ -47,7 +48,7 @@ func InitDubboServer() { ) providerConfig := config.NewProviderConfig( - config.WithProviderService("Server", serviceConfig), + config.WithProviderService(common.GetReference(&Server{}), serviceConfig), ) protocolConfig := config.NewProtocolConfig( diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index d42d8282aa..855c918b62 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -19,6 +19,9 @@ package jsonrpc import ( "context" +) + +import ( perrors "github.com/pkg/errors" ) From 4f8417d2ae199e4e0fffe0caaa297802815dda48 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 4 Sep 2021 15:59:22 +0800 Subject: [PATCH 088/148] fix: remove k8s ut to enhance stablility of ci (#1438) --- registry/kubernetes/registry_test.go | 66 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go index f217048cf4..1125a9ebf4 100644 --- a/registry/kubernetes/registry_test.go +++ b/registry/kubernetes/registry_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "os" "strconv" - "sync" "testing" "time" ) @@ -257,38 +256,39 @@ func TestRegister(t *testing.T) { } } -func TestSubscribe(t *testing.T) { - r := getTestRegistry(t) - defer r.Destroy() - - url, err := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) - if err != nil { - t.Fatal(err) - } - - listener, err := r.DoSubscribe(url) - if err != nil { - t.Fatal(err) - } - - wg := sync.WaitGroup{} - wg.Add(1) - go func() { - defer wg.Done() - registerErr := r.Register(url) - if registerErr != nil { - t.Error(registerErr) - } - }() - - wg.Wait() - - serviceEvent, err := listener.Next() - if err != nil { - t.Fatal(err) - } - t.Logf("get service event %s", serviceEvent) -} +// +//func TestSubscribe(t *testing.T) { +// r := getTestRegistry(t) +// defer r.Destroy() +// +// url, err := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"})) +// if err != nil { +// t.Fatal(err) +// } +// +// listener, err := r.DoSubscribe(url) +// if err != nil { +// t.Fatal(err) +// } +// +// wg := sync.WaitGroup{} +// wg.Add(1) +// go func() { +// defer wg.Done() +// registerErr := r.Register(url) +// if registerErr != nil { +// t.Error(registerErr) +// } +// }() +// +// wg.Wait() +// +// serviceEvent, err := listener.Next() +// if err != nil { +// t.Fatal(err) +// } +// t.Logf("get service event %s", serviceEvent) +//} func TestConsumerDestroy(t *testing.T) { r := getTestRegistry(t) From d7e51774dd2eec27d77cb72a3370db645d65f325 Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Sat, 4 Sep 2021 16:11:45 +0800 Subject: [PATCH 089/148] fix(getty): fix nil panic when set default getty config (#1437) * fix(getty): fix nil panic when set default getty config * style(getty): go fmt * style(getty): add license header Co-authored-by: dongjianhui03 --- remoting/getty/config.go | 12 ++++++--- remoting/getty/getty_client.go | 9 ++++--- remoting/getty/getty_client_test.go | 18 +++++++++++++ remoting/getty/getty_server.go | 10 ++++--- remoting/getty/getty_server_test.go | 41 +++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 remoting/getty/getty_server_test.go diff --git a/remoting/getty/config.go b/remoting/getty/config.go index 5cf36bf17b..234fa86f1f 100644 --- a/remoting/getty/config.go +++ b/remoting/getty/config.go @@ -109,8 +109,8 @@ type ( ) // GetDefaultClientConfig gets client default configuration -func GetDefaultClientConfig() ClientConfig { - return ClientConfig{ +func GetDefaultClientConfig() *ClientConfig { + defaultClientConfig := &ClientConfig{ ReconnectInterval: 0, ConnectionNum: 16, HeartbeatPeriod: "30s", @@ -132,11 +132,13 @@ func GetDefaultClientConfig() ClientConfig { SessionName: "client", }, } + _ = defaultClientConfig.CheckValidity() + return defaultClientConfig } // GetDefaultServerConfig gets server default configuration -func GetDefaultServerConfig() ServerConfig { - return ServerConfig{ +func GetDefaultServerConfig() *ServerConfig { + defaultServerConfig := &ServerConfig{ SessionTimeout: "180s", SessionNumber: 700, GrPoolSize: 120, @@ -156,6 +158,8 @@ func GetDefaultServerConfig() ServerConfig { SessionName: "server", }, } + _ = defaultServerConfig.CheckValidity() + return defaultServerConfig } // CheckValidity confirm getty session params diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go index 226e33e330..d6ca10d5af 100644 --- a/remoting/getty/getty_client.go +++ b/remoting/getty/getty_client.go @@ -49,12 +49,14 @@ var ( errClientClosed = perrors.New("client closed") errClientReadTimeout = perrors.New("maybe the client read timeout or fail to decode tcp stream in Writer.Write") - clientConf *ClientConfig + clientConf *ClientConfig + clientGrPool gxsync.GenericTaskPool ) // it is init client for single protocol. func initClient(protocol string) { + clientConf = GetDefaultClientConfig() if protocol == "" { return } @@ -69,9 +71,9 @@ func initClient(protocol string) { } protocolConf := config.GetRootConfig().Protocols[protocol] - defaultClientConfig := GetDefaultClientConfig() if protocolConf == nil { logger.Info("use default getty client config") + return } else { gettyClientConfig := protocolConf.Params if gettyClientConfig == nil { @@ -82,12 +84,11 @@ func initClient(protocol string) { if err != nil { panic(err) } - err = yaml.Unmarshal(gettyClientConfigBytes, &defaultClientConfig) + err = yaml.Unmarshal(gettyClientConfigBytes, clientConf) if err != nil { panic(err) } } - clientConf = &defaultClientConfig if err := clientConf.CheckValidity(); err != nil { logger.Warnf("[CheckValidity] error: %v", err) return diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index cef1197c83..2820681985 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -38,6 +38,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common" . "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" + "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/remoting" @@ -476,3 +477,20 @@ func (u *UserProvider) Reference() string { func (u User) JavaClassName() string { return "com.ikurento.user.User" } + +func TestInitClient(t *testing.T) { + originRootConf := config.GetRootConfig() + rootConf := config.RootConfig{ + Protocols: map[string]*config.ProtocolConfig{ + "dubbo": { + Name: "dubbo", + Ip: "127.0.0.1", + Port: "20003", + }, + }, + } + config.SetRootConfig(rootConf) + initServer("dubbo") + config.SetRootConfig(*originRootConf) + assert.NotNil(t, srvConf) +} diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go index f048bd7511..e53f0d4fd4 100644 --- a/remoting/getty/getty_server.go +++ b/remoting/getty/getty_server.go @@ -43,9 +43,12 @@ import ( "dubbo.apache.org/dubbo-go/v3/remoting" ) -var srvConf *ServerConfig +var ( + srvConf *ServerConfig +) func initServer(protocol string) { + srvConf = GetDefaultServerConfig() if protocol == "" { return } @@ -60,9 +63,9 @@ func initServer(protocol string) { } protocolConf := config.GetRootConfig().Protocols[protocol] - defaultServerConfig := GetDefaultServerConfig() if protocolConf == nil { logger.Info("use default getty server config") + return } else { gettyServerConfig := protocolConf.Params if gettyServerConfig == nil { @@ -74,12 +77,11 @@ func initServer(protocol string) { if err != nil { panic(err) } - err = yaml.Unmarshal(gettyServerConfigBytes, &defaultServerConfig) + err = yaml.Unmarshal(gettyServerConfigBytes, srvConf) if err != nil { panic(err) } } - srvConf = &defaultServerConfig if err := srvConf.CheckValidity(); err != nil { panic(err) } diff --git a/remoting/getty/getty_server_test.go b/remoting/getty/getty_server_test.go new file mode 100644 index 0000000000..1f0819913d --- /dev/null +++ b/remoting/getty/getty_server_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 getty + +import ( + "dubbo.apache.org/dubbo-go/v3/config" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestInitServer(t *testing.T) { + originRootConf := config.GetRootConfig() + rootConf := config.RootConfig{ + Protocols: map[string]*config.ProtocolConfig{ + "dubbo": { + Name: "dubbo", + Ip: "127.0.0.1", + Port: "20003", + }, + }, + } + config.SetRootConfig(rootConf) + initServer("dubbo") + config.SetRootConfig(*originRootConf) + assert.NotNil(t, srvConf) +} From cb29fbcb6a2e853bc4f9b138b8cdee290a6b2541 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 4 Sep 2021 19:54:17 +0800 Subject: [PATCH 090/148] fix: add get dynamic configuration api (#1439) --- config/config_center_config.go | 12 ++++++++++++ config_center/dynamic_configuration.go | 2 ++ 2 files changed, 14 insertions(+) diff --git a/config/config_center_config.go b/config/config_center_config.go index 84a10dcf19..479bf71df6 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -176,6 +176,18 @@ func startConfigCenter(rc *RootConfig) error { return nil } +func (c *CenterConfig) GetDynamicConfiguration() (config_center.DynamicConfiguration, error) { + configCenterUrl, err := c.toURL() + if err != nil { + return nil, err + } + factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) + if factory == nil { + return nil, errors.New("get config center factory failed") + } + return factory.GetDynamicConfiguration(configCenterUrl) +} + func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, error) { factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol) if factory == nil { diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index 069594de7c..447342e8af 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -56,6 +56,8 @@ type DynamicConfiguration interface { GetInternalProperty(string, ...Option) (string, error) // PublishConfig will publish the config with the (key, group, value) pair + // for zk: path is /$(group)/config/$(key) -> value + // for nacos: group, key -> value PublishConfig(string, string, string) error // RemoveConfig will remove the config white the (key, group) pair From 90348d8238cd49ccab3d70971d29b65c580bf38d Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 4 Sep 2021 21:27:32 +0800 Subject: [PATCH 091/148] store zk value with base64. (#1440) * fix: add get dynamic configuration api * fix: change zk config center data to base64 --- config/root_config.go | 2 +- config_center/zookeeper/impl.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/root_config.go b/config/root_config.go index 1279bf48df..c928b8fa22 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -94,7 +94,7 @@ func (rc *RootConfig) Init() error { return err } if err := rc.ConfigCenter.Init(rc); err != nil { - logger.Info("config center doesn't start.") + logger.Infof("config center doesn't start. error is %s", err) } if err := rc.Application.Init(rc); err != nil { return err diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index b4a500c495..b85d28abea 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -18,6 +18,7 @@ package zookeeper import ( + "encoding/base64" "strings" "sync" ) @@ -114,8 +115,11 @@ func (c *zookeeperDynamicConfiguration) GetProperties(key string, opts ...config if err != nil { return "", perrors.WithStack(err) } - - return string(content), nil + decoded, err := base64.StdEncoding.DecodeString(string(content)) + if err != nil { + return "", perrors.WithStack(err) + } + return string(decoded), nil } // GetInternalProperty For zookeeper, getConfig and getConfigs have the same meaning. @@ -126,7 +130,9 @@ func (c *zookeeperDynamicConfiguration) GetInternalProperty(key string, opts ... // PublishConfig will put the value into Zk with specific path func (c *zookeeperDynamicConfiguration) PublishConfig(key string, group string, value string) error { path := c.getPath(key, group) - err := c.client.CreateWithValue(path, []byte(value)) + strbytes := []byte(value) + encoded := base64.StdEncoding.EncodeToString(strbytes) + err := c.client.CreateWithValue(path, []byte(encoded)) if err != nil { return perrors.WithStack(err) } From a1e4548f1e68a01322e1e68126b8c29bd1e3b2a9 Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Sun, 5 Sep 2021 12:13:49 +0800 Subject: [PATCH 092/148] Fix: metadataService port conflict (#1441) * fix metadata bug * fix metadata bug * fix metadata bug * fix service discovery bug * fix unit test bug --- config/reference_config.go | 15 +++++++++++++-- .../service/exporter/configurable/exporter.go | 5 +++-- .../exporter/configurable/exporter_test.go | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index 44583e69e7..a4142bcb9b 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -137,7 +137,12 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { } if len(rc.urls) == 1 { - rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) + if rc.urls[0].Protocol == constant.SERVICE_REGISTRY_PROTOCOL { + rc.invoker = extension.GetProtocol("registry").Refer(rc.urls[0]) + } else { + rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) + } + // c.URL != "" is direct call if rc.URL != "" { //filter @@ -167,7 +172,13 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { invokers := make([]protocol.Invoker, 0, len(rc.urls)) var regURL *common.URL for _, u := range rc.urls { - invoker := extension.GetProtocol(u.Protocol).Refer(u) + var invoker protocol.Invoker + if u.Protocol == constant.SERVICE_REGISTRY_PROTOCOL { + invoker = extension.GetProtocol("registry").Refer(u) + } else { + invoker = extension.GetProtocol(u.Protocol).Refer(u) + } + // c.URL != "" is direct call if rc.URL != "" { //filter diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 2b35b323a2..50d04850cc 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,6 +18,7 @@ package configurable import ( + "strconv" "sync" ) @@ -64,8 +65,8 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME), config.WithServiceProtocolKeys(constant.DEFAULT_PROTOCOL), config.WithServiceProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( - config.WithProtocolName(url.SubURL.Protocol), - config.WithProtocolPort(url.SubURL.Port), + config.WithProtocolName(constant.DEFAULT_PROTOCOL), + config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)), )), config.WithServiceRegistry("N/A"), config.WithServiceInterface(constant.METADATA_SERVICE_NAME), diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 2bbbdd1bda..09f1c9d60f 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -69,7 +69,7 @@ func TestConfigurableExporter(t *testing.T) { assert.Equal(t, false, exported.IsExported()) assert.NoError(t, exported.Export(registryURL)) assert.Equal(t, true, exported.IsExported()) - assert.Regexp(t, "dubbo://127.0.0.1:20003/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) + assert.Regexp(t, "dubbo://127.0.0.1:20005/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) exported.Unexport() assert.Equal(t, false, exported.IsExported()) }) From 78ca90e296a1577c569957a776eec7af9b472c82 Mon Sep 17 00:00:00 2001 From: WilliamLeaves Date: Tue, 7 Sep 2021 14:44:51 +0800 Subject: [PATCH 093/148] Fixes : grpc client init problem #1416 (#1418) * fix grpc client init problem * add once Co-authored-by: yexiaobo --- protocol/grpc/client.go | 88 +++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 1d37eb193e..60a51dd670 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -20,6 +20,7 @@ package grpc import ( "reflect" "strconv" + "sync" "time" ) @@ -41,48 +42,7 @@ import ( ) var clientConf *ClientConfig - -func init() { - // load rootConfig from runtime - rootConfig := config.GetRootConfig() - - clientConfig := GetClientConfig() - clientConf = &clientConfig - - // check client config and decide whether to use the default config - defer func() { - if clientConf == nil || len(clientConf.ContentSubType) == 0 { - defaultClientConfig := GetDefaultClientConfig() - clientConf = &defaultClientConfig - } - if err := clientConf.Validate(); err != nil { - panic(err) - } - }() - - if rootConfig.Application == nil { - return - } - protocolConf := config.GetRootConfig().Protocols - - if protocolConf == nil { - logger.Info("protocol_conf default use dubbo config") - } else { - grpcConf := protocolConf[GRPC] - if grpcConf == nil { - logger.Warnf("grpcConf is nil") - return - } - grpcConfByte, err := yaml.Marshal(grpcConf) - if err != nil { - panic(err) - } - err = yaml.Unmarshal(grpcConfByte, clientConf) - if err != nil { - panic(err) - } - } -} +var clientConfInitOnce sync.Once // Client is gRPC client include client connection and invoker type Client struct { @@ -92,6 +52,8 @@ type Client struct { // NewClient creates a new gRPC client. func NewClient(url *common.URL) (*Client, error) { + clientConfInitOnce.Do(clientInit) + // If global trace instance was set, it means trace function enabled. // If not, will return NoopTracer. tracer := opentracing.GlobalTracer() @@ -131,6 +93,48 @@ func NewClient(url *common.URL) (*Client, error) { }, nil } +func clientInit() { + // load rootConfig from runtime + rootConfig := config.GetRootConfig() + + clientConfig := GetClientConfig() + clientConf = &clientConfig + + // check client config and decide whether to use the default config + defer func() { + if clientConf == nil || len(clientConf.ContentSubType) == 0 { + defaultClientConfig := GetDefaultClientConfig() + clientConf = &defaultClientConfig + } + if err := clientConf.Validate(); err != nil { + panic(err) + } + }() + + if rootConfig.Application == nil { + return + } + protocolConf := config.GetRootConfig().Protocols + + if protocolConf == nil { + logger.Info("protocol_conf default use dubbo config") + } else { + grpcConf := protocolConf[GRPC] + if grpcConf == nil { + logger.Warnf("grpcConf is nil") + return + } + grpcConfByte, err := yaml.Marshal(grpcConf) + if err != nil { + panic(err) + } + err = yaml.Unmarshal(grpcConfByte, clientConf) + if err != nil { + panic(err) + } + } +} + func getInvoker(impl interface{}, conn *grpc.ClientConn) interface{} { var in []reflect.Value in = append(in, reflect.ValueOf(conn)) From f556336c4ba6cb21c4140437073219f444badf1a Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Wed, 8 Sep 2021 11:15:51 +0800 Subject: [PATCH 094/148] Add get consumer service by InterfaceName api. (#1443) * fix: add get dynamic configuration api * fix: change zk config center data to base64 * fix: add ConsumerServiceByInterfaceName * fix: ut * fix: add lock * fix: fix grpc ut * fix: add comment * fix: change comment --- config/reference_config.go | 3 +- config/service.go | 38 ++++++++++++++++----- protocol/dubbo3/dubbo3_invoker.go | 6 ++-- protocol/dubbo3/internal/client.go | 2 ++ protocol/grpc/client.go | 4 +-- protocol/grpc/grpc_invoker_test.go | 2 +- protocol/grpc/internal/helloworld/client.go | 1 + protocol/grpc/internal/routeguide/client.go | 1 + 8 files changed, 43 insertions(+), 14 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index a4142bcb9b..58d860dfb7 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -94,7 +94,7 @@ func (cc *ReferenceConfig) Init(rc *RootConfig) error { } // Refer ... -func (rc *ReferenceConfig) Refer(_ interface{}) { +func (rc *ReferenceConfig) Refer(srv interface{}) { cfgURL := common.NewURLWithOptions( common.WithPath(rc.InterfaceName), common.WithProtocol(rc.Protocol), @@ -102,6 +102,7 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { common.WithParamsValue(constant.BEAN_NAME_KEY, rc.id), common.WithParamsValue(constant.METADATATYPE_KEY, rc.metaDataType), ) + SetConsumerServiceByInterfaceName(rc.InterfaceName, srv) if rc.ForceTag { cfgURL.AddParam(constant.ForceUseTag, "true") } diff --git a/config/service.go b/config/service.go index 8786867b04..0f039fd61d 100644 --- a/config/service.go +++ b/config/service.go @@ -19,43 +19,65 @@ package config import ( "dubbo.apache.org/dubbo-go/v3/common" + "sync" ) var ( - conServices = map[string]common.RPCService{} // service name -> service - proServices = map[string]common.RPCService{} // service name -> service + // conServicesLock is used to guard conServices map. + conServicesLock = sync.Mutex{} + conServices = map[string]common.RPCService{} // service name -> service + + // proServicesLock is used to guard proServices map + proServicesLock = sync.Mutex{} + proServices = map[string]common.RPCService{} // service name -> service + + // interfaceNameConServicesLock is used to guard interfaceNameConServices map + interfaceNameConServicesLock = sync.Mutex{} + interfaceNameConServices = map[string]common.RPCService{} // interfaceName -> service ) // SetConsumerService is called by init() of implement of RPCService func SetConsumerService(service common.RPCService) { ref := common.GetReference(service) + conServicesLock.Lock() + defer conServicesLock.Unlock() conServices[ref] = service } // SetProviderService is called by init() of implement of RPCService func SetProviderService(service common.RPCService) { ref := common.GetReference(service) + proServicesLock.Lock() + defer proServicesLock.Unlock() proServices[ref] = service } // GetConsumerService gets ConsumerService by @name func GetConsumerService(name string) common.RPCService { + conServicesLock.Lock() + defer conServicesLock.Unlock() return conServices[name] } // GetProviderService gets ProviderService by @name func GetProviderService(name string) common.RPCService { + proServicesLock.Lock() + defer proServicesLock.Unlock() return proServices[name] } -// GetAllProviderService gets all ProviderService -func GetAllProviderService() map[string]common.RPCService { - return proServices +// SetConsumerServiceByInterfaceName is used by pb serialization +func SetConsumerServiceByInterfaceName(interfaceName string, srv common.RPCService) { + interfaceNameConServicesLock.Lock() + defer interfaceNameConServicesLock.Unlock() + interfaceNameConServices[interfaceName] = srv } -// GetAllConsumerService gets all ConsumerService -func GetAllConsumerService() map[string]common.RPCService { - return conServices +// GetConsumerServiceByInterfaceName is used by pb serialization +func GetConsumerServiceByInterfaceName(interfaceName string) common.RPCService { + interfaceNameConServicesLock.Lock() + defer interfaceNameConServicesLock.Unlock() + return interfaceNameConServices[interfaceName] } // GetCallback gets CallbackResponse by @name diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index e2eb80d78a..a55ee54c9a 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -59,8 +59,10 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) { rt := config.GetConsumerConfig().RequestTimeout timeout := url.GetParamDuration(constant.TIMEOUT_KEY, rt) - key := url.GetParam(constant.BEAN_NAME_KEY, "") - consumerService := config.GetConsumerService(key) + // for triple pb serialization. The bean name from provider is the provider reference key, + // which can't locate the target consumer stub, so we use interface key.. + interfaceKey := url.GetParam(constant.INTERFACE_KEY, "") + consumerService := config.GetConsumerServiceByInterfaceName(interfaceKey) dubboSerializaerType := url.GetParam(constant.SERIALIZATION_KEY, constant.PROTOBUF_SERIALIZATION) triCodecType := tripleConstant.CodecType(dubboSerializaerType) diff --git a/protocol/dubbo3/internal/client.go b/protocol/dubbo3/internal/client.go index a1820543f5..06f9f045cd 100644 --- a/protocol/dubbo3/internal/client.go +++ b/protocol/dubbo3/internal/client.go @@ -22,5 +22,7 @@ import ( ) func init() { + // for pb client + config.SetConsumerServiceByInterfaceName("org.apache.dubbo.DubboGreeterImpl", &GreeterClientImpl{}) config.SetConsumerService(&GreeterClientImpl{}) } diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 60a51dd670..ab8c0dba8b 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -83,8 +83,8 @@ func NewClient(url *common.URL) (*Client, error) { return nil, err } - key := url.GetParam(constant.BEAN_NAME_KEY, "") - impl := config.GetConsumerService(key) + key := url.GetParam(constant.INTERFACE_KEY, "") + impl := config.GetConsumerServiceByInterfaceName(key) invoker := getInvoker(impl, conn) return &Client{ diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go index 273f702300..b936f3f381 100644 --- a/protocol/grpc/grpc_invoker_test.go +++ b/protocol/grpc/grpc_invoker_test.go @@ -42,7 +42,7 @@ const ( "&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!" routeguideURL = "grpc://127.0.0.1:30000/routeGuideImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=routeGuideImpl" + - "&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" + + "&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%24RouteGuide" + "&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!" diff --git a/protocol/grpc/internal/helloworld/client.go b/protocol/grpc/internal/helloworld/client.go index ec45dd5861..444424d060 100644 --- a/protocol/grpc/internal/helloworld/client.go +++ b/protocol/grpc/internal/helloworld/client.go @@ -30,6 +30,7 @@ import ( ) func init() { + config.SetConsumerServiceByInterfaceName("io.grpc.examples.helloworld.GreeterGrpc$IGreeter", &GrpcGreeterImpl{}) config.SetConsumerService(&GrpcGreeterImpl{}) } diff --git a/protocol/grpc/internal/routeguide/client.go b/protocol/grpc/internal/routeguide/client.go index 5f79ef0399..dd870b7724 100644 --- a/protocol/grpc/internal/routeguide/client.go +++ b/protocol/grpc/internal/routeguide/client.go @@ -29,6 +29,7 @@ import ( ) func init() { + config.SetConsumerServiceByInterfaceName("io.grpc.examples.helloworld.GreeterGrpc$RouteGuide", &RouteGuideClientImpl{}) config.SetConsumerService(&RouteGuideClientImpl{}) } From cab389386ceba3f30d3e8df16c163044f0aaff85 Mon Sep 17 00:00:00 2001 From: Ming Deng Date: Thu, 9 Sep 2021 23:25:36 +0800 Subject: [PATCH 095/148] Tiny optimization: change type to Serializer to avoid type assertion (#1448) * 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] * improve etcd version and change create to put (#1203) * build(deps): bump github.com/dubbogo/gost from 1.11.14 to 1.11.16 (#1387) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.14 to 1.11.16. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.14...v1.11.16) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.1 (#1386) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.26.0 to 1.27.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.26.0...v1.27.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump go.etcd.io/etcd/client/v3 from 3.5.0-alpha.0 to 3.5.0 (#1383) Bumps [go.etcd.io/etcd/client/v3](https://github.com/etcd-io/etcd) from 3.5.0-alpha.0 to 3.5.0. - [Release notes](https://github.com/etcd-io/etcd/releases) - [Changelog](https://github.com/etcd-io/etcd/blob/main/CHANGELOG-3.5.md) - [Commits](https://github.com/etcd-io/etcd/compare/v3.5.0-alpha.0...v3.5.0) --- updated-dependencies: - dependency-name: go.etcd.io/etcd/client/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Tiny optimization: change type to Serializer to avoid type assertion Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xin.Zh Co-authored-by: AlexStocks Co-authored-by: randy --- protocol/dubbo/impl/codec.go | 2 +- protocol/dubbo/impl/serialization.go | 6 +++--- protocol/dubbo/impl/serialize.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go index 682d5d987a..007bbf378c 100644 --- a/protocol/dubbo/impl/codec.go +++ b/protocol/dubbo/impl/codec.go @@ -281,6 +281,6 @@ func NewDubboCodec(reader *bufio.Reader) *ProtocolCodec { pkgType: 0, bodyLen: 0, headerRead: false, - serializer: s.(Serializer), + serializer: s, } } diff --git a/protocol/dubbo/impl/serialization.go b/protocol/dubbo/impl/serialization.go index 325a85479c..8137a2f125 100644 --- a/protocol/dubbo/impl/serialization.go +++ b/protocol/dubbo/impl/serialization.go @@ -26,7 +26,7 @@ import ( ) var ( - serializers = make(map[string]interface{}) + serializers = make(map[string]Serializer) nameMaps = make(map[byte]string) ) @@ -37,11 +37,11 @@ func init() { } } -func SetSerializer(name string, serializer interface{}) { +func SetSerializer(name string, serializer Serializer) { serializers[name] = serializer } -func GetSerializerById(id byte) (interface{}, error) { +func GetSerializerById(id byte) (Serializer, error) { name, ok := nameMaps[id] if !ok { panic(fmt.Sprintf("serialId %d not found", id)) diff --git a/protocol/dubbo/impl/serialize.go b/protocol/dubbo/impl/serialize.go index cf211bf9fd..771d91ef1b 100644 --- a/protocol/dubbo/impl/serialize.go +++ b/protocol/dubbo/impl/serialize.go @@ -35,6 +35,6 @@ func LoadSerializer(p *DubboPackage) error { if err != nil { panic(err) } - p.SetSerializer(serializer.(Serializer)) + p.SetSerializer(serializer) return nil } From 10b5b9162f25e69115fe4acfa41848e9a1b83668 Mon Sep 17 00:00:00 2001 From: "15301580353@163.com" Date: Fri, 10 Sep 2021 11:00:21 +0800 Subject: [PATCH 096/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9panic=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/logger/logger.go | 2 +- config/consumer_config.go | 2 +- config/reference_config.go | 2 +- config/service_config.go | 2 +- test/integrate/dubbo/go-client/go.sum | 246 ++++--------------------- test/integrate/dubbo/go-server/go.sum | 251 ++++---------------------- 6 files changed, 66 insertions(+), 439 deletions(-) diff --git a/common/logger/logger.go b/common/logger/logger.go index 0aa741050b..6064c5ff68 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -86,7 +86,7 @@ func InitLog(logConfFile string) error { } if path.Ext(logConfFile) != ".yml" { InitLogger(nil) - return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile) + return perrors.Errorf("log configure file name{%s} suffix must be .yml,Please check if your format conforms to the .yml format", logConfFile) } confFileStream, err := ioutil.ReadFile(logConfFile) diff --git a/config/consumer_config.go b/config/consumer_config.go index 1ca32311cc..ad4aae4bcd 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -130,7 +130,7 @@ func (c *ConsumerConfig) Load() { checkok = false count++ if count > maxWait { - errMsg := fmt.Sprintf("Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) + errMsg := fmt.Sprintf("Request timed out, please check configuration,Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) logger.Error(errMsg) panic(errMsg) } diff --git a/config/reference_config.go b/config/reference_config.go index 80a23a2460..fcfd044671 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -124,7 +124,7 @@ func (rc *ReferenceConfig) Refer(_ interface{}) { for _, urlStr := range urlStrings { serviceURL, err := common.NewURL(urlStr) if err != nil { - panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) + panic(fmt.Sprintf("url configuration error please check your configuration,user specified URL %v refer error, error message is %v ", urlStr, err.Error())) } if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { serviceURL.SubURL = cfgURL diff --git a/config/service_config.go b/config/service_config.go index bfef0be59e..c3168b2e77 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -235,7 +235,7 @@ func (svc *ServiceConfig) Export() error { urlMap := svc.getUrlMap() protocolConfigs := loadProtocol(svc.Protocol, svc.rootConfig.Protocols) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs", svc.Interface, svc.Protocol) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs,Please check your configuration center and transfer protocol", svc.Interface, svc.Protocol) return nil } diff --git a/test/integrate/dubbo/go-client/go.sum b/test/integrate/dubbo/go-client/go.sum index 3822da99fd..83e26bf79b 100644 --- a/test/integrate/dubbo/go-client/go.sum +++ b/test/integrate/dubbo/go-client/go.sum @@ -5,60 +5,38 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-sdk-for-go v40.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= -github.com/Azure/go-autorest/autorest v0.10.0/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= -github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= -github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.6.0 h1:tZcn2nJpUrZf+xQY8x+9QY7BxSETMjkdNG4Ts5zahyU= -github.com/RoaringBitmap/roaring v0.6.0/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE= -github.com/RoaringBitmap/roaring v0.6.1/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE= +github.com/RoaringBitmap/roaring v0.7.1 h1:HkcLv8q/kwGJnhEWe+vinu+04DGDdQ7nVivMhNhxP2g= github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -72,31 +50,27 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDH github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1 h1:ceSsU/9z/gv3hzUpl8GceEhQvF3i0BionfdHUGMmjHU= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= +github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= 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= @@ -110,27 +84,20 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= 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/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= 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/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= @@ -142,32 +109,17 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= 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/go.mod h1:HWgGZZQcNhkFpWEc9As671pXAsfoXH7Eyy2MYzoy+xo= -github.com/dubbogo/gost v1.11.11/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= +github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.2-0.20210326124702-e6a866993192/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.0/go.mod h1:duJFWIYOE+Ajxxvk+AOBpEBePFNnviJ52fveZ3vYA04= -github.com/dubbogo/triple v1.0.1-0.20210518093320-be4ea8823a15/go.mod h1:3CPN7tvEeN4G4zWP7Zhz1VmfEyRU8UvUTVm0aP9CV1g= -github.com/dubbogo/triple v1.0.1-0.20210524091548-f33ebded31e9/go.mod h1:4b2yRUdaE6oRl9c+0SDm1mQ6rU9j21uVz8O85KEBsdo= -github.com/dubbogo/triple v1.0.1-0.20210606070217-0815f3a0a013/go.mod h1:4b2yRUdaE6oRl9c+0SDm1mQ6rU9j21uVz8O85KEBsdo= github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -176,25 +128,20 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -207,15 +154,12 @@ github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49P 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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -226,19 +170,25 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= +github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -287,8 +237,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -296,18 +244,14 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -315,7 +259,6 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -327,98 +270,60 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul v1.8.0/go.mod h1:Gg9/UgAQ9rdY3CTvzQZ6g2jcIb7NlIfjI+0pvLk5D1A= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/api v1.5.0/go.mod h1:LqwrLNW876eYSuUOo4ZLHBcdKc038txr/IMfbLPATa4= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.5.0/go.mod h1:fY08Y9z5SvJqevyZNy6WWPXiG3KwBPAvlcdx16zZ0fM= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-bexpr v0.1.2/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= -github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-connlimit v0.2.0/go.mod h1:OUj9FGL1tPIhl/2RCfzYHrIiWj+VVPGNyVPnUX8AqS0= -github.com/hashicorp/go-discover v0.0.0-20200501174627-ad1e96bde088/go.mod h1:vZu6Opqf49xX5lsFAu7iFNewkcVF1sn/wyapZh5ytlg= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-memdb v1.0.3/go.mod h1:LWQ8R70vPrS4OEY9k28D2z8/Zzyu34NVzeRibGAzHO0= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= -github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= -github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.0/go.mod h1:YL0HO+FifKOW2u1ke99DGVu1zhcpZzNwrLIqBC7vbYU= -github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff/go.mod h1:Uf8LaHyrYsgVgHzO2tMZKhqRGlL3UJ6XaSwW2EA1Iqo= github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20191108161836-82f2b5571044/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= -github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= -github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -441,70 +346,60 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= +github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 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= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= -github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.0/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.0.0/go.mod h1:k4XwG94++jLVsSiTxo7qdIfXA9pj9EAeo0QsNNJOLZ8= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -512,14 +407,12 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= +github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.7/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= @@ -528,14 +421,12 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -556,17 +447,15 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -580,8 +469,6 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= @@ -615,36 +502,25 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rboyer/safeio v0.2.1/go.mod h1:Cq/cEPK+YXFn622lsQ0K4KsPZSPtaptHHEldsy7Fmig= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= +github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/conswriter v0.0.0-20180208195008-f5ae3917a627/go.mod h1:7zjs06qF79/FKAJpBvFx3P8Ww4UTIMAe+lpNXDHziac= -github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod h1:BeybITEsBEg6qbIiqJ6/Bqeq25bCLbL7YFmpaFfJDuM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -653,38 +529,28 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 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= -github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -696,12 +562,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= -github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= 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= @@ -709,29 +571,18 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1 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/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vmihailenco/msgpack/v5 v5.3.2/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= -github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= 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/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= @@ -757,33 +608,27 @@ 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= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -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/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= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -794,7 +639,6 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= @@ -807,7 +651,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -822,13 +665,10 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -837,9 +677,8 @@ 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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= 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= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -861,7 +700,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -872,17 +710,11 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -891,10 +723,10 @@ golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7w 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= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -936,16 +768,12 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -965,12 +793,10 @@ google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -983,7 +809,6 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 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= @@ -992,7 +817,6 @@ google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6D google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1006,7 +830,6 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1021,7 +844,6 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1033,16 +855,12 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= @@ -1065,7 +883,6 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= @@ -1078,7 +895,6 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/test/integrate/dubbo/go-server/go.sum b/test/integrate/dubbo/go-server/go.sum index 08e3c03425..83e26bf79b 100644 --- a/test/integrate/dubbo/go-server/go.sum +++ b/test/integrate/dubbo/go-server/go.sum @@ -5,60 +5,38 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-sdk-for-go v40.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= -github.com/Azure/go-autorest/autorest v0.10.0/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/adal v0.8.2/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= -github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= -github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= -github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= -github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.6.0 h1:tZcn2nJpUrZf+xQY8x+9QY7BxSETMjkdNG4Ts5zahyU= -github.com/RoaringBitmap/roaring v0.6.0/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE= -github.com/RoaringBitmap/roaring v0.6.1/go.mod h1:WZ83fjBF/7uBHi6QoFyfGL4+xuV4Qn+xFkm4+vSzrhE= +github.com/RoaringBitmap/roaring v0.7.1 h1:HkcLv8q/kwGJnhEWe+vinu+04DGDdQ7nVivMhNhxP2g= github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -72,31 +50,27 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDH github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1 h1:ceSsU/9z/gv3hzUpl8GceEhQvF3i0BionfdHUGMmjHU= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= +github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.25.41/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= 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= @@ -110,27 +84,20 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= 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/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= 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/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= @@ -139,37 +106,20 @@ github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ 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= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denverdino/aliyungo v0.0.0-20170926055100-d3308649c661/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= -github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= -github.com/dubbogo/gost v1.9.0 h1:UT+dWwvLyJiDotxJERO75jB3Yxgsdy10KztR5ycxRAk= 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/go.mod h1:HWgGZZQcNhkFpWEc9As671pXAsfoXH7Eyy2MYzoy+xo= -github.com/dubbogo/gost v1.11.11/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= +github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.2-0.20210326124702-e6a866993192/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.0/go.mod h1:duJFWIYOE+Ajxxvk+AOBpEBePFNnviJ52fveZ3vYA04= -github.com/dubbogo/triple v1.0.1-0.20210518093320-be4ea8823a15/go.mod h1:3CPN7tvEeN4G4zWP7Zhz1VmfEyRU8UvUTVm0aP9CV1g= -github.com/dubbogo/triple v1.0.1-0.20210524091548-f33ebded31e9/go.mod h1:4b2yRUdaE6oRl9c+0SDm1mQ6rU9j21uVz8O85KEBsdo= -github.com/dubbogo/triple v1.0.1-0.20210606070217-0815f3a0a013/go.mod h1:4b2yRUdaE6oRl9c+0SDm1mQ6rU9j21uVz8O85KEBsdo= github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -178,25 +128,20 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -209,15 +154,12 @@ github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49P 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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -228,19 +170,25 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= +github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -289,8 +237,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -298,18 +244,14 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -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/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -317,7 +259,6 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -329,98 +270,60 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul v1.8.0/go.mod h1:Gg9/UgAQ9rdY3CTvzQZ6g2jcIb7NlIfjI+0pvLk5D1A= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/api v1.5.0/go.mod h1:LqwrLNW876eYSuUOo4ZLHBcdKc038txr/IMfbLPATa4= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.5.0/go.mod h1:fY08Y9z5SvJqevyZNy6WWPXiG3KwBPAvlcdx16zZ0fM= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-bexpr v0.1.2/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= -github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-connlimit v0.2.0/go.mod h1:OUj9FGL1tPIhl/2RCfzYHrIiWj+VVPGNyVPnUX8AqS0= -github.com/hashicorp/go-discover v0.0.0-20200501174627-ad1e96bde088/go.mod h1:vZu6Opqf49xX5lsFAu7iFNewkcVF1sn/wyapZh5ytlg= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-memdb v1.0.3/go.mod h1:LWQ8R70vPrS4OEY9k28D2z8/Zzyu34NVzeRibGAzHO0= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= -github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2-0.20191001231223-f32f5fe8d6a8/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hil v0.0.0-20160711231837-1e86c6b523c5/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= -github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.0/go.mod h1:YL0HO+FifKOW2u1ke99DGVu1zhcpZzNwrLIqBC7vbYU= -github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff/go.mod h1:Uf8LaHyrYsgVgHzO2tMZKhqRGlL3UJ6XaSwW2EA1Iqo= github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20191108161836-82f2b5571044/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU= github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= -github.com/jackc/pgx v3.3.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= -github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= -github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -443,70 +346,60 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= +github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 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= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linode/linodego v0.7.1/go.mod h1:ga11n3ivecUrPCHN0rANxKmfWBJVkOXfLMZinAbj2sY= -github.com/linode/linodego v0.10.0/go.mod h1:cziNP7pbvE3mXIPneHj0oRY8L1WtGEIKlZ8LANE4eXA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.0/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.2.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.0.0/go.mod h1:k4XwG94++jLVsSiTxo7qdIfXA9pj9EAeo0QsNNJOLZ8= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -514,14 +407,12 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY= -github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= +github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.7/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= @@ -530,14 +421,12 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -558,17 +447,15 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -582,8 +469,6 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= @@ -617,36 +502,25 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rboyer/safeio v0.2.1/go.mod h1:Cq/cEPK+YXFn622lsQ0K4KsPZSPtaptHHEldsy7Fmig= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU= +github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/conswriter v0.0.0-20180208195008-f5ae3917a627/go.mod h1:7zjs06qF79/FKAJpBvFx3P8Ww4UTIMAe+lpNXDHziac= -github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod h1:BeybITEsBEg6qbIiqJ6/Bqeq25bCLbL7YFmpaFfJDuM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -655,56 +529,41 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d/go.mod h1:Cw4GTlQccdRGSEf6KiMju767x0NEHE0YIVPJSaXjlsw= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 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= -github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -github.com/tencentcloud/tencentcloud-sdk-go v3.0.83+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= -github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= 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= @@ -712,29 +571,18 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1 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/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vmihailenco/msgpack/v5 v5.3.2/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= -github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698/go.mod h1:YoUyTScD3Vcv2RBm3eGVOq7i1ULiz3OuXoQFWOirmAM= 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/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= @@ -760,33 +608,27 @@ 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= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -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/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= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -797,7 +639,6 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= @@ -810,7 +651,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180611182652-db08ff08e862/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -825,13 +665,10 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -840,9 +677,8 @@ 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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= 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= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -864,7 +700,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -875,17 +710,11 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -894,10 +723,10 @@ golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7w 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= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -939,16 +768,12 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -968,12 +793,10 @@ google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -986,7 +809,6 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 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= @@ -995,7 +817,6 @@ google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6D google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1009,7 +830,6 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1024,10 +844,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1037,21 +855,16 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1070,7 +883,6 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= @@ -1083,7 +895,6 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= From 95f76fec6ba21e67a8a897bb2dff0b6e5bec4bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9B=E5=93=A5?= Date: Fri, 10 Sep 2021 12:30:16 +0800 Subject: [PATCH 097/148] upgrade hessian2 to v1.9.3 (#1446) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5170475cb5..552327633f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-getty v1.4.5 - github.com/apache/dubbo-go-hessian2 v1.9.2 + github.com/apache/dubbo-go-hessian2 v1.9.3 github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.16 diff --git a/go.sum b/go.sum index 0ad685ea8a..8098c3c5db 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/dubbo-getty v1.4.5 h1:MptKbjC0n2Mo/8eFPwirSInH2BfdNG4IZch43PdNvIM= github.com/apache/dubbo-getty v1.4.5/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= -github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= +github.com/apache/dubbo-go-hessian2 v1.9.3 h1:0G9cdOCiKILem1JRKeZtY0FdIUyvzt30qtukMXPtJks= +github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= From 1e912e891a482603f855397b3ed7e772b19c43f3 Mon Sep 17 00:00:00 2001 From: "15301580353@163.com" Date: Fri, 10 Sep 2021 14:33:17 +0800 Subject: [PATCH 098/148] =?UTF-8?q?=E4=BF=AE=E6=94=B9panic=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97=EF=BC=8C=E6=89=93=E5=8D=B0=E4=BA=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E8=AF=A6=E7=BB=86=E5=8E=9F=E5=9B=A0=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=86=92=E7=94=A8=E6=88=B7=E9=9C=80=E8=A6=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/logger/logger.go | 60 ++++++++++++++++++++++++++++++++++------- go.mod | 2 ++ go.sum | 4 +++ 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/common/logger/logger.go b/common/logger/logger.go index 6064c5ff68..140f56fc3f 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -26,6 +26,7 @@ import ( import ( "github.com/apache/dubbo-getty" + "github.com/natefinch/lumberjack" perrors "github.com/pkg/errors" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -44,6 +45,11 @@ type DubboLogger struct { dynamicLevel zap.AtomicLevel } +type Config struct { + LumberjackConfig *lumberjack.Logger `yaml:"lumberjackConfig"` + ZapConfig *zap.Config `yaml:"zapConfig"` +} + // Logger is the interface for Logger types type Logger interface { Info(args ...interface{}) @@ -86,7 +92,7 @@ func InitLog(logConfFile string) error { } if path.Ext(logConfFile) != ".yml" { InitLogger(nil) - return perrors.Errorf("log configure file name{%s} suffix must be .yml,Please check if your format conforms to the .yml format", logConfFile) + return perrors.Errorf("log configure file name{%s} suffix must be .yml", logConfFile) } confFileStream, err := ioutil.ReadFile(logConfFile) @@ -95,7 +101,7 @@ func InitLog(logConfFile string) error { return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", logConfFile, err) } - conf := &zap.Config{} + conf := &Config{} err = yaml.Unmarshal(confFileStream, conf) if err != nil { InitLogger(nil) @@ -108,9 +114,12 @@ func InitLog(logConfFile string) error { } // InitLogger use for init logger by @conf -func InitLogger(conf *zap.Config) { - var zapLoggerConfig zap.Config - if conf == nil { +func InitLogger(conf *Config) { + var ( + zapLogger *zap.Logger + config = &Config{} + ) + if conf == nil || conf.ZapConfig == nil { zapLoggerEncoderConfig := zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", @@ -123,7 +132,7 @@ func InitLogger(conf *zap.Config) { EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, } - zapLoggerConfig = zap.Config{ + config.ZapConfig = &zap.Config{ Level: zap.NewAtomicLevelAt(zap.DebugLevel), Development: false, Encoding: "console", @@ -132,10 +141,17 @@ func InitLogger(conf *zap.Config) { ErrorOutputPaths: []string{"stderr"}, } } else { - zapLoggerConfig = *conf + config.ZapConfig = conf.ZapConfig + } + + if conf == nil || conf.LumberjackConfig == nil { + zapLogger, _ = config.ZapConfig.Build(zap.AddCallerSkip(1)) + } else { + config.LumberjackConfig = conf.LumberjackConfig + zapLogger = initZapLoggerWithSyncer(config) } - zapLogger, _ := zapLoggerConfig.Build(zap.AddCallerSkip(1)) - logger = &DubboLogger{Logger: zapLogger.Sugar(), dynamicLevel: zapLoggerConfig.Level} + + logger = &DubboLogger{Logger: zapLogger.Sugar(), dynamicLevel: config.ZapConfig.Level} // set getty log getty.SetLogger(logger) @@ -174,3 +190,29 @@ func (dl *DubboLogger) SetLoggerLevel(level string) { dl.dynamicLevel.SetLevel(*l) } } + +// initZapLoggerWithSyncer init zap Logger with syncer +func initZapLoggerWithSyncer(conf *Config) *zap.Logger { + core := zapcore.NewCore( + conf.getEncoder(), + conf.getLogWriter(), + zap.NewAtomicLevelAt(zap.DebugLevel), + ) + + return zap.New(core, zap.AddCallerSkip(1)) +} + +// getEncoder get encoder by config, zapcore support json and console encoder +func (c *Config) getEncoder() zapcore.Encoder { + if c.ZapConfig.Encoding == "json" { + return zapcore.NewJSONEncoder(c.ZapConfig.EncoderConfig) + } else if c.ZapConfig.Encoding == "console" { + return zapcore.NewConsoleEncoder(c.ZapConfig.EncoderConfig) + } + return nil +} + +// getLogWriter get Lumberjack writer by LumberjackConfig +func (c *Config) getLogWriter() zapcore.WriteSyncer { + return zapcore.AddSync(c.LumberjackConfig) +} diff --git a/go.mod b/go.mod index 1fa906227c..4f5bf79a51 100644 --- a/go.mod +++ b/go.mod @@ -30,6 +30,7 @@ require ( github.com/mitchellh/mapstructure v1.4.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd github.com/nacos-group/nacos-sdk-go v1.0.8 + github.com/natefinch/lumberjack v2.0.0+incompatible github.com/opentracing/opentracing-go v1.2.0 github.com/pierrec/lz4 v2.2.6+incompatible // indirect github.com/pkg/errors v0.9.1 @@ -44,6 +45,7 @@ require ( go.uber.org/atomic v1.7.0 go.uber.org/zap v1.16.0 google.golang.org/grpc v1.38.0 + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect 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 5411fce5c6..3e6bc3a26b 100644 --- a/go.sum +++ b/go.sum @@ -460,6 +460,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nacos-group/nacos-sdk-go v1.0.8 h1:8pEm05Cdav9sQgJSv5kyvlgfz0SzFUUGI3pWX6SiSnM= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= +github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= +github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= @@ -943,6 +945,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= From 0f8de5a8f300b9e583acea4da1e5ed753ced86a4 Mon Sep 17 00:00:00 2001 From: "15301580353@163.com" Date: Sun, 12 Sep 2021 12:15:57 +0800 Subject: [PATCH 099/148] add logs --- config/consumer_config.go | 2 +- config/reference_config.go | 2 +- config/service_config.go | 2 +- go.mod | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index 37ccd1daa6..25610d0a2d 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -111,7 +111,7 @@ func (cc *ConsumerConfig) Load() { checkok = false count++ if count > maxWait { - errMsg := fmt.Sprintf("Request timed out, please check configuration,Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) + errMsg := fmt.Sprintf("Request timed out, please check configuration, Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version) logger.Error(errMsg) panic(errMsg) } diff --git a/config/reference_config.go b/config/reference_config.go index f751835d14..0318a7bdd7 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -113,7 +113,7 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { for _, urlStr := range urlStrings { serviceURL, err := common.NewURL(urlStr) if err != nil { - panic(fmt.Sprintf("url configuration error please check your configuration,user specified URL %v refer error, error message is %v ", urlStr, err.Error())) + panic(fmt.Sprintf("url configuration error, please check your configuration, user specified URL %v refer error, error message is %v ", urlStr, err.Error())) } if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { serviceURL.SubURL = cfgURL diff --git a/config/service_config.go b/config/service_config.go index a767a7beac..3948fc0697 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -225,7 +225,7 @@ func (svc *ServiceConfig) Export() error { urlMap := svc.getUrlMap() protocolConfigs := loadProtocol(svc.Protocol, svc.Protocols) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs,Please check your configuration center and transfer protocol", svc.Interface, svc.Protocol) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs, Please check your configuration center and transfer protocol ", svc.Interface, svc.Protocol) return nil } diff --git a/go.mod b/go.mod index 8e224154c8..262e25631e 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,6 @@ require ( google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.27.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.16.9 k8s.io/apimachinery v0.16.9 From 9c24d1d52d29c026487aa3581bd1dfdd1bf3c1c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 22:30:40 +0800 Subject: [PATCH 100/148] build(deps): bump github.com/nacos-group/nacos-sdk-go (#1457) Bumps [github.com/nacos-group/nacos-sdk-go](https://github.com/nacos-group/nacos-sdk-go) from 1.0.8 to 1.0.9. - [Release notes](https://github.com/nacos-group/nacos-sdk-go/releases) - [Commits](https://github.com/nacos-group/nacos-sdk-go/compare/v1.0.8...v1.0.9) --- updated-dependencies: - dependency-name: github.com/nacos-group/nacos-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 552327633f..c69ad8e210 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd - github.com/nacos-group/nacos-sdk-go v1.0.8 + github.com/nacos-group/nacos-sdk-go v1.0.9 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 8098c3c5db..45c8b8e73f 100644 --- a/go.sum +++ b/go.sum @@ -481,8 +481,9 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.8 h1:8pEm05Cdav9sQgJSv5kyvlgfz0SzFUUGI3pWX6SiSnM= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= +github.com/nacos-group/nacos-sdk-go v1.0.9 h1:sMvrp6tZj4LdhuHRsS4GCqASB81k3pjmT2ykDQQpwt0= +github.com/nacos-group/nacos-sdk-go v1.0.9/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= From 8d727d630e0e02a48919e11c4058fe3716930d90 Mon Sep 17 00:00:00 2001 From: XavierNiu Date: Wed, 15 Sep 2021 14:02:11 +0800 Subject: [PATCH 101/148] feat(generic-inv): align generic inv interface with java (#1452) --- common/proxy/proxy.go | 4 ++-- config/generic/generic_service.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 819fe287e5..e1c6222f96 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -114,14 +114,13 @@ func (p *Proxy) GetInvoker() protocol.Invoker { func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) { // check parameters, incoming interface must be a elem's pointer. valueOf := reflect.ValueOf(v) - logger.Debugf("[Implement] reflect.TypeOf: %s", valueOf.String()) valueOfElem := valueOf.Elem() typeOf := valueOfElem.Type() // check incoming interface, incoming interface's elem must be a struct. if typeOf.Kind() != reflect.Struct { - logger.Errorf("%s must be a struct ptr", valueOf.String()) + logger.Errorf("The type of RPCService(=\"%T\") must be a pointer of a struct.", v) return } @@ -152,6 +151,7 @@ func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) { start := 0 end := len(in) invCtx := context.Background() + // retrieve the context from the first argument if existed if end > 0 { if in[0].Type().String() == "context.Context" { if !in[0].IsNil() { diff --git a/config/generic/generic_service.go b/config/generic/generic_service.go index 677f97e564..37bf948ad7 100644 --- a/config/generic/generic_service.go +++ b/config/generic/generic_service.go @@ -21,9 +21,13 @@ import ( "context" ) +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + // GenericService uses for generic invoke for service call type GenericService struct { - Invoke func(ctx context.Context, req []interface{}) (interface{}, error) `dubbo:"$invoke"` + Invoke func(ctx context.Context, methodName string, types []string, args []hessian.Object) (interface{}, error) `dubbo:"$invoke"` referenceStr string } From 8c0b66441b347636f2a76625e3a9b45fd04b85f0 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:50:58 +0800 Subject: [PATCH 102/148] =?UTF-8?q?Fix:=20metrics=E3=80=81k8s=E3=80=81ppro?= =?UTF-8?q?f=20(#1459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: prometheus metrics default * fix: fix ut * fix: fix k8s ut * fix: ut --- common/constant/default.go | 2 +- config/root_config.go | 5 + config/service.go | 5 +- filter/metrics/filter.go | 8 +- filter/metrics/filter_test.go | 1 + go.mod | 1 + go.sum | 168 ++++++++++++- imports/imports.go | 1 + .../exporter/configurable/exporter_test.go | 1 + metrics/prometheus/reporter.go | 238 +++++++++++++++--- protocol/dubbo3/internal/server.go | 1 + remoting/getty/getty_server_test.go | 10 +- remoting/kubernetes/client.go | 18 +- remoting/kubernetes/registry_controller.go | 47 +++- 14 files changed, 453 insertions(+), 53 deletions(-) diff --git a/common/constant/default.go b/common/constant/default.go index e7de3e6ed2..91c6742e65 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -52,7 +52,7 @@ const ( const ( DEFAULT_KEY = "default" PREFIX_DEFAULT_KEY = "default." - DEFAULT_SERVICE_FILTERS = EchoFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey + DEFAULT_SERVICE_FILTERS = EchoFilterKey + "," + MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey DEFAULT_REFERENCE_FILTERS = GracefulShutdownConsumerFilterKey GENERIC_REFERENCE_FILTERS = GenericFilterKey GENERIC = "$invoke" diff --git a/config/root_config.go b/config/root_config.go index c928b8fa22..de7731cb02 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -19,6 +19,8 @@ package config import ( "bytes" + "net/http" + _ "net/http/pprof" ) import ( @@ -129,6 +131,9 @@ func (rc *RootConfig) Init() error { if err := rc.Consumer.Init(rc); err != nil { return err } + go func() { + _ = http.ListenAndServe("0.0.0.0:6060", nil) + }() return nil } diff --git a/config/service.go b/config/service.go index 0f039fd61d..06bf87ab27 100644 --- a/config/service.go +++ b/config/service.go @@ -18,10 +18,13 @@ package config import ( - "dubbo.apache.org/dubbo-go/v3/common" "sync" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common" +) + var ( // conServicesLock is used to guard conServices map. conServicesLock = sync.Mutex{} diff --git a/filter/metrics/filter.go b/filter/metrics/filter.go index 9da3a3343b..7b29305ab8 100644 --- a/filter/metrics/filter.go +++ b/filter/metrics/filter.go @@ -25,7 +25,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/filter" "dubbo.apache.org/dubbo-go/v3/metrics" "dubbo.apache.org/dubbo-go/v3/protocol" @@ -74,11 +73,8 @@ func (p *Filter) OnResponse(ctx context.Context, res protocol.Result, invoker pr // make sure that the configuration had been loaded before invoking this method. func newFilter() filter.Filter { if metricFilterInstance == nil { - reporterNames := config.GetMetricConfig().Reporters - reporters := make([]metrics.Reporter, 0, len(reporterNames)) - for _, name := range reporterNames { - reporters = append(reporters, extension.GetMetricReporter(name)) - } + reporters := make([]metrics.Reporter, 0, 1) + reporters = append(reporters, extension.GetMetricReporter("prometheus")) metricFilterInstance = &Filter{ reporters: reporters, } diff --git a/filter/metrics/filter_test.go b/filter/metrics/filter_test.go index f4b3440e05..11e19d39ec 100644 --- a/filter/metrics/filter_test.go +++ b/filter/metrics/filter_test.go @@ -34,6 +34,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metrics" + _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/go.mod b/go.mod index 262e25631e..c8107ddf6a 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module dubbo.apache.org/dubbo-go/v3 go 1.15 require ( + contrib.go.opencensus.io/exporter/prometheus v0.4.0 github.com/RoaringBitmap/roaring v0.7.1 github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 diff --git a/go.sum b/go.sum index face8eb43a..bc3909e2c8 100644 --- a/go.sum +++ b/go.sum @@ -6,11 +6,34 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= +contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= @@ -91,6 +114,9 @@ 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= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -207,16 +233,19 @@ github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0 github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= @@ -238,6 +267,7 @@ github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8 github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= @@ -257,11 +287,16 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -269,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.4/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= @@ -291,7 +327,10 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -299,8 +338,14 @@ github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -391,6 +436,7 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKe github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= @@ -417,6 +463,7 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -604,8 +651,9 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 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/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.28.0 h1:vGVfV9KrDTvWt5boZO0I19g2E3CsWfpPPKZM9dt3mEw= +github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -617,6 +665,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= +github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= @@ -683,6 +733,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -708,7 +759,9 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ= @@ -740,6 +793,10 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -778,6 +835,11 @@ golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -788,6 +850,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= @@ -817,31 +881,47 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/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-20201110031124-69a78807bb2b/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-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -876,18 +956,28 @@ golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/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-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20200803210538-64077c9b5642/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= @@ -896,19 +986,22 @@ golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -941,11 +1034,33 @@ golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 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/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -961,12 +1076,25 @@ google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -978,10 +1106,29 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= @@ -999,9 +1146,14 @@ google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= @@ -1068,6 +1220,8 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.16.9 h1:3vCx0WX9qcg1Hv4aQ/G1tiIKectGVuimvPVTJU4VOCA= k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= @@ -1084,6 +1238,8 @@ k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKf k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE= k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= diff --git a/imports/imports.go b/imports/imports.go index 732612225d..cd346e432f 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -31,6 +31,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" + _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" _ "dubbo.apache.org/dubbo-go/v3/protocol/grpc" diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 09f1c9d60f..55393e1d94 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -31,6 +31,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" + _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" "dubbo.apache.org/dubbo-go/v3/remoting/getty" ) diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 83f6c331dc..02365a17a3 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -19,6 +19,7 @@ package prometheus import ( "context" + "net/http" "strconv" "strings" "sync" @@ -26,7 +27,10 @@ import ( ) import ( + ocprom "contrib.go.opencensus.io/exporter/prometheus" + "github.com/prometheus/client_golang/prometheus" + prom "github.com/prometheus/client_golang/prometheus" ) import ( @@ -47,8 +51,9 @@ const ( methodKey = constant.METHOD_KEY timeoutKey = constant.TIMEOUT_KEY - providerKey = "provider" - consumerKey = "consumer" + // to identify side + providerPrefix = "provider_" + consumerPrefix = "consumer_" // to identify the metric's type histogramSuffix = "_histogram" @@ -57,14 +62,16 @@ const ( ) var ( - labelNames = []string{serviceKey, groupKey, versionKey, methodKey, timeoutKey} - namespace = config.GetApplicationConfig().Name - reporterInstance *PrometheusReporter - reporterInitOnce sync.Once + labelNames = []string{serviceKey, groupKey, versionKey, methodKey, timeoutKey} + namespace = config.GetApplicationConfig().Name + reporterInstance *PrometheusReporter + reporterInitOnce sync.Once + defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000} ) // should initialize after loading configuration func init() { + newPrometheusReporter() extension.SetMetricReporter(reporterName, newPrometheusReporter) } @@ -80,6 +87,13 @@ type PrometheusReporter struct { providerHistogramVec *prometheus.HistogramVec // report the consumer-side's histogram data consumerHistogramVec *prometheus.HistogramVec + + userGauge sync.Map + userSummary sync.Map + userCounter sync.Map + userCounterVec sync.Map + userGaugeVec sync.Map + userSummaryVec sync.Map } // Report reports the duration to Prometheus @@ -108,46 +122,65 @@ func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol methodKey: invocation.MethodName(), timeoutKey: url.GetParam(timeoutKey, ""), } - costMs := float64(cost.Nanoseconds() / constant.MsToNanoRate) sumVec.With(labels).Observe(costMs) hisVec.With(labels).Observe(costMs) } -func newHistogramVec(side string) *prometheus.HistogramVec { - mc := config.GetMetricConfig() +func newHistogramVec(name string, labels []string) *prometheus.HistogramVec { return prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: namespace, - Subsystem: side, - Name: serviceKey + histogramSuffix, + Name: name, Help: "This is the dubbo's histogram metrics", - Buckets: mc.GetHistogramBucket(), + Buckets: defaultHistogramBucket, }, - labelNames) + labels) } -// whether this url represents the application received the request as server -func isProvider(url *common.URL) bool { - role := url.GetParam(constant.ROLE_KEY, "") - return strings.EqualFold(role, strconv.Itoa(common.PROVIDER)) +func newCounter(name string) prometheus.Counter { + return prometheus.NewCounter( + prometheus.CounterOpts{ + Name: name, + }) } -// whether this url represents the application sent then request as client -func isConsumer(url *common.URL) bool { - role := url.GetParam(constant.ROLE_KEY, "") - return strings.EqualFold(role, strconv.Itoa(common.CONSUMER)) +func newCounterVec(name string, labels []string) *prometheus.CounterVec { + return prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: name, + }, labels) +} + +func newGauge(name string) prometheus.Gauge { + return prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: name, + }) +} + +func newGaugeVec(name string, labels []string) *prometheus.GaugeVec { + return prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: name, + }, labels) +} + +func newSummary(name string) prometheus.Summary { + return prometheus.NewSummary( + prometheus.SummaryOpts{ + Name: name, + }) } // newSummaryVec create SummaryVec, the Namespace is dubbo // the objectives is from my experience. -func newSummaryVec(side string) *prometheus.SummaryVec { +func newSummaryVec(name string, labels []string) *prometheus.SummaryVec { return prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: namespace, Help: "This is the dubbo's summary metrics", - Subsystem: side, - Name: serviceKey + summarySuffix, + Name: name, Objectives: map[float64]float64{ 0.5: 0.01, 0.75: 0.01, @@ -157,25 +190,170 @@ func newSummaryVec(side string) *prometheus.SummaryVec { 0.999: 0.0001, }, }, - labelNames, + labels, ) } +// isProvider shows whether this url represents the application received the request as server +func isProvider(url *common.URL) bool { + role := url.GetParam(constant.ROLE_KEY, "") + return strings.EqualFold(role, strconv.Itoa(common.PROVIDER)) +} + +// isConsumer shows whether this url represents the application sent then request as client +func isConsumer(url *common.URL) bool { + role := url.GetParam(constant.ROLE_KEY, "") + return strings.EqualFold(role, strconv.Itoa(common.CONSUMER)) +} + // newPrometheusReporter create new prometheusReporter // it will register the metrics into prometheus func newPrometheusReporter() metrics.Reporter { if reporterInstance == nil { reporterInitOnce.Do(func() { reporterInstance = &PrometheusReporter{ - consumerSummaryVec: newSummaryVec(consumerKey), - providerSummaryVec: newSummaryVec(providerKey), + consumerSummaryVec: newSummaryVec(consumerPrefix+serviceKey+summarySuffix, labelNames), + providerSummaryVec: newSummaryVec(providerPrefix+serviceKey+summarySuffix, labelNames), - consumerHistogramVec: newHistogramVec(consumerKey), - providerHistogramVec: newHistogramVec(providerKey), + consumerHistogramVec: newHistogramVec(consumerPrefix+serviceKey+histogramSuffix, labelNames), + providerHistogramVec: newHistogramVec(providerPrefix+serviceKey+histogramSuffix, labelNames), } - prometheus.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec, + + prom.DefaultRegisterer.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec, reporterInstance.consumerHistogramVec, reporterInstance.providerHistogramVec) + metricsExporter, err := ocprom.NewExporter(ocprom.Options{ + Registry: prom.DefaultRegisterer.(*prom.Registry), + }) + if err != nil { + logger.Errorf("new prometheus reporter with error = %s", err) + return + } + go func() { + mux := http.NewServeMux() + mux.Handle("/metrics", metricsExporter) + if err := http.ListenAndServe(":9090", mux); err != nil { + logger.Errorf("new prometheus reporter with error = %s", err) + } + }() }) } return reporterInstance } + +// setGauge set gauge to target value with given label, if label is not empty, set gauge vec +// if target gauge/gaugevec not exist, just create new gauge and set the value +func (reporter *PrometheusReporter) setGauge(gaugeName string, toSetValue float64, labelMap prometheus.Labels) { + if len(labelMap) == 0 { + // gauge + if val, exist := reporter.userGauge.Load(gaugeName); !exist { + newGauge := newGauge(gaugeName) + _ = prom.DefaultRegisterer.Register(newGauge) + + reporter.userGauge.Store(gaugeName, newGauge) + newGauge.Set(toSetValue) + } else { + val.(prometheus.Gauge).Set(toSetValue) + } + return + } + + // gauge vec + if val, exist := reporter.userGaugeVec.Load(gaugeName); !exist { + keyList := make([]string, 0) + for k, _ := range labelMap { + keyList = append(keyList, k) + } + newGaugeVec := newGaugeVec(gaugeName, keyList) + _ = prom.DefaultRegisterer.Register(newGaugeVec) + reporter.userGaugeVec.Store(gaugeName, newGaugeVec) + newGaugeVec.With(labelMap).Set(toSetValue) + } else { + val.(*prometheus.GaugeVec).With(labelMap).Set(toSetValue) + } +} + +// incCounter inc counter to inc if label is not empty, set counter vec +// if target counter/counterVec not exist, just create new counter and inc the value +func (reporter *PrometheusReporter) incCounter(counterName string, labelMap prometheus.Labels) { + if len(labelMap) == 0 { + // counter + if val, exist := reporter.userCounter.Load(counterName); !exist { + newCounter := newCounter(counterName) + _ = prom.DefaultRegisterer.Register(newCounter) + reporter.userCounter.Store(counterName, newCounter) + newCounter.Inc() + } else { + val.(prometheus.Counter).Inc() + } + return + } + + // counter vec inc + if val, exist := reporter.userCounterVec.Load(counterName); !exist { + keyList := make([]string, 0) + for k, _ := range labelMap { + keyList = append(keyList, k) + } + newCounterVec := newCounterVec(counterName, keyList) + _ = prom.DefaultRegisterer.Register(newCounterVec) + reporter.userSummaryVec.Store(counterName, newCounterVec) + newCounterVec.With(labelMap).Inc() + } else { + val.(*prometheus.CounterVec).With(labelMap).Inc() + } +} + +// incSummary inc summary to target value with given label, if label is not empty, set summary vec +// if target summary/summaryVec not exist, just create new summary and set the value +func (reporter *PrometheusReporter) incSummary(summaryName string, toSetValue float64, labelMap prometheus.Labels) { + if len(labelMap) == 0 { + // summary + if val, exist := reporter.userSummary.Load(summaryName); !exist { + newSummary := newSummary(summaryName) + _ = prom.DefaultRegisterer.Register(newSummary) + reporter.userSummary.Store(summaryName, newSummary) + newSummary.Observe(toSetValue) + } else { + val.(prometheus.Summary).Observe(toSetValue) + } + return + } + + // summary vec + if val, exist := reporter.userSummaryVec.Load(summaryName); !exist { + keyList := make([]string, 0) + for k, _ := range labelMap { + keyList = append(keyList, k) + } + newSummaryVec := newSummaryVec(summaryName, keyList) + _ = prom.DefaultRegisterer.Register(newSummaryVec) + reporter.userSummaryVec.Store(summaryName, newSummaryVec) + newSummaryVec.With(labelMap).Observe(toSetValue) + } else { + val.(*prometheus.SummaryVec).With(labelMap).Observe(toSetValue) + } +} + +func SetGaugeWithLabel(gaugeName string, val float64, label prometheus.Labels) { + reporterInstance.setGauge(gaugeName, val, label) +} + +func SetGauge(gaugeName string, val float64) { + reporterInstance.setGauge(gaugeName, val, make(prometheus.Labels)) +} + +func IncCounterWithLabel(counterName string, label prometheus.Labels) { + reporterInstance.incCounter(counterName, label) +} + +func IncCounter(summaryName string) { + reporterInstance.incCounter(summaryName, make(prometheus.Labels)) +} + +func IncSummaryWithLabel(counterName string, val float64, label prometheus.Labels) { + reporterInstance.incSummary(counterName, val, label) +} + +func IncSummary(summaryName string, val float64) { + reporterInstance.incSummary(summaryName, val, make(prometheus.Labels)) +} diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 2eaca3efbd..e1cf5dafe2 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -27,6 +27,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" + _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" ) // server is used to implement helloworld.GreeterServer. diff --git a/remoting/getty/getty_server_test.go b/remoting/getty/getty_server_test.go index 1f0819913d..09db5eeaf7 100644 --- a/remoting/getty/getty_server_test.go +++ b/remoting/getty/getty_server_test.go @@ -18,11 +18,17 @@ package getty import ( - "dubbo.apache.org/dubbo-go/v3/config" - "github.com/stretchr/testify/assert" "testing" ) +import ( + "github.com/stretchr/testify/assert" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/config" +) + func TestInitServer(t *testing.T) { originRootConf := config.GetRootConfig() rootConf := config.RootConfig{ diff --git a/remoting/kubernetes/client.go b/remoting/kubernetes/client.go index f55ac1a6eb..976dd44e0b 100644 --- a/remoting/kubernetes/client.go +++ b/remoting/kubernetes/client.go @@ -48,8 +48,8 @@ type Client struct { controller *dubboRegistryController } -// newClient returns Client instance for registry -func newClient(url *common.URL) (*Client, error) { +// NewClient returns Client instance for registry +func NewClient(url *common.URL) (*Client, error) { // read type r, err := strconv.Atoi(url.GetParams().Get(constant.ROLE_KEY)) if err != nil { @@ -76,6 +76,18 @@ func newClient(url *common.URL) (*Client, error) { return c, nil } +func (c *Client) SetLabel(k, v string) error { + c.lock.Lock() + defer c.lock.Unlock() + + if err := c.controller.assembleLabel(k, v); err != nil { + return perrors.WithMessagef(err, "add annotation @key = %s @value = %s", k, v) + } + + logger.Debugf("put the @key = %s @value = %s success", k, v) + return nil +} + // Create creates k/v pair in watcher-set func (c *Client) Create(k, v string) error { // the read current pod must be lock, protect every @@ -168,7 +180,7 @@ func ValidateClient(container clientFacade) error { // new Client if client == nil || client.Valid() { - newClient, err := newClient(container.GetURL()) + newClient, err := NewClient(container.GetURL()) if err != nil { logger.Warnf("new kubernetes client: %v)", err) return perrors.WithMessage(err, "new kubernetes client") diff --git a/remoting/kubernetes/registry_controller.go b/remoting/kubernetes/registry_controller.go index 5304b0a625..f6a804aa18 100644 --- a/remoting/kubernetes/registry_controller.go +++ b/remoting/kubernetes/registry_controller.go @@ -22,6 +22,7 @@ import ( "encoding/base64" "encoding/json" "fmt" + "io/ioutil" "os" "strconv" "strings" @@ -62,6 +63,7 @@ const ( // kubernetes inject env var podNameKey = "HOSTNAME" nameSpaceKey = "NAMESPACE" + nameSpaceFilePath = "/var/run/secrets/kubernetes.io/serviceaccount/namespace" needWatchedNameSpaceKey = "DUBBO_NAMESPACE" // all pod annotation key @@ -199,13 +201,20 @@ func (c *dubboRegistryController) readConfig() error { // read current pod name && namespace c.name = os.Getenv(podNameKey) if len(c.name) == 0 { - return perrors.New("read value from env by key (HOSTNAME)") + return perrors.Errorf("read pod name from env %s failed", podNameKey) + } + namespace, err := ioutil.ReadFile(nameSpaceFilePath) + if err == nil && len(namespace) != 0 { + c.namespace = string(namespace) + return nil } c.namespace = os.Getenv(nameSpaceKey) - if len(c.namespace) == 0 { - return perrors.New("read value from env by key (NAMESPACE)") + if len(c.namespace) != 0 { + return nil } - return nil + return perrors.Errorf("get empty namesapce, please check if namespace file at %s exist, or environment %s"+ + " is set", nameSpaceFilePath, nameSpaceKey) + } func (c *dubboRegistryController) initNamespacedPodInformer(ns string) error { @@ -457,6 +466,36 @@ func (c *dubboRegistryController) patchCurrentPod(patch []byte) (*v1.Pod, error) return updatedPod, nil } +func (c *dubboRegistryController) assembleLabel(k, v string) error { + var ( + oldPod = &v1.Pod{} + newPod = &v1.Pod{} + ) + oldPod.Labels = make(map[string]string, 8) + newPod.Labels = make(map[string]string, 8) + currentPod, err := c.readCurrentPod() + if err != nil { + return err + } + // copy current pod labels to oldPod && newPod + for k, v := range currentPod.GetLabels() { + oldPod.Labels[k] = v + newPod.Labels[k] = v + } + newPod.Labels[k] = v + + p, err := c.getPatch(oldPod, newPod) + if err != nil { + return perrors.WithMessage(err, "get patch") + } + + _, err = c.patchCurrentPod(p) + if err != nil { + return perrors.WithMessage(err, "patch to current pod") + } + return nil +} + // assembleDUBBOLabel assembles the dubbo kubernetes label // every dubbo instance should be labeled spec {"dubbo.io/label":"dubbo.io/label-value"} label func (c *dubboRegistryController) assembleDUBBOLabel(p *v1.Pod) (*v1.Pod, *v1.Pod, error) { From 14a9104c5d0da8976377655cb428cf1f30372b61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:51:36 +0800 Subject: [PATCH 103/148] build(deps): bump github.com/dubbogo/gost from 1.11.16 to 1.11.17 (#1456) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.16 to 1.11.17. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.16...v1.11.17) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c69ad8e210..b01629c986 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/apache/dubbo-go-hessian2 v1.9.3 github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.16 + github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.5 github.com/emicklei/go-restful/v3 v3.5.2 github.com/fsnotify/fsnotify v1.5.1 diff --git a/go.sum b/go.sum index 45c8b8e73f..c8f310d022 100644 --- a/go.sum +++ b/go.sum @@ -150,8 +150,9 @@ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl8 github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.17 h1:Dwaoqv/G21nYsGkeQoLbCAOryRPl6B7pEsZSJcr55nE= +github.com/dubbogo/gost v1.11.17/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.3 h1:2k53mh+1U8h1gFjJ8ykzyP4wNdAdgjc5moD+xVHI/AE= github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= From 415053c46567668260a9e4b1df4653e007369cf4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:52:02 +0800 Subject: [PATCH 104/148] build(deps): bump go.uber.org/zap from 1.17.0 to 1.19.1 (#1455) Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.17.0 to 1.19.1. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.17.0...v1.19.1) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index b01629c986..1d069d5f5a 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( go.etcd.io/etcd/client/v3 v3.5.0 go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 go.uber.org/atomic v1.7.0 - go.uber.org/zap v1.17.0 + go.uber.org/zap v1.19.1 google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.27.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index c8f310d022..c9be29bb8f 100644 --- a/go.sum +++ b/go.sum @@ -72,6 +72,8 @@ github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.30.27/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -721,6 +723,8 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -731,8 +735,9 @@ 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.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -764,6 +769,7 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -773,6 +779,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -922,6 +929,8 @@ golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4X golang.org/x/tools v0.0.0-20201014170642-d1624618ad65/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From b7ce6b8a79f2cc01fe34f59e657b6e238d210272 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 21:25:32 +0800 Subject: [PATCH 105/148] build(deps): bump github.com/mitchellh/mapstructure from 1.4.1 to 1.4.2 (#1472) Bumps [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) from 1.4.1 to 1.4.2. - [Release notes](https://github.com/mitchellh/mapstructure/releases) - [Changelog](https://github.com/mitchellh/mapstructure/blob/master/CHANGELOG.md) - [Commits](https://github.com/mitchellh/mapstructure/compare/v1.4.1...v1.4.2) --- updated-dependencies: - dependency-name: github.com/mitchellh/mapstructure dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1d069d5f5a..40f77c724b 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/hashicorp/vault/sdk v0.2.1 github.com/jinzhu/copier v0.3.2 github.com/magiconair/properties v1.8.5 - github.com/mitchellh/mapstructure v1.4.1 + github.com/mitchellh/mapstructure v1.4.2 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd github.com/nacos-group/nacos-sdk-go v1.0.9 github.com/natefinch/lumberjack v2.0.0+incompatible diff --git a/go.sum b/go.sum index c9be29bb8f..d186eb4a09 100644 --- a/go.sum +++ b/go.sum @@ -466,8 +466,8 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= +github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= From e1a08f062a82c09b73c7aec440b6c623b0796e3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Sep 2021 21:25:59 +0800 Subject: [PATCH 106/148] build(deps): bump github.com/emicklei/go-restful/v3 from 3.5.2 to 3.6.0 (#1471) Bumps [github.com/emicklei/go-restful/v3](https://github.com/emicklei/go-restful) from 3.5.2 to 3.6.0. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v3.5.2...v3.6.0) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 40f77c724b..3ac097a877 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.5 - github.com/emicklei/go-restful/v3 v3.5.2 + github.com/emicklei/go-restful/v3 v3.6.0 github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 diff --git a/go.sum b/go.sum index d186eb4a09..6f6ef9f8fd 100644 --- a/go.sum +++ b/go.sum @@ -172,8 +172,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.5.2 h1:RCNMSbcGIVafG4ZfgIXIEHTaV59ZRsi41IvZ7RC9+ls= -github.com/emicklei/go-restful/v3 v3.5.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.6.0 h1:+gBDnGewng66q4tU1qazyTStluvDc1tYJSiXb8wEoCA= +github.com/emicklei/go-restful/v3 v3.6.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= From e17a87af2ba03ee46e983c7fea72c2e1cd655dab Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Wed, 22 Sep 2021 15:45:38 +0800 Subject: [PATCH 107/148] #1458 delete useless log (#1468) Co-authored-by: dongjianhui03 --- filter/echo/filter.go | 1 - filter/seata/filter.go | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/filter/echo/filter.go b/filter/echo/filter.go index bbdbf2264e..c6b367a37c 100644 --- a/filter/echo/filter.go +++ b/filter/echo/filter.go @@ -43,7 +43,6 @@ type Filter struct{} // Invoke response to the callers with its first argument. func (f *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - logger.Infof("invoking echo filter.") logger.Debugf("%v,%v", invocation.MethodName(), len(invocation.Arguments())) if invocation.MethodName() == constant.ECHO && len(invocation.Arguments()) == 1 { return &protocol.RPCResult{ diff --git a/filter/seata/filter.go b/filter/seata/filter.go index 7f441046e8..61e4aa3b19 100644 --- a/filter/seata/filter.go +++ b/filter/seata/filter.go @@ -43,8 +43,7 @@ func init() { // Filter when use seata-golang, use this filter to transfer xid type Filter struct{} -// When use Seata, transfer xid by attachments -// Invoke Get Xid by attachment key `SEATA_XID` +// Invoke Get Xid by attachment key `SEATA_XID`. When use Seata, transfer xid by attachments func (f *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { logger.Infof("invoking seata filter.") xid := invocation.AttachmentsByKey(string(SEATA_XID), "") From ecd652963ea8163b43a923acba4ef71c7b2d185b Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Fri, 24 Sep 2021 13:19:45 +0800 Subject: [PATCH 108/148] Fix the name mapping incompatibility (#1465) * fix metadata bug * fix metadata bug * fix metadata bug * fix name mapping bug for zk * modify comment * fix path incompatible * fix ci failure * fix ci failure * fix ci failure * fix name mapping bug for nacos * feat: etcd fit service name mapping uncoupling * fix name mapping bug for etcd * fix ci failure Co-authored-by: MasterKenway --- common/constant/key.go | 1 + common/metadata_info.go | 2 +- config/instance/metadata_report_test.go | 13 +++- imports/imports.go | 2 +- .../dynamic/service_name_mapping_test.go | 62 ------------------- .../mapping/memory/service_name_mapping.go | 5 +- .../service_name_mapping.go | 42 ++++++------- metadata/mapping/mock_service_name_mapping.go | 8 ++- metadata/mapping/service_name_mapping.go | 8 ++- metadata/report/etcd/report.go | 33 ++++++++++ metadata/report/etcd/report_test.go | 30 +++++++++ metadata/report/nacos/report.go | 45 ++++++++++++++ metadata/report/report.go | 10 +++ metadata/report/zookeeper/report.go | 35 ++++++++++- .../service/exporter/configurable/exporter.go | 2 +- metadata/service/remote/service_test.go | 13 +++- ...vent_publishing_service_discovery_test.go} | 0 .../event/service_name_mapping_listener.go | 10 +-- .../service_discovery_registry.go | 14 +---- 19 files changed, 217 insertions(+), 118 deletions(-) delete mode 100644 metadata/mapping/dynamic/service_name_mapping_test.go rename metadata/mapping/{dynamic => metadata}/service_name_mapping.go (63%) rename registry/event/{event_publishing_service_deiscovery_test.go => event_publishing_service_discovery_test.go} (100%) diff --git a/common/constant/key.go b/common/constant/key.go index 5a5f9d65af..80d2fe794f 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -49,6 +49,7 @@ const ( PORT_KEY = "port" PROTOCOL_KEY = "protocol" PATH_SEPARATOR = "/" + COMMA_SEPARATOR = "," // DUBBO_KEY = "dubbo" SSL_ENABLED_KEY = "ssl-enabled" // PARAMS_TYPE_Key key used in pass through invoker factory, to define param type diff --git a/common/metadata_info.go b/common/metadata_info.go index e64e72a5fe..9c43f69bef 100644 --- a/common/metadata_info.go +++ b/common/metadata_info.go @@ -187,7 +187,7 @@ func NewServiceInfo(name, group, version, protocol, path string, params map[stri Group: group, Version: version, Protocol: protocol, - Path: path, + Path: strings.TrimPrefix(path, "/"), Params: params, ServiceKey: serviceKey, MatchKey: matchKey, diff --git a/config/instance/metadata_report_test.go b/config/instance/metadata_report_test.go index d665f61b1b..e57f75c698 100644 --- a/config/instance/metadata_report_test.go +++ b/config/instance/metadata_report_test.go @@ -22,6 +22,7 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" "github.com/stretchr/testify/assert" ) @@ -50,11 +51,19 @@ func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.Met type mockMetadataReport struct{} -func (m mockMetadataReport) GetAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) { +func (m mockMetadataReport) RegisterServiceAppMapping(string, string, string) error { panic("implement me") } -func (m mockMetadataReport) PublishAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier, info *common.MetadataInfo) error { +func (m mockMetadataReport) GetServiceAppMapping(string, string) (*gxset.HashSet, error) { + panic("implement me") +} + +func (m mockMetadataReport) GetAppMetadata(*identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) { + panic("implement me") +} + +func (m mockMetadataReport) PublishAppMetadata(*identifier.SubscriberMetadataIdentifier, *common.MetadataInfo) error { panic("implement me") } diff --git a/imports/imports.go b/imports/imports.go index cd346e432f..60f238e982 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -25,7 +25,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" + _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" diff --git a/metadata/mapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go deleted file mode 100644 index 5124b30eb0..0000000000 --- a/metadata/mapping/dynamic/service_name_mapping_test.go +++ /dev/null @@ -1,62 +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 dynamic - -import ( - "testing" -) - -import ( - gxset "github.com/dubbogo/gost/container/set" - - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/config_center" -) - -func TestDynamicConfigurationServiceNameMapping(t *testing.T) { - // mock data - appName := "myApp" - dc, err := (&config_center.MockDynamicConfigurationFactory{ - Content: appName, - }).GetDynamicConfiguration(nil) - assert.NoError(t, err) - config.GetApplicationConfig().Name = appName - - mapping := &DynamicConfigurationServiceNameMapping{dc: dc} - intf := constant.METADATA_SERVICE_NAME - group := "myGroup" - version := "myVersion" - protocol := "myProtocol" - - err = mapping.Map(intf, group, version, protocol) - assert.Nil(t, err) - intf = "MyService" - err = mapping.Map(intf, group, version, protocol) - assert.Nil(t, err) - - var result *gxset.HashSet - result, err = mapping.Get(intf, group, version, protocol) - assert.Nil(t, err) - assert.Equal(t, 1, result.Size()) - assert.True(t, result.Contains(appName)) -} diff --git a/metadata/mapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go index cc104399bc..73b0603ea8 100644 --- a/metadata/mapping/memory/service_name_mapping.go +++ b/metadata/mapping/memory/service_name_mapping.go @@ -26,6 +26,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" @@ -37,11 +38,11 @@ func init() { type InMemoryServiceNameMapping struct{} -func (i *InMemoryServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error { +func (i *InMemoryServiceNameMapping) Map(url *common.URL) error { return nil } -func (i *InMemoryServiceNameMapping) Get(serviceInterface string, group string, version string, protocol string) (*gxset.HashSet, error) { +func (i *InMemoryServiceNameMapping) Get(url *common.URL) (*gxset.HashSet, error) { return gxset.NewSet(config.GetApplicationConfig().Name), nil } diff --git a/metadata/mapping/dynamic/service_name_mapping.go b/metadata/mapping/metadata/service_name_mapping.go similarity index 63% rename from metadata/mapping/dynamic/service_name_mapping.go rename to metadata/mapping/metadata/service_name_mapping.go index 7839e07670..572dda868d 100644 --- a/metadata/mapping/dynamic/service_name_mapping.go +++ b/metadata/mapping/metadata/service_name_mapping.go @@ -15,27 +15,24 @@ * limitations under the License. */ -package dynamic +package metadata import ( - "strconv" "sync" - "time" ) import ( - "github.com/dubbogo/gost/container/set" - + gxset "github.com/dubbogo/gost/container/set" perrors "github.com/pkg/errors" ) import ( - commonCfg "dubbo.apache.org/dubbo-go/v3/common/config" + "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/config" - "dubbo.apache.org/dubbo-go/v3/config_center" + "dubbo.apache.org/dubbo-go/v3/config/instance" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" ) @@ -48,14 +45,14 @@ func init() { extension.SetGlobalServiceNameMapping(GetNameMappingInstance) } -// DynamicConfigurationServiceNameMapping is the implementation based on config center +// MetadataServiceNameMapping is the implementation based on metadata report // it's a singleton -type DynamicConfigurationServiceNameMapping struct { - dc config_center.DynamicConfiguration +type MetadataServiceNameMapping struct { } // Map will map the service to this application-level service -func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error { +func (d *MetadataServiceNameMapping) Map(url *common.URL) error { + serviceInterface := url.GetParam(constant.INTERFACE_KEY, "") // metadata service is admin service, should not be mapped if constant.METADATA_SERVICE_NAME == serviceInterface { logger.Info("try to map the metadata service, will be ignored") @@ -63,11 +60,8 @@ func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, gr } appName := config.GetApplicationConfig().Name - value := time.Now().UnixNano() - - err := d.dc.PublishConfig(appName, - d.buildGroup(serviceInterface), - strconv.FormatInt(value, 10)) + metadataReport := instance.GetMetadataReportInstance() + err := metadataReport.RegisterServiceAppMapping(serviceInterface, defaultGroup, appName) if err != nil { return perrors.WithStack(err) } @@ -75,28 +69,28 @@ func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, gr } // Get will return the application-level services. If not found, the empty set will be returned. -// if the dynamic configuration got error, the error will return -func (d *DynamicConfigurationServiceNameMapping) Get(serviceInterface string, group string, version string, protocol string) (*gxset.HashSet, error) { - return d.dc.GetConfigKeysByGroup(d.buildGroup(serviceInterface)) +func (d *MetadataServiceNameMapping) Get(url *common.URL) (*gxset.HashSet, error) { + serviceInterface := url.GetParam(constant.INTERFACE_KEY, "") + metadataReport := instance.GetMetadataReportInstance() + return metadataReport.GetServiceAppMapping(serviceInterface, defaultGroup) } -// buildGroup will return group, now it looks like defaultGroup/serviceInterface -func (d *DynamicConfigurationServiceNameMapping) buildGroup(serviceInterface string) string { +// buildMappingKey will return mapping key, it looks like defaultGroup/serviceInterface +func (d *MetadataServiceNameMapping) buildMappingKey(serviceInterface string) string { // the issue : https://github.com/apache/dubbo/issues/4671 // so other params are ignored and remove, including group string, version string, protocol string return defaultGroup + slash + serviceInterface } var ( - serviceNameMappingInstance *DynamicConfigurationServiceNameMapping + serviceNameMappingInstance *MetadataServiceNameMapping serviceNameMappingOnce sync.Once ) // GetNameMappingInstance return an instance, if not found, it creates one func GetNameMappingInstance() mapping.ServiceNameMapping { serviceNameMappingOnce.Do(func() { - dc := commonCfg.GetEnvInstance().GetDynamicConfiguration() - serviceNameMappingInstance = &DynamicConfigurationServiceNameMapping{dc: dc} + serviceNameMappingInstance = &MetadataServiceNameMapping{} }) return serviceNameMappingInstance } diff --git a/metadata/mapping/mock_service_name_mapping.go b/metadata/mapping/mock_service_name_mapping.go index 14ee000bab..c3aae3dab9 100644 --- a/metadata/mapping/mock_service_name_mapping.go +++ b/metadata/mapping/mock_service_name_mapping.go @@ -21,16 +21,20 @@ import ( gxset "github.com/dubbogo/gost/container/set" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common" +) + type MockServiceNameMapping struct{} func NewMockServiceNameMapping() *MockServiceNameMapping { return &MockServiceNameMapping{} } -func (m *MockServiceNameMapping) Map(string, string, string, string) error { +func (m *MockServiceNameMapping) Map(*common.URL) error { return nil } -func (m *MockServiceNameMapping) Get(string, string, string, string) (*gxset.HashSet, error) { +func (m *MockServiceNameMapping) Get(*common.URL) (*gxset.HashSet, error) { panic("implement me") } diff --git a/metadata/mapping/service_name_mapping.go b/metadata/mapping/service_name_mapping.go index 6caed9f0b4..75b216fff4 100644 --- a/metadata/mapping/service_name_mapping.go +++ b/metadata/mapping/service_name_mapping.go @@ -21,12 +21,16 @@ import ( gxset "github.com/dubbogo/gost/container/set" ) +import ( + "dubbo.apache.org/dubbo-go/v3/common" +) + // ServiceNameMapping try to build the mapping between application-level service and interface-level service. type ServiceNameMapping interface { // Map will map the service to this application-level service - Map(serviceInterface string, group string, version string, protocol string) error + Map(url *common.URL) error // Get will return the application-level services - Get(serviceInterface string, group string, version string, protocol string) (*gxset.HashSet, error) + Get(url *common.URL) (*gxset.HashSet, error) } diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go index 2d83fa3dde..7741e4b2fd 100644 --- a/metadata/report/etcd/report.go +++ b/metadata/report/etcd/report.go @@ -23,7 +23,9 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3" + perrors "github.com/pkg/errors" ) import ( @@ -141,6 +143,37 @@ func (e *etcdMetadataReport) GetServiceDefinition(metadataIdentifier *identifier return content, nil } +// RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name +func (e *etcdMetadataReport) RegisterServiceAppMapping(key string, group string, value string) error { + path := e.root + constant.PATH_SEPARATOR + group + constant.PATH_SEPARATOR + key + oldVal, err := e.client.Get(path) + if perrors.Cause(err) == gxetcd.ErrKVPairNotFound { + return e.client.Put(path, value) + } else if err != nil { + return err + } + if strings.Contains(oldVal, value) { + return nil + } + value = oldVal + constant.COMMA_SEPARATOR + value + return e.client.Put(path, value) +} + +// GetServiceAppMapping get the app names from the specified Dubbo service interface +func (e *etcdMetadataReport) GetServiceAppMapping(key string, group string) (*gxset.HashSet, error) { + path := e.root + constant.PATH_SEPARATOR + group + constant.PATH_SEPARATOR + key + v, err := e.client.Get(path) + if err != nil { + return nil, err + } + appNames := strings.Split(v, constant.COMMA_SEPARATOR) + set := gxset.NewSet() + for _, app := range appNames { + set.Add(app) + } + return set, nil +} + type etcdMetadataReportFactory struct{} // CreateMetadataReport get the MetadataReport instance of etcd diff --git a/metadata/report/etcd/report_test.go b/metadata/report/etcd/report_test.go index 81eece018e..aed380bf90 100644 --- a/metadata/report/etcd/report_test.go +++ b/metadata/report/etcd/report_test.go @@ -114,6 +114,36 @@ func TestEtcdMetadataReport_CRUD(t *testing.T) { e.Close() } +func TestEtcdMetadataReport_ServiceAppMapping(t *testing.T) { + e := initEtcd(t) + url, err := common.NewURL("registry://127.0.0.1:2379", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + if err != nil { + t.Fatal(err) + } + metadataReportFactory := &etcdMetadataReportFactory{} + metadataReport := metadataReportFactory.CreateMetadataReport(url) + assert.NotNil(t, metadataReport) + + _, err = metadataReport.GetServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping") + assert.NotNil(t, err) + + err = metadataReport.RegisterServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping", "demo_provider") + assert.Nil(t, err) + set, err := metadataReport.GetServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping") + assert.Nil(t, err) + assert.Equal(t, 1, set.Size()) + + err = metadataReport.RegisterServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping", "demo_provider2") + assert.Nil(t, err) + err = metadataReport.RegisterServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping", "demo_provider") + assert.Nil(t, err) + set, err = metadataReport.GetServiceAppMapping("com.apache.dubbo.sample.basic.IGreeter", "mapping") + assert.Nil(t, err) + assert.Equal(t, 2, set.Size()) + + e.Close() +} + func newSubscribeMetadataIdentifier() *identifier.SubscriberMetadataIdentifier { return &identifier.SubscriberMetadataIdentifier{ Revision: "subscribe", diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go index 30f68b81bd..37e17d27ae 100644 --- a/metadata/report/nacos/report.go +++ b/metadata/report/nacos/report.go @@ -20,9 +20,11 @@ package nacos import ( "encoding/json" "net/url" + "strings" ) import ( + gxset "github.com/dubbogo/gost/container/set" nacosClient "github.com/dubbogo/gost/database/kv/nacos" "github.com/nacos-group/nacos-sdk-go/vo" @@ -32,6 +34,7 @@ import ( import ( "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/metadata/identifier" @@ -206,6 +209,48 @@ func (n *nacosMetadataReport) getConfig(param vo.ConfigParam) (string, error) { return cfg, nil } +// RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name +func (n *nacosMetadataReport) RegisterServiceAppMapping(key string, group string, value string) error { + oldVal, err := n.getConfig(vo.ConfigParam{ + DataId: key, + Group: group, + }) + if err != nil { + return err + } + if strings.Contains(oldVal, value) { + return nil + } + if oldVal != "" { + value = oldVal + constant.COMMA_SEPARATOR + value + } + return n.storeMetadata(vo.ConfigParam{ + DataId: key, + Group: group, + Content: value, + }) +} + +// GetServiceAppMapping get the app names from the specified Dubbo service interface +func (n *nacosMetadataReport) GetServiceAppMapping(key string, group string) (*gxset.HashSet, error) { + v, err := n.getConfig(vo.ConfigParam{ + DataId: key, + Group: group, + }) + if err != nil { + return nil, err + } + if v == "" { + return nil, perrors.New("There is no service app mapping data.") + } + appNames := strings.Split(v, constant.COMMA_SEPARATOR) + set := gxset.NewSet() + for _, e := range appNames { + set.Add(e) + } + return set, nil +} + type nacosMetadataReportFactory struct{} // nolint diff --git a/metadata/report/report.go b/metadata/report/report.go index 09c393ebaa..ea748d2285 100644 --- a/metadata/report/report.go +++ b/metadata/report/report.go @@ -17,6 +17,10 @@ package report +import ( + gxset "github.com/dubbogo/gost/container/set" +) + import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/metadata/identifier" @@ -63,4 +67,10 @@ type MetadataReport interface { // PublishAppMetadata publish metadata info to reportss PublishAppMetadata(*identifier.SubscriberMetadataIdentifier, *common.MetadataInfo) error + + // RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name + RegisterServiceAppMapping(string, string, string) error + + // GetServiceAppMapping get the app names from the specified Dubbo service interface + GetServiceAppMapping(string, string) (*gxset.HashSet, error) } diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go index 68220c532d..0e08a19667 100644 --- a/metadata/report/zookeeper/report.go +++ b/metadata/report/zookeeper/report.go @@ -25,7 +25,7 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" - + gxset "github.com/dubbogo/gost/container/set" gxzookeeper "github.com/dubbogo/gost/database/kv/zk" ) @@ -142,6 +142,39 @@ func (m *zookeeperMetadataReport) GetServiceDefinition(metadataIdentifier *ident return string(v), err } +// RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name +func (m *zookeeperMetadataReport) RegisterServiceAppMapping(key string, group string, value string) error { + path := m.rootDir + group + constant.PATH_SEPARATOR + key + v, state, err := m.client.GetContent(path) + if err == zk.ErrNoNode { + return m.client.CreateWithValue(path, []byte(value)) + } else if err != nil { + return err + } + oldValue := string(v) + if strings.Contains(oldValue, value) { + return nil + } + value = oldValue + constant.COMMA_SEPARATOR + value + _, err = m.client.SetContent(path, []byte(value), state.Version) + return err +} + +// GetServiceAppMapping get the app names from the specified Dubbo service interface +func (m *zookeeperMetadataReport) GetServiceAppMapping(key string, group string) (*gxset.HashSet, error) { + path := m.rootDir + group + constant.PATH_SEPARATOR + key + v, _, err := m.client.GetContent(path) + if err != nil { + return nil, err + } + appNames := strings.Split(string(v), constant.COMMA_SEPARATOR) + set := gxset.NewSet() + for _, e := range appNames { + set.Add(e) + } + return set, nil +} + type zookeeperMetadataReportFactory struct{} // nolint diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 50d04850cc..feee9480e4 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -31,7 +31,7 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" - _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/dynamic" + _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata" "dubbo.apache.org/dubbo-go/v3/metadata/service" "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" diff --git a/metadata/service/remote/service_test.go b/metadata/service/remote/service_test.go index 938a860d90..fc463670a4 100644 --- a/metadata/service/remote/service_test.go +++ b/metadata/service/remote/service_test.go @@ -23,6 +23,7 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" "github.com/stretchr/testify/assert" ) @@ -55,11 +56,19 @@ func (mrf *metadataReportFactory) CreateMetadataReport(*common.URL) report.Metad type metadataReport struct{} -func (mr metadataReport) GetAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) { +func (mr metadataReport) RegisterServiceAppMapping(string, string, string) error { panic("implement me") } -func (mr metadataReport) PublishAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier, info *common.MetadataInfo) error { +func (mr metadataReport) GetServiceAppMapping(string, string) (*gxset.HashSet, error) { + panic("implement me") +} + +func (mr metadataReport) GetAppMetadata(*identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) { + panic("implement me") +} + +func (mr metadataReport) PublishAppMetadata(*identifier.SubscriberMetadataIdentifier, *common.MetadataInfo) error { panic("implement me") } diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_discovery_test.go similarity index 100% rename from registry/event/event_publishing_service_deiscovery_test.go rename to registry/event/event_publishing_service_discovery_test.go diff --git a/registry/event/service_name_mapping_listener.go b/registry/event/service_name_mapping_listener.go index e7d979a72f..f2dfaf9132 100644 --- a/registry/event/service_name_mapping_listener.go +++ b/registry/event/service_name_mapping_listener.go @@ -27,7 +27,6 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/observer" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" @@ -55,13 +54,10 @@ func (s *serviceNameMappingListener) OnEvent(e observer.Event) error { sc := ex.ServiceConfig urls := sc.GetExportedUrls() - for _, u := range urls { - err := s.nameMapping.Map(u.GetParam(constant.INTERFACE_KEY, ""), - u.GetParam(constant.GROUP_KEY, ""), - u.GetParam(constant.Version, ""), - u.Protocol) + for _, url := range urls { + err := s.nameMapping.Map(url) if err != nil { - return perrors.WithMessage(err, "could not map the service: "+u.String()) + return perrors.WithMessage(err, "could not map the service: "+url.String()) } } } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 655c8a1b6f..ba66a3f2b0 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -181,10 +181,7 @@ func (s *serviceDiscoveryRegistry) Register(url *common.URL) error { logger.Warnf("The URL[%s] has been registry!", url.String()) } - return s.serviceNameMapping.Map(url.GetParam(constant.INTERFACE_KEY, ""), - url.GetParam(constant.GROUP_KEY, ""), - url.GetParam(constant.Version, ""), - url.Protocol) + return s.serviceNameMapping.Map(url) } func shouldRegister(url *common.URL) bool { @@ -303,14 +300,9 @@ func (s *serviceDiscoveryRegistry) getServices(url *common.URL) *gxset.HashSet { } func (s *serviceDiscoveryRegistry) findMappedServices(url *common.URL) *gxset.HashSet { - serviceInterface := url.GetParam(constant.INTERFACE_KEY, url.Path) - group := url.GetParam(constant.GROUP_KEY, "") - version := url.GetParam(constant.VERSION_KEY, "") - protocol := url.Protocol - serviceNames, err := s.serviceNameMapping.Get(serviceInterface, group, version, protocol) + serviceNames, err := s.serviceNameMapping.Get(url) if err != nil { - logger.Errorf("get serviceInterface:[%s] group:[%s] version:[%s] protocol:[%s] from "+ - "serviceNameMap error:%s", err.Error()) + logger.Errorf("get service names catch error, url:%s, err:%s ", url.String(), err.Error()) return gxset.NewSet() } return serviceNames From 7ed2c82519530b5acd042e4428a521fe4bd771ad Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Fri, 24 Sep 2021 13:25:08 +0800 Subject: [PATCH 109/148] Refactor to remove event dispatcher completely (#1368) * delete event dispatcher * delete event dispatcher * delete todo tag * polish code * lock listener operation --- common/extension/event_dispatcher.go | 75 -------- common/extension/event_dispatcher_test.go | 110 ----------- .../dispatcher/direct_event_dispatcher.go | 69 ------- .../direct_event_dispatcher_test.go | 77 -------- .../dispatcher/mock_event_dispatcher.go | 66 ------- common/observer/event_dispatcher.go | 27 --- common/observer/listenable.go | 142 -------------- common/observer/listenable_test.go | 64 ------- config/config_loader.go | 13 +- config/config_loader_options.go | 23 --- registry/etcdv3/service_discovery.go | 63 ++++--- .../customizable_service_instance_listener.go | 72 ------- ...omizable_service_instance_listener_test.go | 72 ------- ...vent_publishing_service_deiscovery_test.go | 176 ------------------ .../event_publishing_service_discovery.go | 156 ---------------- registry/event/log_event_listener.go | 61 ------ registry/event/log_event_listener_test.go | 32 ---- .../metadata_service_url_params_customizer.go | 3 +- .../protocol_ports_metadata_customizer.go | 3 +- .../event/service_config_exported_event.go | 44 ----- registry/event/service_discovery_event.go | 103 ---------- registry/event/service_instance_event.go | 87 --------- .../event/service_name_mapping_listener.go | 89 --------- registry/event/service_revision_customizer.go | 5 +- registry/file/service_discovery.go | 17 -- registry/nacos/service_discovery.go | 58 +++--- registry/nacos/service_discovery_test.go | 8 - registry/service_discovery.go | 9 - .../service_discovery_registry.go | 41 ++-- .../service_discovery_registry_test.go | 7 - registry/zookeeper/service_discovery.go | 62 +++--- 31 files changed, 158 insertions(+), 1676 deletions(-) delete mode 100644 common/extension/event_dispatcher.go delete mode 100644 common/extension/event_dispatcher_test.go delete mode 100644 common/observer/dispatcher/direct_event_dispatcher.go delete mode 100644 common/observer/dispatcher/direct_event_dispatcher_test.go delete mode 100644 common/observer/dispatcher/mock_event_dispatcher.go delete mode 100644 common/observer/event_dispatcher.go delete mode 100644 common/observer/listenable.go delete mode 100644 common/observer/listenable_test.go delete mode 100644 registry/event/customizable_service_instance_listener.go delete mode 100644 registry/event/customizable_service_instance_listener_test.go delete mode 100644 registry/event/event_publishing_service_deiscovery_test.go delete mode 100644 registry/event/event_publishing_service_discovery.go delete mode 100644 registry/event/log_event_listener.go delete mode 100644 registry/event/log_event_listener_test.go delete mode 100644 registry/event/service_config_exported_event.go delete mode 100644 registry/event/service_discovery_event.go delete mode 100644 registry/event/service_instance_event.go delete mode 100644 registry/event/service_name_mapping_listener.go diff --git a/common/extension/event_dispatcher.go b/common/extension/event_dispatcher.go deleted file mode 100644 index f2f6a6d714..0000000000 --- a/common/extension/event_dispatcher.go +++ /dev/null @@ -1,75 +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 extension - -import ( - "sync" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -var ( - globalEventDispatcher observer.EventDispatcher - initEventListeners []func() observer.EventListener - initEventOnce sync.Once -) - -var dispatchers = make(map[string]func() observer.EventDispatcher, 8) - -// SetEventDispatcher, actually, it doesn't really init the global dispatcher -func SetEventDispatcher(name string, v func() observer.EventDispatcher) { - dispatchers[name] = v -} - -// SetAndInitGlobalDispatcher will actually init the global dispatcher -// if there is already a global dispatcher, -// it will be override -// if the dispatcher with the name not found, it will panic -func SetAndInitGlobalDispatcher(name string) { - if len(name) == 0 { - name = "direct" - } - if globalEventDispatcher != nil { - logger.Warnf("EventDispatcher has been initialized. It will be replaced") - } - - if dp, ok := dispatchers[name]; !ok || dp == nil { - panic("EventDispatcher for " + name + " is not found, make sure you have import the package, " + - "like import _ dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher.") - } - globalEventDispatcher = dispatchers[name]() -} - -// GetGlobalDispatcher will init all listener and then return dispatcher -func GetGlobalDispatcher() observer.EventDispatcher { - initEventOnce.Do(func() { - // we should delay to add the listeners to avoid some listeners left - for _, l := range initEventListeners { - globalEventDispatcher.AddEventListener(l()) - } - }) - return globalEventDispatcher -} - -// AddEventListener it will be added in global event dispatcher -func AddEventListener(creator func() observer.EventListener) { - initEventListeners = append(initEventListeners, creator) -} diff --git a/common/extension/event_dispatcher_test.go b/common/extension/event_dispatcher_test.go deleted file mode 100644 index a6baa86d5d..0000000000 --- a/common/extension/event_dispatcher_test.go +++ /dev/null @@ -1,110 +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 extension - -import ( - "reflect" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -func TestSetAndInitGlobalDispatcher(t *testing.T) { - mock := &mockEventDispatcher{} - SetEventDispatcher("mock", func() observer.EventDispatcher { - return mock - }) - - SetAndInitGlobalDispatcher("mock") - dispatcher := GetGlobalDispatcher() - assert.NotNil(t, dispatcher) - assert.Equal(t, mock, dispatcher) - - mock1 := &mockEventDispatcher{} - - SetEventDispatcher("mock1", func() observer.EventDispatcher { - return mock1 - }) - - SetAndInitGlobalDispatcher("mock1") - dispatcher = GetGlobalDispatcher() - assert.NotNil(t, dispatcher) - assert.Equal(t, mock1, dispatcher) -} - -func TestAddEventListener(t *testing.T) { - AddEventListener(func() observer.EventListener { - return &mockEventListener{} - }) - - AddEventListener(func() observer.EventListener { - return &mockEventListener{} - }) - - assert.Equal(t, 2, len(initEventListeners)) -} - -type mockEventListener struct{} - -func (m mockEventListener) GetPriority() int { - panic("implement me") -} - -func (m mockEventListener) OnEvent(e observer.Event) error { - panic("implement me") -} - -func (m mockEventListener) GetEventType() reflect.Type { - panic("implement me") -} - -type mockEventDispatcher struct{} - -func (m mockEventDispatcher) AddEventListener(listener observer.EventListener) { - panic("implement me") -} - -func (m mockEventDispatcher) AddEventListeners(listenersSlice []observer.EventListener) { - panic("implement me") -} - -func (m mockEventDispatcher) RemoveEventListener(listener observer.EventListener) { - panic("implement me") -} - -func (m mockEventDispatcher) RemoveEventListeners(listenersSlice []observer.EventListener) { - panic("implement me") -} - -func (m mockEventDispatcher) GetAllEventListeners() []observer.EventListener { - panic("implement me") -} - -func (m mockEventDispatcher) RemoveAllEventListeners() { - panic("implement me") -} - -func (m mockEventDispatcher) Dispatch(event observer.Event) { - panic("implement me") -} diff --git a/common/observer/dispatcher/direct_event_dispatcher.go b/common/observer/dispatcher/direct_event_dispatcher.go deleted file mode 100644 index 4fc0a1071b..0000000000 --- a/common/observer/dispatcher/direct_event_dispatcher.go +++ /dev/null @@ -1,69 +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 dispatcher - -import ( - "reflect" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -func init() { - extension.SetEventDispatcher("direct", NewDirectEventDispatcher) -} - -// DirectEventDispatcher is align with DirectEventDispatcher interface in Java. -// it's the top abstraction -// Align with 2.7.5 -// Dispatcher event to listener direct -type DirectEventDispatcher struct { - observer.BaseListener -} - -// NewDirectEventDispatcher ac constructor of DirectEventDispatcher -func NewDirectEventDispatcher() observer.EventDispatcher { - return &DirectEventDispatcher{ - BaseListener: observer.NewBaseListener(), - } -} - -// Dispatch event directly -// it lookup the listener by event's type. -// if listener not found, it just return and do nothing -func (ded *DirectEventDispatcher) Dispatch(event observer.Event) { - if event == nil { - logger.Warnf("[DirectEventDispatcher] dispatch event nil") - return - } - eventType := reflect.TypeOf(event).Elem() - ded.Mutex.RLock() - defer ded.Mutex.RUnlock() - listenersSlice, loaded := ded.ListenersCache[eventType] - if !loaded { - return - } - for _, listener := range listenersSlice { - if err := listener.OnEvent(event); err != nil { - logger.Warnf("[DirectEventDispatcher] dispatch event error:%v", err) - } - } -} diff --git a/common/observer/dispatcher/direct_event_dispatcher_test.go b/common/observer/dispatcher/direct_event_dispatcher_test.go deleted file mode 100644 index ba183a6a3b..0000000000 --- a/common/observer/dispatcher/direct_event_dispatcher_test.go +++ /dev/null @@ -1,77 +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 dispatcher - -import ( - "fmt" - "reflect" - "testing" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -func TestDirectEventDispatcher_Dispatch(t *testing.T) { - ded := NewDirectEventDispatcher() - ded.AddEventListener(&TestEventListener{ - BaseListener: observer.NewBaseListener(), - }) - ded.AddEventListener(&TestEventListener1{}) - ded.Dispatch(&TestEvent{}) - ded.Dispatch(nil) -} - -type TestEvent struct { - observer.BaseEvent -} - -type TestEventListener struct { - observer.BaseListener - observer.EventListener -} - -func (tel *TestEventListener) OnEvent(e observer.Event) error { - fmt.Println("TestEventListener") - return nil -} - -func (tel *TestEventListener) GetPriority() int { - return -1 -} - -func (tel *TestEventListener) GetEventType() reflect.Type { - return reflect.TypeOf(&TestEvent{}) -} - -type TestEventListener1 struct { - observer.EventListener -} - -func (tel *TestEventListener1) OnEvent(e observer.Event) error { - fmt.Println("TestEventListener1") - return nil -} - -func (tel *TestEventListener1) GetPriority() int { - return 1 -} - -func (tel *TestEventListener1) GetEventType() reflect.Type { - return reflect.TypeOf(TestEvent{}) -} diff --git a/common/observer/dispatcher/mock_event_dispatcher.go b/common/observer/dispatcher/mock_event_dispatcher.go deleted file mode 100644 index 1835448e76..0000000000 --- a/common/observer/dispatcher/mock_event_dispatcher.go +++ /dev/null @@ -1,66 +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 dispatcher - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -// MockEventDispatcher will do nothing. -// It is only used by tests -// Now the implementation doing nothing, -// But you can modify this if needed -type MockEventDispatcher struct { - Notify chan struct{} - Event observer.Event -} - -func NewMockEventDispatcher() *MockEventDispatcher { - return &MockEventDispatcher{Notify: make(chan struct{}, 1)} -} - -// AddEventListener do nothing -func (m *MockEventDispatcher) AddEventListener(listener observer.EventListener) { -} - -// AddEventListeners do nothing -func (m *MockEventDispatcher) AddEventListeners(listenersSlice []observer.EventListener) { -} - -// RemoveEventListener do nothing -func (m *MockEventDispatcher) RemoveEventListener(listener observer.EventListener) { -} - -// RemoveEventListeners do nothing -func (m *MockEventDispatcher) RemoveEventListeners(listenersSlice []observer.EventListener) { -} - -// GetAllEventListeners return empty list -func (m *MockEventDispatcher) GetAllEventListeners() []observer.EventListener { - return make([]observer.EventListener, 0) -} - -// RemoveAllEventListeners do nothing -func (m *MockEventDispatcher) RemoveAllEventListeners() { -} - -// Dispatch do nothing -func (m *MockEventDispatcher) Dispatch(event observer.Event) { - m.Event = event - m.Notify <- struct{}{} -} diff --git a/common/observer/event_dispatcher.go b/common/observer/event_dispatcher.go deleted file mode 100644 index 17745e68c0..0000000000 --- a/common/observer/event_dispatcher.go +++ /dev/null @@ -1,27 +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 observer - -// EventDispatcher is align with EventDispatcher interface in Java. -// it's the top abstraction -// Align with 2.7.5 -type EventDispatcher interface { - Listenable - // Dispatch event - Dispatch(event Event) -} diff --git a/common/observer/listenable.go b/common/observer/listenable.go deleted file mode 100644 index bf6ae7219b..0000000000 --- a/common/observer/listenable.go +++ /dev/null @@ -1,142 +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 observer - -import ( - "reflect" - "sort" - "sync" -) - -// Listenable could add and remove the event listener -type Listenable interface { - AddEventListener(listener EventListener) - AddEventListeners(listenersSlice []EventListener) - RemoveEventListener(listener EventListener) - RemoveEventListeners(listenersSlice []EventListener) - GetAllEventListeners() []EventListener - RemoveAllEventListeners() -} - -// BaseListener base listenable -type BaseListener struct { - Listenable - ListenersCache map[reflect.Type][]EventListener - Mutex sync.RWMutex -} - -// NewBaseListener a constructor of base listenable -func NewBaseListener() BaseListener { - return BaseListener{ - ListenersCache: make(map[reflect.Type][]EventListener, 8), - } -} - -// AddEventListener add event listener -func (bl *BaseListener) AddEventListener(listener EventListener) { - eventType := listener.GetEventType() - if eventType.Kind() == reflect.Ptr { - eventType = eventType.Elem() - } - bl.Mutex.Lock() - defer bl.Mutex.Unlock() - listenersSlice, loaded := bl.ListenersCache[eventType] - if !loaded { - listenersSlice = make([]EventListener, 0, 8) - } - // return if listenersSlice already has this listener - if loaded && containListener(listenersSlice, listener) { - return - } - listenersSlice = append(listenersSlice, listener) - sort.Slice(listenersSlice, func(i, j int) bool { - return listenersSlice[i].GetPriority() < listenersSlice[j].GetPriority() - }) - bl.ListenersCache[eventType] = listenersSlice -} - -// AddEventListeners add the slice of event listener -func (bl *BaseListener) AddEventListeners(listenersSlice []EventListener) { - for _, listener := range listenersSlice { - bl.AddEventListener(listener) - } -} - -// RemoveEventListener remove the event listener -func (bl *BaseListener) RemoveEventListener(listener EventListener) { - eventType := listener.GetEventType() - if eventType.Kind() == reflect.Ptr { - eventType = eventType.Elem() - } - bl.Mutex.Lock() - defer bl.Mutex.Unlock() - listenersSlice, loaded := bl.ListenersCache[eventType] - if !loaded { - return - } - for i, l := range listenersSlice { - if l == listener { - listenersSlice = append(listenersSlice[:i], listenersSlice[i+1:]...) - } - } - bl.ListenersCache[eventType] = listenersSlice -} - -// RemoveEventListeners remove the slice of event listener -// it will iterate all listener and remove it one by one -func (bl *BaseListener) RemoveEventListeners(listenersSlice []EventListener) { - for _, listener := range listenersSlice { - bl.RemoveEventListener(listener) - } -} - -// RemoveAllEventListeners remove all -// using Lock -func (bl *BaseListener) RemoveAllEventListeners() { - bl.Mutex.Lock() - defer bl.Mutex.Unlock() - bl.ListenersCache = make(map[reflect.Type][]EventListener, 8) -} - -// GetAllEventListeners get all listener -// using RLock -func (bl *BaseListener) GetAllEventListeners() []EventListener { - allListenersSlice := make([]EventListener, 0, 16) - - bl.Mutex.RLock() - defer bl.Mutex.RUnlock() - for _, listenersSlice := range bl.ListenersCache { - allListenersSlice = append(allListenersSlice, listenersSlice...) - } - sort.Slice(allListenersSlice, func(i, j int) bool { - return allListenersSlice[i].GetPriority() < allListenersSlice[j].GetPriority() - }) - return allListenersSlice -} - -// containListener true if contain listener -// it's not thread safe -// usually it should be use in lock scope -func containListener(listenersSlice []EventListener, listener EventListener) bool { - for _, loadListener := range listenersSlice { - if loadListener == listener { - return true - } - } - return false -} diff --git a/common/observer/listenable_test.go b/common/observer/listenable_test.go deleted file mode 100644 index 3ae6e5eb30..0000000000 --- a/common/observer/listenable_test.go +++ /dev/null @@ -1,64 +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 observer - -import ( - "reflect" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestListenable(t *testing.T) { - el := &TestEventListener{} - bl := NewBaseListener() - b := &bl - b.AddEventListener(el) - b.AddEventListener(el) - al := b.GetAllEventListeners() - assert.Equal(t, len(al), 1) - assert.Equal(t, al[0].GetEventType(), reflect.TypeOf(TestEvent{})) - b.RemoveEventListener(el) - assert.Equal(t, len(b.GetAllEventListeners()), 0) - var ts []EventListener - ts = append(ts, el) - b.AddEventListeners(ts) - assert.Equal(t, len(al), 1) -} - -type TestEvent struct { - BaseEvent -} - -type TestEventListener struct { - EventListener -} - -func (tel *TestEventListener) OnEvent(e Event) error { - return nil -} - -func (tel *TestEventListener) GetPriority() int { - return -1 -} - -func (tel *TestEventListener) GetEventType() reflect.Type { - return reflect.TypeOf(TestEvent{}) -} diff --git a/config/config_loader.go b/config/config_loader.go index a87abf4aa5..cd4f171597 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -38,7 +38,6 @@ import ( "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/common/observer/dispatcher" "dubbo.apache.org/dubbo-go/v3/common/yaml" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -90,7 +89,7 @@ func DefaultInit() []LoaderInitOption { if confRouterFile == "" { confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH } - return []LoaderInitOption{RouterInitOption(confRouterFile), BaseInitOption(""), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} + return []LoaderInitOption{RouterInitOption(confRouterFile), ConsumerInitOption(confConFile), ProviderInitOption(confProFile)} } // setDefaultValue set default value for providerConfig or consumerConfig if it is null @@ -325,7 +324,7 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) { metadata := make(map[string]string, 8) metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType - return ®istry.DefaultServiceInstance{ + instance := ®istry.DefaultServiceInstance{ ServiceName: appConfig.Name, Host: host, Port: int(port), @@ -333,7 +332,13 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) { Enable: true, Healthy: true, Metadata: metadata, - }, nil + } + + for _, cus := range extension.GetCustomizers() { + cus.Customize(instance) + } + + return instance, nil } // selectMetadataServiceExportedURL get already be exported url diff --git a/config/config_loader_options.go b/config/config_loader_options.go index bc8aff1a17..f519bec69b 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -21,10 +21,6 @@ import ( "log" ) -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" -) - type LoaderInitOption interface { init() apply() @@ -117,22 +113,3 @@ func RouterInitOption(crf string) LoaderInitOption { }, } } - -func BaseInitOption(cbf string) LoaderInitOption { - return &optionFunc{ - func() { - if cbf == "" { - return - } - confBaseFile = cbf - if err := BaseInit(cbf); err != nil { - log.Printf("[BaseInit] %#v", err) - baseConfig = nil - } - }, - func() { - // init the global event dispatcher - extension.SetAndInitGlobalDispatcher(GetBaseConfig().EventDispatcherType) - }, - } -} diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index 85679f25cd..a081917e7d 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -65,7 +65,8 @@ type etcdV3ServiceDiscovery struct { // services is when register or update will add service name services *gxset.HashSet // child listener - childListenerMap map[string]*etcdv3.EventListener + childListenerMap map[string]*etcdv3.EventListener + instanceListenerMap map[string]*gxset.HashSet } // basic information of this instance @@ -217,28 +218,16 @@ func (e *etcdV3ServiceDiscovery) GetRequestInstances(serviceNames []string, offs // see addServiceInstancesChangedListener in Java func (e *etcdV3ServiceDiscovery) AddListener(listener registry.ServiceInstancesChangedListener) error { for _, t := range listener.GetServiceNames().Values() { - serviceName := t.(string) - err := e.registerSreviceWatcher(serviceName) + err := e.registerServiceInstanceListener(t.(string), listener) if err != nil { return err } - } - return nil -} -// DispatchEventByServiceName dispatches the ServiceInstancesChangedEvent to service instance whose name is serviceName -func (e *etcdV3ServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - return e.DispatchEventForInstances(serviceName, e.GetInstances(serviceName)) -} - -// DispatchEventForInstances dispatches the ServiceInstancesChangedEvent to target instances -func (e *etcdV3ServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - return e.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) -} - -// DispatchEvent dispatches the event -func (e *etcdV3ServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - extension.GetGlobalDispatcher().Dispatch(event) + err = e.registerServiceWatcher(t.(string)) + if err != nil { + return err + } + } return nil } @@ -256,8 +245,24 @@ func toParentPath(serviceName string) string { return ROOT + constant.PATH_SEPARATOR + serviceName } +// register service instance listener, instance listener and watcher are matched through serviceName +func (e *etcdV3ServiceDiscovery) registerServiceInstanceListener(serviceName string, listener registry.ServiceInstancesChangedListener) error { + initLock.Lock() + defer initLock.Unlock() + + set, found := e.instanceListenerMap[serviceName] + if !found { + set = gxset.NewSet(listener) + set.Add(listener) + e.instanceListenerMap[serviceName] = set + return nil + } + set.Add(listener) + return nil +} + // register service watcher -func (e *etcdV3ServiceDiscovery) registerSreviceWatcher(serviceName string) error { +func (e *etcdV3ServiceDiscovery) registerServiceWatcher(serviceName string) error { initLock.Lock() defer initLock.Unlock() @@ -284,7 +289,15 @@ func (e *etcdV3ServiceDiscovery) DataChange(eventType remoting.Event) bool { instance.ServiceName = "" } - if err := e.DispatchEventByServiceName(instance.ServiceName); err != nil { + // notify instance listener instance change + name := instance.ServiceName + instances := e.GetInstances(name) + for _, lis := range e.instanceListenerMap[instance.ServiceName].Values() { + var instanceLis registry.ServiceInstancesChangedListener + instanceLis = lis.(registry.ServiceInstancesChangedListener) + err = instanceLis.OnEvent(registry.NewServiceInstancesChangedEvent(name, instances)) + } + if err != nil { return false } } @@ -324,5 +337,11 @@ func newEtcdV3ServiceDiscovery(name string) (registry.ServiceDiscovery, error) { descriptor := fmt.Sprintf("etcd-service-discovery[%s]", remoteConfig.Address) - return &etcdV3ServiceDiscovery{descriptor, client, nil, gxset.NewSet(), make(map[string]*etcdv3.EventListener)}, nil + return &etcdV3ServiceDiscovery{ + descriptor, + client, + nil, + gxset.NewSet(), + make(map[string]*etcdv3.EventListener), + make(map[string]*gxset.HashSet)}, nil } diff --git a/registry/event/customizable_service_instance_listener.go b/registry/event/customizable_service_instance_listener.go deleted file mode 100644 index e38199ffce..0000000000 --- a/registry/event/customizable_service_instance_listener.go +++ /dev/null @@ -1,72 +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 event - -import ( - "reflect" - "sync" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -func init() { - extension.AddEventListener(GetCustomizableServiceInstanceListener) -} - -// customizableServiceInstanceListener is singleton -type customizableServiceInstanceListener struct{} - -// GetPriority return priority 9999, -// 9999 is big enough to make sure it will be last invoked -func (c *customizableServiceInstanceListener) GetPriority() int { - return 9999 -} - -// OnEvent if the event is ServiceInstancePreRegisteredEvent -// it will iterate all ServiceInstanceCustomizer instances -// or it will do nothing -func (c *customizableServiceInstanceListener) OnEvent(e observer.Event) error { - if preRegEvent, ok := e.(*ServiceInstancePreRegisteredEvent); ok { - for _, cus := range extension.GetCustomizers() { - cus.Customize(preRegEvent.serviceInstance) - } - } - return nil -} - -// GetEventType will return ServiceInstancePreRegisteredEvent -func (c *customizableServiceInstanceListener) GetEventType() reflect.Type { - return reflect.TypeOf(&ServiceInstancePreRegisteredEvent{}) -} - -var ( - customizableServiceInstanceListenerInstance *customizableServiceInstanceListener - customizableServiceInstanceListenerOnce sync.Once -) - -// GetCustomizableServiceInstanceListener returns an instance -// if the instance was not initialized, we create one -func GetCustomizableServiceInstanceListener() observer.EventListener { - customizableServiceInstanceListenerOnce.Do(func() { - customizableServiceInstanceListenerInstance = &customizableServiceInstanceListener{} - }) - return customizableServiceInstanceListenerInstance -} diff --git a/registry/event/customizable_service_instance_listener_test.go b/registry/event/customizable_service_instance_listener_test.go deleted file mode 100644 index 963f0aaa2b..0000000000 --- a/registry/event/customizable_service_instance_listener_test.go +++ /dev/null @@ -1,72 +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 event - -import ( - "testing" - "time" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -func TestGetCustomizableServiceInstanceListener(t *testing.T) { - - cus := GetCustomizableServiceInstanceListener() - - assert.Equal(t, 9999, cus.GetPriority()) - - extension.AddCustomizers(&mockCustomizer{}) - - err := cus.OnEvent(&mockEvent{}) - assert.Nil(t, err) - err = cus.OnEvent(NewServiceInstancePreRegisteredEvent("hello", createInstance())) - assert.Nil(t, err) - - tp := cus.GetEventType() - assert.NotNil(t, tp) -} - -type mockEvent struct{} - -func (m *mockEvent) String() string { - panic("implement me") -} - -func (m *mockEvent) GetSource() interface{} { - panic("implement me") -} - -func (m *mockEvent) GetTimestamp() time.Time { - panic("implement me") -} - -type mockCustomizer struct{} - -func (m *mockCustomizer) GetPriority() int { - return 0 -} - -func (m *mockCustomizer) Customize(instance registry.ServiceInstance) { -} diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go deleted file mode 100644 index 13983b1188..0000000000 --- a/registry/event/event_publishing_service_deiscovery_test.go +++ /dev/null @@ -1,176 +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 event - -import ( - "reflect" - "testing" -) - -import ( - gxset "github.com/dubbogo/gost/container/set" - gxpage "github.com/dubbogo/gost/hash/page" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" - "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/metadata/mapping" - _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -func TestEventPublishingServiceDiscovery_DispatchEvent(t *testing.T) { - // extension.SetMetadataService("local", local.NewMetadataService) - - config.GetApplicationConfig().MetadataType = "local" - - extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { - return mapping.NewMockServiceNameMapping() - }) - - dc := NewEventPublishingServiceDiscovery(&ServiceDiscoveryA{}) - tsd := &TestServiceDiscoveryDestroyingEventListener{ - BaseListener: observer.NewBaseListener(), - } - tsd.SetT(t) - tsi := &TestServiceInstancePreRegisteredEventListener{} - tsi.SetT(t) - extension.AddEventListener(func() observer.EventListener { - return tsd - }) - extension.AddEventListener(func() observer.EventListener { - return tsi - }) - extension.SetEventDispatcher("direct", dispatcher.NewDirectEventDispatcher) - extension.SetAndInitGlobalDispatcher("direct") - err := dc.Destroy() - assert.Nil(t, err) - si := ®istry.DefaultServiceInstance{ID: "testServiceInstance"} - err = dc.Register(si) - assert.Nil(t, err) -} - -type TestServiceDiscoveryDestroyingEventListener struct { - suite.Suite - observer.BaseListener -} - -func (tel *TestServiceDiscoveryDestroyingEventListener) OnEvent(e observer.Event) error { - e1, ok := e.(*ServiceDiscoveryDestroyingEvent) - assert.Equal(tel.T(), ok, true) - assert.Equal(tel.T(), "testServiceDiscovery", e1.GetOriginal().String()) - assert.Equal(tel.T(), "testServiceDiscovery", e1.GetServiceDiscovery().String()) - return nil -} - -func (tel *TestServiceDiscoveryDestroyingEventListener) GetPriority() int { - return -1 -} - -func (tel *TestServiceDiscoveryDestroyingEventListener) GetEventType() reflect.Type { - return reflect.TypeOf(ServiceDiscoveryDestroyingEvent{}) -} - -type TestServiceInstancePreRegisteredEventListener struct { - suite.Suite - observer.BaseListener -} - -func (tel *TestServiceInstancePreRegisteredEventListener) OnEvent(e observer.Event) error { - e1, ok := e.(*ServiceInstancePreRegisteredEvent) - assert.Equal(tel.T(), ok, true) - assert.Equal(tel.T(), "testServiceInstance", e1.getServiceInstance().GetID()) - return nil -} - -func (tel *TestServiceInstancePreRegisteredEventListener) GetPriority() int { - return -1 -} - -func (tel *TestServiceInstancePreRegisteredEventListener) GetEventType() reflect.Type { - return reflect.TypeOf(ServiceInstancePreRegisteredEvent{}) -} - -type ServiceDiscoveryA struct{} - -// String return mockServiceDiscovery -func (msd *ServiceDiscoveryA) String() string { - return "testServiceDiscovery" -} - -// Destroy do nothing -func (msd *ServiceDiscoveryA) Destroy() error { - return nil -} - -func (msd *ServiceDiscoveryA) Register(instance registry.ServiceInstance) error { - return nil -} - -func (msd *ServiceDiscoveryA) Update(instance registry.ServiceInstance) error { - return nil -} - -func (msd *ServiceDiscoveryA) Unregister(instance registry.ServiceInstance) error { - return nil -} - -func (msd *ServiceDiscoveryA) GetDefaultPageSize() int { - return 1 -} - -func (msd *ServiceDiscoveryA) GetServices() *gxset.HashSet { - return nil -} - -func (msd *ServiceDiscoveryA) GetInstances(serviceName string) []registry.ServiceInstance { - return nil -} - -func (msd *ServiceDiscoveryA) GetInstancesByPage(serviceName string, offset int, pageSize int) gxpage.Pager { - return nil -} - -func (msd *ServiceDiscoveryA) GetHealthyInstancesByPage(serviceName string, offset int, pageSize int, healthy bool) gxpage.Pager { - return nil -} - -func (msd *ServiceDiscoveryA) GetRequestInstances(serviceNames []string, offset int, requestedSize int) map[string]gxpage.Pager { - return nil -} - -func (msd *ServiceDiscoveryA) AddListener(listener registry.ServiceInstancesChangedListener) error { - return nil -} - -func (msd *ServiceDiscoveryA) DispatchEventByServiceName(serviceName string) error { - return nil -} - -func (msd *ServiceDiscoveryA) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - return nil -} - -func (msd *ServiceDiscoveryA) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - return nil -} diff --git a/registry/event/event_publishing_service_discovery.go b/registry/event/event_publishing_service_discovery.go deleted file mode 100644 index b360dab8e9..0000000000 --- a/registry/event/event_publishing_service_discovery.go +++ /dev/null @@ -1,156 +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 event - -import ( - gxset "github.com/dubbogo/gost/container/set" - gxpage "github.com/dubbogo/gost/hash/page" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/metadata/service" - "dubbo.apache.org/dubbo-go/v3/metadata/service/local" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -// EventPublishingServiceDiscovery will enhance Service Discovery -// Publish some event about service discovery -type EventPublishingServiceDiscovery struct { - serviceDiscovery registry.ServiceDiscovery -} - -// NewEventPublishingServiceDiscovery is a constructor -func NewEventPublishingServiceDiscovery(serviceDiscovery registry.ServiceDiscovery) *EventPublishingServiceDiscovery { - return &EventPublishingServiceDiscovery{ - serviceDiscovery: serviceDiscovery, - } -} - -// String returns serviceDiscovery.String() -func (epsd *EventPublishingServiceDiscovery) String() string { - return epsd.serviceDiscovery.String() -} - -// Destroy delegate function -func (epsd *EventPublishingServiceDiscovery) Destroy() error { - f := func() error { - return epsd.serviceDiscovery.Destroy() - } - return epsd.executeWithEvents(NewServiceDiscoveryDestroyingEvent(epsd, epsd.serviceDiscovery), - f, NewServiceDiscoveryDestroyedEvent(epsd, epsd.serviceDiscovery)) -} - -// Register delegate function -func (epsd *EventPublishingServiceDiscovery) Register(instance registry.ServiceInstance) error { - f := func() error { - return epsd.serviceDiscovery.Register(instance) - } - return epsd.executeWithEvents(NewServiceInstancePreRegisteredEvent(epsd.serviceDiscovery, instance), - f, NewServiceInstanceRegisteredEvent(epsd.serviceDiscovery, instance)) -} - -// Update returns the result of serviceDiscovery.Update -func (epsd *EventPublishingServiceDiscovery) Update(instance registry.ServiceInstance) error { - f := func() error { - return epsd.serviceDiscovery.Update(instance) - } - return epsd.executeWithEvents(nil, f, nil) -} - -// Unregister unregister the instance and drop ServiceInstancePreUnregisteredEvent and ServiceInstanceUnregisteredEvent -func (epsd *EventPublishingServiceDiscovery) Unregister(instance registry.ServiceInstance) error { - f := func() error { - return epsd.serviceDiscovery.Unregister(instance) - } - return epsd.executeWithEvents(NewServiceInstancePreUnregisteredEvent(epsd.serviceDiscovery, instance), - f, NewServiceInstanceUnregisteredEvent(epsd.serviceDiscovery, instance)) -} - -// GetDefaultPageSize returns the result of serviceDiscovery.GetDefaultPageSize -func (epsd *EventPublishingServiceDiscovery) GetDefaultPageSize() int { - return epsd.serviceDiscovery.GetDefaultPageSize() -} - -// GetServices returns the result of serviceDiscovery.GetServices -func (epsd *EventPublishingServiceDiscovery) GetServices() *gxset.HashSet { - return epsd.serviceDiscovery.GetServices() -} - -// GetInstances returns the result of serviceDiscovery.GetInstances -func (epsd *EventPublishingServiceDiscovery) GetInstances(serviceName string) []registry.ServiceInstance { - return epsd.serviceDiscovery.GetInstances(serviceName) -} - -// GetInstancesByPage returns the result of serviceDiscovery.GetInstancesByPage -func (epsd *EventPublishingServiceDiscovery) GetInstancesByPage(serviceName string, offset int, pageSize int) gxpage.Pager { - return epsd.serviceDiscovery.GetInstancesByPage(serviceName, offset, pageSize) -} - -// GetHealthyInstancesByPage returns the result of serviceDiscovery.GetHealthyInstancesByPage -func (epsd *EventPublishingServiceDiscovery) GetHealthyInstancesByPage(serviceName string, offset int, pageSize int, healthy bool) gxpage.Pager { - return epsd.serviceDiscovery.GetHealthyInstancesByPage(serviceName, offset, pageSize, healthy) -} - -// GetRequestInstances returns result from serviceDiscovery.GetRequestInstances -func (epsd *EventPublishingServiceDiscovery) GetRequestInstances(serviceNames []string, offset int, requestedSize int) map[string]gxpage.Pager { - return epsd.serviceDiscovery.GetRequestInstances(serviceNames, offset, requestedSize) -} - -// AddListener add event listener -func (epsd *EventPublishingServiceDiscovery) AddListener(listener registry.ServiceInstancesChangedListener) error { - extension.GetGlobalDispatcher().AddEventListener(listener) - return epsd.serviceDiscovery.AddListener(listener) -} - -// DispatchEventByServiceName pass serviceName to serviceDiscovery -func (epsd *EventPublishingServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - return epsd.serviceDiscovery.DispatchEventByServiceName(serviceName) -} - -// DispatchEventForInstances pass params to serviceDiscovery -func (epsd *EventPublishingServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - return epsd.serviceDiscovery.DispatchEventForInstances(serviceName, instances) -} - -// DispatchEvent pass the event to serviceDiscovery -func (epsd *EventPublishingServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - return epsd.serviceDiscovery.DispatchEvent(event) -} - -// executeWithEvents dispatch before event and after event if return error will dispatch exception event -func (epsd *EventPublishingServiceDiscovery) executeWithEvents(beforeEvent observer.Event, f func() error, afterEvent observer.Event) error { - globalDispatcher := extension.GetGlobalDispatcher() - if beforeEvent != nil { - globalDispatcher.Dispatch(beforeEvent) - } - if err := f(); err != nil { - globalDispatcher.Dispatch(NewServiceDiscoveryExceptionEvent(epsd, epsd.serviceDiscovery, err)) - return err - } - if afterEvent != nil { - globalDispatcher.Dispatch(afterEvent) - } - return nil -} - -// getMetadataService returns metadata service instance -func getMetadataService() (service.MetadataService, error) { - return local.GetLocalMetadataService() -} diff --git a/registry/event/log_event_listener.go b/registry/event/log_event_listener.go deleted file mode 100644 index 9ccfcdc5b4..0000000000 --- a/registry/event/log_event_listener.go +++ /dev/null @@ -1,61 +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 event - -import ( - "reflect" - "sync" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/logger" - "dubbo.apache.org/dubbo-go/v3/common/observer" -) - -func init() { - extension.AddEventListener(GetLogEventListener) -} - -// logEventListener is singleton -type logEventListener struct{} - -func (l *logEventListener) GetPriority() int { - return 0 -} - -func (l *logEventListener) OnEvent(e observer.Event) error { - logger.Info("Event happen: " + e.String()) - return nil -} - -func (l *logEventListener) GetEventType() reflect.Type { - return reflect.TypeOf(&observer.BaseEvent{}) -} - -var ( - logEventListenerInstance *logEventListener - logEventListenerOnce sync.Once -) - -func GetLogEventListener() observer.EventListener { - logEventListenerOnce.Do(func() { - logEventListenerInstance = &logEventListener{} - }) - return logEventListenerInstance -} diff --git a/registry/event/log_event_listener_test.go b/registry/event/log_event_listener_test.go deleted file mode 100644 index 3136564687..0000000000 --- a/registry/event/log_event_listener_test.go +++ /dev/null @@ -1,32 +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 event - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -func TestLogEventListener(t *testing.T) { - l := &logEventListener{} - assert.Equal(t, 0, l.GetPriority()) - assert.Nil(t, l.OnEvent(&ServiceDiscoveryDestroyedEvent{})) -} diff --git a/registry/event/metadata_service_url_params_customizer.go b/registry/event/metadata_service_url_params_customizer.go index bfe7fb7f85..53e79b44e2 100644 --- a/registry/event/metadata_service_url_params_customizer.go +++ b/registry/event/metadata_service_url_params_customizer.go @@ -30,6 +30,7 @@ import ( "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/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -54,7 +55,7 @@ func (m *metadataServiceURLParamsMetadataCustomizer) GetPriority() int { } func (m *metadataServiceURLParamsMetadataCustomizer) Customize(instance registry.ServiceInstance) { - ms, err := getMetadataService() + ms, err := local.GetLocalMetadataService() if err != nil { logger.Errorf("could not find the metadata service", err) return diff --git a/registry/event/protocol_ports_metadata_customizer.go b/registry/event/protocol_ports_metadata_customizer.go index 5a6e9ca337..058c0b9f27 100644 --- a/registry/event/protocol_ports_metadata_customizer.go +++ b/registry/event/protocol_ports_metadata_customizer.go @@ -26,6 +26,7 @@ import ( "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/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -44,7 +45,7 @@ func (p *ProtocolPortsMetadataCustomizer) GetPriority() int { // Customize put the the string like [{"protocol": "dubbo", "port": 123}] into instance's metadata func (p *ProtocolPortsMetadataCustomizer) Customize(instance registry.ServiceInstance) { - metadataService, err := getMetadataService() + metadataService, err := local.GetLocalMetadataService() if err != nil { logger.Errorf("Could not init the MetadataService", err) return diff --git a/registry/event/service_config_exported_event.go b/registry/event/service_config_exported_event.go deleted file mode 100644 index af566e3b28..0000000000 --- a/registry/event/service_config_exported_event.go +++ /dev/null @@ -1,44 +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 event - -import ( - "time" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/config" -) - -// ServiceConfigExportedEvent represents an service was exported -type ServiceConfigExportedEvent struct { - observer.BaseEvent - ServiceConfig *config.ServiceConfig -} - -// NewServiceConfigExportedEvent create an instance -func NewServiceConfigExportedEvent(serviceConfig *config.ServiceConfig) *ServiceConfigExportedEvent { - return &ServiceConfigExportedEvent{ - BaseEvent: observer.BaseEvent{ - Source: serviceConfig, - Timestamp: time.Now(), - }, - ServiceConfig: serviceConfig, - } -} diff --git a/registry/event/service_discovery_event.go b/registry/event/service_discovery_event.go deleted file mode 100644 index 823529413c..0000000000 --- a/registry/event/service_discovery_event.go +++ /dev/null @@ -1,103 +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 event - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -// ServiceDiscoveryEvent means that something happens to service discovery instance -type ServiceDiscoveryEvent struct { - observer.BaseEvent - original registry.ServiceDiscovery -} - -// NewServiceDiscoveryEvent returns an instance -func NewServiceDiscoveryEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery) *ServiceDiscoveryEvent { - return &ServiceDiscoveryEvent{ - BaseEvent: *observer.NewBaseEvent(discovery), - original: original, - } -} - -// GetServiceDiscovery returns the event source -func (sde *ServiceDiscoveryEvent) GetServiceDiscovery() registry.ServiceDiscovery { - return sde.GetSource().(registry.ServiceDiscovery) -} - -// GetOriginal actually I think we can remove this method. -func (sde *ServiceDiscoveryEvent) GetOriginal() registry.ServiceDiscovery { - return sde.original -} - -// ServiceDiscoveryDestroyingEvent -// this event will be dispatched before service discovery be destroyed -type ServiceDiscoveryDestroyingEvent struct { - ServiceDiscoveryEvent -} - -// ServiceDiscoveryExceptionEvent -// this event will be dispatched when the error occur in service discovery -type ServiceDiscoveryExceptionEvent struct { - ServiceDiscoveryEvent - err error -} - -// ServiceDiscoveryInitializedEvent -// this event will be dispatched after service discovery initialize -type ServiceDiscoveryInitializedEvent struct { - ServiceDiscoveryEvent -} - -// ServiceDiscoveryInitializingEvent -// this event will be dispatched before service discovery initialize -type ServiceDiscoveryInitializingEvent struct { - ServiceDiscoveryEvent -} - -// ServiceDiscoveryDestroyedEvent -// this event will be dispatched after service discovery be destroyed -type ServiceDiscoveryDestroyedEvent struct { - ServiceDiscoveryEvent -} - -// NewServiceDiscoveryDestroyingEvent create a ServiceDiscoveryDestroyingEvent -func NewServiceDiscoveryDestroyingEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery) *ServiceDiscoveryDestroyingEvent { - return &ServiceDiscoveryDestroyingEvent{*NewServiceDiscoveryEvent(discovery, original)} -} - -// NewServiceDiscoveryExceptionEvent create a ServiceDiscoveryExceptionEvent -func NewServiceDiscoveryExceptionEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery, err error) *ServiceDiscoveryExceptionEvent { - return &ServiceDiscoveryExceptionEvent{*NewServiceDiscoveryEvent(discovery, original), err} -} - -// NewServiceDiscoveryInitializedEvent create a ServiceDiscoveryInitializedEvent -func NewServiceDiscoveryInitializedEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery) *ServiceDiscoveryInitializedEvent { - return &ServiceDiscoveryInitializedEvent{*NewServiceDiscoveryEvent(discovery, original)} -} - -// NewServiceDiscoveryInitializingEvent create a ServiceDiscoveryInitializingEvent -func NewServiceDiscoveryInitializingEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery) *ServiceDiscoveryInitializingEvent { - return &ServiceDiscoveryInitializingEvent{*NewServiceDiscoveryEvent(discovery, original)} -} - -// NewServiceDiscoveryDestroyedEvent create a ServiceDiscoveryDestroyedEvent -func NewServiceDiscoveryDestroyedEvent(discovery registry.ServiceDiscovery, original registry.ServiceDiscovery) *ServiceDiscoveryDestroyedEvent { - return &ServiceDiscoveryDestroyedEvent{*NewServiceDiscoveryEvent(discovery, original)} -} diff --git a/registry/event/service_instance_event.go b/registry/event/service_instance_event.go deleted file mode 100644 index bac8029572..0000000000 --- a/registry/event/service_instance_event.go +++ /dev/null @@ -1,87 +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 event - -import ( - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/registry" -) - -// ServiceInstanceEvent means something happen to this ServiceInstance -// like register this service instance -type ServiceInstanceEvent struct { - observer.BaseEvent - serviceInstance registry.ServiceInstance -} - -// NewServiceInstanceEvent create a ServiceInstanceEvent -func NewServiceInstanceEvent(source interface{}, instance registry.ServiceInstance) *ServiceInstanceEvent { - return &ServiceInstanceEvent{ - BaseEvent: *observer.NewBaseEvent(source), - serviceInstance: instance, - } -} - -// getServiceInstance return the service instance -func (sie *ServiceInstanceEvent) getServiceInstance() registry.ServiceInstance { - return sie.serviceInstance -} - -// ServiceInstancePreRegisteredEvent -// this event will be dispatched before service instance be registered -type ServiceInstancePreRegisteredEvent struct { - ServiceInstanceEvent -} - -// ServiceInstancePreUnregisteredEvent -// this event will be dispatched before service instance be unregistered -type ServiceInstancePreUnregisteredEvent struct { - ServiceInstanceEvent -} - -// ServiceInstanceRegisteredEvent -// this event will be dispatched after service instance be registered -type ServiceInstanceRegisteredEvent struct { - ServiceInstanceEvent -} - -// ServiceInstanceRegisteredEvent -// this event will be dispatched after service instance be unregistered -type ServiceInstanceUnregisteredEvent struct { - ServiceInstanceEvent -} - -// NewServiceInstancePreRegisteredEvent create a ServiceInstancePreRegisteredEvent -func NewServiceInstancePreRegisteredEvent(source interface{}, instance registry.ServiceInstance) *ServiceInstancePreRegisteredEvent { - return &ServiceInstancePreRegisteredEvent{*NewServiceInstanceEvent(source, instance)} -} - -// NewServiceInstancePreUnregisteredEvent create a ServiceInstancePreUnregisteredEvent -func NewServiceInstancePreUnregisteredEvent(source interface{}, instance registry.ServiceInstance) *ServiceInstancePreUnregisteredEvent { - return &ServiceInstancePreUnregisteredEvent{*NewServiceInstanceEvent(source, instance)} -} - -// NewServiceInstanceRegisteredEvent create a ServiceInstanceRegisteredEvent -func NewServiceInstanceRegisteredEvent(source interface{}, instance registry.ServiceInstance) *ServiceInstanceRegisteredEvent { - return &ServiceInstanceRegisteredEvent{*NewServiceInstanceEvent(source, instance)} -} - -// NewServiceInstanceUnregisteredEvent create a ServiceInstanceUnregisteredEvent -func NewServiceInstanceUnregisteredEvent(source interface{}, instance registry.ServiceInstance) *ServiceInstanceUnregisteredEvent { - return &ServiceInstanceUnregisteredEvent{*NewServiceInstanceEvent(source, instance)} -} diff --git a/registry/event/service_name_mapping_listener.go b/registry/event/service_name_mapping_listener.go deleted file mode 100644 index e7d979a72f..0000000000 --- a/registry/event/service_name_mapping_listener.go +++ /dev/null @@ -1,89 +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 event - -import ( - "reflect" - "sync" -) - -import ( - perrors "github.com/pkg/errors" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/metadata/mapping" -) - -func init() { - extension.AddEventListener(GetServiceNameMappingListener) -} - -// serviceNameMappingListener listen to service name mapping event -// usually it means that we exported some service -// it's a singleton -type serviceNameMappingListener struct { - nameMapping mapping.ServiceNameMapping -} - -// GetPriority return 3, which ensure that this listener will be invoked after log listener -func (s *serviceNameMappingListener) GetPriority() int { - return 3 -} - -// OnEvent only handle ServiceConfigExportedEvent -func (s *serviceNameMappingListener) OnEvent(e observer.Event) error { - if ex, ok := e.(*ServiceConfigExportedEvent); ok { - sc := ex.ServiceConfig - urls := sc.GetExportedUrls() - - for _, u := range urls { - err := s.nameMapping.Map(u.GetParam(constant.INTERFACE_KEY, ""), - u.GetParam(constant.GROUP_KEY, ""), - u.GetParam(constant.Version, ""), - u.Protocol) - if err != nil { - return perrors.WithMessage(err, "could not map the service: "+u.String()) - } - } - } - return nil -} - -// GetEventType return ServiceConfigExportedEvent -func (s *serviceNameMappingListener) GetEventType() reflect.Type { - return reflect.TypeOf(&ServiceConfigExportedEvent{}) -} - -var ( - serviceNameMappingListenerInstance *serviceNameMappingListener - serviceNameMappingListenerOnce sync.Once -) - -// GetServiceNameMappingListener returns an instance -func GetServiceNameMappingListener() observer.EventListener { - serviceNameMappingListenerOnce.Do(func() { - serviceNameMappingListenerInstance = &serviceNameMappingListener{ - nameMapping: extension.GetGlobalServiceNameMapping(), - } - }) - return serviceNameMappingListenerInstance -} diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go index 3acf655933..77e022cc17 100644 --- a/registry/event/service_revision_customizer.go +++ b/registry/event/service_revision_customizer.go @@ -28,6 +28,7 @@ import ( "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/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" ) @@ -47,7 +48,7 @@ func (e *exportedServicesRevisionMetadataCustomizer) GetPriority() int { // Customize calculate the revision for exported urls and then put it into instance metadata func (e *exportedServicesRevisionMetadataCustomizer) Customize(instance registry.ServiceInstance) { - ms, err := getMetadataService() + ms, err := local.GetLocalMetadataService() if err != nil { logger.Errorf("could not get metadata service", err) return @@ -74,7 +75,7 @@ func (e *subscribedServicesRevisionMetadataCustomizer) GetPriority() int { // Customize calculate the revision for subscribed urls and then put it into instance metadata func (e *subscribedServicesRevisionMetadataCustomizer) Customize(instance registry.ServiceInstance) { - ms, err := getMetadataService() + ms, err := local.GetLocalMetadataService() if err != nil { logger.Errorf("could not get metadata service", err) return diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index b6c7a319ec..015a45e8f9 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -268,20 +268,3 @@ func (fssd *fileSystemServiceDiscovery) AddListener(listener registry.ServiceIns // fssd.dynamicConfiguration.AddListener(listener.ServiceName) return nil } - -// DispatchEventByServiceName dispatches the ServiceInstancesChangedEvent to service instance whose name is serviceName -func (fssd *fileSystemServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - return fssd.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, fssd.GetInstances(serviceName))) -} - -// DispatchEventForInstances dispatches the ServiceInstancesChangedEvent to target instances -func (fssd *fileSystemServiceDiscovery) DispatchEventForInstances(serviceName string, - instances []registry.ServiceInstance) error { - return fssd.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) -} - -// DispatchEvent dispatches the event -func (fssd *fileSystemServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - extension.GetGlobalDispatcher().Dispatch(event) - return nil -} diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 57d4becd74..2328b4b455 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -62,6 +62,9 @@ type nacosServiceDiscovery struct { namingClient *nacosClient.NacosNamingClient // cache registry instances registryInstances []registry.ServiceInstance + + instanceListenerMap map[string]*gxset.HashSet + listenerLock sync.Mutex } // Destroy will close the service discovery. @@ -210,8 +213,30 @@ func (n *nacosServiceDiscovery) GetRequestInstances(serviceNames []string, offse return res } +func (n *nacosServiceDiscovery) registerInstanceListener(listener registry.ServiceInstancesChangedListener) { + n.listenerLock.Lock() + defer n.listenerLock.Unlock() + + for _, t := range listener.GetServiceNames().Values() { + serviceName, ok := t.(string) + if !ok { + logger.Errorf("service name error %s", t) + continue + } + listenerSet, found := n.instanceListenerMap[serviceName] + if !found { + listenerSet = gxset.NewSet(listener) + listenerSet.Add(listener) + n.instanceListenerMap[serviceName] = listenerSet + } else { + listenerSet.Add(listener) + } + } +} + // AddListener will add a listener func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesChangedListener) error { + n.registerInstanceListener(listener) for _, t := range listener.GetServiceNames().Values() { serviceName := t.(string) err := n.namingClient.Client().Subscribe(&vo.SubscribeParam{ @@ -241,7 +266,13 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh }) } - e := n.DispatchEventForInstances(serviceName, instances) + var e error + for _, lis := range n.instanceListenerMap[serviceName].Values() { + var instanceListener registry.ServiceInstancesChangedListener + instanceListener = lis.(registry.ServiceInstancesChangedListener) + e = instanceListener.OnEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) + } + if e != nil { logger.Errorf("Dispatching event got exception, service name: %s, err: %v", serviceName, err) } @@ -254,22 +285,6 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh return nil } -// DispatchEventByServiceName will dispatch the event for the service with the service name -func (n *nacosServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - return n.DispatchEventForInstances(serviceName, n.GetInstances(serviceName)) -} - -// DispatchEventForInstances will dispatch the event to those instances -func (n *nacosServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - return n.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) -} - -// DispatchEvent will dispatch the event -func (n *nacosServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - extension.GetGlobalDispatcher().Dispatch(event) - return nil -} - // toRegisterInstance convert the ServiceInstance to RegisterInstanceParam // the Ephemeral will be true func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInstance) vo.RegisterInstanceParam { @@ -347,10 +362,11 @@ func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) { descriptor := fmt.Sprintf("nacos-service-discovery[%s]", rc.Address) newInstance := &nacosServiceDiscovery{ - group: group, - namingClient: client, - descriptor: descriptor, - registryInstances: []registry.ServiceInstance{}, + group: group, + namingClient: client, + descriptor: descriptor, + registryInstances: []registry.ServiceInstance{}, + instanceListenerMap: make(map[string]*gxset.HashSet), } instanceMap[name] = newInstance return newInstance, nil diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 03b1b9cb8c..1c438c53fa 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -32,8 +32,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" "dubbo.apache.org/dubbo-go/v3/registry" @@ -75,15 +73,11 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { return } prepareData() - extension.SetEventDispatcher("mock", func() observer.EventDispatcher { - return dispatcher.NewMockEventDispatcher() - }) extension.SetGlobalServiceNameMapping(func() mapping.ServiceNameMapping { return mapping.NewMockServiceNameMapping() }) - extension.SetAndInitGlobalDispatcher("mock") rand.Seed(time.Now().Unix()) serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) id := "id" @@ -153,8 +147,6 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { assert.Equal(t, "b", v) // test dispatcher event - err = serviceDiscovery.DispatchEventByServiceName(serviceName) - assert.Nil(t, err) hs := gxset.NewSet() hs.Add(serviceName) // test AddListener diff --git a/registry/service_discovery.go b/registry/service_discovery.go index 70b7b76d7b..c90ff1120e 100644 --- a/registry/service_discovery.go +++ b/registry/service_discovery.go @@ -75,13 +75,4 @@ type ServiceDiscovery interface { // AddListener adds a new ServiceInstancesChangedListenerImpl // see addServiceInstancesChangedListener in Java AddListener(listener ServiceInstancesChangedListener) error - - // DispatchEventByServiceName dispatches the ServiceInstancesChangedEvent to service instance whose name is serviceName - DispatchEventByServiceName(serviceName string) error - - // DispatchEventForInstances dispatches the ServiceInstancesChangedEvent to target instances - DispatchEventForInstances(serviceName string, instances []ServiceInstance) error - - // DispatchEvent dispatches the event - DispatchEvent(event *ServiceInstancesChangedEvent) error } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 1feb8f1555..40a0bf3566 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -134,7 +134,7 @@ func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { if err != nil { return nil, perrors.WithMessage(err, "Create service discovery fialed") } - return event.NewEventPublishingServiceDiscovery(originServiceDiscovery), nil + return originServiceDiscovery, nil } func parseServices(literalServices string) *gxset.HashSet { @@ -235,20 +235,12 @@ func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.No } s.serviceListeners[serviceNamesKey] = listener listener.AddListenerAndNotify(protocolServiceKey, notify) - s.registerServiceInstancesChangedListener(url, listener) - return nil -} -func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url *common.URL, listener registry.ServiceInstancesChangedListener) { - // FIXME ServiceNames.String() is not good - listenerId := listener.GetServiceNames().String() + ":" + getUrlKey(url) - if !s.subscribedServices.Contains(listenerId) { - err := s.serviceDiscovery.AddListener(listener) - if err != nil { - logger.Errorf("add listener[%s] catch error,url:%s err:%s", listenerId, url.String(), err.Error()) - } + err = s.serviceDiscovery.AddListener(listener) + if err != nil { + logger.Errorf("add instance listener catch error,url:%s err:%s", url.String(), err.Error()) } - + return nil } func getUrlKey(url *common.URL) string { @@ -352,5 +344,26 @@ func tryInitMetadataService(url *common.URL) { if err != nil { logger.Errorf("could not export the metadata service", err) } - extension.GetGlobalDispatcher().Dispatch(event.NewServiceConfigExportedEvent(expt.(*configurable.MetadataServiceExporter).ServiceConfig)) + + // report interface-app mapping + err = publishMapping(expt.(*configurable.MetadataServiceExporter).ServiceConfig) + if err != nil { + logger.Errorf("Publish interface-application mapping failed", err) + } +} + +// OnEvent only handle ServiceConfigExportedEvent +func publishMapping(sc *config.ServiceConfig) error { + urls := sc.GetExportedUrls() + + for _, u := range urls { + err := extension.GetGlobalServiceNameMapping().Map(u.GetParam(constant.INTERFACE_KEY, ""), + u.GetParam(constant.GROUP_KEY, ""), + u.GetParam(constant.Version, ""), + u.Protocol) + if err != nil { + return perrors.WithMessage(err, "could not map the service: "+u.String()) + } + } + return nil } diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go index 8c926429b2..d8b84454cb 100644 --- a/registry/servicediscovery/service_discovery_registry_test.go +++ b/registry/servicediscovery/service_discovery_registry_test.go @@ -30,8 +30,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/extension" - "dubbo.apache.org/dubbo-go/v3/common/observer" - "dubbo.apache.org/dubbo-go/v3/common/observer/dispatcher" "dubbo.apache.org/dubbo-go/v3/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" "dubbo.apache.org/dubbo-go/v3/metadata/service" @@ -59,11 +57,6 @@ func TestServiceDiscoveryRegistry_Register(t *testing.T) { return mapping.NewMockServiceNameMapping() }) - extension.SetEventDispatcher("mock", func() observer.EventDispatcher { - return dispatcher.NewMockEventDispatcher() - }) - extension.SetAndInitGlobalDispatcher("mock") - config.GetBaseConfig().ServiceDiscoveries["mock"] = &config.ServiceDiscoveryConfig{ Protocol: "mock", } diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index 15cf134be0..b1909ae6b8 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -64,13 +64,14 @@ type zookeeperServiceDiscovery struct { client *gxzookeeper.ZookeeperClient csd *curator_discovery.ServiceDiscovery // listener *zookeeper.ZkEventListener - url *common.URL - wg sync.WaitGroup - cltLock sync.Mutex - listenLock sync.Mutex - done chan struct{} - rootPath string - listenNames []string + url *common.URL + wg sync.WaitGroup + cltLock sync.Mutex + listenLock sync.Mutex + done chan struct{} + rootPath string + listenNames []string + instanceListenerMap map[string]*gxset.HashSet } // newZookeeperServiceDiscovery the constructor of newZookeeperServiceDiscovery @@ -105,8 +106,9 @@ func newZookeeperServiceDiscovery(name string) (registry.ServiceDiscovery, error common.WithParamsValue(constant.CONFIG_TIMEOUT_KEY, remoteConfig.TimeoutStr)) url.Location = remoteConfig.Address zksd := &zookeeperServiceDiscovery{ - url: url, - rootPath: rootPath, + url: url, + rootPath: rootPath, + instanceListenerMap: make(map[string]*gxset.HashSet), } err := zookeeper.ValidateZookeeperClient(zksd, url.Location) if err != nil { @@ -272,6 +274,7 @@ func (zksd *zookeeperServiceDiscovery) GetRequestInstances(serviceNames []string func (zksd *zookeeperServiceDiscovery) AddListener(listener registry.ServiceInstancesChangedListener) error { zksd.listenLock.Lock() defer zksd.listenLock.Unlock() + for _, t := range listener.GetServiceNames().Values() { serviceName, ok := t.(string) if !ok { @@ -279,23 +282,24 @@ func (zksd *zookeeperServiceDiscovery) AddListener(listener registry.ServiceInst continue } zksd.listenNames = append(zksd.listenNames, serviceName) - zksd.csd.ListenServiceEvent(serviceName, zksd) + listenerSet, found := zksd.instanceListenerMap[serviceName] + if !found { + listenerSet = gxset.NewSet(listener) + listenerSet.Add(listener) + zksd.instanceListenerMap[serviceName] = listenerSet + } else { + listenerSet.Add(listener) + } } - return nil -} -func (zksd *zookeeperServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - return zksd.DispatchEventForInstances(serviceName, zksd.GetInstances(serviceName)) -} - -// DispatchEventForInstances dispatch ServiceInstancesChangedEvent -func (zksd *zookeeperServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - return zksd.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) -} - -// nolint -func (zksd *zookeeperServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { - extension.GetGlobalDispatcher().Dispatch(event) + for _, t := range listener.GetServiceNames().Values() { + serviceName, ok := t.(string) + if !ok { + logger.Errorf("service name error %s", t) + continue + } + zksd.csd.ListenServiceEvent(serviceName, zksd) + } return nil } @@ -306,7 +310,15 @@ func (zksd *zookeeperServiceDiscovery) DataChange(eventType remoting.Event) bool path = strings.TrimPrefix(path, constant.PATH_SEPARATOR) // get service name in zk path serviceName := strings.Split(path, constant.PATH_SEPARATOR)[0] - err := zksd.DispatchEventByServiceName(serviceName) + + var err error + instances := zksd.GetInstances(serviceName) + for _, lis := range zksd.instanceListenerMap[serviceName].Values() { + var instanceListener registry.ServiceInstancesChangedListener + instanceListener = lis.(registry.ServiceInstancesChangedListener) + err = instanceListener.OnEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) + } + if err != nil { logger.Errorf("[zkServiceDiscovery] DispatchEventByServiceName{%s} error = err{%v}", serviceName, err) return false From 491f15613361df6b555ecfb8d7bcc0eb7ea88316 Mon Sep 17 00:00:00 2001 From: "yuyu.zx" Date: Fri, 24 Sep 2021 13:27:19 +0800 Subject: [PATCH 110/148] fix: add format placeholder for error --- registry/servicediscovery/service_discovery_registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 40a0bf3566..5fffcd47c0 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -348,7 +348,7 @@ func tryInitMetadataService(url *common.URL) { // report interface-app mapping err = publishMapping(expt.(*configurable.MetadataServiceExporter).ServiceConfig) if err != nil { - logger.Errorf("Publish interface-application mapping failed", err) + logger.Errorf("Publish interface-application mapping failed, got error %#v", err) } } From 526ea1a8a28c8aca065803cef3a0e2e4e07c1ff7 Mon Sep 17 00:00:00 2001 From: MasterKenway <40176260+MasterKenway@users.noreply.github.com> Date: Fri, 24 Sep 2021 13:33:29 +0800 Subject: [PATCH 111/148] Feat: config enhance (service discovery) (#1469) * feat: fit metadata report config * feat: add export after config load style: remove redundant imports fix: remove nacos redundant n.group * fix: remove useless code --- config/config_loader.go | 7 +++++++ registry/etcdv3/service_discovery.go | 31 ++++++++-------------------- registry/file/service_discovery.go | 4 +--- registry/nacos/service_discovery.go | 2 +- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index c8e529b91c..e15cb7e30f 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -382,6 +382,13 @@ func registerServiceInstance() { remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) } } + + if GetApplicationConfig().MetadataType == constant.REMOTE_METADATA_STORAGE_TYPE { + // publish metadata to remote + if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { + remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) + } + } } // diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go index a46763344f..214ea42bfb 100644 --- a/registry/etcdv3/service_discovery.go +++ b/registry/etcdv3/service_discovery.go @@ -30,8 +30,6 @@ import ( gxpage "github.com/dubbogo/gost/hash/page" "github.com/hashicorp/vault/sdk/helper/jsonutil" - - perrors "github.com/pkg/errors" ) import ( @@ -292,38 +290,27 @@ func (e *etcdV3ServiceDiscovery) DataChange(eventType remoting.Event) bool { return true } -// netEcdv3ServiceDiscovery +// newEtcdv3ServiceDiscovery func newEtcdV3ServiceDiscovery() (registry.ServiceDiscovery, error) { initLock.Lock() defer initLock.Unlock() - // todo fix - sdc, ok := config.GetRootConfig().ServiceDiscoveries[""] - if !ok || len(sdc.RemoteRef) == 0 { - return nil, perrors.New("could not init the etcd service instance because the config is invalid") - } + metadataReportConfig := config.GetMetadataReportConfg() - remoteConfig, ok := config.GetRootConfig().Remotes[sdc.RemoteRef] - if !ok { - return nil, perrors.New("could not find the remote config for name: " + sdc.RemoteRef) - } - - // init etcdv3 client - timeout, err := time.ParseDuration(remoteConfig.TimeoutStr) + to, err := time.ParseDuration(metadataReportConfig.Timeout) if err != nil { - logger.Errorf("timeout config %v is invalid,err is %v", remoteConfig.TimeoutStr, err.Error()) - return nil, perrors.WithMessagef(err, "new etcd service discovery(address:%v)", remoteConfig.Address) + logger.Errorf("timeout config %v is invalid,err is %v", metadataReportConfig.Timeout, err.Error()) + return nil, err } - - logger.Infof("etcd address is: %v,timeout is:%s", remoteConfig.Address, timeout.String()) + logger.Infof("etcd address is: %v,timeout is:%s", metadataReportConfig.Timeout, to.String()) client := etcdv3.NewServiceDiscoveryClient( gxetcd.WithName(gxetcd.RegistryETCDV3Client), - gxetcd.WithTimeout(timeout), - gxetcd.WithEndpoints(strings.Split(remoteConfig.Address, ",")...), + gxetcd.WithTimeout(to), + gxetcd.WithEndpoints(strings.Split(metadataReportConfig.Address, ",")...), ) - descriptor := fmt.Sprintf("etcd-service-discovery[%s]", remoteConfig.Address) + descriptor := fmt.Sprintf("etcd-service-discovery[%s]", metadataReportConfig.Address) return &etcdV3ServiceDiscovery{descriptor, client, nil, gxset.NewSet(), make(map[string]*etcdv3.EventListener)}, nil } diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index e8657d9e71..1c74163386 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -57,9 +57,7 @@ type fileSystemServiceDiscovery struct { } func newFileSystemServiceDiscovery() (registry.ServiceDiscovery, error) { - // todo fix - sdc, ok := config.GetRootConfig().ServiceDiscoveries[""] - if !ok || sdc.Protocol != constant.FILE_KEY { + if config.GetMetadataReportConfg().Protocol != constant.FILE_KEY { return nil, perrors.New("could not init the instance because the config is invalid") } diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index b744dc8ee8..ee7e276afa 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -218,8 +218,8 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh for _, t := range listener.GetServiceNames().Values() { serviceName := t.(string) err := n.namingClient.Client().Subscribe(&vo.SubscribeParam{ - ServiceName: serviceName, GroupName: n.group, + ServiceName: serviceName, SubscribeCallback: func(services []model.SubscribeService, err error) { if err != nil { logger.Errorf("Could not handle the subscribe notification because the err is not nil."+ From 0697950e18505e3989d738fb2750d3dc67e60587 Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Fri, 24 Sep 2021 13:50:46 +0800 Subject: [PATCH 112/148] feat(*): add graceful shutdown (#1470) * feat(*): add graceful shutdown * feat(*): merge destroyProviderProtocols and destroyConsumerProtocols Co-authored-by: dongjianhui03 --- common/constant/key.go | 39 +++--- config/config_setter.go | 4 - config/graceful_shutdown.go | 234 ++++++++++++++++-------------------- filter/gshutdown/filter.go | 4 +- 4 files changed, 124 insertions(+), 157 deletions(-) diff --git a/common/constant/key.go b/common/constant/key.go index 80d2fe794f..bf8b3e1c81 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -65,25 +65,26 @@ const ( // Filter Keys const ( - AccessLogFilterKey = "accesslog" - ActiveFilterKey = "active" - AuthConsumerFilterKey = "sign" - AuthProviderFilterKey = "auth" - EchoFilterKey = "echo" - ExecuteLimitFilterKey = "execute" - GenericFilterKey = "generic" - GenericServiceFilterKey = "generic_service" - GracefulShutdownProviderFilterKey = "pshutdown" - GracefulShutdownConsumerFilterKey = "cshutdown" - HystrixConsumerFilterKey = "hystrix_consumer" - HystrixProviderFilterKey = "hystrix_provider" - MetricsFilterKey = "metrics" - SeataFilterKey = "seata" - SentinelProviderFilterKey = "sentinel-provider" - SentinelConsumerFilterKey = "sentinel-consumer" - TokenFilterKey = "token" - TpsLimitFilterKey = "tps" - TracingFilterKey = "tracing" + AccessLogFilterKey = "accesslog" + ActiveFilterKey = "active" + AuthConsumerFilterKey = "sign" + AuthProviderFilterKey = "auth" + EchoFilterKey = "echo" + ExecuteLimitFilterKey = "execute" + GenericFilterKey = "generic" + GenericServiceFilterKey = "generic_service" + GracefulShutdownProviderFilterKey = "pshutdown" + GracefulShutdownConsumerFilterKey = "cshutdown" + GracefulShutdownFilterShutdownConfig = "GracefulShutdownFilterShutdownConfig" + HystrixConsumerFilterKey = "hystrix_consumer" + HystrixProviderFilterKey = "hystrix_provider" + MetricsFilterKey = "metrics" + SeataFilterKey = "seata" + SentinelProviderFilterKey = "sentinel-provider" + SentinelConsumerFilterKey = "sentinel-consumer" + TokenFilterKey = "token" + TpsLimitFilterKey = "tps" + TracingFilterKey = "tracing" ) const ( diff --git a/config/config_setter.go b/config/config_setter.go index 9f114f26d0..7f409e3828 100644 --- a/config/config_setter.go +++ b/config/config_setter.go @@ -17,10 +17,6 @@ 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 d37ad82733..6c0b755500 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -18,6 +18,9 @@ package config import ( + "os" + "os/signal" + "runtime/debug" "time" ) @@ -51,61 +54,49 @@ import ( const defaultShutDownTime = time.Second * 60 // nolint -//func GracefulShutdownInit() { -// signals := make(chan os.Signal, 1) -// -// signal.Notify(signals, ShutdownSignals...) -// -// // retrieve ShutdownConfig for gracefulShutdownFilter -// if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(config.Setter); ok && config.GetConsumerConfig().ShutdownConfig != nil { -// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetConsumerConfig().ShutdownConfig) -// } -// if filter, ok := extension.GetFilter(constant.GracefulShutdownProviderFilterKey).(config.Setter); ok && config.GetProviderConfig().ShutdownConfig != nil { -// filter.Set(config.GracefulShutdownFilterShutdownConfig, config.GetProviderConfig().ShutdownConfig) -// } -// -// go func() { -// select { -// case sig := <-signals: -// logger.Infof("get signal %s, applicationConfig will shutdown.", sig) -// // gracefulShutdownOnce.Do(func() { -// time.AfterFunc(totalTimeout(), func() { -// logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ") -// os.Exit(0) -// }) -// BeforeShutdown() -// // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior -// for _, dumpSignal := range DumpHeapShutdownSignals { -// if sig == dumpSignal { -// debug.WriteHeapDump(os.Stdout.Fd()) -// } -// } -// os.Exit(0) -// } -// }() -//} +func GracefulShutdownInit() { + signals := make(chan os.Signal, 1) + + signal.Notify(signals, ShutdownSignals...) + + // retrieve ShutdownConfig for gracefulShutdownFilter + if filter, ok := extension.GetFilter(constant.GracefulShutdownConsumerFilterKey).(Setter); ok && rootConfig.Shutdown != nil { + filter.Set(constant.GracefulShutdownFilterShutdownConfig, rootConfig.Shutdown) + } + + go func() { + select { + case sig := <-signals: + logger.Infof("get signal %s, applicationConfig will shutdown.", sig) + // gracefulShutdownOnce.Do(func() { + time.AfterFunc(totalTimeout(), func() { + logger.Warn("Shutdown gracefully timeout, applicationConfig will shutdown immediately. ") + os.Exit(0) + }) + BeforeShutdown() + // those signals' original behavior is exit with dump ths stack, so we try to keep the behavior + for _, dumpSignal := range DumpHeapShutdownSignals { + if sig == dumpSignal { + debug.WriteHeapDump(os.Stdout.Fd()) + } + } + os.Exit(0) + } + }() +} // BeforeShutdown provides processing flow before shutdown func BeforeShutdown() { destroyAllRegistries() // waiting for a short time so that the clients have enough time to get the notification that server shutdowns // The value of configuration depends on how long the clients will get notification. - //waitAndAcceptNewRequests() - - // reject the new request, but keeping waiting for accepting requests - //waitForReceivingRequests() - - // we fetch the protocols from Consumer.References. Consumer.ProtocolConfig doesn't contains all protocol, like jsonrpc - //consumerProtocols := getConsumerProtocols() - - // If this applicationConfig is not the provider, it will do nothing - //destroyProviderProtocols(consumerProtocols) + waitAndAcceptNewRequests() - // reject sending the new request, and waiting for response of sending requests - //waitForSendingRequests() + // reject sending/receiving the new request, but keeping waiting for accepting requests + waitForSendingAndReceivingRequests() - // If this applicationConfig is not the consumer, it will do nothing - //destroyConsumerProtocols(consumerProtocols) + // destroy all protocols + destroyProtocols() logger.Info("Graceful shutdown --- Execute the custom callbacks.") customCallbacks := extension.GetAllCustomShutdownCallbacks() @@ -120,68 +111,56 @@ func destroyAllRegistries() { registryProtocol.Destroy() } -func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { - logger.Info("Graceful shutdown --- Destroy consumer's protocols. ") +// destroyProtocols destroys protocols. +// First we destroy provider's protocols, and then we destroy the consumer protocols. +func destroyProtocols() { + logger.Info("Graceful shutdown --- Destroy protocols. ") + logger.Info("Graceful shutdown --- First destroy provider's protocols. ") + + consumerProtocols := getConsumerProtocols() + if rootConfig.Protocols == nil { + return + } + + for _, protocol := range rootConfig.Protocols { + // the protocol is the consumer's protocol too, we can not destroy it. + if consumerProtocols.Contains(protocol.Name) { + continue + } + extension.GetProtocol(protocol.Name).Destroy() + } + + logger.Info("Graceful shutdown --- Second destroy consumer's protocols. ") for name := range consumerProtocols.Items { extension.GetProtocol(name.(string)).Destroy() } } -// destroyProviderProtocols destroys the provider's protocol. -// if the protocol is consumer's protocol too, we will keep it -//func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { -// logger.Info("Graceful shutdown --- Destroy provider's protocols. ") -// -// if config.providerConfig == nil || config.providerConfig.Protocols == nil { -// return -// } -// -// for _, protocol := range config.providerConfig.Protocols { -// -// // the protocol is the consumer's protocol too, we can not destroy it. -// if consumerProtocols.Contains(protocol.Name) { -// continue -// } -// extension.GetProtocol(protocol.Name).Destroy() -// } -//} - -//func waitAndAcceptNewRequests() { -// logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") -// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { -// return -// } -// -// timeout := config.providerConfig.ShutdownConfig.GetStepTimeout() -// -// // ignore this step -// if timeout < 0 { -// return -// } -// time.Sleep(timeout) -//} - -// for provider. It will wait for processing receiving requests -//func waitForReceivingRequests() { -// logger.Info("Graceful shutdown --- Keep waiting until accepting requests finish or timeout. ") -// if config.providerConfig == nil || config.providerConfig.ShutdownConfig == nil { -// // ignore this step -// return -// } -// config.providerConfig.ShutdownConfig.RejectRequest = true -// waitingProcessedTimeout(config.providerConfig.ShutdownConfig) -//} - -// for consumer. It will wait for the response of sending requests -//func waitForSendingRequests() { -// logger.Info("Graceful shutdown --- Keep waiting until sending requests getting response or timeout ") -// if config.consumerConfig == nil || config.consumerConfig.ShutdownConfig == nil { -// // ignore this step -// return -// } -// config.consumerConfig.ShutdownConfig.RejectRequest = true -// waitingProcessedTimeout(config.consumerConfig.ShutdownConfig) -//} +func waitAndAcceptNewRequests() { + logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ") + if rootConfig.Shutdown == nil { + return + } + + timeout := rootConfig.Shutdown.GetStepTimeout() + + // ignore this step + if timeout < 0 { + return + } + time.Sleep(timeout) +} + +//for provider. It will wait for processing receiving requests +func waitForSendingAndReceivingRequests() { + logger.Info("Graceful shutdown --- Keep waiting until sending/accepting requests finish or timeout. ") + if rootConfig == nil || rootConfig.Shutdown == nil { + // ignore this step + return + } + rootConfig.Shutdown.RejectRequest = true + waitingProcessedTimeout(rootConfig.Shutdown) +} func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { timeout := shutdownConfig.GetStepTimeout() @@ -196,33 +175,24 @@ func waitingProcessedTimeout(shutdownConfig *ShutdownConfig) { } } -//func totalTimeout() time.Duration { -// providerShutdown := defaultShutDownTime -// if config.providerConfig != nil && config.providerConfig.ShutdownConfig != nil { -// providerShutdown = config.providerConfig.ShutdownConfig.GetTimeout() -// } -// -// var consumerShutdown time.Duration -// if config.consumerConfig != nil && config.consumerConfig.ShutdownConfig != nil { -// consumerShutdown = config.consumerConfig.ShutdownConfig.GetTimeout() -// } -// -// timeout := providerShutdown -// if consumerShutdown > providerShutdown { -// timeout = consumerShutdown -// } -// return timeout -//} +func totalTimeout() time.Duration { + timeout := defaultShutDownTime + if rootConfig.Shutdown != nil && rootConfig.Shutdown.GetTimeout() > timeout { + timeout = rootConfig.Shutdown.GetTimeout() + } + + return timeout +} // we can not get the protocols from consumerConfig because some protocol don't have configuration, like jsonrpc. -//func getConsumerProtocols() *gxset.HashSet { -// result := gxset.NewSet() -// if config.consumerConfig == nil || config.consumerConfig.References == nil { -// return result -// } -// -// for _, reference := range config.consumerConfig.References { -// result.Add(reference.Protocol) -// } -// return result -//} +func getConsumerProtocols() *gxset.HashSet { + result := gxset.NewSet() + if rootConfig.Consumer == nil || rootConfig.Consumer.References == nil { + return result + } + + for _, reference := range rootConfig.Consumer.References { + result.Add(reference.Protocol) + } + return result +} diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go index 1bbc19774e..7b4a90571c 100644 --- a/filter/gshutdown/filter.go +++ b/filter/gshutdown/filter.go @@ -68,12 +68,12 @@ func (f *Filter) OnResponse(ctx context.Context, result protocol.Result, invoker func (f *Filter) Set(name string, conf interface{}) { switch name { - case config.GracefulShutdownFilterShutdownConfig: + case constant.GracefulShutdownFilterShutdownConfig: if shutdownConfig, ok := conf.(*config.ShutdownConfig); !ok { f.shutdownConfig = shutdownConfig return } - logger.Warnf("the type of config for {%s} should be *config.ShutdownConfig", config.GracefulShutdownFilterShutdownConfig) + logger.Warnf("the type of config for {%s} should be *config.ShutdownConfig", constant.GracefulShutdownFilterShutdownConfig) default: // do nothing } From 20721712985200ead0e256ff46f37de4536d7c31 Mon Sep 17 00:00:00 2001 From: zhaoyunxing <2385585770@qq.com> Date: Sat, 25 Sep 2021 17:28:29 +0800 Subject: [PATCH 113/148] Config enhance (#1467) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * up:配置优化 * up:修改registryid获取逻辑 * up:修改registryid获取逻辑 * fmt * fix:测试通过 * 代码结构调整 * 代码结构调整 * 代码结构调整 * 代码结构调整 * fmt * fix:update get provider instance * cac -> once * up:更新初始化方法 * fmt * 更新默认端口 * 代码优化 * 优化日志打印 * add new root config * 解决启动问题 * up:处理nil问题 * fmt * fmt --- common/constant/key.go | 2 + common/extension/registry.go | 8 +- config/application_config.go | 72 +++++++- ...k_config.go => application_config_test.go} | 18 +- config/config_center_config.go | 29 ++-- config/config_loader.go | 13 +- config/config_loader_test.go | 75 +++------ config/config_utils.go | 1 + config/consumer_config.go | 37 +++-- config/dubbo_bootstrap.go | 112 +++++++++++++ config/logger_config.go | 41 +++-- config/logger_config_test.go | 1 - config/metadata_report_config.go | 49 +++--- config/protocol_config.go | 15 +- config/protocol_config_test.go | 4 +- config/provider_config.go | 103 ++++-------- config/provider_config_test.go | 46 +++--- config/reference_config.go | 18 +- config/registry_config.go | 32 ++-- config/registry_config_test.go | 4 +- config/root_config.go | 156 ++---------------- config/service_config.go | 71 +------- config/testdata/config/app/application.yaml | 2 +- .../config/application/application.yaml | 4 + .../testdata/config/protocol/application.yaml | 5 + .../config/protocol/empty_application.yaml | 5 + .../testdata/config/provider/application.yaml | 5 + .../config/provider/registry_application.yaml | 11 +- .../testdata/config/service/hello_service.go | 31 ---- .../testdata/config/service/order_service.go | 31 ---- go.mod | 3 +- go.sum | 13 -- integrate_test.sh | 2 +- .../exporter/configurable/exporter_test.go | 2 +- metrics/prometheus/reporter.go | 33 ++-- protocol/dubbo3/internal/server.go | 6 +- 36 files changed, 487 insertions(+), 573 deletions(-) rename config/{network_config.go => application_config_test.go} (75%) create mode 100644 config/dubbo_bootstrap.go create mode 100644 config/testdata/config/application/application.yaml delete mode 100644 config/testdata/config/service/hello_service.go delete mode 100644 config/testdata/config/service/order_service.go diff --git a/common/constant/key.go b/common/constant/key.go index bf8b3e1c81..849d1def0d 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -177,6 +177,7 @@ const ( const ( RegistryConfigPrefix = "dubbo.registries" + ApplicationConfigPrefix = "dubbo.application" ConfigCenterPrefix = "dubbo.config-center" SingleRegistryConfigPrefix = "dubbo.registry" ReferenceConfigPrefix = "dubbo.reference" @@ -190,6 +191,7 @@ const ( ShutdownConfigPrefix = "dubbo.shutdown" MetadataReportPrefix = "dubbo.metadata-report" RouterConfigPrefix = "dubbo.router" + LoggerConfigPrefix = "dubbo.logger" ) const ( diff --git a/common/extension/registry.go b/common/extension/registry.go index 31cb80cd76..abce206f27 100644 --- a/common/extension/registry.go +++ b/common/extension/registry.go @@ -22,17 +22,17 @@ import ( "dubbo.apache.org/dubbo-go/v3/registry" ) -var registrys = make(map[string]func(config *common.URL) (registry.Registry, error)) +var registries = make(map[string]func(config *common.URL) (registry.Registry, error)) // SetRegistry sets the registry extension with @name func SetRegistry(name string, v func(_ *common.URL) (registry.Registry, error)) { - registrys[name] = v + registries[name] = v } // GetRegistry finds the registry extension with @name func GetRegistry(name string, config *common.URL) (registry.Registry, error) { - if registrys[name] == nil { + if registries[name] == nil { panic("registry for " + name + " does not exist. please make sure that you have imported the package dubbo.apache.org/dubbo-go/v3/registry/" + name + ".") } - return registrys[name](config) + return registries[name](config) } diff --git a/config/application_config.go b/config/application_config.go index b9334ad970..11181093a9 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -19,6 +19,8 @@ package config import ( "github.com/creasty/defaults" + + "github.com/pkg/errors" ) import ( @@ -37,25 +39,77 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadata-type" json:"metadataType,omitempty" property:"metadataType"` } -// Prefix dubbo.applicationConfig +// Prefix dubbo.application func (ApplicationConfig) Prefix() string { - return constant.DUBBO + ".application" + return constant.ApplicationConfigPrefix } -func (ac *ApplicationConfig) Init(rc *RootConfig) error { - // ignore refresh action - if rc.refresh || ac == nil { - rootConfig.Application = new(ApplicationConfig) - return nil +// Init application config and set default value +func (ac *ApplicationConfig) Init() error { + if ac == nil { + return errors.New("application is null") } - defaults.MustSet(ac) if err := ac.check(); err != nil { return err } return nil } +func GetApplicationInstance(opts ...ApplicationConfigOpt) *ApplicationConfig { + ac := &ApplicationConfig{} + for _, opt := range opts { + opt(ac) + } + return ac +} + func (ac *ApplicationConfig) check() error { - defaults.MustSet(ac) + if err := defaults.Set(ac); err != nil { + return err + } return verify(ac) } + +type ApplicationConfigOpt func(config *ApplicationConfig) + +func WithOrganization(organization string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Organization = organization + } +} + +func WithName(name string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Name = name + } +} + +func WithModule(module string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Module = module + } +} + +func WithVersion(version string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Version = version + } +} + +func WithOwner(owner string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Owner = owner + } +} + +func WithEnvironment(env string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.Environment = env + } +} + +func WithMetadataType(metadataType string) ApplicationConfigOpt { + return func(ac *ApplicationConfig) { + ac.MetadataType = metadataType + } +} diff --git a/config/network_config.go b/config/application_config_test.go similarity index 75% rename from config/network_config.go rename to config/application_config_test.go index e07aca17fe..398fa6e514 100644 --- a/config/network_config.go +++ b/config/application_config_test.go @@ -17,9 +17,19 @@ package config -type NetworkConfig struct { -} +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +func TestApplicationConfig(t *testing.T) { + + err := Load(WithPath("./testdata/config/application/application.yaml")) + assert.Nil(t, err) -func initNetworkConfig(rc *RootConfig) error { - return nil + center := rootConfig.Registries + assert.NotNil(t, center) } diff --git a/config/config_center_config.go b/config/config_center_config.go index 479bf71df6..b0b4e60ba5 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -49,10 +49,9 @@ import ( // // CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type CenterConfig struct { - Protocol string `yaml:"protocol" json:"protocol,omitempty"` - Address string `yaml:"address" json:"address,omitempty"` - DataId string `yaml:"data-id" json:"data-id,omitempty"` - // Deprecated + Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty"` + Address string `validate:"required" yaml:"address" json:"address,omitempty"` + DataId string `validate:"required" yaml:"data-id" json:"data-id,omitempty"` Cluster string `yaml:"cluster" json:"cluster,omitempty"` Group string `default:"dubbo" yaml:"group" json:"group,omitempty"` Username string `yaml:"username" json:"username,omitempty"` @@ -72,19 +71,31 @@ type CenterConfig struct { Params map[string]string `yaml:"params" json:"parameters,omitempty"` } +// Prefix dubbo.config-center +func (CenterConfig) Prefix() string { + return constant.ConfigCenterPrefix +} + +func GetConfigCenterInstance(opts ...CenterConfigOpt) *CenterConfig { + cc := &CenterConfig{ + Params: make(map[string]string, 1), + } + for _, opt := range opts { + opt(cc) + } + return cc +} + func (c *CenterConfig) check() error { if err := defaults.Set(c); err != nil { return err } c.translateConfigAddress() - if c.Address == "" || c.Protocol == "" { - return errors.Errorf("invalid config center config %+v", c) - } return verify(c) } func (c *CenterConfig) Init(rc *RootConfig) error { - if rc.refresh || c == nil { + if c == nil { return nil } if err := c.check(); err != nil { @@ -171,8 +182,6 @@ func startConfigCenter(rc *RootConfig) error { return err } - rc.refresh = false - rc.ConfigCenter = nil return nil } diff --git a/config/config_loader.go b/config/config_loader.go index e15cb7e30f..2886269be8 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -25,8 +25,6 @@ import ( ) import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/knadh/koanf" "github.com/knadh/koanf/parsers/json" "github.com/knadh/koanf/parsers/toml" @@ -45,29 +43,22 @@ import ( ) var ( - rootConfig *RootConfig + rootConfig = GetInstance() maxWait = 3 ) func Load(opts ...LoaderConfOption) error { - hessian.RegisterPOJO(&common.MetadataInfo{}) - hessian.RegisterPOJO(&common.ServiceInfo{}) - hessian.RegisterPOJO(&common.URL{}) // conf conf := NewLoaderConf(opts...) - // init config - rootConfig = new(RootConfig) koan := getKoanf(conf) if err := koan.UnmarshalWithConf(rootConfig.Prefix(), rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err } - rootConfig.refresh = false - extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) if err := rootConfig.Init(); err != nil { return err } - registerServiceInstance() + rootConfig.Start() return nil } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index eaa8358d5e..73b96fc50e 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -25,22 +25,13 @@ import ( "github.com/stretchr/testify/assert" ) -import ( - "dubbo.apache.org/dubbo-go/v3/config/testdata/config/service" -) - -func init() { - SetProviderService(new(service.OrderService)) - SetProviderService(new(service.HelloService)) -} - const ( configPath = "./testdata/application.yaml" ) func TestLoad(t *testing.T) { - Load(WithPath(configPath)) - + err := Load(WithPath(configPath)) + assert.Nil(t, err) t.Run("application", func(t *testing.T) { application := rootConfig.Application @@ -59,7 +50,7 @@ func TestLoad(t *testing.T) { assert.Equal(t, 2, len(registries)) //address= nacos://127.0.0.1:8848 Translate Registry Address assert.Equal(t, "nacos", registries["nacos"].Protocol) - assert.Equal(t, "10s", registries["zk"].Timeout) + assert.Equal(t, "5s", registries["zk"].Timeout) }) //config-center @@ -74,52 +65,32 @@ func TestLoad(t *testing.T) { //TestLoadConfigCenter test key config_center、config-center 、configCenter func TestLoadConfigCenter(t *testing.T) { - t.Run("config-center", func(t *testing.T) { - Load(WithPath("./testdata/config/center/conf-application.yaml")) - conf := rootConfig.ConfigCenter - assert.Equal(t, "nacos", conf.Protocol) - assert.Equal(t, "10s", conf.Timeout) - assert.Equal(t, "./logs", conf.LogDir) - }) + err := Load(WithPath("./testdata/config/center/conf-application.yaml")) + assert.Nil(t, err) + conf := rootConfig.ConfigCenter + assert.Equal(t, "nacos", conf.Protocol) + assert.Equal(t, "10s", conf.Timeout) + assert.Equal(t, "./logs", conf.LogDir) } func TestGetRegistriesConfig(t *testing.T) { - t.Run("registry", func(t *testing.T) { - Load(WithPath("./testdata/config/registry/application.yaml")) - registries := rootConfig.Registries - - assert.Equal(t, 2, len(registries)) - // nacos - assert.Equal(t, "nacos", registries["nacos"].Protocol) - assert.Equal(t, "5s", registries["nacos"].Timeout) - assert.Equal(t, "127.0.0.1:8848", registries["nacos"].Address) - assert.Equal(t, "dev", registries["nacos"].Group) - // zk - assert.Equal(t, "zookeeper", registries["zk"].Protocol) - assert.Equal(t, "10s", registries["zk"].Timeout) - assert.Equal(t, "127.0.0.1:2181", registries["zk"].Address) - assert.Equal(t, "test", registries["zk"].Group) - }) -} - -func TestGetProviderConfig(t *testing.T) { - // empty registry - t.Run("empty registry", func(t *testing.T) { - assert.Nil(t, Load(WithPath("./testdata/config/provider/empty_registry_application.yaml"))) - provider := rootConfig.Provider - assert.Equal(t, 0, len(provider.Registry)) - }) + err := Load(WithPath("./testdata/config/registry/application.yaml")) - t.Run("root registry", func(t *testing.T) { - Load(WithPath("./testdata/config/provider/registry_application.yaml")) - provider := rootConfig.Provider - assert.NotNil(t, provider) - }) -} + assert.Nil(t, err) + registries := rootConfig.Registries -func TestRootConfig(t *testing.T) { - Load(WithPath("./testdata/config/app/application.yaml")) + assert.Equal(t, 2, len(registries)) + // nacos + assert.Equal(t, "nacos", registries["nacos"].Protocol) + assert.Equal(t, "5s", registries["nacos"].Timeout) + assert.Equal(t, "127.0.0.1:8848", registries["nacos"].Address) + assert.Equal(t, "dev", registries["nacos"].Group) + // zk + assert.Equal(t, "zookeeper", registries["zk"].Protocol) + assert.Equal(t, "5s", registries["zk"].Timeout) + assert.Equal(t, "127.0.0.1:2181", registries["zk"].Address) + assert.Equal(t, "test", registries["zk"].Group) } // diff --git a/config/config_utils.go b/config/config_utils.go index 13ae4d788d..82e2859fbf 100644 --- a/config/config_utils.go +++ b/config/config_utils.go @@ -93,6 +93,7 @@ func removeDuplicateElement(items []string) []string { func translateRegistryIds(registryIds []string) []string { ids := make([]string, 0) for _, id := range registryIds { + ids = append(ids, strings.Split(id, ",")...) } return removeDuplicateElement(ids) diff --git a/config/consumer_config.go b/config/consumer_config.go index 25610d0a2d..9f76e4cb40 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -49,10 +49,8 @@ type ConsumerConfig struct { Check bool `yaml:"check" json:"check,omitempty" property:"check"` References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - // ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol-conf,omitempty" property:"protocol-conf"` + FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` - // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` - ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` rootConfig *RootConfig } @@ -66,8 +64,12 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { if cc == nil { return nil } - for k, _ := range cc.References { - if err := cc.References[k].Init(rc); err != nil { + cc.Registry = translateRegistryIds(cc.Registry) + if len(cc.Registry) <= 0 { + cc.Registry = rc.getRegistryIds() + } + for _, reference := range cc.References { + if err := reference.Init(rc); err != nil { return err } } @@ -78,7 +80,6 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { return err } cc.rootConfig = rc - cc.Load() return nil } @@ -127,7 +128,6 @@ func (cc *ConsumerConfig) Load() { break } } - } // SetConsumerConfig sets consumerConfig by @c @@ -196,13 +196,6 @@ func configCenterRefreshConsumer() error { //} return nil } - -///////////////////////////////////// consumer config api -// ConsumerConfigOpt is the options to init ConsumerConfig -type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig - -// NewEmptyConsumerConfig returns default ConsumerConfig -// with connection timeout = 3s, request timeout = 3s func NewEmptyConsumerConfig() *ConsumerConfig { newConsumerConfig := &ConsumerConfig{ @@ -224,6 +217,22 @@ func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { return newConfig } +///////////////////////////////////// consumer config api +// ConsumerConfigOpt is the options to init ConsumerConfig +type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig + +// GetConsumerInstance returns ConsumerConfig with @opts +func GetConsumerInstance(opts ...ConsumerConfigOpt) *ConsumerConfig { + cc := &ConsumerConfig{ + References: make(map[string]*ReferenceConfig, 8), + Check: true, + } + for _, opt := range opts { + opt(cc) + } + return cc +} + // WithRootConfig returns ConsumerConfigOpt with given @rootConfig func WithRootConfig(rootConfig *RootConfig) ConsumerConfigOpt { return func(config *ConsumerConfig) *ConsumerConfig { diff --git a/config/dubbo_bootstrap.go b/config/dubbo_bootstrap.go new file mode 100644 index 0000000000..c509287fa1 --- /dev/null +++ b/config/dubbo_bootstrap.go @@ -0,0 +1,112 @@ +/* + * 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 + +import ( + "sync" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/common/logger" +) + +var ( + startOnce sync.Once +) + +func GetInstance(opts ...RootConfigOpt) *RootConfig { + registerPOJO() + rc := &RootConfig{ + ConfigCenter: GetConfigCenterInstance(), + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReportConfig: &MetadataReportConfig{}, + Application: GetApplicationInstance(), + Registries: make(map[string]*RegistryConfig), + Protocols: GetProtocolsInstance(), + Provider: GetProviderInstance(), + Consumer: GetConsumerInstance(), + MetricConfig: &MetricConfig{}, + Logger: GetLoggerConfigInstance(), + } + for _, opt := range opts { + opt(rc) + } + return rc +} + +func registerPOJO() { + hessian.RegisterPOJO(&common.MetadataInfo{}) + hessian.RegisterPOJO(&common.ServiceInfo{}) + hessian.RegisterPOJO(&common.URL{}) +} + +func (rc *RootConfig) Init() error { + + if err := rc.Logger.Init(); err != nil { + return err + } + if err := rc.ConfigCenter.Init(rc); err != nil { + logger.Warnf("config center doesn't start. error is %s", err) + } + if err := rc.Application.Init(); err != nil { + return err + } + if err := initProtocolsConfig(rc); err != nil { + return err + } + if err := initRegistryConfig(rc); err != nil { + return err + } + if err := initServiceDiscoveryConfig(rc); err != nil { + return err + } + if err := rc.MetadataReportConfig.Init(rc); err != nil { + return err + } + if err := initMetricConfig(rc); err != nil { + return err + } + if err := initRouterConfig(rc); err != nil { + return err + } + // provider、consumer must last init + if err := rc.Provider.Init(rc); err != nil { + return err + } + if err := rc.Consumer.Init(rc); err != nil { + return err + } + + rc.Start() + return nil +} + +func (rc *RootConfig) Start() { + startOnce.Do(func() { + rc.Provider.Load() + rc.Consumer.Load() + extension.SetAndInitGlobalDispatcher(rootConfig.EventDispatcherType) + registerServiceInstance() + }) +} diff --git a/config/logger_config.go b/config/logger_config.go index de7e9b0855..d829256c65 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -31,6 +31,7 @@ import ( ) import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/common/yaml" ) @@ -66,39 +67,49 @@ type EncoderConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty"` } -func initLoggerConfig(rc *RootConfig) error { - logConfig := rc.Logger - if logConfig == nil { - logConfig = new(LoggerConfig) +// Prefix dubbo.logger +func (LoggerConfig) Prefix() string { + return constant.LoggerConfigPrefix +} + +func GetLoggerConfigInstance() *LoggerConfig { + lc := &LoggerConfig{} + return lc +} + +func (lc *LoggerConfig) Init() error { + + if lc == nil { + lc = GetLoggerConfigInstance() } - err := logConfig.check() + err := lc.check() if err != nil { return err } - rc.Logger = logConfig - byte, err := yaml.MarshalYML(logConfig) + + bytes, err := yaml.MarshalYML(lc) if err != nil { return err } logConf := &logger.Config{} - if err = yaml.UnmarshalYML(byte, logConf); err != nil { + if err = yaml.UnmarshalYML(bytes, logConf); err != nil { return err } - err = logConfig.ZapConfig.EncoderConfig.setEncoderConfig(&(logConf.ZapConfig.EncoderConfig)) + err = lc.ZapConfig.EncoderConfig.setEncoderConfig(&(logConf.ZapConfig.EncoderConfig)) if err != nil { return err } - logConfig.ZapConfig.setZapConfig(logConf.ZapConfig) + lc.ZapConfig.setZapConfig(logConf.ZapConfig) logger.InitLogger(logConf) return nil } -func (l *LoggerConfig) check() error { - if err := defaults.Set(l); err != nil { +func (lc *LoggerConfig) check() error { + if err := defaults.Set(lc); err != nil { return err } - return verify(l) + return verify(lc) } func (e *ZapConfig) setZapConfig(config *zap.Config) { @@ -135,9 +146,9 @@ func (e *EncoderConfig) setEncoderConfig(encoderConfig *zapcore.EncoderConfig) e return nil } -func (l *LoggerConfig) getUrlMap() url.Values { +func (lc *LoggerConfig) getUrlMap() url.Values { urlMap := url.Values{} - for key, val := range l.ZapConfig.EncoderConfig.Params { + for key, val := range lc.ZapConfig.EncoderConfig.Params { urlMap.Set(key, val) } return urlMap diff --git a/config/logger_config_test.go b/config/logger_config_test.go index faa96a758b..94e464fdad 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -30,7 +30,6 @@ import ( ) func TestLoggerInit(t *testing.T) { - t.Run("empty use default", func(t *testing.T) { err := Load(WithPath("./testdata/config/logger/empty_log.yaml")) assert.Nil(t, err) diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 70ec753802..888edd16ef 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -34,14 +34,13 @@ import ( // MetadataReportConfig is app level configuration type MetadataReportConfig struct { - Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` - Address string `required:"true" yaml:"address" json:"address"` - Username string `yaml:"username" json:"username,omitempty"` - Password string `yaml:"password" json:"password,omitempty"` - Timeout string `yaml:"timeout" json:"timeout,omitempty"` - Group string `yaml:"group" json:"group,omitempty"` - - MetadataReportType string + Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` + Address string `required:"true" yaml:"address" json:"address"` + Username string `yaml:"username" json:"username,omitempty"` + Password string `yaml:"password" json:"password,omitempty"` + Timeout string `yaml:"timeout" json:"timeout,omitempty"` + Group string `yaml:"group" json:"group,omitempty"` + MetadataType string `default:"local" yaml:"metadata-type" json:"metadata-type"` } // Prefix dubbo.consumer @@ -49,23 +48,21 @@ func (MetadataReportConfig) Prefix() string { return constant.MetadataReportPrefix } -func (m *MetadataReportConfig) Init(rc *RootConfig) error { - if m == nil { +func (mc *MetadataReportConfig) Init(rc *RootConfig) error { + if mc == nil { return nil } - m.MetadataReportType = rc.Application.MetadataType - return m.StartMetadataReport() + mc.MetadataType = rc.Application.MetadataType + return mc.StartMetadataReport() } -// nolint -func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { - res, err := common.NewURL(c.Address, - //common.WithParams(urlMap), - common.WithUsername(c.Username), - common.WithPassword(c.Password), - common.WithLocation(c.Address), - common.WithProtocol(c.Protocol), - common.WithParamsValue(constant.METADATATYPE_KEY, c.MetadataReportType), +func (mc *MetadataReportConfig) ToUrl() (*common.URL, error) { + res, err := common.NewURL(mc.Address, + common.WithUsername(mc.Username), + common.WithPassword(mc.Password), + common.WithLocation(mc.Address), + common.WithProtocol(mc.Protocol), + common.WithParamsValue(constant.METADATATYPE_KEY, mc.MetadataType), ) if err != nil || len(res.Protocol) == 0 { return nil, perrors.New("Invalid MetadataReportConfig.") @@ -74,16 +71,16 @@ func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { return res, nil } -func (c *MetadataReportConfig) IsValid() bool { - return len(c.Protocol) != 0 +func (mc *MetadataReportConfig) IsValid() bool { + return len(mc.Protocol) != 0 } // StartMetadataReport: The entry of metadata report start -func (c *MetadataReportConfig) StartMetadataReport() error { - if c == nil || !c.IsValid() { +func (mc *MetadataReportConfig) StartMetadataReport() error { + if mc == nil || !mc.IsValid() { return nil } - if tmpUrl, err := c.ToUrl(); err == nil { + if tmpUrl, err := mc.ToUrl(); err == nil { instance.GetMetadataReportInstance(tmpUrl) return nil } else { diff --git a/config/protocol_config.go b/config/protocol_config.go index ab24145ee6..0a1a1a9716 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -29,10 +29,19 @@ import ( type ProtocolConfig struct { Name string `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"` Ip string `yaml:"ip" json:"ip,omitempty" property:"ip"` - Port string `default:"2000" yaml:"port" json:"port,omitempty" property:"port"` + Port string `default:"20000" yaml:"port" json:"port,omitempty" property:"port"` Params interface{} `yaml:"params" json:"params,omitempty" property:"params"` } +// Prefix dubbo.config-center +func (ProtocolConfig) Prefix() string { + return constant.ConfigCenterPrefix +} + +func GetProtocolsInstance() map[string]*ProtocolConfig { + return make(map[string]*ProtocolConfig, 1) +} + func initProtocolsConfig(rc *RootConfig) error { protocols := rc.Protocols if len(protocols) <= 0 { @@ -52,7 +61,9 @@ func initProtocolsConfig(rc *RootConfig) error { } func (p *ProtocolConfig) check() error { - defaults.MustSet(p) + if err := defaults.Set(p); err != nil { + return err + } return verify(p) } diff --git a/config/protocol_config_test.go b/config/protocol_config_test.go index 64d77371dd..b27812046d 100644 --- a/config/protocol_config_test.go +++ b/config/protocol_config_test.go @@ -34,7 +34,7 @@ func TestGetProtocolsConfig(t *testing.T) { assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) - assert.Equal(t, string("2000"), protocols["dubbo"].Port) + assert.Equal(t, string("20000"), protocols["dubbo"].Port) }) t.Run("use config", func(t *testing.T) { @@ -44,6 +44,6 @@ func TestGetProtocolsConfig(t *testing.T) { assert.NotNil(t, protocols) // default assert.Equal(t, "dubbo", protocols["dubbo"].Name) - assert.Equal(t, string("2000"), protocols["dubbo"].Port) + assert.Equal(t, string("20000"), protocols["dubbo"].Port) }) } diff --git a/config/provider_config.go b/config/provider_config.go index f8bd8fdeed..a77f3f9c19 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -32,10 +32,8 @@ import ( // ProviderConfig is the default configuration of service provider type ProviderConfig struct { - //base.ShutdownConfig `yaml:",inline" property:"base"` - //center.configCenter `yaml:"-"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - // Register whether registration is required + // Deprecated Register whether registration is required Register bool `yaml:"register" json:"register" property:"register"` // Registry registry ids Registry []string `yaml:"registry" json:"registry" property:"registry"` @@ -49,9 +47,14 @@ type ProviderConfig struct { ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } -func (c *ProviderConfig) CheckConfig() error { - // todo check - defaults.MustSet(c) +func (ProviderConfig) Prefix() string { + return constant.ProviderConfigPrefix +} + +func (c *ProviderConfig) check() error { + if err := defaults.Set(c); err != nil { + return err + } return verify(c) } @@ -59,45 +62,21 @@ func (c *ProviderConfig) Init(rc *RootConfig) error { if c == nil { return nil } - for k, _ := range c.Services { - if err := c.Services[k].Init(rc); err != nil { + c.Registry = translateRegistryIds(c.Registry) + if len(c.Registry) <= 0 { + c.Registry = rc.getRegistryIds() + } + for _, service := range c.Services { + if err := service.Init(rc); err != nil { return err } } - if err := defaults.Set(c); err != nil { + if err := c.check(); err != nil { return err } - c.Registry = translateRegistryIds(c.Registry) - c.Load() return nil } -func (c *ProviderConfig) Validate(r *RootConfig) { - ids := make([]string, 0) - for key := range r.Registries { - ids = append(ids, key) - } - c.Registry = removeDuplicateElement(ids) - for k, _ := range c.Services { - c.Services[k].Validate(r) - } - // todo set default application -} - -// UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function -//func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { -// if err := defaults.Set(c); err != nil { -// return err -// } -// type plain ProviderConfig -// return unmarshal((*plain)(c)) -//} - -// Prefix dubbo.provider -func (c *ProviderConfig) Prefix() string { - return constant.ProviderConfigPrefix -} - func (c *ProviderConfig) Load() { for key, svs := range c.Services { rpcService := GetProviderService(key) @@ -111,6 +90,7 @@ func (c *ProviderConfig) Load() { logger.Errorf(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } + } // SetProviderConfig sets provider config by @p @@ -118,43 +98,6 @@ func SetProviderConfig(p ProviderConfig) { rootConfig.Provider = &p } -// -//// ProviderInit loads config file to init provider config -//func ProviderInit(confProFile string) error { -// if len(confProFile) == 0 { -// return perrors.Errorf("applicationConfig configure(provider) file name is nil") -// } -// providerConfig = &ProviderConfig{} -// fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) -// if err != nil { -// return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) -// } -// -// provider fileStream = bytes.NewBuffer(fileStream) -// // set method interfaceId & interfaceName -// for k, v := range provider Services { -// // set id for reference -// for _, n := range provider Services[k].Methods { -// n.InterfaceName = v.InterfaceName -// n.InterfaceId = k -// } -// } -// -// return nil -//} -// -//func configCenterRefreshProvider() error { -// // fresh it -// if provider ConfigCenterConfig != nil { -// provider fatherConfig = providerConfig -// if err := provider startConfigCenter((* providerConfig).BaseConfig); err != nil { -// return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) -// } -// provider fresh() -// } -// return nil -//} - ///////////////////////////////////// provider config api // ProviderConfigOpt is the type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig @@ -177,6 +120,18 @@ func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { return newConfig } +// GetProviderInstance returns ProviderConfig with given @opts +func GetProviderInstance(opts ...ProviderConfigOpt) *ProviderConfig { + newConfig := &ProviderConfig{ + Services: make(map[string]*ServiceConfig), + Registry: make([]string, 8), + } + for _, opt := range opts { + opt(newConfig) + } + return newConfig +} + // WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig func WithProviderService(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { return func(config *ProviderConfig) *ProviderConfig { diff --git a/config/provider_config_test.go b/config/provider_config_test.go index 4427b0d9d3..27b3c6695c 100644 --- a/config/provider_config_test.go +++ b/config/provider_config_test.go @@ -17,25 +17,33 @@ package config -//import ( -// "dubbo.apache.org/dubbo-go/v3/config" -// "dubbo.apache.org/dubbo-go/v3/config/consumer" -// "path/filepath" -// "testing" -//) -// -//import ( -// "github.com/stretchr/testify/assert" -//) -// -//func TestConsumerInit(t *testing.T) { -// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") -// assert.NoError(t, err) -// assert.NoError(t, consumer.ConsumerInit(conPath)) -// assert.Equal(t, "default", config.consumerConfig.ProxyFactory) -// assert.Equal(t, "dubbo.properties", config.consumerConfig.ConfigCenterConfig.ConfigFile) -// assert.Equal(t, "100ms", config.consumerConfig.Connect_Timeout) -//} +import ( + "testing" +) + +import ( + "github.com/stretchr/testify/assert" +) + +func TestProviderConfigEmptyRegistry(t *testing.T) { + err := Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) + assert.Nil(t, err) + provider := rootConfig.Provider + assert.Equal(t, 1, len(provider.Registry)) + assert.Equal(t, "nacos", provider.Registry[0]) +} + +func TestProviderConfigRootRegistry(t *testing.T) { + err := Load(WithPath("./testdata/config/provider/registry_application.yaml")) + assert.Nil(t, err) + provider := rootConfig.Provider + assert.NotNil(t, provider) + assert.Equal(t, 2, len(provider.Services)) + + assert.Equal(t, 2, len(provider.Services["HelloService"].Registry)) + assert.Equal(t, 1, len(provider.Services["OrderService"].Registry)) +} + // //func TestConsumerInitWithDefaultProtocol(t *testing.T) { // conPath, err := filepath.Abs("./testdata/consumer_config_withoutProtocol.yml") diff --git a/config/reference_config.go b/config/reference_config.go index 0318a7bdd7..986a39076e 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -77,20 +77,24 @@ func (rc *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + rc.InterfaceName + "." } -func (cc *ReferenceConfig) Init(rc *RootConfig) error { - for k, _ := range cc.Methods { - if err := cc.Methods[k].Init(); err != nil { +func (rc *ReferenceConfig) Init(root *RootConfig) error { + for _, method := range rc.Methods { + if err := method.Init(); err != nil { return err } } if err := defaults.Set(rc); err != nil { return err } - cc.rootConfig = rc - if rc.Application != nil { - cc.metaDataType = rc.Application.MetadataType + rc.rootConfig = root + if root.Application != nil { + rc.metaDataType = root.Application.MetadataType } - return verify(cc) + rc.Registry = translateRegistryIds(rc.Registry) + if len(rc.Registry) <= 0 { + rc.Registry = root.Consumer.Registry + } + return verify(rc) } // Refer ... diff --git a/config/registry_config.go b/config/registry_config.go index f96bbb4318..c811eeed9f 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -38,10 +38,10 @@ import ( // RegistryConfig is the configuration of the registry center type RegistryConfig struct { Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Timeout string `default:"10s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second + Timeout string `default:"5s" validate:"required" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` Namespace string `yaml:"namespace" json:"namespace,omitempty" property:"namespace"` - TTL string `default:"10m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute + TTL string `default:"10s" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute // for registry Address string `validate:"required" yaml:"address" json:"address,omitempty" property:"address"` Username string `yaml:"username" json:"username,omitempty" property:"username"` @@ -58,7 +58,7 @@ type RegistryConfig struct { RegistryType string `yaml:"registry-type"` } -// Prefix dubbo.registriesConfig +// Prefix dubbo.registries func (RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix } @@ -71,8 +71,16 @@ func (c *RegistryConfig) check() error { return verify(c) } -func (c *RegistryConfig) Init() error { - return c.check() +// initRegistryConfig init registry config +func initRegistryConfig(rc *RootConfig) error { + registries := rc.Registries + for key, reg := range registries { + if err := reg.check(); err != nil { + return err + } + registries[key] = reg + } + return nil } func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { @@ -97,27 +105,27 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { // eg:address=nacos://127.0.0.1:8848 will return 127.0.0.1:8848 and protocol will set nacos func (c *RegistryConfig) translateRegistryAddress() string { if strings.Contains(c.Address, "://") { - translatedUrl, err := url.Parse(c.Address) + u, err := url.Parse(c.Address) if err != nil { logger.Errorf("The registry url is invalid, error: %#v", err) panic(err) } - c.Protocol = translatedUrl.Scheme - c.Address = strings.Replace(c.Address, translatedUrl.Scheme+"://", "", -1) + c.Protocol = u.Scheme + c.Address = strings.Join([]string{u.Host, u.Path}, "") } return c.Address } func (c *RegistryConfig) GetInstance(roleType common.RoleType) (registry.Registry, error) { - url, err := c.toURL(roleType) + u, err := c.toURL(roleType) if err != nil { return nil, err } // if the protocol == registry, set protocol the registry value in url.params - if url.Protocol == constant.REGISTRY_PROTOCOL { - url.Protocol = url.GetParam(constant.REGISTRY_KEY, "") + if u.Protocol == constant.REGISTRY_PROTOCOL { + u.Protocol = u.GetParam(constant.REGISTRY_KEY, "") } - return extension.GetRegistry(url.Protocol, url) + return extension.GetRegistry(u.Protocol, u) } func (c *RegistryConfig) toURL(roleType common.RoleType) (*common.URL, error) { diff --git a/config/registry_config_test.go b/config/registry_config_test.go index f1f4716d30..d9c5521d02 100644 --- a/config/registry_config_test.go +++ b/config/registry_config_test.go @@ -68,8 +68,8 @@ func TestTranslateRegistryAddress(t *testing.T) { reg := new(RegistryConfig) reg.Address = "nacos://127.0.0.1:8848" - address := reg.translateRegistryAddress() + reg.translateRegistryAddress() assert.Equal(t, "nacos", reg.Protocol) - assert.Equal(t, "127.0.0.1:8848", address) + assert.Equal(t, "127.0.0.1:8848", reg.Address) } diff --git a/config/root_config.go b/config/root_config.go index de7731cb02..36d24b5e7c 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -18,14 +18,11 @@ package config import ( - "bytes" - "net/http" _ "net/http/pprof" ) import ( "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" ) // RootConfig is the root config @@ -62,25 +59,14 @@ type RootConfig struct { // Shutdown config Shutdown *ShutdownConfig `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` - // Deprecated - Network map[interface{}]interface{} `yaml:"network" json:"network,omitempty" property:"network"` - Router []*RouterConfig `yaml:"router" json:"router,omitempty" property:"router"` - // is refresh action - refresh bool - // prefix string - fatherConfig interface{} - EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"` - fileStream *bytes.Buffer + + EventDispatcherType string `default:"direct" yaml:"event-dispatcher-type" json:"event-dispatcher-type,omitempty"` // cache file used to store the current used configurations. CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"` } -func init() { - rootConfig = NewRootConfig() -} - func SetRootConfig(r RootConfig) { rootConfig = &r } @@ -90,137 +76,28 @@ func (RootConfig) Prefix() string { return constant.DUBBO } -// Init init config -func (rc *RootConfig) Init() error { - if err := initLoggerConfig(rc); err != nil { - return err - } - if err := rc.ConfigCenter.Init(rc); err != nil { - logger.Infof("config center doesn't start. error is %s", err) - } - if err := rc.Application.Init(rc); err != nil { - return err - } - if err := initProtocolsConfig(rc); err != nil { - return err - } - for i, _ := range rc.Registries { - if err := rc.Registries[i].Init(); err != nil { - return err - } - } - if err := initServiceDiscoveryConfig(rc); err != nil { - return err - } - if err := rc.MetadataReportConfig.Init(rc); err != nil { - return err - } - if err := initMetricConfig(rc); err != nil { - return err - } - if err := initNetworkConfig(rc); err != nil { - return err - } - if err := initRouterConfig(rc); err != nil { - return err - } - // provider、consumer must last init - if err := rc.Provider.Init(rc); err != nil { - return err - } - if err := rc.Consumer.Init(rc); err != nil { - return err - } - go func() { - _ = http.ListenAndServe("0.0.0.0:6060", nil) - }() - return nil -} - -//func (rc *RootConfig) CheckConfig() error { -// defaults.MustSet(rc) -// -// if err := rc.Application.CheckConfig(); err != nil { -// return err -// } -// -// for k, _ := range rc.Registries { -// if err := rc.Registries[k].CheckConfig(); err != nil { -// return err -// } -// } -// -// for k, _ := range rc.Protocols { -// if err := rc.Protocols[k].CheckConfig(); err != nil { -// return err -// } -// } -// -// if err := rc.ConfigCenter.CheckConfig(); err != nil { -// return err -// } -// -// if err := rc.MetadataReportConfig.CheckConfig(); err != nil { -// return err -// } -// -// if err := rc.Provider.CheckConfig(); err != nil { -// return err -// } -// -// if err := rc.Consumer.CheckConfig(); err != nil { -// return err -// } -// -// return verify(rootConfig) -//} - -//func (rc *RootConfig) Validate() { -// // 2. validate config -// rc.Application.Validate() -// -// for k, _ := range rc.Registries { -// rc.Registries[k].Validate() -// } -// -// for k, _ := range rc.Protocols { -// rc.Protocols[k].Validate() -// } -// -// for k, _ := range rc.Registries { -// rc.Registries[k].Validate() -// } -// -// rc.ConfigCenter.Validate() -// rc.MetadataReportConfig.Validate() -// rc.Provider.Validate(rc) -// rc.Consumer.Validate(rc) -//} - -//GetApplicationConfig get applicationConfig config - func GetRootConfig() *RootConfig { return rootConfig } func GetProviderConfig() *ProviderConfig { if err := check(); err != nil { - return NewProviderConfig() + return GetProviderInstance() } if rootConfig.Provider != nil { return rootConfig.Provider } - return NewProviderConfig() + return GetProviderInstance() } func GetConsumerConfig() *ConsumerConfig { if err := check(); err != nil { - return NewConsumerConfig() + return GetConsumerInstance() } if rootConfig.Consumer != nil { return rootConfig.Consumer } - return NewConsumerConfig() + return GetConsumerInstance() } func GetApplicationConfig() *ApplicationConfig { @@ -309,15 +186,16 @@ func GetApplicationConfig() *ApplicationConfig { // return provider, nil //} -//// getRegistryIds get registry keys -//func getRegistryIds() []string { -// ids := make([]string, 0) -// for key := range rootConfig.Registries { -// ids = append(ids, key) -// } -// return removeDuplicateElement(ids) -//} +// getRegistryIds get registry ids +func (rc *RootConfig) getRegistryIds() []string { + ids := make([]string, 0) + for key := range rc.Registries { + ids = append(ids, key) + } + return removeDuplicateElement(ids) +} +// NewRootConfig get root config func NewRootConfig(opts ...RootConfigOpt) *RootConfig { newRootConfig := &RootConfig{ ConfigCenter: &CenterConfig{}, @@ -326,8 +204,8 @@ func NewRootConfig(opts ...RootConfigOpt) *RootConfig { Application: &ApplicationConfig{}, Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig), - Provider: NewProviderConfig(), - Consumer: NewConsumerConfig(), + Provider: GetProviderInstance(), + Consumer: GetConsumerInstance(), MetricConfig: &MetricConfig{}, } for _, o := range opts { diff --git a/config/service_config.go b/config/service_config.go index 3948fc0697..53dce7ac3a 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -93,7 +93,7 @@ type ServiceConfig struct { // Prefix returns dubbo.service.${InterfaceName}. func (svc *ServiceConfig) Prefix() string { - return constant.ServiceConfigPrefix + svc.id + return strings.Join([]string{constant.ServiceConfigPrefix, svc.id}, ".") } func (svc *ServiceConfig) Init(rc *RootConfig) error { @@ -111,75 +111,14 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { if rc.Provider != nil { svc.ProxyFactoryKey = rc.Provider.ProxyFactory } - + svc.Registry = translateRegistryIds(svc.Registry) + if len(svc.Registry) <= 0 { + svc.Registry = rc.Provider.Registry + } svc.export = true return verify(svc) } -// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function -//func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { -// if err := defaults.Set(c); err != nil { -// return err -// } -// type plain ServiceConfig -// if err := unmarshal((*plain)(c)); err != nil { -// return err -// } -// c.exported = atomic.NewBool(false) -// c.unexported = atomic.NewBool(false) -// c.export = true -// return nil -//} - -func (svc *ServiceConfig) CheckConfig() error { - // todo check - defaults.MustSet(svc) - return verify(svc) -} - -func (svc *ServiceConfig) Validate(rootConfig *RootConfig) { - svc.exported = atomic.NewBool(false) - svc.unexported = atomic.NewBool(false) - svc.export = true - // todo set default application -} - -//getRegistryServices get registry services -func getRegistryServices(side int, services map[string]*ServiceConfig, registryIds []string) map[string]*ServiceConfig { - var ( - svc *ServiceConfig - exist bool - initService map[string]common.RPCService - registryServices map[string]*ServiceConfig - ) - if side == common.PROVIDER { - initService = proServices - } else if side == common.CONSUMER { - initService = conServices - } - registryServices = make(map[string]*ServiceConfig, len(initService)) - for key := range initService { - //存在配置了使用用户的配置 - if svc, exist = services[key]; !exist { - svc = new(ServiceConfig) - } - defaults.MustSet(svc) - if len(svc.Registry) <= 0 { - svc.Registry = registryIds - } - svc.id = key - svc.export = true - svc.unexported = atomic.NewBool(false) - svc.exported = atomic.NewBool(false) - svc.Registry = translateRegistryIds(svc.Registry) - if err := verify(svc); err != nil { - return nil - } - registryServices[key] = svc - } - return registryServices -} - // InitExported will set exported as false atom bool func (svc *ServiceConfig) InitExported() { svc.exported = atomic.NewBool(false) diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml index 2dcb875165..4cd30cc61e 100644 --- a/config/testdata/config/app/application.yaml +++ b/config/testdata/config/app/application.yaml @@ -2,7 +2,7 @@ dubbo: registries: nacos: timeout: 3s - address: zookeeper://127.0.0.1:2182 + address: nacos://127.0.0.1:8848 protocols: dubbo: name: dubbo diff --git a/config/testdata/config/application/application.yaml b/config/testdata/config/application/application.yaml new file mode 100644 index 0000000000..ea32df4caa --- /dev/null +++ b/config/testdata/config/application/application.yaml @@ -0,0 +1,4 @@ +dubbo: + registries: + nacos: + address: nacos://127.0.0.1:8848 \ No newline at end of file diff --git a/config/testdata/config/protocol/application.yaml b/config/testdata/config/protocol/application.yaml index bc0aecba71..4f06d63f49 100644 --- a/config/testdata/config/protocol/application.yaml +++ b/config/testdata/config/protocol/application.yaml @@ -1,2 +1,7 @@ dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 protocols: \ No newline at end of file diff --git a/config/testdata/config/protocol/empty_application.yaml b/config/testdata/config/protocol/empty_application.yaml index bc0aecba71..4f06d63f49 100644 --- a/config/testdata/config/protocol/empty_application.yaml +++ b/config/testdata/config/protocol/empty_application.yaml @@ -1,2 +1,7 @@ dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 protocols: \ No newline at end of file diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml index 45e7231273..8816257a05 100644 --- a/config/testdata/config/provider/application.yaml +++ b/config/testdata/config/provider/application.yaml @@ -1,4 +1,9 @@ dubbo: + registries: + nacos: + timeout: 5s + group: dev + address: nacos://127.0.0.1:8848 provider: register: true registry: diff --git a/config/testdata/config/provider/registry_application.yaml b/config/testdata/config/provider/registry_application.yaml index f5b04deb25..dd08a0d4fd 100644 --- a/config/testdata/config/provider/registry_application.yaml +++ b/config/testdata/config/provider/registry_application.yaml @@ -1,10 +1,13 @@ dubbo: + registries: + nacos: + timeout: 3s + address: naocs://127.0.0.1:8848 provider: - register: true - registry: nacos,zk + registry: nacos services: - helloService: + HelloService: interface: org.dubbo.service.HelloService registry: nacos,zk - orderService: + OrderService: interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/service/hello_service.go b/config/testdata/config/service/hello_service.go deleted file mode 100644 index b2b97d5829..0000000000 --- a/config/testdata/config/service/hello_service.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 service - -import ( - "context" -) - -type HelloService struct { - // say hello - Say func(ctx context.Context, req []interface{}) error -} - -func (HelloService) Reference() string { - return "helloService" -} diff --git a/config/testdata/config/service/order_service.go b/config/testdata/config/service/order_service.go deleted file mode 100644 index 9b43de8bc4..0000000000 --- a/config/testdata/config/service/order_service.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 service - -import ( - "context" -) - -type OrderService struct { - // GetOrders - GetOrders func(ctx context.Context, req []interface{}) error -} - -func (OrderService) Reference() string { - return "orderService" -} diff --git a/go.mod b/go.mod index c8107ddf6a..8ba6c83598 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module dubbo.apache.org/dubbo-go/v3 go 1.15 require ( - contrib.go.opencensus.io/exporter/prometheus v0.4.0 github.com/RoaringBitmap/roaring v0.7.1 github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 @@ -20,6 +19,7 @@ require ( github.com/go-co-op/gocron v0.1.1 github.com/go-playground/validator/v10 v10.7.0 github.com/go-resty/resty/v2 v2.3.0 + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 @@ -34,6 +34,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.0 + github.com/prometheus/common v0.28.0 // indirect github.com/satori/go.uuid v1.2.0 github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 diff --git a/go.sum b/go.sum index bc3909e2c8..5519d42789 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= -contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= @@ -238,14 +236,12 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= @@ -267,7 +263,6 @@ github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8 github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= @@ -330,7 +325,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -665,8 +659,6 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8= -github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= @@ -733,7 +725,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -795,8 +786,6 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -903,7 +892,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/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-20201110031124-69a78807bb2b/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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= @@ -1153,7 +1141,6 @@ google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= diff --git a/integrate_test.sh b/integrate_test.sh index 682e7e7ca8..b12c653fd8 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -37,7 +37,7 @@ echo "github pull request head branch -> ${GITHUB_HEAD_REF}" samples_testing() { echo "use dubbo-go-samples $3 branch for integration testing" - git clone -b "$3" https://github.com/apache/dubbo-go-samples.git samples && cd samples + git clone -b master https://github.com/apache/dubbo-go-samples.git samples && cd samples # update dubbo-go to current commit id go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/"$1"/v3@"$2" diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 55393e1d94..1fe775d9a5 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -78,7 +78,7 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := config.NewProviderConfig( + providerConfig := config.GetProviderInstance( config.WithProviderService("MockService", config.NewServiceConfig())) providerConfig.Services["MockService"].InitExported() config.SetRootConfig(config.RootConfig{ diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 02365a17a3..96ec3093ae 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -19,7 +19,6 @@ package prometheus import ( "context" - "net/http" "strconv" "strings" "sync" @@ -27,8 +26,6 @@ import ( ) import ( - ocprom "contrib.go.opencensus.io/exporter/prometheus" - "github.com/prometheus/client_golang/prometheus" prom "github.com/prometheus/client_golang/prometheus" ) @@ -71,7 +68,7 @@ var ( // should initialize after loading configuration func init() { - newPrometheusReporter() + //newPrometheusReporter() extension.SetMetricReporter(reporterName, newPrometheusReporter) } @@ -221,20 +218,20 @@ func newPrometheusReporter() metrics.Reporter { prom.DefaultRegisterer.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec, reporterInstance.consumerHistogramVec, reporterInstance.providerHistogramVec) - metricsExporter, err := ocprom.NewExporter(ocprom.Options{ - Registry: prom.DefaultRegisterer.(*prom.Registry), - }) - if err != nil { - logger.Errorf("new prometheus reporter with error = %s", err) - return - } - go func() { - mux := http.NewServeMux() - mux.Handle("/metrics", metricsExporter) - if err := http.ListenAndServe(":9090", mux); err != nil { - logger.Errorf("new prometheus reporter with error = %s", err) - } - }() + //metricsExporter, err := ocprom.NewExporter(ocprom.Options{ + // Registry: prom.DefaultRegisterer.(*prom.Registry), + //}) + //if err != nil { + // logger.Errorf("new prometheus reporter with error = %s", err) + // return + //} + //go func() { + // mux := http.NewServeMux() + // mux.Handle("/metrics", metricsExporter) + // if err := http.ListenAndServe(":9090", mux); err != nil { + // logger.Errorf("new prometheus reporter with error = %s", err) + // } + //}() }) } return reporterInstance diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index e1cf5dafe2..5ba17651b3 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -48,7 +48,7 @@ func InitDubboServer() { config.WithServiceProtocolKeys("tripleKey"), ) - providerConfig := config.NewProviderConfig( + providerConfig := config.GetProviderInstance( config.WithProviderService(common.GetReference(&Server{}), serviceConfig), ) @@ -57,12 +57,12 @@ func InitDubboServer() { config.WithProtocolPort("20003"), ) - rootConfig := config.NewRootConfig( + rootConfig := config.GetInstance( config.WithRootProviderConfig(providerConfig), config.WithRootProtocolConfig("tripleKey", protocolConfig), ) - config.SetProviderConfig(*providerConfig) // set to providerConfig ptr config.SetProviderService(&Server{}) rootConfig.Init() + rootConfig.Start() } From 26aa12b8b070927bd09a70f81c6f909218419652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=95=E6=B0=98=E6=B0=9A?= Date: Sun, 26 Sep 2021 13:02:24 +0800 Subject: [PATCH 114/148] Ftr: add fatal method for logger(config-enhance branch) (#1482) * feat: add fatal method for logger * test: add test for logger fatal & fatalf --- common/logger/logger.go | 2 ++ common/logger/logging.go | 10 ++++++++++ config/logger_config_test.go | 14 ++++++++++++++ go.mod | 1 + go.sum | 2 ++ 5 files changed, 29 insertions(+) diff --git a/common/logger/logger.go b/common/logger/logger.go index e5c999f99e..6d4f207cd9 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -50,11 +50,13 @@ type Logger interface { Warn(args ...interface{}) Error(args ...interface{}) Debug(args ...interface{}) + Fatal(args ...interface{}) Infof(fmt string, args ...interface{}) Warnf(fmt string, args ...interface{}) Errorf(fmt string, args ...interface{}) Debugf(fmt string, args ...interface{}) + Fatalf(fmt string, args ...interface{}) } // InitLogger use for init logger by @conf diff --git a/common/logger/logging.go b/common/logger/logging.go index 7a31ece203..d114423c3d 100644 --- a/common/logger/logging.go +++ b/common/logger/logging.go @@ -56,3 +56,13 @@ func Errorf(fmt string, args ...interface{}) { func Debugf(fmt string, args ...interface{}) { logger.Debugf(fmt, args...) } + +// Fatal logs a message, then calls os.Exit. +func Fatal(args ...interface{}) { + logger.Fatal(args...) +} + +// Fatalf logs a templated message, then calls os.Exit. +func Fatalf(fmt string, args ...interface{}) { + logger.Fatalf(fmt, args...) +} diff --git a/config/logger_config_test.go b/config/logger_config_test.go index 94e464fdad..8be1854000 100644 --- a/config/logger_config_test.go +++ b/config/logger_config_test.go @@ -18,10 +18,12 @@ package config import ( + "os" "testing" ) import ( + "bou.ke/monkey" "github.com/stretchr/testify/assert" ) @@ -29,6 +31,10 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" ) +func fakeExit(int) { + panic("os.Exit called") +} + func TestLoggerInit(t *testing.T) { t.Run("empty use default", func(t *testing.T) { err := Load(WithPath("./testdata/config/logger/empty_log.yaml")) @@ -38,6 +44,14 @@ func TestLoggerInit(t *testing.T) { assert.NotNil(t, loggerConfig) assert.Equal(t, []string{"stderr"}, loggerConfig.ZapConfig.OutputPaths) logger.Info("hello") + patch := monkey.Patch(os.Exit, fakeExit) + defer patch.Unpatch() + assert.PanicsWithValue(t, "os.Exit called", func() { + logger.Fatalf("%s", "error") + }, "os.Exit was not called") + assert.PanicsWithValue(t, "os.Exit called", func() { + logger.Fatal("error") + }, "os.Exit was not called") }) t.Run("use config", func(t *testing.T) { diff --git a/go.mod b/go.mod index 8ba6c83598..d41d5c5ef9 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module dubbo.apache.org/dubbo-go/v3 go 1.15 require ( + bou.ke/monkey v1.0.2 github.com/RoaringBitmap/roaring v0.7.1 github.com/Workiva/go-datastructures v1.0.52 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 diff --git a/go.sum b/go.sum index 5519d42789..e479db5e61 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= +bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI= +bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= From 4314ba8b9ecb31cfb9bbb64c27cc5aa9cf56eb04 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 26 Sep 2021 18:30:38 +0800 Subject: [PATCH 115/148] fix: remove old integrate test --- .github/workflows/github-actions.yml | 8 - Makefile | 11 +- test/integrate/dubbo/go-client/Dockerfile | 42 - test/integrate/dubbo/go-client/client.go | 67 -- test/integrate/dubbo/go-client/client.yml | 59 -- test/integrate/dubbo/go-client/go.mod | 10 - test/integrate/dubbo/go-client/go.sum | 903 ---------------------- test/integrate/dubbo/go-client/log.yml | 27 - test/integrate/dubbo/go-client/user.go | 57 -- test/integrate/dubbo/go-client/version.go | 20 - test/integrate/dubbo/go-server/Dockerfile | 41 - test/integrate/dubbo/go-server/go.mod | 14 - test/integrate/dubbo/go-server/go.sum | 903 ---------------------- test/integrate/dubbo/go-server/log.yml | 27 - test/integrate/dubbo/go-server/server.go | 56 -- test/integrate/dubbo/go-server/server.yml | 55 -- test/integrate/dubbo/go-server/user.go | 67 -- test/integrate/dubbo/go-server/version.go | 20 - 18 files changed, 2 insertions(+), 2385 deletions(-) delete mode 100644 test/integrate/dubbo/go-client/Dockerfile delete mode 100644 test/integrate/dubbo/go-client/client.go delete mode 100644 test/integrate/dubbo/go-client/client.yml delete mode 100644 test/integrate/dubbo/go-client/go.mod delete mode 100644 test/integrate/dubbo/go-client/go.sum delete mode 100644 test/integrate/dubbo/go-client/log.yml delete mode 100644 test/integrate/dubbo/go-client/user.go delete mode 100644 test/integrate/dubbo/go-client/version.go delete mode 100644 test/integrate/dubbo/go-server/Dockerfile delete mode 100644 test/integrate/dubbo/go-server/go.mod delete mode 100644 test/integrate/dubbo/go-server/go.sum delete mode 100644 test/integrate/dubbo/go-server/log.yml delete mode 100644 test/integrate/dubbo/go-server/server.go delete mode 100644 test/integrate/dubbo/go-server/server.yml delete mode 100644 test/integrate/dubbo/go-server/user.go delete mode 100644 test/integrate/dubbo/go-server/version.go diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 0ffb5c6f53..89557d0edb 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -68,18 +68,10 @@ jobs: run: | make verify - # This step only runs when the event type is a pull_request - name: Integrate Test - if: ${{ github.event_name == 'pull_request' }} run: | chmod +x integrate_test.sh && [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] && [[ -n "${{github.event.pull_request.head.sha}}" ]] && [[ -n "${{github.base_ref}}" ]] && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}} - # This step only runs when the event type is a push - - name: Integrate Test - if: ${{ github.event_name == 'push' }} - run: | - chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF - - name: Post Coverage run: bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 2f6c9bd4e2..bee04cbfa5 100644 --- a/Makefile +++ b/Makefile @@ -47,17 +47,10 @@ prepareLic: $(GO_LICENSE_CHECKER) -version || (wget https://github.com/lsm-dev/license-header-checker/releases/download/v1.2.0/$(GO_LICENSE_CHECKER_DIR).zip -O $(GO_LICENSE_CHECKER_DIR).zip && unzip -o $(GO_LICENSE_CHECKER_DIR).zip && mkdir -p $(GO_PATH)/bin/ && cp $(GO_LICENSE_CHECKER_DIR)/64bit/license-header-checker $(GO_PATH)/bin/) ls /tmp/tools/license/license.txt || wget -P $(LICENSE_DIR) https://github.com/dubbogo/resources/raw/master/tools/license/license.txt -prepareZk: - ls $(ZK_JAR) || (mkdir -p $(ZK_JAR_PATH)&& wget -P $(ZK_JAR_PATH) https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/${ZK_JAR_NAME}) - @for i in $(ZK_TEST_LIST); do \ - mkdir -p $$i$(ZK_FATJAR_BASE);\ - cp ${ZK_JAR} $$i$(ZK_FATJAR_BASE);\ - done - -prepare: prepareZk prepareLic +prepare: prepareLic .PHONE: test -test: clean prepareZk +test: clean $(GO_TEST) ./... -coverprofile=coverage.txt -covermode=atomic deps: prepare diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile deleted file mode 100644 index a069c5d16f..0000000000 --- a/test/integrate/dubbo/go-client/Dockerfile +++ /dev/null @@ -1,42 +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. -# - -FROM golang - -WORKDIR /go/src/dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-client - -ENV CONF_CONSUMER_FILE_PATH "client.yml" -ENV APP_LOG_CONF_FILE "log.yml" - -# for pull_request, it is pr origin repository -# for merge int develop/master, it is github.com/apache/dubbo-go -ARG REPO -# for pull_request, it is pr origin commit id -# for merge int develop/master, it is the commit id that trigger the ci workflow -ARG COMMITID - -ADD . /go/src/dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-client - -# update dubbo-go to current commit id -RUN test ${REPO} && echo "dubbo.apache.org/dubbo-go/v3 will be replace to github.com/${REPO}/v3@${COMMITID}" -RUN test ${REPO} && go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/${REPO}/v3@${COMMITID} - -ENV GO111MODULE on - -RUN go mod tidy && go install dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-client - -CMD go-client \ No newline at end of file diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go deleted file mode 100644 index bcc3946616..0000000000 --- a/test/integrate/dubbo/go-client/client.go +++ /dev/null @@ -1,67 +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 main - -import ( - "context" - "fmt" - "time" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" -) - -import ( - _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" - _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" - _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" -) - -func println(format string, args ...interface{}) { - fmt.Printf("\033[32;40m"+format+"\033[0m\n", args...) -} - -// they are necessary: -// export CONF_CONSUMER_FILE_PATH="xxx" -// export APP_LOG_CONF_FILE="xxx" -func main() { - hessian.RegisterPOJO(&User{}) - config.Load() - time.Sleep(3e9) - - println("\n\n\nstart to test dubbo") - - go func() { - select { - case <-time.After(time.Minute): - panic("provider not start after client already running 1min") - } - }() - user := &User{} - err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) - if err != nil { - panic(err) - } - println("response result: %v\n", user) -} diff --git a/test/integrate/dubbo/go-client/client.yml b/test/integrate/dubbo/go-client/client.yml deleted file mode 100644 index 8f17b6b88f..0000000000 --- a/test/integrate/dubbo/go-client/client.yml +++ /dev/null @@ -1,59 +0,0 @@ -# dubbo client yaml configure file - - -check: true -# client -request_timeout : "3s" -# connect timeout -connect_timeout : "3s" - -# application config -application: - organization : "ikurento.com" - name : "BDTService" - module : "dubbogo user-info client" - version : "0.0.1" - owner : "ZX" - environment : "dev" - -registries : - "demoZk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - - -references: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "demoZk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 - - -protocol_conf: - dubbo: - reconnect_interval: 0 - connection_number: 2 - heartbeat_period: "5s" - session_timeout: "20s" - pool_size: 64 - pool_ttl: 600 - getty_session_param: - compress_encoding: false - tcp_no_delay: true - tcp_keep_alive: true - keep_alive_period: "120s" - tcp_r_buf_size: 262144 - tcp_w_buf_size: 65536 - tcp_read_timeout: "1s" - tcp_write_timeout: "5s" - wait_timeout: "1s" - max_msg_len: 1024000 - session_name: "client" diff --git a/test/integrate/dubbo/go-client/go.mod b/test/integrate/dubbo/go-client/go.mod deleted file mode 100644 index 4491a61529..0000000000 --- a/test/integrate/dubbo/go-client/go.mod +++ /dev/null @@ -1,10 +0,0 @@ -module dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-client - -go 1.13 - -require ( - dubbo.apache.org/dubbo-go/v3 v3.0.0 - github.com/apache/dubbo-go-hessian2 v1.9.2 -) - -replace dubbo.apache.org/dubbo-go/v3 => ../../../../../dubbo-go diff --git a/test/integrate/dubbo/go-client/go.sum b/test/integrate/dubbo/go-client/go.sum deleted file mode 100644 index 83e26bf79b..0000000000 --- a/test/integrate/dubbo/go-client/go.sum +++ /dev/null @@ -1,903 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.7.1 h1:HkcLv8q/kwGJnhEWe+vinu+04DGDdQ7nVivMhNhxP2g= -github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTrRXv9zpIg= -github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= -github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -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/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -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/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -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= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= -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.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= -github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvyukov/go-fuzz v0.0.0-20210429054444-fca39067bc72/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -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/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= -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/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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= -github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= -github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= -github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -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= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -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= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= -github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= -github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -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= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= -github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= -github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -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= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= -github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -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/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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -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/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= -github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= -github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -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= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -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= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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 v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -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= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -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.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -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/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -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/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= -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/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= -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/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= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= -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.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= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= -golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -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/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -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= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -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/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= -k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= -k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= -k8s.io/client-go v0.16.9/go.mod h1:ThjPlh7Kx+XoBFOCt775vx5J7atwY7F/zaFzTco5gL0= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/test/integrate/dubbo/go-client/log.yml b/test/integrate/dubbo/go-client/log.yml deleted file mode 100644 index 21f97bcbc4..0000000000 --- a/test/integrate/dubbo/go-client/log.yml +++ /dev/null @@ -1,27 +0,0 @@ -level: "debug" -development: false -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go deleted file mode 100644 index 000752c653..0000000000 --- a/test/integrate/dubbo/go-client/user.go +++ /dev/null @@ -1,57 +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 main - -import ( - "context" - "time" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - -var userProvider = new(UserProvider) - -func init() { - config.SetConsumerService(userProvider) - hessian.RegisterPOJO(&User{}) -} - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (User) JavaClassName() string { - return "com.ikurento.user.User" -} diff --git a/test/integrate/dubbo/go-client/version.go b/test/integrate/dubbo/go-client/version.go deleted file mode 100644 index 92974643b3..0000000000 --- a/test/integrate/dubbo/go-client/version.go +++ /dev/null @@ -1,20 +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 main - -var Version = "2.6.0" diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile deleted file mode 100644 index b7c9b849cd..0000000000 --- a/test/integrate/dubbo/go-server/Dockerfile +++ /dev/null @@ -1,41 +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. -# - -FROM golang - -WORKDIR /go/src/dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-server - -ENV CONF_PROVIDER_FILE_PATH "server.yml" -ENV APP_LOG_CONF_FILE "log.yml" - -# for pull_request, it is pr origin repository -# for merge int develop/master, it is github.com/apache/dubbo-go -ARG REPO -# for pull_request, it is pr origin commit id -# for merge int develop/master, it is the commit id that trigger the ci workflow -ARG COMMITID - -ADD . /go/src/dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-server -# update dubbo-go to current commit id -RUN test ${REPO} && echo "dubbo.apache.org/dubbo-go/v3 will be replace to github.com/${REPO}/v3@${COMMITID}" -RUN test ${REPO} && go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/${REPO}/v3@${COMMITID} - -ENV GO111MODULE on - -RUN go mod tidy && go install dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-server - -CMD go-server \ No newline at end of file diff --git a/test/integrate/dubbo/go-server/go.mod b/test/integrate/dubbo/go-server/go.mod deleted file mode 100644 index 8b34f59a80..0000000000 --- a/test/integrate/dubbo/go-server/go.mod +++ /dev/null @@ -1,14 +0,0 @@ -module dubbo.apache.org/dubbo-go/v3/test/integrate/dubbo/go-server - -go 1.13 - -require ( - dubbo.apache.org/dubbo-go/v3 v3.0.0 - // useless dubbo-go version number, it will be replaced when run by this Docker file: ../Dockerfile: - //``` - // RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} || go get -u dubbo.apache.org/dubbo-go/v3@develop - //``` - github.com/apache/dubbo-go-hessian2 v1.9.2 -) - -replace dubbo.apache.org/dubbo-go/v3 => ../../../../../dubbo-go diff --git a/test/integrate/dubbo/go-server/go.sum b/test/integrate/dubbo/go-server/go.sum deleted file mode 100644 index 83e26bf79b..0000000000 --- a/test/integrate/dubbo/go-server/go.sum +++ /dev/null @@ -1,903 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/RoaringBitmap/roaring v0.7.1 h1:HkcLv8q/kwGJnhEWe+vinu+04DGDdQ7nVivMhNhxP2g= -github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 h1:rFw4nCn9iMW+Vajsk51NtYIcwSTkXr+JGrMd36kTDJw= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alibaba/sentinel-golang v1.0.2 h1:Acopq74hOtZN4MV1v811MQ6QcqPFLDSczTrRXv9zpIg= -github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI= -github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek= -github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= -github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -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/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -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/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -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/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -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= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g= -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.13 h1:sWvK1QbHpPBMmRQJV9qIH3syLegQBQa4xAPof3/Kv5c= -github.com/dubbogo/gost v1.11.13/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= -github.com/dubbogo/net v0.0.3/go.mod h1:B6/ka3g8VzcyrmdCH4VkHP1K0aHeI37FmclS+TCwIBU= -github.com/dubbogo/triple v1.0.1/go.mod h1:O6vQD2XLCWugzAk0P27HTW4+Uhkd8sjaQn0BZijdGzU= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvyukov/go-fuzz v0.0.0-20210429054444-fca39067bc72/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.4.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -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/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= -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/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= -github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= -github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= -github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= -github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= -github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= -github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= -github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -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= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -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= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= -github.com/google/uuid v1.1.2/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/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw= -github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= -github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q= -github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= -github.com/hashicorp/vault/sdk v0.1.14-0.20200519221838-e0cfd64bc267/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 h1:mGIXW/lubQ4B+3bXTLxcTMTjUNDqoF6T/HUW9LbFx9s= -github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -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= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= -github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= -github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -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= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= -github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -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/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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -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/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= -github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v3.20.11-0.20201116082039-2fb5da2f2449+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= -github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -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= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -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= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -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 v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -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= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -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.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/stephens2424/writerset v1.0.2/go.mod h1:aS2JhsMn6eA7e82oNmW4rfsgAOp9COBTTl8mzkwADnc= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= -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/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= -github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -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.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -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/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= -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/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= -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/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= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= -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.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= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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 h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= -golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -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/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -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= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -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/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.16.9/go.mod h1:Y7dZNHs1Xy0mSwSlzL9QShi6qkljnN41yR8oWCRTDe8= -k8s.io/apimachinery v0.16.9 h1:ESUZ4hMBUKF2kn2HBFL5zM/wQv4j/0uRbR7AjgqGJ4o= -k8s.io/apimachinery v0.16.9/go.mod h1:Xk2vD2TRRpuWYLQNM6lT9R7DSFZUYG03SarNkbGrnKE= -k8s.io/client-go v0.16.9/go.mod h1:ThjPlh7Kx+XoBFOCt775vx5J7atwY7F/zaFzTco5gL0= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/test/integrate/dubbo/go-server/log.yml b/test/integrate/dubbo/go-server/log.yml deleted file mode 100644 index 21f97bcbc4..0000000000 --- a/test/integrate/dubbo/go-server/log.yml +++ /dev/null @@ -1,27 +0,0 @@ -level: "debug" -development: false -disableCaller: false -disableStacktrace: false -sampling: -encoding: "console" - -# encoder -encoderConfig: - messageKey: "message" - levelKey: "level" - timeKey: "time" - nameKey: "logger" - callerKey: "caller" - stacktraceKey: "stacktrace" - lineEnding: "" - levelEncoder: "capitalColor" - timeEncoder: "iso8601" - durationEncoder: "seconds" - callerEncoder: "short" - nameEncoder: "" - -outputPaths: - - "stderr" -errorOutputPaths: - - "stderr" -initialFields: diff --git a/test/integrate/dubbo/go-server/server.go b/test/integrate/dubbo/go-server/server.go deleted file mode 100644 index b1c16704c8..0000000000 --- a/test/integrate/dubbo/go-server/server.go +++ /dev/null @@ -1,56 +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 main - -import ( - "time" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" -) - -import ( - _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" - _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" - "dubbo.apache.org/dubbo-go/v3/config" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" - _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo" - _ "dubbo.apache.org/dubbo-go/v3/registry/protocol" - _ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper" -) - -var stopC = make(chan struct{}) - -// they are necessary: -// export CONF_PROVIDER_FILE_PATH="xxx" -// export APP_LOG_CONF_FILE="xxx" -func main() { - hessian.RegisterPOJO(&User{}) - config.Load() - - select { - case <-stopC: - // wait getty send resp to consumer - time.Sleep(3 * time.Second) - return - case <-time.After(time.Minute): - panic("provider already running 1 min, but can't be call by consumer") - } -} diff --git a/test/integrate/dubbo/go-server/server.yml b/test/integrate/dubbo/go-server/server.yml deleted file mode 100644 index aa519ccb05..0000000000 --- a/test/integrate/dubbo/go-server/server.yml +++ /dev/null @@ -1,55 +0,0 @@ -# dubbo server yaml configure file - - -# application config -application: - organization : "ikurento.com" - name : "BDTService" - module : "dubbogo user-info server" - version : "0.0.1" - owner : "ZX" - environment : "dev" - -registries : - "demoZk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - -services: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "demoZk" - protocol : "dubbo" - # 相当于dubbo.xml中的interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 - loadbalance: "random" - -protocols: - "dubbo": - name: "dubbo" - port: 20000 - - -protocol_conf: - dubbo: - session_number: 700 - session_timeout: "20s" - getty_session_param: - compress_encoding: false - tcp_no_delay: true - tcp_keep_alive: true - keep_alive_period: "120s" - tcp_r_buf_size: 262144 - tcp_w_buf_size: 65536 - tcp_read_timeout: "1s" - tcp_write_timeout: "5s" - wait_timeout: "1s" - max_msg_len: 1024000 - session_name: "server" diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go deleted file mode 100644 index c34d16cff2..0000000000 --- a/test/integrate/dubbo/go-server/user.go +++ /dev/null @@ -1,67 +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 main - -import ( - "context" - "fmt" - "time" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/config" -) - -func init() { - config.SetProviderService(new(UserProvider)) - // ------for hessian2------ - hessian.RegisterPOJO(&User{}) -} - -type User struct { - ID string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct{} - -func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) { - println("req:%#v", req) - rsp := User{"A001", "Alex Stocks", 18, time.Now()} - println("rsp:%#v", rsp) - close(stopC) - return &rsp, nil -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} - -func (u User) JavaClassName() string { - return "com.ikurento.user.User" -} - -func println(format string, args ...interface{}) { - fmt.Printf("\033[32;40m"+format+"\033[0m\n", args...) -} diff --git a/test/integrate/dubbo/go-server/version.go b/test/integrate/dubbo/go-server/version.go deleted file mode 100644 index 92974643b3..0000000000 --- a/test/integrate/dubbo/go-server/version.go +++ /dev/null @@ -1,20 +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 main - -var Version = "2.6.0" From 91ebda2e80d403733a7d19cbba6936512b2d3897 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 26 Sep 2021 20:23:11 +0800 Subject: [PATCH 116/148] fix: integrate test script --- integrate_test.sh | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/integrate_test.sh b/integrate_test.sh index b12c653fd8..e2684ffdf0 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -35,35 +35,11 @@ echo "github pull request repo param -> $1" echo "github pull request base branch -> $3" echo "github pull request head branch -> ${GITHUB_HEAD_REF}" -samples_testing() { - echo "use dubbo-go-samples $3 branch for integration testing" - git clone -b master https://github.com/apache/dubbo-go-samples.git samples && cd samples +echo "use dubbo-go-samples $3 branch for integration testing" +git clone -b master https://github.com/apache/dubbo-go-samples.git samples && cd samples - # update dubbo-go to current commit id - go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/"$1"/v3@"$2" +# update dubbo-go to current commit id +go mod edit -replace=dubbo.apache.org/dubbo-go/v3=github.com/"$1"/v3@"$2" - # start integrate test - ./start_integrate_test.sh -} - -local_testing() { - echo "use test/integrate/dubbo for integration testing" - # default use zk as registry - #start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - echo "zookeeper listen in [:]2181" - - # build go-server image - cd ./test/integrate/dubbo/go-server - docker build . -t ci-provider --build-arg REPO="$1" --build-arg COMMITID="$2" - cd "${ROOT_DIR}" - docker run -d --network host ci-provider -} - -# check dubbo-go-samples corresponding branch -res=$(git ls-remote --heads https://github.com/apache/dubbo-go-samples.git "$3" | wc -l) -if [ "$res" -eq "1" ]; then - samples_testing "$@" -else - local_testing "$@" -fi +# start integrate test +./start_integrate_test.sh From aa7a12dc33bb87e3342d831c96aece21a75a3299 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sun, 26 Sep 2021 20:35:36 +0800 Subject: [PATCH 117/148] fix: gitlab action --- .github/workflows/github-actions.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 89557d0edb..0ffb5c6f53 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -68,10 +68,18 @@ jobs: run: | make verify + # This step only runs when the event type is a pull_request - name: Integrate Test + if: ${{ github.event_name == 'pull_request' }} run: | chmod +x integrate_test.sh && [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] && [[ -n "${{github.event.pull_request.head.sha}}" ]] && [[ -n "${{github.base_ref}}" ]] && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}} + # This step only runs when the event type is a push + - name: Integrate Test + if: ${{ github.event_name == 'push' }} + run: | + chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF + - name: Post Coverage run: bash <(curl -s https://codecov.io/bash) From 732b6955e37a7b9cc58b742f86c9872b612f6beb Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 27 Sep 2021 15:42:54 +0800 Subject: [PATCH 118/148] fix: remove caceh --- .gitignore | 2 ++ ...yTest:1.0.0:test_group:service:nacos:revisiona@@test_group@@ | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 metadata/report/nacos/cache/config/com.test.MyTest:1.0.0:test_group:service:nacos:revisiona@@test_group@@ diff --git a/.gitignore b/.gitignore index 464f5cccff..6605c27bbb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ classes vendor/ logs/ .vscode/ +cache +log/ # unit test remoting/zookeeper/zookeeper-4unittest/ diff --git a/metadata/report/nacos/cache/config/com.test.MyTest:1.0.0:test_group:service:nacos:revisiona@@test_group@@ b/metadata/report/nacos/cache/config/com.test.MyTest:1.0.0:test_group:service:nacos:revisiona@@test_group@@ deleted file mode 100644 index 5a98cb77d8..0000000000 --- a/metadata/report/nacos/cache/config/com.test.MyTest:1.0.0:test_group:service:nacos:revisiona@@test_group@@ +++ /dev/null @@ -1 +0,0 @@ -registry://console.nacos.io:80?registry.role=3 \ No newline at end of file From c164f38e36d637d977012e76a615e7ffcf967187 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 27 Sep 2021 15:51:31 +0800 Subject: [PATCH 119/148] fix: remove cache and log --- .../cache/config/dubbo.properties@@dubbo-go@@ | 1 - .../nacos/log/nacos-sdk.log-202109260800 | 12 -- ...ubbo.user.UserProvider:1.0.0:guangzhou-idc | 1 - ...ento.user.UserProvider:1.0.0:guangzhou-idc | 1 - ...ento.user.UserProvider:2.0.0:guangzhou-idc | 1 - registry/nacos/log/nacos-sdk.log-202109260800 | 153 ------------------ remoting/nacos/log/nacos-sdk.log-202109260800 | 9 -- 7 files changed, 178 deletions(-) delete mode 100644 config_center/nacos/cache/config/dubbo.properties@@dubbo-go@@ delete mode 100644 config_center/nacos/log/nacos-sdk.log-202109260800 delete mode 100644 registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc delete mode 100644 registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc delete mode 100644 registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc delete mode 100644 registry/nacos/log/nacos-sdk.log-202109260800 delete mode 100644 remoting/nacos/log/nacos-sdk.log-202109260800 diff --git a/config_center/nacos/cache/config/dubbo.properties@@dubbo-go@@ b/config_center/nacos/cache/config/dubbo.properties@@dubbo-go@@ deleted file mode 100644 index f6add2462a..0000000000 --- a/config_center/nacos/cache/config/dubbo.properties@@dubbo-go@@ +++ /dev/null @@ -1 +0,0 @@ -dubbo.protocol.name=dubbo \ No newline at end of file diff --git a/config_center/nacos/log/nacos-sdk.log-202109260800 b/config_center/nacos/log/nacos-sdk.log-202109260800 deleted file mode 100644 index e1ce45e011..0000000000 --- a/config_center/nacos/log/nacos-sdk.log-202109260800 +++ /dev/null @@ -1,12 +0,0 @@ -2021-09-26T17:53:25.229+0800 INFO logDir: cacheDir: -2021-09-26T17:53:25.231+0800 INFO logDir: cacheDir: -2021-09-26T17:53:30.232+0800 INFO logDir: cacheDir: -2021-09-26T17:53:32.773+0800 ERROR [cache.ReadConfigFromFile] error: failed to read config cache file:/Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@,err:open /Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@: no such file or directory -2021-09-26T18:04:54.585+0800 INFO logDir: cacheDir: -2021-09-26T18:04:54.586+0800 INFO logDir: cacheDir: -2021-09-26T18:04:59.591+0800 INFO logDir: cacheDir: -2021-09-26T18:05:01.945+0800 ERROR [cache.ReadConfigFromFile] error: failed to read config cache file:/Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@,err:open /Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@: no such file or directory -2021-09-26T18:10:10.507+0800 INFO logDir: cacheDir: -2021-09-26T18:10:10.509+0800 INFO logDir: cacheDir: -2021-09-26T18:10:15.511+0800 INFO logDir: cacheDir: -2021-09-26T18:10:17.814+0800 ERROR [cache.ReadConfigFromFile] error: failed to read config cache file:/Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@,err:open /Users/laurence/Desktop/workplace/dubbogo/dubbo-go/config_center/nacos/cache/config/dubbo.properties@@dubbo@@: no such file or directory diff --git a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc b/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc deleted file mode 100644 index 699468d846..0000000000 --- a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc +++ /dev/null @@ -1 +0,0 @@ -{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632651037797,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc"} \ No newline at end of file diff --git a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc b/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc deleted file mode 100644 index 1248b9e68d..0000000000 --- a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc +++ /dev/null @@ -1 +0,0 @@ -{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632651037494,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc"} \ No newline at end of file diff --git a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc b/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc deleted file mode 100644 index be346be664..0000000000 --- a/registry/nacos/cache/naming/DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc +++ /dev/null @@ -1 +0,0 @@ -{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632651080378,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} \ No newline at end of file diff --git a/registry/nacos/log/nacos-sdk.log-202109260800 b/registry/nacos/log/nacos-sdk.log-202109260800 deleted file mode 100644 index eb79199cc9..0000000000 --- a/registry/nacos/log/nacos-sdk.log-202109260800 +++ /dev/null @@ -1,153 +0,0 @@ -2021-09-26T17:53:58.274+0800 INFO udp server start, port: 55716 -2021-09-26T17:53:58.278+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T17:53:58.654+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T17:53:58.655+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:03.656+0800 INFO Local IP:30.225.19.232 -2021-09-26T17:54:03.725+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:03.740+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T17:54:03.867+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T17:54:03.943+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T17:54:03.943+0800 INFO adding DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc with to listener map -2021-09-26T17:54:03.943+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:04.013+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T17:54:04.089+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T17:54:04.327+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T17:54:04.327+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T17:54:04.327+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:04.417+0800 INFO adding beat: <{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T17:54:04.418+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc with to listener map -2021-09-26T17:54:04.418+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:04.493+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc -2021-09-26T17:54:04.493+0800 INFO remove beat: DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc@127.0.0.2:20000 from beat map -2021-09-26T17:54:04.493+0800 INFO deregister instance namespaceId:<>,serviceName: with instance:<127.0.0.2:20000@> -2021-09-26T17:54:08.815+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:09.016+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:09.487+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:09.558+0800 INFO instance[DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc#127.0.0.2#20000] stop heartBeating -2021-09-26T17:54:13.997+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:14.090+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:14.661+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:19.069+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:19.236+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:19.891+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:24.146+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:24.309+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:24.967+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:26.373+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true},{"valid":false,"marked":false,"instanceId":"127.0.0.2#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":false,"ephemeral":true}],"checksum":"","lastRefTime":1632650066479,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T17:54:29.222+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:29.387+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:30.041+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:34.297+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:34.467+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:35.208+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:39.387+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:39.541+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:40.350+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:44.465+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:44.626+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T17:54:45.428+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T17:54:48.385+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632650088492,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T17:54:48.386+0800 INFO removing @@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map -2021-09-26T17:54:48.386+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:05:22.129+0800 INFO udp server start, port: 55177 -2021-09-26T18:05:22.130+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:05:22.285+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T18:05:22.285+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:27.286+0800 INFO Local IP:30.225.19.232 -2021-09-26T18:05:27.365+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T18:05:27.366+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:27.445+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:05:27.586+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T18:05:27.586+0800 INFO adding DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:05:27.586+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:27.661+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T18:05:27.737+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:05:27.810+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T18:05:27.810+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:05:27.811+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:27.883+0800 INFO adding beat: <{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T18:05:27.883+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc with to listener map -2021-09-26T18:05:27.883+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:27.960+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc -2021-09-26T18:05:27.960+0800 INFO remove beat: DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc@127.0.0.2:20000 from beat map -2021-09-26T18:05:27.960+0800 INFO deregister instance namespaceId:<>,serviceName: with instance:<127.0.0.2:20000@> -2021-09-26T18:05:32.512+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:32.662+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:32.960+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:33.032+0800 INFO instance[DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc#127.0.0.2#20000] stop heartBeating -2021-09-26T18:05:37.586+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:37.738+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:38.034+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:42.662+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:42.814+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:43.110+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:47.744+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:47.898+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:48.193+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:49.225+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true},{"valid":false,"marked":false,"instanceId":"127.0.0.2#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":false,"ephemeral":true}],"checksum":"","lastRefTime":1632650749330,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T18:05:52.830+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:52.984+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:53.278+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:05:57.913+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:58.072+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:05:58.372+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:06:02.998+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:06:03.156+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:06:03.454+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:06:08.319+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:06:08.392+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:06:08.532+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:06:11.323+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632650771424,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T18:06:11.326+0800 INFO removing @@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:06:11.326+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:10:32.159+0800 INFO udp server start, port: 55409 -2021-09-26T18:10:32.160+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:10:32.314+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T18:10:32.314+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:37.316+0800 INFO Local IP:30.225.19.232 -2021-09-26T18:10:37.393+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:37.396+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T18:10:37.543+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:10:37.621+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> to beat map -2021-09-26T18:10:37.621+0800 INFO adding DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:10:37.621+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:37.700+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc -2021-09-26T18:10:37.783+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:10:37.854+0800 INFO adding beat: <{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T18:10:37.855+0800 INFO register instance namespaceId:<>,serviceName: with instance:<{"valid":false,"marked":false,"instanceId":"","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"","serviceName":"","enabled":true,"healthy":true,"ephemeral":true}> -2021-09-26T18:10:37.855+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:37.927+0800 INFO adding beat: <{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> to beat map -2021-09-26T18:10:37.927+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc with to listener map -2021-09-26T18:10:37.927+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.2","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:38.006+0800 INFO service not found in cache DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc -2021-09-26T18:10:38.008+0800 INFO remove beat: DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc@127.0.0.2:20000 from beat map -2021-09-26T18:10:38.008+0800 INFO deregister instance namespaceId:<>,serviceName: with instance:<127.0.0.2:20000@> -2021-09-26T18:10:42.476+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:42.695+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:43.000+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:43.071+0800 INFO instance[DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc#127.0.0.2#20000] stop heartBeating -2021-09-26T18:10:47.549+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:47.769+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:48.072+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:52.622+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:52.840+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:53.146+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:57.696+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:57.914+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:10:58.221+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:10:59.258+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true},{"valid":false,"marked":false,"instanceId":"127.0.0.2#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.2","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":false,"ephemeral":true}],"checksum":"","lastRefTime":1632651059362,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T18:11:02.836+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:03.055+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:03.361+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:11:07.909+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:08.129+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:08.434+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:11:12.984+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:13.205+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:13.507+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:11:18.056+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:18.276+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.dubbo.user.UserProvider:1.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.dubbo.user.UserProvider","path":"/com.dubbo.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"1.0.0"},"scheduled":false}> -2021-09-26T18:11:18.581+0800 INFO namespaceId:<> sending beat to server:<{"ip":"127.0.0.1","port":20000,"weight":1,"serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","cluster":"","metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"scheduled":false}> -2021-09-26T18:11:20.346+0800 INFO service key:%s was updated to:%sDEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc{"dom":"","cacheMillis":10000,"useSpecifiedUrl":false,"hosts":[{"valid":false,"marked":false,"instanceId":"127.0.0.1#20000#DEFAULT#DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","port":20000,"ip":"127.0.0.1","weight":1,"metadata":{"category":"providers","cluster":"mock","group":"guangzhou-idc","interface":"com.ikurento.user.UserProvider","path":"/com.ikurento.user.UserProvider","protocol":"dubbo","registry.role":"3","version":"2.0.0"},"clusterName":"DEFAULT","serviceName":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc","enabled":true,"healthy":true,"ephemeral":true}],"checksum":"","lastRefTime":1632651080378,"env":"","clusters":"","metadata":null,"name":"DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"} -2021-09-26T18:11:20.348+0800 INFO removing @@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map -2021-09-26T18:11:20.348+0800 INFO adding DEFAULT_GROUP@@providers:com.ikurento.user.UserProvider2:1.0.0:guangzhou-idc with to listener map diff --git a/remoting/nacos/log/nacos-sdk.log-202109260800 b/remoting/nacos/log/nacos-sdk.log-202109260800 deleted file mode 100644 index 800ba2597a..0000000000 --- a/remoting/nacos/log/nacos-sdk.log-202109260800 +++ /dev/null @@ -1,9 +0,0 @@ -2021-09-26T17:54:01.705+0800 ERROR login has error unknown user! -2021-09-26T17:54:01.705+0800 INFO udp server start, port: 55385 -2021-09-26T17:54:01.705+0800 INFO logDir: cacheDir: -2021-09-26T18:05:24.602+0800 ERROR login has error unknown user! -2021-09-26T18:05:24.604+0800 INFO udp server start, port: 54988 -2021-09-26T18:05:24.605+0800 INFO logDir: cacheDir: -2021-09-26T18:10:35.126+0800 ERROR login has error unknown user! -2021-09-26T18:10:35.129+0800 INFO udp server start, port: 55071 -2021-09-26T18:10:35.130+0800 INFO logDir: cacheDir: From 19306efe4313926af582f30622045407c4dd2c50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:50:08 +0800 Subject: [PATCH 120/148] build(deps): bump google.golang.org/grpc from 1.38.0 to 1.41.0 (#1486) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.38.0 to 1.41.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.38.0...v1.41.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 4d2a899219..f591b977c7 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( go.etcd.io/etcd/server/v3 v3.5.0-alpha.0 go.uber.org/atomic v1.7.0 go.uber.org/zap v1.19.1 - google.golang.org/grpc v1.38.0 + google.golang.org/grpc v1.41.0 google.golang.org/protobuf v1.27.1 gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index 3f0db58753..35299040b9 100644 --- a/go.sum +++ b/go.sum @@ -123,6 +123,7 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 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= @@ -181,8 +182,6 @@ github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= -github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6 h1:ZrCFQ/a0rgK5EBF9FiiSYvCmtC2sLzOoFAbqBVmsA94= -github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c h1:/Qrdqo2JVrywDANk04DHrvdfREdIApAWZ6stbYZfNaM= github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -205,6 +204,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -792,6 +792,7 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1155,8 +1156,9 @@ google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E= +google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From e4fd3e8c3730c180cf5769be09c7e9a1f69bc2e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:51:32 +0800 Subject: [PATCH 121/148] build(deps): bump github.com/knadh/koanf from 1.1.1 to 1.2.3 (#1488) Bumps [github.com/knadh/koanf](https://github.com/knadh/koanf) from 1.1.1 to 1.2.3. - [Release notes](https://github.com/knadh/koanf/releases) - [Commits](https://github.com/knadh/koanf/compare/v1.1.1...v1.2.3) --- updated-dependencies: - dependency-name: github.com/knadh/koanf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f591b977c7..f1d913fe6d 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hashicorp/vault/sdk v0.2.1 github.com/jinzhu/copier v0.3.2 - github.com/knadh/koanf v1.1.1 + github.com/knadh/koanf v1.2.3 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.2 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd diff --git a/go.sum b/go.sum index 35299040b9..a95af347ad 100644 --- a/go.sum +++ b/go.sum @@ -474,8 +474,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf v1.1.1 h1:doO5UBvSXcmngdr/u54HKe+Uz4ZZw0/YHVzSsnE3vD4= -github.com/knadh/koanf v1.1.1/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= +github.com/knadh/koanf v1.2.3 h1:2Rkr0YhhYk+4QEOm800Q3Pu0Wi87svTxM6uuEb4WhYw= +github.com/knadh/koanf v1.2.3/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= From c5007483e06dc4420dc2e83d8d95ba3f0b9e6126 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:51:55 +0800 Subject: [PATCH 122/148] build(deps): bump github.com/go-playground/validator/v10 (#1489) Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.7.0 to 10.9.0. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.7.0...v10.9.0) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 37 ++++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index f1d913fe6d..e27e484b77 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 - github.com/go-playground/validator/v10 v10.7.0 + github.com/go-playground/validator/v10 v10.9.0 github.com/go-resty/resty/v2 v2.3.0 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.4.4 diff --git a/go.sum b/go.sum index a95af347ad..f95f372ca2 100644 --- a/go.sum +++ b/go.sum @@ -256,12 +256,12 @@ github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nA github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM= -github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A= +github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= @@ -481,14 +481,15 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 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/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 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= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo= github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4= @@ -564,7 +565,6 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -613,6 +613,7 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -672,6 +673,9 @@ github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -731,6 +735,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= @@ -827,8 +832,9 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= 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= @@ -905,6 +911,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R 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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -989,8 +996,11 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1179,8 +1189,9 @@ gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUy gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= From b6b6d12b16186b637c4f9d6c0761f0ad2e155393 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 12:53:08 +0800 Subject: [PATCH 123/148] build(deps): bump github.com/dubbogo/gost from 1.11.16 to 1.11.17 (#1490) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.16 to 1.11.17. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.16...v1.11.17) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e27e484b77..f5f247990d 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/apache/dubbo-go-hessian2 v1.9.2 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.16 + github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c github.com/emicklei/go-restful/v3 v3.5.2 github.com/fsnotify/fsnotify v1.5.1 diff --git a/go.sum b/go.sum index f95f372ca2..c2f058173b 100644 --- a/go.sum +++ b/go.sum @@ -177,8 +177,9 @@ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl8 github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.11.16 h1:fvOw8aKQ0BuUYuD+MaXAYFvT7tg2l7WAS5SL5gZJpFs= github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.17 h1:Dwaoqv/G21nYsGkeQoLbCAOryRPl6B7pEsZSJcr55nE= +github.com/dubbogo/gost v1.11.17/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= From 667aa535d98bad50f79ee4cb2efae29a9c36c596 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 18:56:49 +0800 Subject: [PATCH 124/148] build(deps): bump github.com/apache/dubbo-go-hessian2 (#1492) Bumps [github.com/apache/dubbo-go-hessian2](https://github.com/apache/dubbo-go-hessian2) from 1.9.2 to 1.9.3. - [Release notes](https://github.com/apache/dubbo-go-hessian2/releases) - [Commits](https://github.com/apache/dubbo-go-hessian2/compare/v1.9.2...v1.9.3) --- updated-dependencies: - dependency-name: github.com/apache/dubbo-go-hessian2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f5f247990d..0e576d8a6b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-getty v1.4.5 - github.com/apache/dubbo-go-hessian2 v1.9.2 + github.com/apache/dubbo-go-hessian2 v1.9.3 github.com/creasty/defaults v1.5.1 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.17 diff --git a/go.sum b/go.sum index c2f058173b..22343dfa3f 100644 --- a/go.sum +++ b/go.sum @@ -77,8 +77,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/dubbo-getty v1.4.5 h1:MptKbjC0n2Mo/8eFPwirSInH2BfdNG4IZch43PdNvIM= github.com/apache/dubbo-getty v1.4.5/go.mod h1:mcDyiu7M/TVrYDyL8TxDemQkOdvEqqHSQ4jOuYejY1w= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= -github.com/apache/dubbo-go-hessian2 v1.9.2 h1:XuI8KvENSfKiAhiCBS4RNihmQDoPNmGWKT3gTui0p9A= -github.com/apache/dubbo-go-hessian2 v1.9.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= +github.com/apache/dubbo-go-hessian2 v1.9.3 h1:0G9cdOCiKILem1JRKeZtY0FdIUyvzt30qtukMXPtJks= +github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= From 7b9caa1c8dd2f17c0f4be7c66a546cc29cc3e5f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Sep 2021 18:57:29 +0800 Subject: [PATCH 125/148] build(deps): bump github.com/emicklei/go-restful/v3 from 3.5.2 to 3.7.0 (#1487) Bumps [github.com/emicklei/go-restful/v3](https://github.com/emicklei/go-restful) from 3.5.2 to 3.7.0. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v3.5.2...v3.7.0) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0e576d8a6b..5e18e06cfb 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c - github.com/emicklei/go-restful/v3 v3.5.2 + github.com/emicklei/go-restful/v3 v3.7.0 github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 diff --git a/go.sum b/go.sum index 22343dfa3f..1e2f3847d3 100644 --- a/go.sum +++ b/go.sum @@ -197,8 +197,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.5.2 h1:RCNMSbcGIVafG4ZfgIXIEHTaV59ZRsi41IvZ7RC9+ls= -github.com/emicklei/go-restful/v3 v3.5.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.7.0 h1:j0vVy2jEc6pJb7dBZkkqXP0mvggYEVUA9upClUMsCts= +github.com/emicklei/go-restful/v3 v3.7.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= From 5f9998a3e0671f0e1669d4a767f5620dcea05138 Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Wed, 29 Sep 2021 16:12:45 +0800 Subject: [PATCH 126/148] add application registry --- config/service_config.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 53dce7ac3a..32baae11b6 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -89,6 +89,7 @@ type ServiceConfig struct { exporters []protocol.Exporter metadataType string + rootConfig *RootConfig } // Prefix returns dubbo.service.${InterfaceName}. @@ -104,6 +105,7 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { return err } svc.exported = atomic.NewBool(false) + svc.rootConfig=rc svc.metadataType = rc.Application.MetadataType svc.unexported = atomic.NewBool(false) svc.Registries = rc.Registries @@ -345,13 +347,13 @@ func (svc *ServiceConfig) getUrlMap() url.Values { // todo: move urlMap.Set(constant.SERIALIZATION_KEY, svc.Serialization) // application config info - //urlMap.Set(constant.APPLICATION_KEY, applicationConfig.Name) - //urlMap.Set(constant.ORGANIZATION_KEY, applicationConfig.Organization) - //urlMap.Set(constant.NAME_KEY, applicationConfig.Name) - //urlMap.Set(constant.MODULE_KEY, applicationConfig.Module) - //urlMap.Set(constant.APP_VERSION_KEY, applicationConfig.Version) - //urlMap.Set(constant.OWNER_KEY, applicationConfig.Owner) - //urlMap.Set(constant.ENVIRONMENT_KEY, applicationConfig.Environment) + urlMap.Set(constant.APPLICATION_KEY, svc.rootConfig.Application.Name) + urlMap.Set(constant.ORGANIZATION_KEY, svc.rootConfig.Application.Organization) + urlMap.Set(constant.NAME_KEY, svc.rootConfig.Application.Name) + urlMap.Set(constant.MODULE_KEY, svc.rootConfig.Application.Module) + urlMap.Set(constant.APP_VERSION_KEY, svc.rootConfig.Application.Version) + urlMap.Set(constant.OWNER_KEY, svc.rootConfig.Application.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, svc.rootConfig.Application.Environment) // filter if svc.Filter == "" { From 7c8c2cc257d3e0cc91b7427b693e6fd701c4d69f Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Wed, 29 Sep 2021 16:17:53 +0800 Subject: [PATCH 127/148] fmt --- config/service_config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/service_config.go b/config/service_config.go index 32baae11b6..efcd117f93 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -105,7 +105,7 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { return err } svc.exported = atomic.NewBool(false) - svc.rootConfig=rc + svc.rootConfig = rc svc.metadataType = rc.Application.MetadataType svc.unexported = atomic.NewBool(false) svc.Registries = rc.Registries From 60b85abe9059baf09ce8cedc8a9dec1fc31e69de Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Wed, 29 Sep 2021 16:59:08 +0800 Subject: [PATCH 128/148] add properties cofig resolver --- config/config_loader_options.go | 2 + config/config_resolver.go | 58 ++++++++++++++++ config/parsers/properties/properties.go | 88 +++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 config/config_resolver.go create mode 100644 config/parsers/properties/properties.go diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 8179905efc..4de1a6606d 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -40,6 +40,8 @@ type loaderConf struct { path string // loaderConf file delim default . delim string + // config + b []byte } func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { diff --git a/config/config_resolver.go b/config/config_resolver.go new file mode 100644 index 0000000000..39deffd2c6 --- /dev/null +++ b/config/config_resolver.go @@ -0,0 +1,58 @@ +/* + * 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 + +import ( + "github.com/knadh/koanf" + "github.com/knadh/koanf/parsers/json" + "github.com/knadh/koanf/parsers/toml" + "github.com/knadh/koanf/parsers/yaml" + "github.com/knadh/koanf/providers/file" + "github.com/pkg/errors" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/config/parsers/properties" +) + +// GetConfigResolver get config resolver +func GetConfigResolver(conf *loaderConf) *koanf.Koanf { + var ( + k *koanf.Koanf + err error + ) + k = koanf.New(conf.delim) + + switch conf.genre { + case "yaml", "yml": + err = k.Load(file.Provider(conf.path), yaml.Parser()) + case "json": + err = k.Load(file.Provider(conf.path), json.Parser()) + case "toml": + err = k.Load(file.Provider(conf.path), toml.Parser()) + case "properties": + err = k.Load(file.Provider(conf.path), properties.Parser()) + default: + err = errors.Errorf("no support %s file type", conf.genre) + } + + if err != nil { + panic(err) + } + return k +} diff --git a/config/parsers/properties/properties.go b/config/parsers/properties/properties.go new file mode 100644 index 0000000000..e8d9ec72ad --- /dev/null +++ b/config/parsers/properties/properties.go @@ -0,0 +1,88 @@ +/* + * 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 properties + +import ( + "strings" +) + +import ( + "github.com/magiconair/properties" +) + +type Properties struct{} + +func Parser() *Properties { + return &Properties{} +} + +// Unmarshal parses the given properties bytes. +func (p *Properties) Unmarshal(b []byte) (map[string]interface{}, error) { + out := make(map[string]interface{}) + if load, err := properties.Load(b, properties.UTF8); err != nil { + return nil, err + } else { + // see viper#unmarshalReader + for _, key := range load.Keys() { + value, _ := load.Get(key) + // recursively build nested maps + path := strings.Split(key, ".") + lastKey := strings.ToLower(path[len(path)-1]) + deepestMap := deepSearch(out, path[0:len(path)-1]) + // set innermost value + deepestMap[lastKey] = value + } + return out, nil + } +} + +// Marshal marshals the given config map to YAML bytes. +func (p *Properties) Marshal(o map[string]interface{}) ([]byte, error) { + return nil, nil +} + +// deepSearch scans deep maps, following the key indexes listed in the +// sequence "path". +// The last value is expected to be another map, and is returned. +// +// In case intermediate keys do not exist, or map to a non-map value, +// a new map is created and inserted, and the search continues from there: +// the initial map "m" may be modified! +func deepSearch(m map[string]interface{}, path []string) map[string]interface{} { + for _, k := range path { + m2, ok := m[k] + if !ok { + // intermediate key does not exist + // => create it and continue from there + m3 := make(map[string]interface{}) + m[k] = m3 + m = m3 + continue + } + m3, ok := m2.(map[string]interface{}) + if !ok { + // intermediate key is a value + // => replace with a new map + m3 = make(map[string]interface{}) + m[k] = m3 + } + // continue search from here + m = m3 + } + return m +} From dfe8011590417496fc8c4fdb971bd2ad246d6b10 Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Wed, 29 Sep 2021 17:03:45 +0800 Subject: [PATCH 129/148] fix:application nil --- config/service_config.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index efcd117f93..c55cd67578 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -89,7 +89,6 @@ type ServiceConfig struct { exporters []protocol.Exporter metadataType string - rootConfig *RootConfig } // Prefix returns dubbo.service.${InterfaceName}. @@ -105,7 +104,6 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { return err } svc.exported = atomic.NewBool(false) - svc.rootConfig = rc svc.metadataType = rc.Application.MetadataType svc.unexported = atomic.NewBool(false) svc.Registries = rc.Registries @@ -347,13 +345,13 @@ func (svc *ServiceConfig) getUrlMap() url.Values { // todo: move urlMap.Set(constant.SERIALIZATION_KEY, svc.Serialization) // application config info - urlMap.Set(constant.APPLICATION_KEY, svc.rootConfig.Application.Name) - urlMap.Set(constant.ORGANIZATION_KEY, svc.rootConfig.Application.Organization) - urlMap.Set(constant.NAME_KEY, svc.rootConfig.Application.Name) - urlMap.Set(constant.MODULE_KEY, svc.rootConfig.Application.Module) - urlMap.Set(constant.APP_VERSION_KEY, svc.rootConfig.Application.Version) - urlMap.Set(constant.OWNER_KEY, svc.rootConfig.Application.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, svc.rootConfig.Application.Environment) + urlMap.Set(constant.APPLICATION_KEY, GetRootConfig().Application.Name) + urlMap.Set(constant.ORGANIZATION_KEY, GetRootConfig().Application.Organization) + urlMap.Set(constant.NAME_KEY, GetRootConfig().Application.Name) + urlMap.Set(constant.MODULE_KEY, GetRootConfig().Application.Module) + urlMap.Set(constant.APP_VERSION_KEY, GetRootConfig().Application.Version) + urlMap.Set(constant.OWNER_KEY, GetRootConfig().Application.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, GetRootConfig().Application.Environment) // filter if svc.Filter == "" { From 25667db67c7bf1feb02cd10ead5e0925a3b5c309 Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Wed, 29 Sep 2021 17:04:21 +0800 Subject: [PATCH 130/148] fix:application nil --- config/service_config.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index c55cd67578..d499ba6ea1 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -345,13 +345,14 @@ func (svc *ServiceConfig) getUrlMap() url.Values { // todo: move urlMap.Set(constant.SERIALIZATION_KEY, svc.Serialization) // application config info - urlMap.Set(constant.APPLICATION_KEY, GetRootConfig().Application.Name) - urlMap.Set(constant.ORGANIZATION_KEY, GetRootConfig().Application.Organization) - urlMap.Set(constant.NAME_KEY, GetRootConfig().Application.Name) - urlMap.Set(constant.MODULE_KEY, GetRootConfig().Application.Module) - urlMap.Set(constant.APP_VERSION_KEY, GetRootConfig().Application.Version) - urlMap.Set(constant.OWNER_KEY, GetRootConfig().Application.Owner) - urlMap.Set(constant.ENVIRONMENT_KEY, GetRootConfig().Application.Environment) + ac := GetApplicationConfig() + urlMap.Set(constant.APPLICATION_KEY, ac.Name) + urlMap.Set(constant.ORGANIZATION_KEY, ac.Organization) + urlMap.Set(constant.NAME_KEY, ac.Name) + urlMap.Set(constant.MODULE_KEY, ac.Module) + urlMap.Set(constant.APP_VERSION_KEY, ac.Version) + urlMap.Set(constant.OWNER_KEY, ac.Owner) + urlMap.Set(constant.ENVIRONMENT_KEY, ac.Environment) // filter if svc.Filter == "" { From a9e9f9ac62b719e025e4b733b21b0e3b20a67032 Mon Sep 17 00:00:00 2001 From: zhaoyunxing Date: Thu, 30 Sep 2021 18:30:26 +0800 Subject: [PATCH 131/148] add properties resolver (#1496) * add properties resolver * fmt --- config/config_loader.go | 32 +------------------ config/config_loader_options.go | 31 +++++++++++++----- config/config_loader_options_test.go | 29 ++--------------- config/config_resolver.go | 20 +++++++++--- .../config/properties/application.properties | 13 ++++++++ 5 files changed, 55 insertions(+), 70 deletions(-) create mode 100644 config/testdata/config/properties/application.properties diff --git a/config/config_loader.go b/config/config_loader.go index 6a3f411612..2495751861 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -19,18 +19,12 @@ package config import ( "errors" - "fmt" "reflect" "strconv" ) import ( "github.com/knadh/koanf" - "github.com/knadh/koanf/parsers/json" - "github.com/knadh/koanf/parsers/toml" - yaml "github.com/knadh/koanf/parsers/yaml" - "github.com/knadh/koanf/providers/file" - perrors "github.com/pkg/errors" ) @@ -49,7 +43,7 @@ var ( func Load(opts ...LoaderConfOption) error { // conf conf := NewLoaderConf(opts...) - koan := getKoanf(conf) + koan := GetConfigResolver(conf) if err := koan.UnmarshalWithConf(rootConfig.Prefix(), rootConfig, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { return err @@ -68,30 +62,6 @@ func check() error { return nil } -func getKoanf(conf *loaderConf) *koanf.Koanf { - var ( - k *koanf.Koanf - err error - ) - k = koanf.New(conf.delim) - - switch conf.genre { - case "yaml", "yml": - err = k.Load(file.Provider(conf.path), yaml.Parser()) - case "json": - err = k.Load(file.Provider(conf.path), json.Parser()) - case "toml": - err = k.Load(file.Provider(conf.path), toml.Parser()) - default: - err = errors.New(fmt.Sprintf("Unsupported %s file type", conf.genre)) - } - - if err != nil { - panic(err) - } - return k -} - // registerServiceInstance register service instance func registerServiceInstance() { url := selectMetadataServiceExportedURL() diff --git a/config/config_loader_options.go b/config/config_loader_options.go index 4de1a6606d..f98c8a5350 100644 --- a/config/config_loader_options.go +++ b/config/config_loader_options.go @@ -14,10 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package config import ( "fmt" + "io/ioutil" "os" "path/filepath" "runtime" @@ -40,8 +42,8 @@ type loaderConf struct { path string // loaderConf file delim default . delim string - // config - b []byte + // config bytes + bytes []byte } func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { @@ -49,16 +51,22 @@ func NewLoaderConf(opts ...LoaderConfOption) *loaderConf { if configFilePathFromEnv := os.Getenv(constant.CONFIG_FILE_ENV_KEY); configFilePathFromEnv != "" { configFilePath = configFilePathFromEnv } - + genre := strings.Split(configFilePath, ".") conf := &loaderConf{ - genre: "yaml", - path: configFilePath, + genre: genre[len(genre)-1], + path: absolutePath(configFilePath), delim: ".", } - for _, opt := range opts { opt.apply(conf) } + if len(conf.bytes) <= 0 { + bytes, err := ioutil.ReadFile(conf.path) + if err != nil { + panic(err) + } + conf.bytes = bytes + } return conf } @@ -72,7 +80,7 @@ func (fn loaderConfigFunc) apply(vc *loaderConf) { fn(vc) } -// WithGenre set loaderConf Genre +// WithGenre set load config genre func WithGenre(genre string) LoaderConfOption { return loaderConfigFunc(func(conf *loaderConf) { g := strings.ToLower(genre) @@ -83,10 +91,17 @@ func WithGenre(genre string) LoaderConfOption { }) } -// WithPath set loaderConf path +// WithPath set load config path func WithPath(path string) LoaderConfOption { return loaderConfigFunc(func(conf *loaderConf) { conf.path = absolutePath(path) + bytes, err := ioutil.ReadFile(path) + if err != nil { + panic(err) + } + conf.bytes = bytes + genre := strings.Split(path, ".") + conf.genre = genre[len(genre)-1] }) } diff --git a/config/config_loader_options_test.go b/config/config_loader_options_test.go index 5f4d7715cf..7704d52997 100644 --- a/config/config_loader_options_test.go +++ b/config/config_loader_options_test.go @@ -34,30 +34,7 @@ func TestCheckGenre(t *testing.T) { assert.Nil(t, err) } -func TestNewLoaderConf(t *testing.T) { - conf := NewLoaderConf() - assert.Equal(t, ".", conf.delim) - assert.Equal(t, "yaml", conf.genre) - assert.Equal(t, "../conf/dubbogo.yaml", conf.path) -} - -func TestWithDelim(t *testing.T) { - conf := NewLoaderConf(WithDelim(":")) - assert.Equal(t, ":", conf.delim) - assert.Equal(t, "yaml", conf.genre) - assert.Equal(t, "../conf/dubbogo.yaml", conf.path) -} - -func TestWithPath(t *testing.T) { - conf := NewLoaderConf(WithPath("./conf/app.yaml")) - assert.Equal(t, ".", conf.delim) - assert.Equal(t, "yaml", conf.genre) - assert.Equal(t, absolutePath("./conf/app.yaml"), conf.path) -} - -func TestWithGenre(t *testing.T) { - conf := NewLoaderConf(WithGenre("json")) - assert.Equal(t, ".", conf.delim) - assert.Equal(t, "json", conf.genre) - assert.Equal(t, "../conf/dubbogo.yaml", conf.path) +func TestFileGenre(t *testing.T) { + conf := NewLoaderConf(WithPath("../config/testdata/config/properties/application.properties")) + assert.Equal(t, conf.genre, "properties") } diff --git a/config/config_resolver.go b/config/config_resolver.go index 39deffd2c6..a875756b3f 100644 --- a/config/config_resolver.go +++ b/config/config_resolver.go @@ -22,7 +22,7 @@ import ( "github.com/knadh/koanf/parsers/json" "github.com/knadh/koanf/parsers/toml" "github.com/knadh/koanf/parsers/yaml" - "github.com/knadh/koanf/providers/file" + "github.com/knadh/koanf/providers/rawbytes" "github.com/pkg/errors" ) @@ -36,17 +36,27 @@ func GetConfigResolver(conf *loaderConf) *koanf.Koanf { k *koanf.Koanf err error ) + if len(conf.genre) <= 0 { + conf.genre = "yaml" + } + if len(conf.delim) <= 0 { + conf.delim = "." + } + bytes := conf.bytes + if len(bytes) <= 0 { + panic(errors.New("bytes is nil,please set bytes or file path")) + } k = koanf.New(conf.delim) switch conf.genre { case "yaml", "yml": - err = k.Load(file.Provider(conf.path), yaml.Parser()) + err = k.Load(rawbytes.Provider(bytes), yaml.Parser()) case "json": - err = k.Load(file.Provider(conf.path), json.Parser()) + err = k.Load(rawbytes.Provider(bytes), json.Parser()) case "toml": - err = k.Load(file.Provider(conf.path), toml.Parser()) + err = k.Load(rawbytes.Provider(bytes), toml.Parser()) case "properties": - err = k.Load(file.Provider(conf.path), properties.Parser()) + err = k.Load(rawbytes.Provider(bytes), properties.Parser()) default: err = errors.Errorf("no support %s file type", conf.genre) } diff --git a/config/testdata/config/properties/application.properties b/config/testdata/config/properties/application.properties new file mode 100644 index 0000000000..273dbddcfe --- /dev/null +++ b/config/testdata/config/properties/application.properties @@ -0,0 +1,13 @@ +dubbo.application.name=dubbo-go +dubbo.application.module=local +dubbo.application.version=1.0.0 +dubbo.application.owner=zhaoyunxing +dubbo.registries.nacos.protocol=nacos +dubbo.registries.nacos.timeout=5s +dubbo.registries.nacos.address=127.0.0.1:8848 +dubbo.registries.zk.protocol=zookeeper +dubbo.registries.zk.timeout=5s +dubbo.registries.zk.group=dev +dubbo.registries.zk.address=127.0.0.1:2181 +dubbo.services.HelloService.interface=org.dubbo.service.HelloService +dubbo.services.HelloService.registry=nacos,zk \ No newline at end of file From 9220fa451bd6361797b1ab953a4736ddf1ea0974 Mon Sep 17 00:00:00 2001 From: Mulavar <978007503@qq.com> Date: Sat, 2 Oct 2021 09:58:50 +0800 Subject: [PATCH 132/148] feat(config): add root config api builder (#1491) * feat(config): add root&application config api * feat(config): add protocol config api * feat(config): remove structure embedding * feat(config): add registry config api builder * feat(config): add service discovery config api builder * feat(config): add prefix Set * feat(config): add consumer&provider&metric&metadata&remote_route&logger config api Co-authored-by: dongjianhui03 --- config/application_config.go | 50 +++++++++++++ config/config_loader.go | 12 ++-- config/consumer_config.go | 55 ++++++++++++++ config/dubbo_bootstrap.go | 63 +++++++++++----- config/graceful_shutdown_config.go | 37 ++++++++++ config/logger_config.go | 26 +++++++ config/metadata_report_config.go | 59 ++++++++++++++- config/metric_config.go | 57 +++++++++++++-- config/protocol_config.go | 57 +++++++++------ config/provider_config.go | 95 ++++++++++++++++++++++-- config/registry_config.go | 109 ++++++++++++++++++++++++---- config/remote_config.go | 80 ++++++++++++++++++--- config/root_config.go | 112 +++++++++++++++++++++++++---- config/router_config.go | 93 +++++++++++++++++++++++- config/service_config.go | 2 +- config/service_discovery_config.go | 34 ++++++++- go.sum | 2 - remoting/nacos/builder_test.go | 2 +- 18 files changed, 846 insertions(+), 99 deletions(-) diff --git a/config/application_config.go b/config/application_config.go index 11181093a9..cb52c6bdef 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -113,3 +113,53 @@ func WithMetadataType(metadataType string) ApplicationConfigOpt { ac.MetadataType = metadataType } } + +func NewApplicationConfigBuilder() *ApplicationConfigBuilder { + return &ApplicationConfigBuilder{application: &ApplicationConfig{}} +} + +type ApplicationConfigBuilder struct { + application *ApplicationConfig +} + +func (acb *ApplicationConfigBuilder) SetOrganization(organization string) *ApplicationConfigBuilder { + acb.application.Organization = organization + return acb +} + +func (acb *ApplicationConfigBuilder) SetName(name string) *ApplicationConfigBuilder { + acb.application.Name = name + return acb +} + +func (acb *ApplicationConfigBuilder) SetModule(module string) *ApplicationConfigBuilder { + acb.application.Module = module + return acb +} + +func (acb *ApplicationConfigBuilder) SetVersion(version string) *ApplicationConfigBuilder { + acb.application.Version = version + return acb +} + +func (acb *ApplicationConfigBuilder) SetOwner(owner string) *ApplicationConfigBuilder { + acb.application.Owner = owner + return acb +} + +func (acb *ApplicationConfigBuilder) SetEnvironment(environment string) *ApplicationConfigBuilder { + acb.application.Environment = environment + return acb +} + +func (acb *ApplicationConfigBuilder) SetMetadataType(metadataType string) *ApplicationConfigBuilder { + acb.application.MetadataType = metadataType + return acb +} + +func (acb *ApplicationConfigBuilder) Build() *ApplicationConfig { + if err := acb.application.Init(); err != nil { + panic(err) + } + return acb.application +} diff --git a/config/config_loader.go b/config/config_loader.go index 6a3f411612..7d611be914 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -188,19 +188,19 @@ func RPCService(service common.RPCService) { // So you don't need to worry about the race condition func GetMetricConfig() *MetricConfig { // todo - //if GetBaseConfig().MetricConfig == nil { + //if GetBaseConfig().Metric == nil { // configAccessMutex.Lock() // defer configAccessMutex.Unlock() - // if GetBaseConfig().MetricConfig == nil { - // GetBaseConfig().MetricConfig = &metric.MetricConfig{} + // if GetBaseConfig().Metric == nil { + // GetBaseConfig().Metric = &metric.Metric{} // } //} - //return GetBaseConfig().MetricConfig - return rootConfig.MetricConfig + //return GetBaseConfig().Metric + return rootConfig.Metric } func GetMetadataReportConfg() *MetadataReportConfig { - return rootConfig.MetadataReportConfig + return rootConfig.MetadataReport } func IsProvider() bool { diff --git a/config/consumer_config.go b/config/consumer_config.go index 9f76e4cb40..d80b139e29 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -272,3 +272,58 @@ func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { return config } } + +type ConsumerConfigBuilder struct { + consumerConfig *ConsumerConfig +} + +func NewConsumerConfigBuilder() *ConsumerConfigBuilder { + return &ConsumerConfigBuilder{consumerConfig: &ConsumerConfig{}} +} + +func (ccb *ConsumerConfigBuilder) SetFilter(filter string) *ConsumerConfigBuilder { + ccb.consumerConfig.Filter = filter + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetRegistry(registry []string) *ConsumerConfigBuilder { + ccb.consumerConfig.Registry = registry + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetRequestTimeout(requestTimeout string) *ConsumerConfigBuilder { + ccb.consumerConfig.RequestTimeout = requestTimeout + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetProxyFactory(proxyFactory string) *ConsumerConfigBuilder { + ccb.consumerConfig.ProxyFactory = proxyFactory + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetCheck(check bool) *ConsumerConfigBuilder { + ccb.consumerConfig.Check = check + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetReferences(references map[string]*ReferenceConfig) *ConsumerConfigBuilder { + ccb.consumerConfig.References = references + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetFilterConf(filterConf interface{}) *ConsumerConfigBuilder { + ccb.consumerConfig.FilterConf = filterConf + return ccb +} + +func (ccb *ConsumerConfigBuilder) SetRootConfig(rootConfig *RootConfig) *ConsumerConfigBuilder { + ccb.consumerConfig.rootConfig = rootConfig + return ccb +} + +func (ccb *ConsumerConfigBuilder) Build() *ConsumerConfig { + if err := ccb.consumerConfig.Init(ccb.consumerConfig.rootConfig); err != nil { + panic(err) + } + return ccb.consumerConfig +} diff --git a/config/dubbo_bootstrap.go b/config/dubbo_bootstrap.go index 6793e26f1a..f5ccf922b0 100644 --- a/config/dubbo_bootstrap.go +++ b/config/dubbo_bootstrap.go @@ -27,6 +27,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" ) @@ -37,16 +38,16 @@ var ( func GetInstance(opts ...RootConfigOpt) *RootConfig { registerPOJO() rc := &RootConfig{ - ConfigCenter: GetConfigCenterInstance(), - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReportConfig: &MetadataReportConfig{}, - Application: GetApplicationInstance(), - Registries: make(map[string]*RegistryConfig), - Protocols: GetProtocolsInstance(), - Provider: GetProviderInstance(), - Consumer: GetConsumerInstance(), - MetricConfig: &MetricConfig{}, - Logger: GetLoggerConfigInstance(), + ConfigCenter: GetConfigCenterInstance(), + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReport: &MetadataReportConfig{}, + Application: GetApplicationInstance(), + Registries: make(map[string]*RegistryConfig), + Protocols: GetProtocolsInstance(), + Provider: GetProviderInstance(), + Consumer: GetConsumerInstance(), + Metric: &MetricConfig{}, + Logger: GetLoggerConfigInstance(), } for _, opt := range opts { opt(rc) @@ -71,19 +72,45 @@ func (rc *RootConfig) Init() error { if err := rc.Application.Init(); err != nil { return err } - if err := initProtocolsConfig(rc); err != nil { - return err + + // init protocol + protocols := rc.Protocols + if len(protocols) <= 0 { + protocol := &ProtocolConfig{} + protocols = make(map[string]*ProtocolConfig, 1) + protocols[constant.DUBBO] = protocol + rc.Protocols = protocols } - if err := initRegistryConfig(rc); err != nil { - return err + for _, protocol := range protocols { + if err := protocol.Init(); err != nil { + return err + } } - if err := initServiceDiscoveryConfig(rc); err != nil { - return err + + // init registry + registries := rc.Registries + if registries != nil { + for _, reg := range registries { + if err := reg.Init(); err != nil { + return err + } + } + } + + // init serviceDiscoveries + serviceDiscoveries := rc.ServiceDiscoveries + if serviceDiscoveries != nil { + for _, sd := range serviceDiscoveries { + if err := sd.Init(); err != nil { + return err + } + } } - if err := rc.MetadataReportConfig.Init(rc); err != nil { + + if err := rc.MetadataReport.Init(rc); err != nil { return err } - if err := initMetricConfig(rc); err != nil { + if err := rc.Metric.Init(); err != nil { return err } if err := initRouterConfig(rc); err != nil { diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index 76720a31d2..fdf2376cbe 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -83,3 +83,40 @@ func (config *ShutdownConfig) GetStepTimeout() time.Duration { } return result } + +type ShutdownConfigBuilder struct { + shutdownConfig *ShutdownConfig +} + +func NewShutDownConfigBuilder() *ShutdownConfigBuilder { + return &ShutdownConfigBuilder{shutdownConfig: &ShutdownConfig{}} +} + +func (scb *ShutdownConfigBuilder) SetTimeout(timeout string) *ShutdownConfigBuilder { + scb.shutdownConfig.Timeout = timeout + return scb +} + +func (scb *ShutdownConfigBuilder) SetStepTimeout(stepTimeout string) *ShutdownConfigBuilder { + scb.shutdownConfig.StepTimeout = stepTimeout + return scb +} + +func (scb *ShutdownConfigBuilder) SetRejectRequestHandler(rejectRequestHandler string) *ShutdownConfigBuilder { + scb.shutdownConfig.RejectRequestHandler = rejectRequestHandler + return scb +} + +func (scb *ShutdownConfigBuilder) SetRequestsFinished(requestsFinished bool) *ShutdownConfigBuilder { + scb.shutdownConfig.RequestsFinished = requestsFinished + return scb +} + +func (scb *ShutdownConfigBuilder) SetRejectRequest(rejectRequest bool) *ShutdownConfigBuilder { + scb.shutdownConfig.RejectRequest = rejectRequest + return scb +} + +func (scb *ShutdownConfigBuilder) Build() *ShutdownConfig { + return scb.shutdownConfig +} diff --git a/config/logger_config.go b/config/logger_config.go index d829256c65..0e7ec435ad 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -153,3 +153,29 @@ func (lc *LoggerConfig) getUrlMap() url.Values { } return urlMap } + +type LoggerConfigBuilder struct { + loggerConfig *LoggerConfig +} + +// nolint +func NewLoggerConfigBuilder() *LoggerConfigBuilder { + return &LoggerConfigBuilder{loggerConfig: &LoggerConfig{}} +} + +// nolint +func (lcb *LoggerConfigBuilder) SetLumberjackConfig(lumberjackConfig *lumberjack.Logger) *LoggerConfigBuilder { + lcb.loggerConfig.LumberjackConfig = lumberjackConfig + return lcb +} + +// nolint +func (lcb *LoggerConfigBuilder) SetZapConfig(zapConfig ZapConfig) *LoggerConfigBuilder { + lcb.loggerConfig.ZapConfig = zapConfig + return lcb +} + +// nolint +func (lcb *LoggerConfigBuilder) Build() *LoggerConfig { + return lcb.loggerConfig +} diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 888edd16ef..22f1fcbb8f 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -65,7 +65,7 @@ func (mc *MetadataReportConfig) ToUrl() (*common.URL, error) { common.WithParamsValue(constant.METADATATYPE_KEY, mc.MetadataType), ) if err != nil || len(res.Protocol) == 0 { - return nil, perrors.New("Invalid MetadataReportConfig.") + return nil, perrors.New("Invalid MetadataReport Config.") } res.SetParam("metadata", res.Protocol) return res, nil @@ -122,3 +122,60 @@ func selectMetadataServiceExportedURL() *common.URL { } return selectedUrl } + +type MetadataReportConfigBuilder struct { + metadataReportConfig *MetadataReportConfig +} + +// nolint +func NewMetadataReportConfigBuilder() *MetadataReportConfigBuilder { + return &MetadataReportConfigBuilder{metadataReportConfig: &MetadataReportConfig{}} +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetProtocol(protocol string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Protocol = protocol + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetAddress(address string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Address = address + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetUsername(username string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Username = username + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetPassword(password string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Password = password + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetTimeout(timeout string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Timeout = timeout + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetGroup(group string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.Group = group + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) SetMetadataType(metadataType string) *MetadataReportConfigBuilder { + mrcb.metadataReportConfig.MetadataType = metadataType + return mrcb +} + +// nolint +func (mrcb *MetadataReportConfigBuilder) Build() *MetadataReportConfig { + // TODO Init + return mrcb.metadataReportConfig +} diff --git a/config/metric_config.go b/config/metric_config.go index e6d0a5a171..64f6b2d47f 100644 --- a/config/metric_config.go +++ b/config/metric_config.go @@ -19,17 +19,19 @@ package config var defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000} -// This is the config struct for all metrics implementation +// MetricConfig This is the config struct for all metrics implementation type MetricConfig struct { - Reporters []string `yaml:"reporters" json:"reporters,omitempty"` + Reporters []string `yaml:"reporters" json:"reporters,omitempty"` + // TODO s? HistogramBucket []float64 `yaml:"histogram_bucket" json:"histogram_bucket,omitempty"` } -func initMetricConfig(rc *RootConfig) error { +// nolint +func (mc *MetricConfig) Init() error { return nil } -// find the histogram bucket +// GetHistogramBucket find the histogram bucket // if it's empty, the default value will be return func (mc *MetricConfig) GetHistogramBucket() []float64 { if len(mc.HistogramBucket) == 0 { @@ -37,3 +39,50 @@ func (mc *MetricConfig) GetHistogramBucket() []float64 { } return mc.HistogramBucket } + +type MetricConfigBuilder struct { + metricConfig *MetricConfig +} + +// nolint +func NewMetricConfigBuilder() *MetricConfigBuilder { + return &MetricConfigBuilder{metricConfig: &MetricConfig{}} +} + +// nolint +func (mcb *MetricConfigBuilder) SetReporters(reporters []string) *MetricConfigBuilder { + mcb.metricConfig.Reporters = reporters + return mcb +} + +// nolint +func (mcb *MetricConfigBuilder) AddReporter(reporter string) *MetricConfigBuilder { + if mcb.metricConfig.Reporters == nil { + mcb.metricConfig.Reporters = make([]string, 0) + } + mcb.metricConfig.Reporters = append(mcb.metricConfig.Reporters, reporter) + return mcb +} + +// nolint +func (mcb *MetricConfigBuilder) SetHistogramBucket(histogramBucket []float64) *MetricConfigBuilder { + mcb.metricConfig.HistogramBucket = histogramBucket + return mcb +} + +// nolint +func (mcb *MetricConfigBuilder) AddBucket(bucket float64) *MetricConfigBuilder { + if mcb.metricConfig.HistogramBucket == nil { + mcb.metricConfig.HistogramBucket = make([]float64, 0) + } + mcb.metricConfig.HistogramBucket = append(mcb.metricConfig.HistogramBucket, bucket) + return mcb +} + +// nolint +func (mcb *MetricConfigBuilder) Build() *MetricConfig { + if err := mcb.metricConfig.Init(); err != nil { + panic(err) + } + return mcb.metricConfig +} diff --git a/config/protocol_config.go b/config/protocol_config.go index 0a1a1a9716..39dcd00e5e 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -42,25 +42,7 @@ func GetProtocolsInstance() map[string]*ProtocolConfig { return make(map[string]*ProtocolConfig, 1) } -func initProtocolsConfig(rc *RootConfig) error { - protocols := rc.Protocols - if len(protocols) <= 0 { - protocol := new(ProtocolConfig) - protocols = make(map[string]*ProtocolConfig, 1) - protocols[constant.DUBBO] = protocol - rc.Protocols = protocols - return protocol.check() - } - for _, protocol := range protocols { - if err := protocol.check(); err != nil { - return err - } - } - rc.Protocols = protocols - return nil -} - -func (p *ProtocolConfig) check() error { +func (p *ProtocolConfig) Init() error { if err := defaults.Set(p); err != nil { return err } @@ -87,7 +69,7 @@ func NewProtocolConfig(opts ...ProtocolConfigOpt) *ProtocolConfig { type ProtocolConfigOpt func(config *ProtocolConfig) *ProtocolConfig // WithProtocolIP set ProtocolConfig with given binding @ip -// Deprecated: the param @ip would be used as service lisener binding and would be registered to registry center +// Deprecated: the param @ip would be used as service listener binding and would be registered to registry center func WithProtocolIP(ip string) ProtocolConfigOpt { return func(config *ProtocolConfig) *ProtocolConfig { config.Ip = ip @@ -108,3 +90,38 @@ func WithProtocolPort(port string) ProtocolConfigOpt { return config } } + +func NewProtocolConfigBuilder() *ProtocolConfigBuilder { + return &ProtocolConfigBuilder{protocolConfig: &ProtocolConfig{}} +} + +type ProtocolConfigBuilder struct { + protocolConfig *ProtocolConfig +} + +func (pcb *ProtocolConfigBuilder) SetName(name string) *ProtocolConfigBuilder { + pcb.protocolConfig.Name = name + return pcb +} + +func (pcb *ProtocolConfigBuilder) SetIp(ip string) *ProtocolConfigBuilder { + pcb.protocolConfig.Ip = ip + return pcb +} + +func (pcb *ProtocolConfigBuilder) SetPort(port string) *ProtocolConfigBuilder { + pcb.protocolConfig.Port = port + return pcb +} + +func (pcb *ProtocolConfigBuilder) SetParams(params interface{}) *ProtocolConfigBuilder { + pcb.protocolConfig.Params = params + return pcb +} + +func (pcb *ProtocolConfigBuilder) Build() *ProtocolConfig { + if err := pcb.protocolConfig.Init(); err != nil { + panic(err) + } + return pcb.protocolConfig +} diff --git a/config/provider_config.go b/config/provider_config.go index a77f3f9c19..09c286471c 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -35,16 +35,17 @@ type ProviderConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // Deprecated Register whether registration is required Register bool `yaml:"register" json:"register" property:"register"` - // Registry registry ids + // Registry registry ids TODO Registries? Registry []string `yaml:"registry" json:"registry" property:"registry"` // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` - FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` - // ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf"` + FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` + + rootConfig *RootConfig } func (ProviderConfig) Prefix() string { @@ -98,8 +99,7 @@ func SetProviderConfig(p ProviderConfig) { rootConfig.Provider = &p } -///////////////////////////////////// provider config api -// ProviderConfigOpt is the +// nolint type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig // NewEmptyProviderConfig returns ProviderConfig with default ApplicationConfig @@ -132,7 +132,7 @@ func GetProviderInstance(opts ...ProviderConfigOpt) *ProviderConfig { return newConfig } -// WithProviderServices returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig +// WithProviderService returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig func WithProviderService(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { return func(config *ProviderConfig) *ProviderConfig { config.Services[serviceName] = serviceConfig @@ -147,3 +147,86 @@ func WithProviderRegistryKeys(registryKey ...string) ProviderConfigOpt { return config } } + +type ProviderConfigBuilder struct { + providerConfig *ProviderConfig +} + +// nolint +func NewProviderConfigBuilder() *ProviderConfigBuilder { + return &ProviderConfigBuilder{providerConfig: &ProviderConfig{}} +} + +// nolint +func (pcb *ProviderConfigBuilder) SetFilter(filter string) *ProviderConfigBuilder { + pcb.providerConfig.Filter = filter + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetRegister(register bool) *ProviderConfigBuilder { + pcb.providerConfig.Register = register + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetRegistry(registry []string) *ProviderConfigBuilder { + pcb.providerConfig.Registry = registry + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetServices(services map[string]*ServiceConfig) *ProviderConfigBuilder { + pcb.providerConfig.Services = services + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) AddService(serviceName string, serviceConfig *ServiceConfig) *ProviderConfigBuilder { + if pcb.providerConfig.Services == nil { + pcb.providerConfig.Services = make(map[string]*ServiceConfig) + } + pcb.providerConfig.Services[serviceName] = serviceConfig + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetProxyFactory(proxyFactory string) *ProviderConfigBuilder { + pcb.providerConfig.ProxyFactory = proxyFactory + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetFilterConf(filterConf interface{}) *ProviderConfigBuilder { + pcb.providerConfig.FilterConf = filterConf + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetConfigType(configType map[string]string) *ProviderConfigBuilder { + pcb.providerConfig.ConfigType = configType + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) AddConfigType(key, value string) *ProviderConfigBuilder { + if pcb.providerConfig.ConfigType == nil { + pcb.providerConfig.ConfigType = make(map[string]string) + } + pcb.providerConfig.ConfigType[key] = value + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) SetRootConfig(rootConfig *RootConfig) *ProviderConfigBuilder { + pcb.providerConfig.rootConfig = rootConfig + return pcb +} + +// nolint +func (pcb *ProviderConfigBuilder) Build() *ProviderConfig { + if err := pcb.providerConfig.Init(pcb.providerConfig.rootConfig); err != nil { + panic(err) + } + return pcb.providerConfig +} diff --git a/config/registry_config.go b/config/registry_config.go index c811eeed9f..51e3539076 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -63,7 +63,7 @@ func (RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix } -func (c *RegistryConfig) check() error { +func (c *RegistryConfig) Init() error { if err := defaults.Set(c); err != nil { return err } @@ -71,18 +71,6 @@ func (c *RegistryConfig) check() error { return verify(c) } -// initRegistryConfig init registry config -func initRegistryConfig(rc *RootConfig) error { - registries := rc.Registries - for key, reg := range registries { - if err := reg.check(); err != nil { - return err - } - registries[key] = reg - } - return nil -} - func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { urlMap := url.Values{} urlMap.Set(constant.GROUP_KEY, c.Group) @@ -284,3 +272,98 @@ func WithRegistryParams(params map[string]string) RegistryConfigOpt { return config } } + +func NewRegistryConfigBuilder() *RegistryConfigBuilder { + return &RegistryConfigBuilder{ + registryConfig: &RegistryConfig{}, + } +} + +type RegistryConfigBuilder struct { + registryConfig *RegistryConfig +} + +func (rcb *RegistryConfigBuilder) SetProtocol(protocol string) *RegistryConfigBuilder { + rcb.registryConfig.Protocol = protocol + return rcb +} + +func (rcb *RegistryConfigBuilder) SetTimeout(timeout string) *RegistryConfigBuilder { + rcb.registryConfig.Timeout = timeout + return rcb +} + +func (rcb *RegistryConfigBuilder) SetGroup(group string) *RegistryConfigBuilder { + rcb.registryConfig.Group = group + return rcb +} + +func (rcb *RegistryConfigBuilder) SetNamespace(namespace string) *RegistryConfigBuilder { + rcb.registryConfig.Namespace = namespace + return rcb +} + +func (rcb *RegistryConfigBuilder) SetTTL(ttl string) *RegistryConfigBuilder { + rcb.registryConfig.TTL = ttl + return rcb +} + +func (rcb *RegistryConfigBuilder) SetAddress(address string) *RegistryConfigBuilder { + rcb.registryConfig.Address = address + return rcb +} + +func (rcb *RegistryConfigBuilder) SetUsername(username string) *RegistryConfigBuilder { + rcb.registryConfig.Username = username + return rcb +} + +func (rcb *RegistryConfigBuilder) SetPassword(password string) *RegistryConfigBuilder { + rcb.registryConfig.Password = password + return rcb +} + +func (rcb *RegistryConfigBuilder) SetSimplified(simplified bool) *RegistryConfigBuilder { + rcb.registryConfig.Simplified = simplified + return rcb +} + +func (rcb *RegistryConfigBuilder) SetPreferred(preferred bool) *RegistryConfigBuilder { + rcb.registryConfig.Preferred = preferred + return rcb +} + +func (rcb *RegistryConfigBuilder) SetZone(zone string) *RegistryConfigBuilder { + rcb.registryConfig.Zone = zone + return rcb +} + +func (rcb *RegistryConfigBuilder) SetWeight(weight int64) *RegistryConfigBuilder { + rcb.registryConfig.Weight = weight + return rcb +} + +func (rcb *RegistryConfigBuilder) SetParams(params map[string]string) *RegistryConfigBuilder { + rcb.registryConfig.Params = params + return rcb +} + +func (rcb *RegistryConfigBuilder) addParam(key, value string) *RegistryConfigBuilder { + if rcb.registryConfig.Params == nil { + rcb.registryConfig.Params = make(map[string]string) + } + rcb.registryConfig.Params[key] = value + return rcb +} + +func (rcb *RegistryConfigBuilder) SetRegistryType(registryType string) *RegistryConfigBuilder { + rcb.registryConfig.RegistryType = registryType + return rcb +} + +func (rcb *RegistryConfigBuilder) Build() *RegistryConfig { + if err := rcb.registryConfig.Init(); err != nil { + panic(err) + } + return rcb.registryConfig +} diff --git a/config/remote_config.go b/config/remote_config.go index 820f744b0b..444db6ee8e 100644 --- a/config/remote_config.go +++ b/config/remote_config.go @@ -31,17 +31,17 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// RemoteConfig: usually we need some middleware, including nacos, zookeeper +// RemoteConfig usually we need some middleware, including nacos, zookeeper // this represents an instance of this middleware // so that other module, like config center, registry could reuse the config // but now, only metadata report, metadata service, service discovery use this structure type RemoteConfig struct { - Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Address string `yaml:"address" json:"address,omitempty" property:"address"` - TimeoutStr string `default:"5s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` - Username string `yaml:"username" json:"username,omitempty" property:"username"` - Password string `yaml:"password" json:"password,omitempty" property:"password"` - Params map[string]string `yaml:"params" json:"params,omitempty"` + Protocol string `yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + Address string `yaml:"address" json:"address,omitempty" property:"address"` + Timeout string `default:"5s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"` + Username string `yaml:"username" json:"username,omitempty" property:"username"` + Password string `yaml:"password" json:"password,omitempty" property:"password"` + Params map[string]string `yaml:"params" json:"params,omitempty"` } // Prefix dubbo.remote. @@ -49,10 +49,15 @@ func (rc *RemoteConfig) Prefix() string { return constant.RemotePrefix } -// Timeout return timeout duration. +// nolint +func (rc *RemoteConfig) Init() error { + return nil +} + +// GetTimeout return timeout duration. // if the configure is invalid, or missing, the default value 5s will be returned -func (rc *RemoteConfig) Timeout() time.Duration { - if res, err := time.ParseDuration(rc.TimeoutStr); err == nil { +func (rc *RemoteConfig) GetTimeout() time.Duration { + if res, err := time.ParseDuration(rc.Timeout); err == nil { return res } return 5 * time.Second @@ -87,10 +92,63 @@ 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) + urlMap.Set(constant.CONFIG_TIMEOUT_KEY, rc.Timeout) for key, val := range rc.Params { urlMap.Set(key, val) } return urlMap } + +func NewRemoteConfigBuilder() *RemoteConfigBuilder { + return &RemoteConfigBuilder{remoteConfig: &RemoteConfig{}} +} + +type RemoteConfigBuilder struct { + remoteConfig *RemoteConfig +} + +func (rcb *RemoteConfigBuilder) SetProtocol(protocol string) *RemoteConfigBuilder { + rcb.remoteConfig.Protocol = protocol + return rcb +} + +func (rcb *RemoteConfigBuilder) SetAddress(address string) *RemoteConfigBuilder { + rcb.remoteConfig.Address = address + return rcb +} + +func (rcb *RemoteConfigBuilder) SetTimeout(timeout string) *RemoteConfigBuilder { + rcb.remoteConfig.Timeout = timeout + return rcb +} + +func (rcb *RemoteConfigBuilder) SetUsername(username string) *RemoteConfigBuilder { + rcb.remoteConfig.Username = username + return rcb +} + +func (rcb *RemoteConfigBuilder) SetPassword(password string) *RemoteConfigBuilder { + rcb.remoteConfig.Password = password + return rcb +} + +func (rcb *RemoteConfigBuilder) SetParams(params map[string]string) *RemoteConfigBuilder { + rcb.remoteConfig.Params = params + return rcb +} + +func (rcb *RemoteConfigBuilder) AddParam(key, value string) *RemoteConfigBuilder { + if rcb.remoteConfig.Params == nil { + rcb.remoteConfig.Params = make(map[string]string) + } + rcb.remoteConfig.Params[key] = value + return rcb +} + +func (rcb *RemoteConfigBuilder) Build() *RemoteConfig { + if err := rcb.remoteConfig.Init(); err != nil { + panic(err) + } + return rcb.remoteConfig +} diff --git a/config/root_config.go b/config/root_config.go index 36d24b5e7c..e5a39bb81c 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -38,12 +38,13 @@ type RootConfig struct { // Remotes to be remove in 3.0 config-enhance Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` + // TODO ConfigCenter and CenterConfig? ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` // ServiceDiscoveries to be remove in 3.0 config-enhance ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` - MetadataReportConfig *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` + MetadataReport *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` // provider config Provider *ProviderConfig `yaml:"provider" json:"provider" property:"provider"` @@ -51,7 +52,7 @@ type RootConfig struct { // consumer config Consumer *ConsumerConfig `yaml:"consumer" json:"consumer" property:"consumer"` - MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty" property:"metrics"` + Metric *MetricConfig `yaml:"metrics" json:"metrics,omitempty" property:"metrics"` // Logger log Logger *LoggerConfig `yaml:"logger" json:"logger,omitempty" property:"logger"` @@ -198,15 +199,15 @@ func (rc *RootConfig) getRegistryIds() []string { // NewRootConfig get root config func NewRootConfig(opts ...RootConfigOpt) *RootConfig { newRootConfig := &RootConfig{ - ConfigCenter: &CenterConfig{}, - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReportConfig: &MetadataReportConfig{}, - Application: &ApplicationConfig{}, - Registries: make(map[string]*RegistryConfig), - Protocols: make(map[string]*ProtocolConfig), - Provider: GetProviderInstance(), - Consumer: GetConsumerInstance(), - MetricConfig: &MetricConfig{}, + ConfigCenter: &CenterConfig{}, + ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), + MetadataReport: &MetadataReportConfig{}, + Application: &ApplicationConfig{}, + Registries: make(map[string]*RegistryConfig), + Protocols: make(map[string]*ProtocolConfig), + Provider: GetProviderInstance(), + Consumer: GetConsumerInstance(), + Metric: &MetricConfig{}, } for _, o := range opts { o(newRootConfig) @@ -219,7 +220,7 @@ type RootConfigOpt func(config *RootConfig) // WithMetricsConfig set root config with given @metricsConfig func WithMetricsConfig(metricsConfig *MetricConfig) RootConfigOpt { return func(rc *RootConfig) { - rc.MetricConfig = metricsConfig + rc.Metric = metricsConfig } } @@ -261,7 +262,7 @@ func WithRootApplicationConfig(appConfig *ApplicationConfig) RootConfigOpt { // WithRootMetadataReportConfig set root config with given @metadataReportConfig func WithRootMetadataReportConfig(metadataReportConfig *MetadataReportConfig) RootConfigOpt { return func(rc *RootConfig) { - rc.MetadataReportConfig = metadataReportConfig + rc.MetadataReport = metadataReportConfig } } @@ -278,3 +279,88 @@ func WithRootCenterConfig(centerConfig *CenterConfig) RootConfigOpt { rc.ConfigCenter = centerConfig } } + +func NewRootConfigBuilder() *RootConfigBuilder { + return &RootConfigBuilder{rootConfig: &RootConfig{}} +} + +type RootConfigBuilder struct { + rootConfig *RootConfig +} + +func (rb *RootConfigBuilder) SetApplication(application *ApplicationConfig) *RootConfigBuilder { + rb.rootConfig.Application = application + return rb +} + +func (rb *RootConfigBuilder) SetProtocols(protocols map[string]*ProtocolConfig) *RootConfigBuilder { + rb.rootConfig.Protocols = protocols + return rb +} + +func (rb *RootConfigBuilder) SetRegistries(registries map[string]*RegistryConfig) *RootConfigBuilder { + rb.rootConfig.Registries = registries + return rb +} + +func (rb *RootConfigBuilder) SetRemotes(remotes map[string]*RemoteConfig) *RootConfigBuilder { + rb.rootConfig.Remotes = remotes + return rb +} + +func (rb *RootConfigBuilder) SetServiceDiscoveries(serviceDiscoveries map[string]*ServiceDiscoveryConfig) *RootConfigBuilder { + rb.rootConfig.ServiceDiscoveries = serviceDiscoveries + return rb +} + +func (rb *RootConfigBuilder) SetMetadataReport(metadataReport *MetadataReportConfig) *RootConfigBuilder { + rb.rootConfig.MetadataReport = metadataReport + return rb +} + +func (rb *RootConfigBuilder) SetProvider(provider *ProviderConfig) *RootConfigBuilder { + rb.rootConfig.Provider = provider + return rb +} + +func (rb *RootConfigBuilder) SetConsumer(consumer *ConsumerConfig) *RootConfigBuilder { + rb.rootConfig.Consumer = consumer + return rb +} + +func (rb *RootConfigBuilder) SetMetric(metric *MetricConfig) *RootConfigBuilder { + rb.rootConfig.Metric = metric + return rb +} + +func (rb *RootConfigBuilder) SetLogger(logger *LoggerConfig) *RootConfigBuilder { + rb.rootConfig.Logger = logger + return rb +} + +func (rb *RootConfigBuilder) SetShutdown(shutdown *ShutdownConfig) *RootConfigBuilder { + rb.rootConfig.Shutdown = shutdown + return rb +} + +func (rb *RootConfigBuilder) SetRouter(router []*RouterConfig) *RootConfigBuilder { + rb.rootConfig.Router = router + return rb +} + +func (rb *RootConfigBuilder) SetEventDispatcherType(eventDispatcherType string) *RootConfigBuilder { + rb.rootConfig.EventDispatcherType = eventDispatcherType + return rb +} + +func (rb *RootConfigBuilder) SetCacheFile(cacheFile string) *RootConfigBuilder { + rb.rootConfig.CacheFile = cacheFile + return rb +} + +func (rb *RootConfigBuilder) Build() *RootConfig { + if err := rb.rootConfig.Init(); err != nil { + panic(err) + } + return rb.rootConfig +} diff --git a/config/router_config.go b/config/router_config.go index 28cf7a0864..854fa8e8ce 100644 --- a/config/router_config.go +++ b/config/router_config.go @@ -51,7 +51,7 @@ func (RouterConfig) Prefix() string { return constant.RouterConfigPrefix } -func (c *RouterConfig) check() error { +func (c *RouterConfig) Init() error { if err := defaults.Set(c); err != nil { return err } @@ -62,7 +62,7 @@ func initRouterConfig(rc *RootConfig) error { routers := rc.Router if len(routers) > 0 { for _, r := range routers { - if err := r.check(); err != nil { + if err := r.Init(); err != nil { return err } } @@ -91,3 +91,92 @@ func initRouterConfig(rc *RootConfig) error { // chain.SetVSAndDRConfigByte(vsBytes, drBytes) // return nil //} + +type RouterConfigBuilder struct { + routerConfig *RouterConfig +} + +// nolint +func NewRouterConfigBuilder() *RouterConfigBuilder { + return &RouterConfigBuilder{routerConfig: &RouterConfig{}} +} + +// nolint +func (rcb *RouterConfigBuilder) SetScope(scope string) *RouterConfigBuilder { + rcb.routerConfig.Scope = scope + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetKey(key string) *RouterConfigBuilder { + rcb.routerConfig.Key = key + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetForce(force bool) *RouterConfigBuilder { + rcb.routerConfig.Force = force + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetRuntime(runtime bool) *RouterConfigBuilder { + rcb.routerConfig.Runtime = runtime + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetEnable(enable bool) *RouterConfigBuilder { + rcb.routerConfig.Enable = enable + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetValid(valid bool) *RouterConfigBuilder { + rcb.routerConfig.Valid = valid + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetPriority(priority int) *RouterConfigBuilder { + rcb.routerConfig.Priority = priority + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetConditions(conditions []string) *RouterConfigBuilder { + rcb.routerConfig.Conditions = conditions + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) AddCondition(condition string) *RouterConfigBuilder { + if rcb.routerConfig.Conditions == nil { + rcb.routerConfig.Conditions = make([]string, 0) + } + rcb.routerConfig.Conditions = append(rcb.routerConfig.Conditions, condition) + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) SetTags(tags []Tag) *RouterConfigBuilder { + rcb.routerConfig.Tags = tags + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) AddTag(tag Tag) *RouterConfigBuilder { + if rcb.routerConfig.Tags == nil { + rcb.routerConfig.Tags = make([]Tag, 0) + } + rcb.routerConfig.Tags = append(rcb.routerConfig.Tags, tag) + return rcb +} + +// nolint +func (rcb *RouterConfigBuilder) Build() *RouterConfig { + if err := rcb.routerConfig.Init(); err != nil { + panic(err) + } + return rcb.routerConfig +} diff --git a/config/service_config.go b/config/service_config.go index 53dce7ac3a..3bb16693c7 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -410,7 +410,7 @@ func (svc *ServiceConfig) GetExportedUrls() []*common.URL { } func (svc *ServiceConfig) publishServiceDefinition(url *common.URL) { - //svc.rootConfig.MetadataReportConfig. + //svc.rootConfig.MetadataReport. if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { remoteMetadataService.PublishServiceDefinition(url) } diff --git a/config/service_discovery_config.go b/config/service_discovery_config.go index 2ba2bde0bc..d93aea57f0 100644 --- a/config/service_discovery_config.go +++ b/config/service_discovery_config.go @@ -37,6 +37,38 @@ func (ServiceDiscoveryConfig) Prefix() string { return constant.ServiceDiscPrefix } -func initServiceDiscoveryConfig(rc *RootConfig) error { +func (ServiceDiscoveryConfig) Init() error { return nil } + +func NewServiceDiscoveryConfigBuilder() *ServiceDiscoveryConfigBuilder { + return &ServiceDiscoveryConfigBuilder{ + serviceDiscoveryConfig: &ServiceDiscoveryConfig{}, + } +} + +type ServiceDiscoveryConfigBuilder struct { + serviceDiscoveryConfig *ServiceDiscoveryConfig +} + +func (sdcb *ServiceDiscoveryConfigBuilder) SetProtocol(protocol string) *ServiceDiscoveryConfigBuilder { + sdcb.serviceDiscoveryConfig.Protocol = protocol + return sdcb +} + +func (sdcb *ServiceDiscoveryConfigBuilder) SetGroup(group string) *ServiceDiscoveryConfigBuilder { + sdcb.serviceDiscoveryConfig.Group = group + return sdcb +} + +func (sdcb *ServiceDiscoveryConfigBuilder) SetRemoteRef(remoteRef string) *ServiceDiscoveryConfigBuilder { + sdcb.serviceDiscoveryConfig.RemoteRef = remoteRef + return sdcb +} + +func (sdcb *ServiceDiscoveryConfigBuilder) Build() *ServiceDiscoveryConfig { + if err := sdcb.serviceDiscoveryConfig.Init(); err != nil { + panic(err) + } + return sdcb.serviceDiscoveryConfig +} diff --git a/go.sum b/go.sum index 3f0db58753..a4412af1f0 100644 --- a/go.sum +++ b/go.sum @@ -181,8 +181,6 @@ github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= -github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6 h1:ZrCFQ/a0rgK5EBF9FiiSYvCmtC2sLzOoFAbqBVmsA94= -github.com/dubbogo/triple v1.0.6-0.20210904050749-5721796f3fd6/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c h1:/Qrdqo2JVrywDANk04DHrvdfREdIApAWZ6stbYZfNaM= github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go index 89992d6cb8..eb4c1a6996 100644 --- a/remoting/nacos/builder_test.go +++ b/remoting/nacos/builder_test.go @@ -50,7 +50,7 @@ func TestNewNacosClient(t *testing.T) { assert.NotNil(t, err) rc.Address = "console.nacos.io:80" - rc.TimeoutStr = "10s" + rc.Timeout = "10s" client, err = NewNacosClient(rc) assert.NotNil(t, client) assert.Nil(t, err) From 929b2f4b84cb6d4ce4f96580e28f7b3862b85331 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 2 Oct 2021 15:27:27 +0800 Subject: [PATCH 133/148] fix: finish api --- config/application_config.go | 55 -- config/config_center_config.go | 143 ++--- config/config_loader.go | 2 +- config/config_loader_test.go | 593 ------------------ config/consumer_config.go | 152 +---- config/dubbo_bootstrap.go | 22 +- config/graceful_shutdown_test.go | 6 +- config/protocol_config.go | 45 -- config/provider_config.go | 74 +-- config/provider_config_test.go | 10 +- config/reference_config.go | 80 +-- config/root_config.go | 194 +----- config/service_config.go | 184 ++---- .../service/exporter/configurable/exporter.go | 29 +- .../exporter/configurable/exporter_test.go | 5 +- metrics/prometheus/reporter.go | 1 + protocol/dubbo3/internal/server.go | 25 +- protocol/grpc/grpc_protocol_test.go | 4 +- registry/protocol/protocol.go | 2 +- 19 files changed, 219 insertions(+), 1407 deletions(-) delete mode 100644 config/config_loader_test.go diff --git a/config/application_config.go b/config/application_config.go index cb52c6bdef..fb766bef02 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -55,14 +55,6 @@ func (ac *ApplicationConfig) Init() error { return nil } -func GetApplicationInstance(opts ...ApplicationConfigOpt) *ApplicationConfig { - ac := &ApplicationConfig{} - for _, opt := range opts { - opt(ac) - } - return ac -} - func (ac *ApplicationConfig) check() error { if err := defaults.Set(ac); err != nil { return err @@ -70,50 +62,6 @@ func (ac *ApplicationConfig) check() error { return verify(ac) } -type ApplicationConfigOpt func(config *ApplicationConfig) - -func WithOrganization(organization string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Organization = organization - } -} - -func WithName(name string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Name = name - } -} - -func WithModule(module string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Module = module - } -} - -func WithVersion(version string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Version = version - } -} - -func WithOwner(owner string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Owner = owner - } -} - -func WithEnvironment(env string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.Environment = env - } -} - -func WithMetadataType(metadataType string) ApplicationConfigOpt { - return func(ac *ApplicationConfig) { - ac.MetadataType = metadataType - } -} - func NewApplicationConfigBuilder() *ApplicationConfigBuilder { return &ApplicationConfigBuilder{application: &ApplicationConfig{}} } @@ -158,8 +106,5 @@ func (acb *ApplicationConfigBuilder) SetMetadataType(metadataType string) *Appli } func (acb *ApplicationConfigBuilder) Build() *ApplicationConfig { - if err := acb.application.Init(); err != nil { - panic(err) - } return acb.application } diff --git a/config/config_center_config.go b/config/config_center_config.go index b0b4e60ba5..6ac615f9b5 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -76,16 +76,6 @@ func (CenterConfig) Prefix() string { return constant.ConfigCenterPrefix } -func GetConfigCenterInstance(opts ...CenterConfigOpt) *CenterConfig { - cc := &CenterConfig{ - Params: make(map[string]string, 1), - } - for _, opt := range opts { - opt(cc) - } - return cc -} - func (c *CenterConfig) check() error { if err := defaults.Set(c); err != nil { return err @@ -140,21 +130,6 @@ func (c *CenterConfig) translateConfigAddress() string { // toURL will compatible with baseConfig.ShutdownConfig.Address and baseConfig.ShutdownConfig.RemoteRef before 1.6.0 // After 1.6.0 will not compatible, only baseConfig.ShutdownConfig.RemoteRef func (c *CenterConfig) toURL() (*common.URL, error) { - //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())) - //} - //rc, ok := baseConfig.GetRemoteConfig(remoteRef) - //if !ok { - // return nil, perrors.New("Could not find out the remote ref config, name: " + remoteRef) - //} - //// set protocol if remote not set - //if len(rc.Protocol) <= 0 { - // rc.Protocol = baseConfig.ConfigCenterConfig.Protocol - //} return common.NewURL(c.Address, common.WithProtocol(c.Protocol), common.WithParams(c.GetUrlMap())) @@ -211,105 +186,57 @@ func (c *CenterConfig) prepareEnvironment(configCenterUrl *common.URL) (string, envInstance.SetDynamicConfiguration(dynamicConfig) return dynamicConfig.GetProperties(c.DataId, config_center.WithGroup(c.Group)) - //if err != nil { - // logger.Errorf("Get config content in dynamic configuration error , error message is %v", err) - // return errors.WithStack(err) - //} - //yaml.Unmarshal([]byte(conten),rootConfig) - //var appGroup string - //var appContent string - //if config2.providerConfig != nil && config2.providerConfig.ApplicationConfig != nil && - // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ProviderConfig" { - // appGroup = config2.providerConfig.ApplicationConfig.Name - //} else if config2.consumerConfig != nil && config2.consumerConfig.ApplicationConfig != nil && - // reflect.ValueOf(baseConfig.fatherConfig).Elem().Type().Name() == "ConsumerConfig" { - // appGroup = config2.consumerConfig.ApplicationConfig.Name - //} - // - //if len(appGroup) != 0 { - // configFile := baseConfig.ConfigCenterConfig.AppConfigFile - // if len(configFile) == 0 { - // configFile = baseConfig.ConfigCenterConfig.ConfigFile - // } - // appContent, err = dynamicConfig.GetProperties(configFile, config_center.WithGroup(appGroup)) - // if err != nil { - // return perrors.WithStack(err) - // } - //} - //// global config file - //mapContent, err := dynamicConfig.Parser().Parse(content) - //if err != nil { - // return perrors.WithStack(err) - //} - //envInstance.UpdateExternalConfigMap(mapContent) - // - //// appGroup config file - //if len(appContent) != 0 { - // appMapContent, err := dynamicConfig.Parser().Parse(appContent) - // if err != nil { - // return perrors.WithStack(err) - // } - // envInstance.UpdateAppExternalConfigMap(appMapContent) - //} } -type CenterConfigOpt func(config *CenterConfig) +func NewConfigCenterConfigBuilder() *ConfigCenterConfigBuilder { + return &ConfigCenterConfigBuilder{configCenterConfig: newEmptyConfigCenterConfig()} +} -func NewConfigCenterConfig(opts ...CenterConfigOpt) *CenterConfig { - centerConfig := &CenterConfig{ - Params: make(map[string]string), - } - for _, o := range opts { - o(centerConfig) - } - return centerConfig +type ConfigCenterConfigBuilder struct { + configCenterConfig *CenterConfig } -// WithConfigCenterProtocol set ProtocolConfig with given protocolName protocol -func WithConfigCenterProtocol(protocol string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Protocol = protocol - } +func (ccb *ConfigCenterConfigBuilder) SetProtocol(protocol string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Protocol = protocol + return ccb } -// WithConfigCenterAddress set ProtocolConfig with given @addr -func WithConfigCenterAddress(addr string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Address = addr - } +func (ccb *ConfigCenterConfigBuilder) SetUserName(userName string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Username = userName + return ccb } -// WithConfigCenterDataID set ProtocolConfig with given @dataID -func WithConfigCenterDataID(dataID string) CenterConfigOpt { - return func(config *CenterConfig) { - config.DataId = dataID - } +func (ccb *ConfigCenterConfigBuilder) SetAddress(address string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Address = address + return ccb } -// WithConfigCenterGroup set ProtocolConfig with given @group -func WithConfigCenterGroup(group string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Group = group - } +func (ccb *ConfigCenterConfigBuilder) SetPassword(password string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Password = password + return ccb } -// WithConfigCenterUsername set ProtocolConfig with given @username -func WithConfigCenterUsername(username string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Username = username - } +func (ccb *ConfigCenterConfigBuilder) SetNamespace(namespace string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Namespace = namespace + return ccb } -// WithConfigCenterPassword set ProtocolConfig with given @password -func WithConfigCenterPassword(password string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Password = password - } +func (ccb *ConfigCenterConfigBuilder) SetDataID(dataID string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.DataId = dataID + return ccb } -// WithConfigCenterNamespace set ProtocolConfig with given @namespace -func WithConfigCenterNamespace(namespace string) CenterConfigOpt { - return func(config *CenterConfig) { - config.Namespace = namespace +func (ccb *ConfigCenterConfigBuilder) SetGroup(group string) *ConfigCenterConfigBuilder { + ccb.configCenterConfig.Group = group + return ccb +} + +func (ccb *ConfigCenterConfigBuilder) Build() *CenterConfig { + return ccb.configCenterConfig +} + +func newEmptyConfigCenterConfig() *CenterConfig { + return &CenterConfig{ + Params: make(map[string]string), } } diff --git a/config/config_loader.go b/config/config_loader.go index 7d611be914..b309cc5a5a 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -42,7 +42,7 @@ import ( ) var ( - rootConfig = GetInstance() + rootConfig = NewRootConfigBuilder().Build() maxWait = 3 ) diff --git a/config/config_loader_test.go b/config/config_loader_test.go deleted file mode 100644 index 73b96fc50e..0000000000 --- a/config/config_loader_test.go +++ /dev/null @@ -1,593 +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 config - -import ( - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -const ( - configPath = "./testdata/application.yaml" -) - -func TestLoad(t *testing.T) { - err := Load(WithPath(configPath)) - assert.Nil(t, err) - t.Run("application", func(t *testing.T) { - application := rootConfig.Application - - assert.Equal(t, "dubbo-go", application.Organization) - assert.Equal(t, "dubbo-go", application.Name) - assert.Equal(t, "local", application.Module) - assert.Equal(t, "1.0.0", application.Version) - assert.Equal(t, "zhaoyunxing", application.Owner) - assert.Equal(t, "dev", application.Environment) - assert.Equal(t, "local", application.MetadataType) - }) - - t.Run("registries", func(t *testing.T) { - registries := rootConfig.Registries - - assert.Equal(t, 2, len(registries)) - //address= nacos://127.0.0.1:8848 Translate Registry Address - assert.Equal(t, "nacos", registries["nacos"].Protocol) - assert.Equal(t, "5s", registries["zk"].Timeout) - }) - - //config-center - t.Run("config-center", func(t *testing.T) { - conf := rootConfig.ConfigCenter - - assert.Equal(t, "nacos", conf.Protocol) - }) - -} - -//TestLoadConfigCenter test key config_center、config-center 、configCenter -func TestLoadConfigCenter(t *testing.T) { - - err := Load(WithPath("./testdata/config/center/conf-application.yaml")) - assert.Nil(t, err) - conf := rootConfig.ConfigCenter - assert.Equal(t, "nacos", conf.Protocol) - assert.Equal(t, "10s", conf.Timeout) - assert.Equal(t, "./logs", conf.LogDir) -} - -func TestGetRegistriesConfig(t *testing.T) { - - err := Load(WithPath("./testdata/config/registry/application.yaml")) - - assert.Nil(t, err) - registries := rootConfig.Registries - - assert.Equal(t, 2, len(registries)) - // nacos - assert.Equal(t, "nacos", registries["nacos"].Protocol) - assert.Equal(t, "5s", registries["nacos"].Timeout) - assert.Equal(t, "127.0.0.1:8848", registries["nacos"].Address) - assert.Equal(t, "dev", registries["nacos"].Group) - // zk - assert.Equal(t, "zookeeper", registries["zk"].Protocol) - assert.Equal(t, "5s", registries["zk"].Timeout) - assert.Equal(t, "127.0.0.1:2181", registries["zk"].Address) - assert.Equal(t, "test", registries["zk"].Group) -} - -// -//func TestLoadWithSingleReg(t *testing.T) { -// reference.doInitConsumerWithSingleRegistry() -// mockInitProviderWithSingleRegistry() -// -// ms := &MockService{} -// instance.SetConsumerService(ms) -// instance.SetProviderService(ms) -// -// extension.SetProtocol("registry", reference.GetProtocol) -// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) -// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) -// var mm *mockMetadataService -// GetApplicationConfig().MetadataType = "mock" -// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { -// if mm == nil { -// mm = &mockMetadataService{ -// exportedServiceURLs: new(sync.Map), -// lock: new(sync.RWMutex), -// } -// } -// return mm, nil -// }) -// Load() -// -// assert.Equal(t, ms, GetRPCService(ms.Reference())) -// ms2 := &struct { -// MockService -// }{} -// RPCService(ms2) -// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) -// -// service2.conServices = map[string]common.RPCService{} -// service2.proServices = map[string]common.RPCService{} -// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) -// consumerConfig = nil -// providerConfig = nil -//} -// -//func TestWithNoRegLoad(t *testing.T) { -// reference.doInitConsumer() -// service2.doInitProvider() -// providerConfig.Services["MockService"].Registry = "" -// consumerConfig.References["MockService"].Registry = "" -// ms := &MockService{} -// instance.SetConsumerService(ms) -// instance.SetProviderService(ms) -// -// extension.SetProtocol("registry", reference.GetProtocol) -// extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, cluster_impl.NewZoneAwareCluster) -// extension.SetProxyFactory("default", proxy_factory.NewDefaultProxyFactory) -// var mm *mockMetadataService -// GetApplicationConfig().MetadataType = "mock" -// extension.SetLocalMetadataService("mock", func() (metadataService service.MetadataService, err error) { -// if mm == nil { -// mm = &mockMetadataService{ -// exportedServiceURLs: new(sync.Map), -// lock: new(sync.RWMutex), -// } -// } -// return mm, nil -// }) -// Load() -// -// assert.Equal(t, ms, GetRPCService(ms.Reference())) -// ms2 := &struct { -// MockService -// }{} -// RPCService(ms2) -// assert.NotEqual(t, ms2, GetRPCService(ms2.Reference())) -// -// service2.conServices = map[string]common.RPCService{} -// service2.proServices = map[string]common.RPCService{} -// err := common.ServiceMap.UnRegister("com.MockService", "mock", -// common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) -// assert.Nil(t, err) -// common.ServiceMap.UnRegister("com.MockService", "mock", common.ServiceKey("com.MockService", "huadong_idc", "1.0.0")) -// consumerConfig = nil -// providerConfig = nil -//} -// -//func TestSetDefaultValue(t *testing.T) { -// proConfig := &provider.ProviderConfig{Registries: make(map[string]*registry2.RegistryConfig), Protocols: make(map[string]*protocol2.ProtocolConfig)} -// assert.Nil(t, proConfig.ApplicationConfig) -// setDefaultValue(proConfig) -// assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181") -// assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s") -// assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper") -// assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo") -// assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000") -// assert.NotNil(t, proConfig.ApplicationConfig) -// -// conConfig := &consumer.ShutdownConfig{Registries: make(map[string]*registry2.RegistryConfig)} -// assert.Nil(t, conConfig.ApplicationConfig) -// setDefaultValue(conConfig) -// assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181") -// assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s") -// assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper") -// assert.NotNil(t, conConfig.ApplicationConfig) -// -//} -//func TestConfigLoaderWithConfigCenter(t *testing.T) { -// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { -// return &config_center.MockDynamicConfigurationFactory{} -// }) -// -// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") -// assert.NoError(t, err) -// proPath, err := filepath.Abs(mockProviderConfigPath) -// assert.NoError(t, err) -// -// assert.Nil(t, consumerConfig) -// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) -// assert.Nil(t, providerConfig) -// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) -// -// err = consumer.ConsumerInit(conPath) -// assert.NoError(t, err) -// err = consumer.configCenterRefreshConsumer() -// assert.NoError(t, err) -// err = provider.ProviderInit(proPath) -// assert.NoError(t, err) -// err = provider.configCenterRefreshProvider() -// assert.NoError(t, err) -// -// assert.NotNil(t, consumerConfig) -// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) -// assert.NotNil(t, providerConfig) -// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) -// -// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) -// assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address) -//} -// -//func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) { -// consumerConfig = nil -// providerConfig = nil -// config.NewEnvInstance() -// extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { -// return &config_center.MockDynamicConfigurationFactory{Content: ` -// dubbo.consumer.request_timeout=5s -// dubbo.consumer.connect_timeout=5s -// dubbo.applicationConfig.organization=ikurento.com -// dubbo.applicationConfig.name=BDTService -// dubbo.applicationConfig.module=dubbogo user-info server -// dubbo.applicationConfig.version=0.0.1 -// dubbo.applicationConfig.owner=ZX -// dubbo.applicationConfig.environment=dev -// dubbo.registry.address=mock://127.0.0.1:2182 -// dubbo.service.com.ikurento.user.UserProvider.protocol=dubbo -// dubbo.service.com.ikurento.user.UserProvider.interface=com.ikurento.user.UserProvider -// dubbo.service.com.ikurento.user.UserProvider.loadbalance=random -// dubbo.service.com.ikurento.user.UserProvider.warmup=100 -// dubbo.service.com.ikurento.user.UserProvider.cluster=failover -// dubbo.protocols.jsonrpc1.name=jsonrpc -// dubbo.protocols.jsonrpc1.ip=127.0.0.1 -// dubbo.protocols.jsonrpc1.port=20001 -//`} -// }) -// -// conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml") -// assert.NoError(t, err) -// proPath, err := filepath.Abs(mockProviderConfigPath) -// assert.NoError(t, err) -// -// assert.Nil(t, consumerConfig) -// assert.Equal(t, consumer.ShutdownConfig{}, GetConsumerConfig()) -// assert.Nil(t, providerConfig) -// assert.Equal(t, provider.ProviderConfig{}, GetProviderConfig()) -// -// err = consumer.ConsumerInit(conPath) -// assert.NoError(t, err) -// checkApplicationName(consumerConfig.ApplicationConfig) -// err = consumer.configCenterRefreshConsumer() -// checkRegistries(consumerConfig.Registries, consumerConfig.Registry) -// assert.NoError(t, err) -// err = provider.ProviderInit(proPath) -// assert.NoError(t, err) -// checkApplicationName(providerConfig.ApplicationConfig) -// err = provider.configCenterRefreshProvider() -// checkRegistries(providerConfig.Registries, providerConfig.Registry) -// assert.NoError(t, err) -// -// assert.NotNil(t, consumerConfig) -// assert.NotEqual(t, consumer.ShutdownConfig{}, GetConsumerConfig()) -// assert.NotNil(t, providerConfig) -// assert.NotEqual(t, provider.ProviderConfig{}, GetProviderConfig()) -// -// assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name) -// assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address) -//} -// -//func TestGetBaseConfig(t *testing.T) { -// bc := GetBaseConfig() -// assert.NotNil(t, bc) -// _, found := bc.GetRemoteConfig("mock") -// assert.False(t, found) -//} -// -//// mockInitProviderWithSingleRegistry will init a mocked providerConfig -//func mockInitProviderWithSingleRegistry() { -// providerConfig = &provider.ProviderConfig{ -// BaseConfig: base.ShutdownConfig{ -// applicationConfig.ShutdownConfig: &applicationConfig.ShutdownConfig{ -// Organization: "dubbo_org", -// Name: "dubbo", -// Module: "module", -// Version: "1.0.0", -// Owner: "dubbo", -// Environment: "test", -// }, -// }, -// -// Registry: ®istry2.RegistryConfig{ -// Address: "mock://127.0.0.1:2181", -// Username: "user1", -// Password: "pwd1", -// }, -// Registries: map[string]*registry2.RegistryConfig{}, -// -// Services: map[string]*service2.ShutdownConfig{ -// "MockService": { -// InterfaceName: "com.MockService", -// Protocol: "mock", -// Cluster: "failover", -// Loadbalance: "random", -// Retries: "3", -// Group: "huadong_idc", -// Version: "1.0.0", -// Methods: []*method.MethodConfig{ -// { -// Name: "GetUser", -// Retries: "2", -// LoadBalance: "random", -// Weight: 200, -// }, -// { -// Name: "GetUser1", -// Retries: "2", -// LoadBalance: "random", -// Weight: 200, -// }, -// }, -// exported: new(atomic.Bool), -// }, -// }, -// Protocols: map[string]*protocol2.ProtocolConfig{ -// "mock": { -// Name: "mock", -// Ip: "127.0.0.1", -// Port: "20000", -// }, -// }, -// } -//} -// -//type mockMetadataService struct { -// exportedServiceURLs *sync.Map -// lock *sync.RWMutex -//} -// -//func (m *mockMetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetMetadataInfo(revision string) (*common.MetadataInfo, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetExportedServiceURLs() []*common.URL { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetMetadataServiceURL() *common.URL { -// panic("implement me") -//} -// -//func (m *mockMetadataService) SetMetadataServiceURL(url *common.URL) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) Reference() string { -// panic("implement me") -//} -// -//func (m *mockMetadataService) ServiceName() (string, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) ExportURL(url *common.URL) (bool, error) { -// return m.addURL(m.exportedServiceURLs, url), nil -//} -// -//func (m *mockMetadataService) UnexportURL(*common.URL) error { -// panic("implement me") -//} -// -//func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) UnsubscribeURL(*common.URL) error { -// panic("implement me") -//} -// -//func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error { -// return nil -//} -// -//func (m *mockMetadataService) MethodMapper() map[string]string { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) Version() (string, error) { -// panic("implement me") -//} -// -//func (m *mockMetadataService) addURL(targetMap *sync.Map, url *common.URL) bool { -// var ( -// urlSet interface{} -// loaded bool -// ) -// logger.Debug(url.ServiceKey()) -// if urlSet, loaded = targetMap.LoadOrStore(url.ServiceKey(), skip.New(uint64(0))); loaded { -// m.lock.RLock() -// wantedUrl := urlSet.(*skip.SkipList).Get(url) -// if len(wantedUrl) > 0 && wantedUrl[0] != nil { -// m.lock.RUnlock() -// return false -// } -// m.lock.RUnlock() -// } -// m.lock.Lock() -// // double chk -// wantedUrl := urlSet.(*skip.SkipList).Get(url) -// if len(wantedUrl) > 0 && wantedUrl[0] != nil { -// m.lock.Unlock() -// return false -// } -// urlSet.(*skip.SkipList).Insert(url) -// m.lock.Unlock() -// return true -//} -// -//func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { -// // using skip list to dedup and sorting -// var res []*common.URL -// services.Range(func(key, value interface{}) bool { -// urls := value.(*skip.SkipList) -// for i := uint64(0); i < urls.Len(); i++ { -// url := urls.ByPosition(i).(*common.URL) -// if url.GetParam(constant.INTERFACE_KEY, url.Path) != constant.METADATA_SERVICE_NAME { -// res = append(res, url) -// } -// } -// return true -// }) -// sort.Sort(common.URLSlice(res)) -// return res -//} -// -//type mockServiceDiscoveryRegistry struct{} -// -//func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) IsAvailable() bool { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) Destroy() { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) Register(*common.URL) error { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) UnRegister(*common.URL) error { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) Subscribe(*common.URL, registry.NotifyListener) error { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) UnSubscribe(*common.URL, registry.NotifyListener) error { -// panic("implement me") -//} -// -//func (mr *mockServiceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscovery { -// return &mockServiceDiscovery{} -//} -// -//type mockServiceDiscovery struct{} -// -//func (m *mockServiceDiscovery) String() string { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) Destroy() error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) Register(registry.ServiceInstance) error { -// return nil -//} -// -//func (m *mockServiceDiscovery) Update(registry.ServiceInstance) error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) Unregister(registry.ServiceInstance) error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetDefaultPageSize() int { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetServices() *gxset.HashSet { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetInstances(string) []registry.ServiceInstance { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetInstancesByPage(string, int, int) gxpage.Pager { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetHealthyInstancesByPage(string, int, int, bool) gxpage.Pager { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) GetRequestInstances([]string, int, int) map[string]gxpage.Pager { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) AddListener(registry.ServiceInstancesChangedListener) error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) DispatchEventByServiceName(string) error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) DispatchEventForInstances(string, []registry.ServiceInstance) error { -// panic("implement me") -//} -// -//func (m *mockServiceDiscovery) DispatchEvent(*registry.ServiceInstancesChangedEvent) error { -// panic("implement me") -//} -// -//func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} { -// if len(urls) == 0 { -// return []interface{}{} -// } -// -// res := make([]interface{}, 0, len(urls)) -// for _, u := range urls { -// res = append(res, u.String()) -// } -// 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/consumer_config.go b/config/consumer_config.go index d80b139e29..c3924cc822 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -42,7 +42,7 @@ type ConsumerConfig struct { // ConnectTimeout will be remove in 3.0 config-enhance ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` // support string - Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries []string `yaml:"registries" json:"registries,omitempty" property:"registries"` RequestTimeout string `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"` ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` @@ -64,9 +64,9 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { if cc == nil { return nil } - cc.Registry = translateRegistryIds(cc.Registry) - if len(cc.Registry) <= 0 { - cc.Registry = rc.getRegistryIds() + cc.Registries = translateRegistryIds(cc.Registries) + if len(cc.Registries) <= 0 { + cc.Registries = rc.getRegistryIds() } for _, reference := range cc.References { if err := reference.Init(rc); err != nil { @@ -135,71 +135,8 @@ func SetConsumerConfig(c ConsumerConfig) { rootConfig.Consumer = &c } -// ConsumerInit loads config file to init consumer config -func ConsumerInit(confConFile string) error { - //if confConFile == "" { - // return perrors.Errorf("applicationConfig configure(consumer) file name is nil") - //} - //consumerConfig = &ShutdownConfig{} - //fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) - //if err != nil { - // return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) - //} - //consumerConfig.fileStream = bytes.NewBuffer(fileStream) - //// set method interfaceId & interfaceName - //for k, v := range consumerConfig.References { - // // set id for reference - // for _, n := range consumerConfig.References[k].Methods { - // n.InterfaceName = v.InterfaceName - // n.InterfaceId = k - // } - //} - //if consumerConfig.Request_Timeout != "" { - // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) - // } - // if consumerConfig.RequestTimeout >= time.Duration(MaxWheelTimeSpan) { - // return perrors.WithMessagef(err, "request_timeout %s should be less than %s", - // consumerConfig.Request_Timeout, time.Duration(MaxWheelTimeSpan)) - // } - //} - //if consumerConfig.Connect_Timeout != "" { - // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) - // } - //} - // - //logger.Debugf("consumer config{%#v}\n", consumerConfig) - - return nil -} - -func configCenterRefreshConsumer() error { - //// fresh it - //var err error - //if consumerConfig.Request_Timeout != "" { - // if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil { - // return perrors.WithMessagef(err, "time.ParseDuration(Request_Timeout{%#v})", consumerConfig.Request_Timeout) - // } - //} - //if consumerConfig.Connect_Timeout != "" { - // if consumerConfig.ConnectTimeout, err = time.ParseDuration(consumerConfig.Connect_Timeout); err != nil { - // return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) - // } - //} - //if consumerConfig.ConfigCenterConfig != nil { - // consumerConfig.SetFatherConfig(consumerConfig) - // if err = consumerConfig.startConfigCenter((*consumerConfig).BaseConfig); err != nil { - // return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) - // } - // consumerConfig.fresh() - //} - return nil -} -func NewEmptyConsumerConfig() *ConsumerConfig { - +func newEmptyConsumerConfig() *ConsumerConfig { newConsumerConfig := &ConsumerConfig{ - //Registries: make(map[string]*RegistryConfig, 8), References: make(map[string]*ReferenceConfig, 8), ConnectTimeout: "3s", RequestTimeout: "3s", @@ -208,77 +145,12 @@ func NewEmptyConsumerConfig() *ConsumerConfig { return newConsumerConfig } -// NewConsumerConfig returns ConsumerConfig with @opts -func NewConsumerConfig(opts ...ConsumerConfigOpt) *ConsumerConfig { - newConfig := NewEmptyConsumerConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -///////////////////////////////////// consumer config api -// ConsumerConfigOpt is the options to init ConsumerConfig -type ConsumerConfigOpt func(config *ConsumerConfig) *ConsumerConfig - -// GetConsumerInstance returns ConsumerConfig with @opts -func GetConsumerInstance(opts ...ConsumerConfigOpt) *ConsumerConfig { - cc := &ConsumerConfig{ - References: make(map[string]*ReferenceConfig, 8), - Check: true, - } - for _, opt := range opts { - opt(cc) - } - return cc -} - -// WithRootConfig returns ConsumerConfigOpt with given @rootConfig -func WithRootConfig(rootConfig *RootConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.rootConfig = rootConfig - return config - } -} - -// WithConsumerReferenceConfig returns ConsumerConfigOpt with -func WithConsumerReferenceConfig(referenceKey string, refConfig *ReferenceConfig) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.References[referenceKey] = refConfig - return config - } -} - -// WithConsumerConnTimeout returns ConsumerConfigOpt with given consumer conn @timeout -func WithConsumerConnTimeout(timeout string) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.ConnectTimeout = timeout - return config - } -} - -// WithConsumerRequestTimeout returns ConsumerConfigOpt with given consumer request @timeout -func WithConsumerRequestTimeout(timeout string) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.RequestTimeout = timeout - return config - } -} - -// WithConsumerConfigCheck returns ConsumerConfigOpt with given @check flag -func WithConsumerConfigCheck(check bool) ConsumerConfigOpt { - return func(config *ConsumerConfig) *ConsumerConfig { - config.Check = check - return config - } -} - type ConsumerConfigBuilder struct { consumerConfig *ConsumerConfig } func NewConsumerConfigBuilder() *ConsumerConfigBuilder { - return &ConsumerConfigBuilder{consumerConfig: &ConsumerConfig{}} + return &ConsumerConfigBuilder{consumerConfig: newEmptyConsumerConfig()} } func (ccb *ConsumerConfigBuilder) SetFilter(filter string) *ConsumerConfigBuilder { @@ -286,8 +158,8 @@ func (ccb *ConsumerConfigBuilder) SetFilter(filter string) *ConsumerConfigBuilde return ccb } -func (ccb *ConsumerConfigBuilder) SetRegistry(registry []string) *ConsumerConfigBuilder { - ccb.consumerConfig.Registry = registry +func (ccb *ConsumerConfigBuilder) SetRegistries(registryKeys ...string) *ConsumerConfigBuilder { + ccb.consumerConfig.Registries = registryKeys return ccb } @@ -306,6 +178,11 @@ func (ccb *ConsumerConfigBuilder) SetCheck(check bool) *ConsumerConfigBuilder { return ccb } +func (ccb *ConsumerConfigBuilder) AddReference(referenceKey string, referenceConfig *ReferenceConfig) *ConsumerConfigBuilder { + ccb.consumerConfig.References[referenceKey] = referenceConfig + return ccb +} + func (ccb *ConsumerConfigBuilder) SetReferences(references map[string]*ReferenceConfig) *ConsumerConfigBuilder { ccb.consumerConfig.References = references return ccb @@ -322,8 +199,5 @@ func (ccb *ConsumerConfigBuilder) SetRootConfig(rootConfig *RootConfig) *Consume } func (ccb *ConsumerConfigBuilder) Build() *ConsumerConfig { - if err := ccb.consumerConfig.Init(ccb.consumerConfig.rootConfig); err != nil { - panic(err) - } return ccb.consumerConfig } diff --git a/config/dubbo_bootstrap.go b/config/dubbo_bootstrap.go index f5ccf922b0..1513d792e8 100644 --- a/config/dubbo_bootstrap.go +++ b/config/dubbo_bootstrap.go @@ -35,26 +35,6 @@ var ( startOnce sync.Once ) -func GetInstance(opts ...RootConfigOpt) *RootConfig { - registerPOJO() - rc := &RootConfig{ - ConfigCenter: GetConfigCenterInstance(), - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReport: &MetadataReportConfig{}, - Application: GetApplicationInstance(), - Registries: make(map[string]*RegistryConfig), - Protocols: GetProtocolsInstance(), - Provider: GetProviderInstance(), - Consumer: GetConsumerInstance(), - Metric: &MetricConfig{}, - Logger: GetLoggerConfigInstance(), - } - for _, opt := range opts { - opt(rc) - } - return rc -} - func registerPOJO() { hessian.RegisterPOJO(&common.MetadataInfo{}) hessian.RegisterPOJO(&common.ServiceInfo{}) @@ -62,7 +42,7 @@ func registerPOJO() { } func (rc *RootConfig) Init() error { - + registerPOJO() if err := rc.Logger.Init(); err != nil { return err } diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go index 825ba7e27f..5be5d82238 100644 --- a/config/graceful_shutdown_test.go +++ b/config/graceful_shutdown_test.go @@ -63,7 +63,7 @@ package config // // // without configuration // config.consumerConfig = nil -// config.providerConfig = nil +// config.referenceConfig = nil // BeforeShutdown() // // config.consumerConfig = &consumer.ShutdownConfig{ @@ -83,7 +83,7 @@ package config // Name: "mock", // } // -// config.providerConfig = &provider.ProviderConfig{ +// config.referenceConfig = &provider.ProviderConfig{ // ShutdownConfig: &ShutdownConfig{ // Timeout: "1", // StepTimeout: "1s", @@ -93,7 +93,7 @@ package config // // test destroy protocol // BeforeShutdown() // -// config.providerConfig = &provider.ProviderConfig{ +// config.referenceConfig = &provider.ProviderConfig{ // ShutdownConfig: &ShutdownConfig{ // Timeout: "1", // StepTimeout: "-1s", diff --git a/config/protocol_config.go b/config/protocol_config.go index 39dcd00e5e..8c4f8ecb84 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -49,48 +49,6 @@ func (p *ProtocolConfig) Init() error { return verify(p) } -func NewDefaultProtocolConfig() *ProtocolConfig { - return &ProtocolConfig{ - Name: constant.DEFAULT_PROTOCOL, - Port: "20000", - Ip: "127.0.0.1", - } -} - -// NewProtocolConfig returns ProtocolConfig with given @opts -func NewProtocolConfig(opts ...ProtocolConfigOpt) *ProtocolConfig { - newConfig := NewDefaultProtocolConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -type ProtocolConfigOpt func(config *ProtocolConfig) *ProtocolConfig - -// WithProtocolIP set ProtocolConfig with given binding @ip -// Deprecated: the param @ip would be used as service listener binding and would be registered to registry center -func WithProtocolIP(ip string) ProtocolConfigOpt { - return func(config *ProtocolConfig) *ProtocolConfig { - config.Ip = ip - return config - } -} - -func WithProtocolName(protcolName string) ProtocolConfigOpt { - return func(config *ProtocolConfig) *ProtocolConfig { - config.Name = protcolName - return config - } -} - -func WithProtocolPort(port string) ProtocolConfigOpt { - return func(config *ProtocolConfig) *ProtocolConfig { - config.Port = port - return config - } -} - func NewProtocolConfigBuilder() *ProtocolConfigBuilder { return &ProtocolConfigBuilder{protocolConfig: &ProtocolConfig{}} } @@ -120,8 +78,5 @@ func (pcb *ProtocolConfigBuilder) SetParams(params interface{}) *ProtocolConfigB } func (pcb *ProtocolConfigBuilder) Build() *ProtocolConfig { - if err := pcb.protocolConfig.Init(); err != nil { - panic(err) - } return pcb.protocolConfig } diff --git a/config/provider_config.go b/config/provider_config.go index 09c286471c..7f805c4d68 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -35,8 +35,8 @@ type ProviderConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // Deprecated Register whether registration is required Register bool `yaml:"register" json:"register" property:"register"` - // Registry registry ids TODO Registries? - Registry []string `yaml:"registry" json:"registry" property:"registry"` + // Registries registry ids TODO Registries? + Registries []string `yaml:"registries" json:"registries" property:"registries"` // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` @@ -63,9 +63,9 @@ func (c *ProviderConfig) Init(rc *RootConfig) error { if c == nil { return nil } - c.Registry = translateRegistryIds(c.Registry) - if len(c.Registry) <= 0 { - c.Registry = rc.getRegistryIds() + c.Registries = translateRegistryIds(c.Registries) + if len(c.Registries) <= 0 { + c.Registries = rc.getRegistryIds() } for _, service := range c.Services { if err := service.Init(rc); err != nil { @@ -94,70 +94,23 @@ func (c *ProviderConfig) Load() { } -// SetProviderConfig sets provider config by @p -func SetProviderConfig(p ProviderConfig) { - rootConfig.Provider = &p -} - -// nolint -type ProviderConfigOpt func(config *ProviderConfig) *ProviderConfig - -// NewEmptyProviderConfig returns ProviderConfig with default ApplicationConfig -func NewEmptyProviderConfig() *ProviderConfig { +// newEmptyProviderConfig returns ProviderConfig with default ApplicationConfig +func newEmptyProviderConfig() *ProviderConfig { newProviderConfig := &ProviderConfig{ - Services: make(map[string]*ServiceConfig), - Registry: make([]string, 8), + Services: make(map[string]*ServiceConfig), + Registries: make([]string, 8), } return newProviderConfig } -// NewProviderConfig returns ProviderConfig with given @opts -func NewProviderConfig(opts ...ProviderConfigOpt) *ProviderConfig { - newConfig := NewEmptyProviderConfig() - for _, v := range opts { - v(newConfig) - } - return newConfig -} - -// GetProviderInstance returns ProviderConfig with given @opts -func GetProviderInstance(opts ...ProviderConfigOpt) *ProviderConfig { - newConfig := &ProviderConfig{ - Services: make(map[string]*ServiceConfig), - Registry: make([]string, 8), - } - for _, opt := range opts { - opt(newConfig) - } - return newConfig -} - -// WithProviderService returns ProviderConfig with given serviceNameKey @serviceName and @serviceConfig -func WithProviderService(serviceName string, serviceConfig *ServiceConfig) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Services[serviceName] = serviceConfig - return config - } -} - -// WithProviderRegistryKeys returns ProviderConfigOpt with given @registryKey and registry @registryConfig -func WithProviderRegistryKeys(registryKey ...string) ProviderConfigOpt { - return func(config *ProviderConfig) *ProviderConfig { - config.Registry = append(config.Registry, registryKey...) - return config - } -} - type ProviderConfigBuilder struct { providerConfig *ProviderConfig } -// nolint func NewProviderConfigBuilder() *ProviderConfigBuilder { - return &ProviderConfigBuilder{providerConfig: &ProviderConfig{}} + return &ProviderConfigBuilder{providerConfig: newEmptyProviderConfig()} } -// nolint func (pcb *ProviderConfigBuilder) SetFilter(filter string) *ProviderConfigBuilder { pcb.providerConfig.Filter = filter return pcb @@ -170,8 +123,8 @@ func (pcb *ProviderConfigBuilder) SetRegister(register bool) *ProviderConfigBuil } // nolint -func (pcb *ProviderConfigBuilder) SetRegistry(registry []string) *ProviderConfigBuilder { - pcb.providerConfig.Registry = registry +func (pcb *ProviderConfigBuilder) SetRegistries(registryKeys ...string) *ProviderConfigBuilder { + pcb.providerConfig.Registries = registryKeys return pcb } @@ -225,8 +178,5 @@ func (pcb *ProviderConfigBuilder) SetRootConfig(rootConfig *RootConfig) *Provide // nolint func (pcb *ProviderConfigBuilder) Build() *ProviderConfig { - if err := pcb.providerConfig.Init(pcb.providerConfig.rootConfig); err != nil { - panic(err) - } return pcb.providerConfig } diff --git a/config/provider_config_test.go b/config/provider_config_test.go index 27b3c6695c..712c816dfa 100644 --- a/config/provider_config_test.go +++ b/config/provider_config_test.go @@ -29,8 +29,8 @@ func TestProviderConfigEmptyRegistry(t *testing.T) { err := Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) assert.Nil(t, err) provider := rootConfig.Provider - assert.Equal(t, 1, len(provider.Registry)) - assert.Equal(t, "nacos", provider.Registry[0]) + assert.Equal(t, 1, len(provider.Registries)) + assert.Equal(t, "nacos", provider.Registries[0]) } func TestProviderConfigRootRegistry(t *testing.T) { @@ -40,8 +40,8 @@ func TestProviderConfigRootRegistry(t *testing.T) { assert.NotNil(t, provider) assert.Equal(t, 2, len(provider.Services)) - assert.Equal(t, 2, len(provider.Services["HelloService"].Registry)) - assert.Equal(t, 1, len(provider.Services["OrderService"].Registry)) + assert.Equal(t, 2, len(provider.Services["HelloService"].Registries)) + assert.Equal(t, 1, len(provider.Services["OrderService"].Registries)) } // @@ -56,5 +56,5 @@ func TestProviderConfigRootRegistry(t *testing.T) { // conPath, err := filepath.Abs("./testdata/provider_config_withoutProtocol.yml") // assert.NoError(t, err) // assert.NoError(t, ProviderInit(conPath)) -// assert.Equal(t, "dubbo", config.providerConfig.Services["UserProvider"].Protocol) +// assert.Equal(t, "dubbo", config.referenceConfig.Services["UserProvider"].Protocol) //} diff --git a/config/reference_config.go b/config/reference_config.go index 986a39076e..f70c25bc1e 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -50,7 +50,7 @@ type ReferenceConfig struct { URL string `yaml:"url" json:"url,omitempty" property:"url"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries []string `yaml:"registries" json:"registries,omitempty" property:"registries"` Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` @@ -90,9 +90,9 @@ func (rc *ReferenceConfig) Init(root *RootConfig) error { if root.Application != nil { rc.metaDataType = root.Application.MetadataType } - rc.Registry = translateRegistryIds(rc.Registry) - if len(rc.Registry) <= 0 { - rc.Registry = root.Consumer.Registry + rc.Registries = translateRegistryIds(rc.Registries) + if len(rc.Registries) <= 0 { + rc.Registries = root.Consumer.Registries } return verify(rc) } @@ -133,7 +133,7 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { } } else { // 2. assemble SubURL from register center's configuration mode - rc.urls = loadRegistries(rc.Registry, rc.rootConfig.Registries, common.CONSUMER) + rc.urls = loadRegistries(rc.Registries, rc.rootConfig.Registries, common.CONSUMER) // set url to regURLs for _, regURL := range rc.urls { @@ -323,71 +323,37 @@ func (rc *ReferenceConfig) postProcessConfig(url *common.URL) { //////////////////////////////////// reference config api -// ReferenceConfigOpt is consumer's reference config -type ReferenceConfigOpt func(config *ReferenceConfig) *ReferenceConfig - -// NewReferenceConfig The only way to get a new ReferenceConfig -func NewReferenceConfigWithID(id string) *ReferenceConfig { - return &ReferenceConfig{id: id} -} - -// NewEmptyReferenceConfig returns empty ReferenceConfig -func NewEmptyReferenceConfig() *ReferenceConfig { - newReferenceConfig := NewReferenceConfigWithID("") +// newEmptyReferenceConfig returns empty ReferenceConfig +func newEmptyReferenceConfig() *ReferenceConfig { + newReferenceConfig := &ReferenceConfig{} newReferenceConfig.Methods = make([]*MethodConfig, 0, 8) newReferenceConfig.Params = make(map[string]string, 8) return newReferenceConfig } -// NewReferenceConfig returns ReferenceConfig with given @opts -func NewReferenceConfig(opts ...ReferenceConfigOpt) *ReferenceConfig { - newReferenceConfig := NewEmptyReferenceConfig() - for _, v := range opts { - v(newReferenceConfig) - } - return newReferenceConfig +type ReferenceConfigBuilder struct { + referenceConfig *ReferenceConfig } -// WithReferenceRegistry returns ReferenceConfigOpt with given registryKey: @registry -func WithReferenceRegistry(registryKeys ...string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Registry = registryKeys - return config - } +func NewReferenceConfigBuilder() *ReferenceConfigBuilder { + return &ReferenceConfigBuilder{referenceConfig: newEmptyReferenceConfig()} } -// WithReferenceProtocolName returns ReferenceConfigOpt with given protocolName: @protocol -func WithReferenceProtocolName(protocol string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Protocol = protocol - return config - } +func (pcb *ReferenceConfigBuilder) SetInterface(interfaceName string) *ReferenceConfigBuilder { + pcb.referenceConfig.InterfaceName = interfaceName + return pcb } -// WithReferenceInterface returns ReferenceConfigOpt with given @interfaceName -func WithReferenceInterface(interfaceName string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.InterfaceName = interfaceName - return config - } +func (pcb *ReferenceConfigBuilder) SetRegistries(registryKeys ...string) *ReferenceConfigBuilder { + pcb.referenceConfig.Registries = registryKeys + return pcb } -// WithReferenceCluster returns ReferenceConfigOpt with given cluster name: @cluster -func WithReferenceCluster(cluster string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Cluster = cluster - return config - } +func (pcb *ReferenceConfigBuilder) SetProtocol(protocolName string) *ReferenceConfigBuilder { + pcb.referenceConfig.Protocol = protocolName + return pcb } -// WithReferenceMethod returns ReferenceConfigOpt with given @method, @retries, and load balance: @lb -func WithReferenceMethod(methodName, retries, lb string) ReferenceConfigOpt { - return func(config *ReferenceConfig) *ReferenceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: methodName, - Retries: retries, - LoadBalance: lb, - }) - return config - } +func (pcb *ReferenceConfigBuilder) Build() *ReferenceConfig { + return pcb.referenceConfig } diff --git a/config/root_config.go b/config/root_config.go index e5a39bb81c..86e5ed0f16 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -83,110 +83,28 @@ func GetRootConfig() *RootConfig { func GetProviderConfig() *ProviderConfig { if err := check(); err != nil { - return GetProviderInstance() + return NewProviderConfigBuilder().Build() } if rootConfig.Provider != nil { return rootConfig.Provider } - return GetProviderInstance() + return NewProviderConfigBuilder().Build() } func GetConsumerConfig() *ConsumerConfig { if err := check(); err != nil { - return GetConsumerInstance() + return NewConsumerConfigBuilder().Build() } if rootConfig.Consumer != nil { return rootConfig.Consumer } - return GetConsumerInstance() + return NewConsumerConfigBuilder().Build() } func GetApplicationConfig() *ApplicationConfig { return rootConfig.Application } -// GetConfigCenterConfig get config center config -//func GetConfigCenterConfig() (*CenterConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// conf := rootConfig.ConfigCenter -// if conf == nil { -// return nil, errors.New("config center config is null") -// } -// if err := defaults.Set(conf); err != nil { -// return nil, err -// } -// conf.translateConfigAddress() -// if err := verify(conf); err != nil { -// return nil, err -// } -// return conf, nil -//} - -// GetRegistriesConfig get registry config default zookeeper registry -//func GetRegistriesConfig() (map[string]*RegistryConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// -// if registriesConfig != nil { -// return registriesConfig, nil -// } -// registriesConfig = initRegistriesConfig(rootConfig.Registries) -// for _, reg := range registriesConfig { -// if err := defaults.Set(reg); err != nil { -// return nil, err -// } -// reg.translateRegistryAddress() -// if err := verify(reg); err != nil { -// return nil, err -// } -// } -// -// return registriesConfig, nil -//} - -// GetProtocolsConfig get protocols config default dubbo protocol -//func GetProtocolsConfig() (map[string]*ProtocolConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// -// protocols := getProtocolsConfig(rootConfig.Protocols) -// for _, protocol := range protocols { -// if err := defaults.Set(protocol); err != nil { -// return nil, err -// } -// if err := verify(protocol); err != nil { -// return nil, err -// } -// } -// return protocols, nil -//} - -// GetProviderConfig get provider config -//func GetProviderConfig() (*ProviderConfig, error) { -// if err := check(); err != nil { -// return nil, err -// } -// -// if providerConfig != nil { -// return providerConfig, nil -// } -// provider := getProviderConfig(rootConfig.Provider) -// if err := defaults.Set(provider); err != nil { -// return nil, err -// } -// if err := verify(provider); err != nil { -// return nil, err -// } -// -// provider.Services = getRegistryServices(common.PROVIDER, provider.Services, provider.Registry) -// providerConfig = provider -// return provider, nil -//} - // getRegistryIds get registry ids func (rc *RootConfig) getRegistryIds() []string { ids := make([]string, 0) @@ -196,92 +114,24 @@ func (rc *RootConfig) getRegistryIds() []string { return removeDuplicateElement(ids) } -// NewRootConfig get root config -func NewRootConfig(opts ...RootConfigOpt) *RootConfig { +// newEmptyRootConfig get empty root config +func newEmptyRootConfig() *RootConfig { newRootConfig := &RootConfig{ - ConfigCenter: &CenterConfig{}, + ConfigCenter: NewConfigCenterConfigBuilder().Build(), ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReport: &MetadataReportConfig{}, - Application: &ApplicationConfig{}, + MetadataReport: NewMetadataReportConfigBuilder().Build(), + Application: NewApplicationConfigBuilder().Build(), Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig), - Provider: GetProviderInstance(), - Consumer: GetConsumerInstance(), - Metric: &MetricConfig{}, - } - for _, o := range opts { - o(newRootConfig) + Provider: NewProviderConfigBuilder().Build(), + Consumer: NewConsumerConfigBuilder().Build(), + Metric: NewMetricConfigBuilder().Build(), } return newRootConfig } -type RootConfigOpt func(config *RootConfig) - -// WithMetricsConfig set root config with given @metricsConfig -func WithMetricsConfig(metricsConfig *MetricConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Metric = metricsConfig - } -} - -// WithRootConsumerConfig set root config with given @consumerConfig -func WithRootConsumerConfig(consumerConfig *ConsumerConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Consumer = consumerConfig - } -} - -// WithRootProviderConfig set root config with given @providerConfig -func WithRootProviderConfig(providerConfig *ProviderConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Provider = providerConfig - } -} - -// WithRootProtocolConfig set root config with key @protocolName and given @protocolConfig -func WithRootProtocolConfig(protocolName string, protocolConfig *ProtocolConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Protocols[protocolName] = protocolConfig - } -} - -// WithRootRegistryConfig set root config with key @registryKey and given @regConfig -func WithRootRegistryConfig(registryKey string, regConfig *RegistryConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Registries[registryKey] = regConfig - } -} - -// WithRootApplicationConfig set root config with given @appConfig -func WithRootApplicationConfig(appConfig *ApplicationConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.Application = appConfig - } -} - -// WithRootMetadataReportConfig set root config with given @metadataReportConfig -func WithRootMetadataReportConfig(metadataReportConfig *MetadataReportConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.MetadataReport = metadataReportConfig - } -} - -// WithRootServiceDiscoverConfig set root config with given @serviceDiscConfig and key @name -func WithRootServiceDiscoverConfig(name string, serviceDiscConfig *ServiceDiscoveryConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.ServiceDiscoveries[name] = serviceDiscConfig - } -} - -// WithRootCenterConfig set root config with given centerConfig -func WithRootCenterConfig(centerConfig *CenterConfig) RootConfigOpt { - return func(rc *RootConfig) { - rc.ConfigCenter = centerConfig - } -} - func NewRootConfigBuilder() *RootConfigBuilder { - return &RootConfigBuilder{rootConfig: &RootConfig{}} + return &RootConfigBuilder{rootConfig: newEmptyRootConfig()} } type RootConfigBuilder struct { @@ -293,6 +143,16 @@ func (rb *RootConfigBuilder) SetApplication(application *ApplicationConfig) *Roo return rb } +func (rb *RootConfigBuilder) AddProtocol(protocolKey string, protocolConfig *ProtocolConfig) *RootConfigBuilder { + rb.rootConfig.Protocols[protocolKey] = protocolConfig + return rb +} + +func (rb *RootConfigBuilder) AddRegistry(registryKey string, registryConfig *RegistryConfig) *RootConfigBuilder { + rb.rootConfig.Registries[registryKey] = registryConfig + return rb +} + func (rb *RootConfigBuilder) SetProtocols(protocols map[string]*ProtocolConfig) *RootConfigBuilder { rb.rootConfig.Protocols = protocols return rb @@ -358,9 +218,11 @@ func (rb *RootConfigBuilder) SetCacheFile(cacheFile string) *RootConfigBuilder { return rb } +func (rb *RootConfigBuilder) SetConfigCenter(configCenterConfig *CenterConfig) *RootConfigBuilder { + rb.rootConfig.ConfigCenter = configCenterConfig + return rb +} + func (rb *RootConfigBuilder) Build() *RootConfig { - if err := rb.rootConfig.Init(); err != nil { - panic(err) - } return rb.rootConfig } diff --git a/config/service_config.go b/config/service_config.go index 3bb16693c7..32724dd84a 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -50,9 +50,9 @@ import ( type ServiceConfig struct { id string Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocol []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + Protocols []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' Interface string `validate:"required" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registry []string `yaml:"registry" json:"registry,omitempty" property:"registry"` + Registries []string `yaml:"registries" json:"registry,omitempty" property:"registry"` Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Group string `yaml:"group" json:"group,omitempty" property:"group"` @@ -76,8 +76,8 @@ type ServiceConfig struct { Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - Protocols map[string]*ProtocolConfig - Registries map[string]*RegistryConfig + RCProtocols map[string]*ProtocolConfig + RCRegistries map[string]*RegistryConfig ProxyFactoryKey string unexported *atomic.Bool exported *atomic.Bool @@ -106,14 +106,14 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { svc.exported = atomic.NewBool(false) svc.metadataType = rc.Application.MetadataType svc.unexported = atomic.NewBool(false) - svc.Registries = rc.Registries - svc.Protocols = rc.Protocols + svc.RCRegistries = rc.Registries + svc.RCProtocols = rc.Protocols if rc.Provider != nil { svc.ProxyFactoryKey = rc.Provider.ProxyFactory } - svc.Registry = translateRegistryIds(svc.Registry) - if len(svc.Registry) <= 0 { - svc.Registry = rc.Provider.Registry + svc.Registries = translateRegistryIds(svc.Registries) + if len(svc.Registries) <= 0 { + svc.Registries = rc.Provider.Registries } svc.export = true return verify(svc) @@ -160,11 +160,11 @@ func (svc *ServiceConfig) Export() error { return nil } - regUrls := loadRegistries(svc.Registry, svc.Registries, common.PROVIDER) + regUrls := loadRegistries(svc.Registries, svc.RCRegistries, common.PROVIDER) urlMap := svc.getUrlMap() - protocolConfigs := loadProtocol(svc.Protocol, svc.Protocols) + protocolConfigs := loadProtocol(svc.Protocols, svc.RCProtocols) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs, Please check your configuration center and transfer protocol ", svc.Interface, svc.Protocol) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs, Please check your configuration center and transfer protocol ", svc.Interface, svc.Protocols) return nil } @@ -423,145 +423,97 @@ func (svc *ServiceConfig) postProcessConfig(url *common.URL) { } } -// ServiceConfigOpt is the option to init ServiceConfig -type ServiceConfigOpt func(config *ServiceConfig) *ServiceConfig - -// NewDefaultServiceConfig returns default ServiceConfig -func NewDefaultServiceConfig() *ServiceConfig { +// newEmptyServiceConfig returns default ServiceConfig +func newEmptyServiceConfig() *ServiceConfig { newServiceConfig := &ServiceConfig{ - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, - Protocols: make(map[string]*ProtocolConfig), - Registries: make(map[string]*RegistryConfig), + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + RCProtocols: make(map[string]*ProtocolConfig), + RCRegistries: make(map[string]*RegistryConfig), } newServiceConfig.Params = make(map[string]string) newServiceConfig.Methods = make([]*MethodConfig, 0, 8) return newServiceConfig } -// NewServiceConfig returns ServiceConfig with given @opts -func NewServiceConfig(opts ...ServiceConfigOpt) *ServiceConfig { - defaultServiceConfig := NewDefaultServiceConfig() - for _, v := range opts { - v(defaultServiceConfig) - } - return defaultServiceConfig +type ServiceConfigBuilder struct { + serviceConfig *ServiceConfig } -// WithServiceRegistry returns ServiceConfigOpt with given registryKey @registry -func WithServiceRegistry(registry string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Registry = append(config.Registry, registry) - return config - } +func NewServiceConfigBuilder() *ServiceConfigBuilder { + return &ServiceConfigBuilder{serviceConfig: newEmptyServiceConfig()} } -// WithServiceProtocolKeys returns ServiceConfigOpt with given protocolKey @protocol -func WithServiceProtocolKeys(protocolKeys ...string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Protocol = protocolKeys - return config - } +func (pcb *ServiceConfigBuilder) SetRegistries(registries ...string) *ServiceConfigBuilder { + pcb.serviceConfig.Registries = registries + return pcb } -// WithServiceInterface returns ServiceConfigOpt with given @interfaceName -func WithServiceInterface(interfaceName string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Interface = interfaceName - return config - } +func (pcb *ServiceConfigBuilder) SetProtocols(protocols ...string) *ServiceConfigBuilder { + pcb.serviceConfig.Protocols = protocols + return pcb } -// WithServiceMetadataType returns ServiceConfigOpt with given @metadataType -func WithServiceMetadataType(metadataType string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.metadataType = metadataType - return config - } +func (pcb *ServiceConfigBuilder) SetInterface(interfaceName string) *ServiceConfigBuilder { + pcb.serviceConfig.Interface = interfaceName + return pcb } -// WithServiceLoadBalance returns ServiceConfigOpt with given load balance @lb -func WithServiceLoadBalance(lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Loadbalance = lb - return config - } +func (pcb *ServiceConfigBuilder) SetMetadataType(setMetadataType string) *ServiceConfigBuilder { + pcb.serviceConfig.metadataType = setMetadataType + return pcb } -// WithServiceWarmUpTime returns ServiceConfigOpt with given @warmUp time -func WithServiceWarmUpTime(warmUp string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Warmup = warmUp - return config - } +func (pcb *ServiceConfigBuilder) SetLoadBalancce(lb string) *ServiceConfigBuilder { + pcb.serviceConfig.Loadbalance = lb + return pcb } -// WithServiceCluster returns ServiceConfigOpt with given cluster name @cluster -func WithServiceCluster(cluster string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Cluster = cluster - return config - } +func (pcb *ServiceConfigBuilder) SetWarmUpTie(warmUp string) *ServiceConfigBuilder { + pcb.serviceConfig.Warmup = warmUp + return pcb } -// WithServiceMethod returns ServiceConfigOpt with given @name, @retries and load balance @lb -func WithServiceMethod(name, retries, lb string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Methods = append(config.Methods, &MethodConfig{ - Name: name, - Retries: retries, - LoadBalance: lb, - }) - return config - } +func (pcb *ServiceConfigBuilder) SetCluster(cluster string) *ServiceConfigBuilder { + pcb.serviceConfig.Cluster = cluster + return pcb } -func WithServiceProtocol(protocolName string, protocolConfig *ProtocolConfig) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Protocols[protocolName] = protocolConfig - return config - } +func (pcb *ServiceConfigBuilder) AddRCProtocol(protocolName string, protocolConfig *ProtocolConfig) *ServiceConfigBuilder { + pcb.serviceConfig.RCProtocols[protocolName] = protocolConfig + return pcb } -func WithServiceRegistries(registryName string, registryConfig *RegistryConfig) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Registries[registryName] = registryConfig - return config - } +func (pcb *ServiceConfigBuilder) AddRCRegistry(registryName string, registryConfig *RegistryConfig) *ServiceConfigBuilder { + pcb.serviceConfig.RCRegistries[registryName] = registryConfig + return pcb } -func WithServiceGroup(group string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Group = group - return config - } +func (pcb *ServiceConfigBuilder) SetGroup(group string) *ServiceConfigBuilder { + pcb.serviceConfig.Group = group + return pcb +} +func (pcb *ServiceConfigBuilder) SetVersion(version string) *ServiceConfigBuilder { + pcb.serviceConfig.Version = version + return pcb } -func WithServiceVersion(version string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.Version = version - return config - } +func (pcb *ServiceConfigBuilder) SetProxyFactoryKey(proxyFactoryKey string) *ServiceConfigBuilder { + pcb.serviceConfig.ProxyFactoryKey = proxyFactoryKey + return pcb } -func WithProxyFactoryKey(proxyFactoryKey string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.ProxyFactoryKey = proxyFactoryKey - return config - } +func (pcb *ServiceConfigBuilder) SetRPCService(service common.RPCService) *ServiceConfigBuilder { + pcb.serviceConfig.rpcService = service + return pcb } -func WithRPCService(service common.RPCService) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.rpcService = service - return config - } +func (pcb *ServiceConfigBuilder) SetServiceID(id string) *ServiceConfigBuilder { + pcb.serviceConfig.id = id + return pcb } -func WithServiceID(id string) ServiceConfigOpt { - return func(config *ServiceConfig) *ServiceConfig { - config.id = id - return config - } +func (pcb *ServiceConfigBuilder) Build() *ServiceConfig { + return pcb.serviceConfig } diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index feee9480e4..dbe032cb81 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -61,21 +61,20 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { version, _ := exporter.metadataService.Version() exporter.lock.Lock() defer exporter.lock.Unlock() - exporter.ServiceConfig = config.NewServiceConfig( - config.WithServiceID(constant.SIMPLE_METADATA_SERVICE_NAME), - config.WithServiceProtocolKeys(constant.DEFAULT_PROTOCOL), - config.WithServiceProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfig( - config.WithProtocolName(constant.DEFAULT_PROTOCOL), - config.WithProtocolPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)), - )), - config.WithServiceRegistry("N/A"), - config.WithServiceInterface(constant.METADATA_SERVICE_NAME), - config.WithServiceGroup(config.GetApplicationConfig().Name), - config.WithServiceVersion(version), - config.WithProxyFactoryKey(constant.DEFAULT_Key), - config.WithServiceInterface(constant.METADATA_SERVICE_NAME), - config.WithServiceMetadataType(constant.REMOTE_METADATA_STORAGE_TYPE), - ) + exporter.ServiceConfig = config.NewServiceConfigBuilder(). + SetServiceID(constant.SIMPLE_METADATA_SERVICE_NAME). + SetProtocols(constant.DEFAULT_PROTOCOL). + AddRCProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfigBuilder(). + SetName(constant.DEFAULT_PROTOCOL). + SetPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)). + Build()). + SetRegistries("N/A"). + SetInterface(constant.METADATA_SERVICE_NAME). + SetGroup(config.GetApplicationConfig().Name). + SetVersion(version). + SetProxyFactoryKey(constant.DEFAULT_Key). + SetMetadataType(constant.REMOTE_METADATA_STORAGE_TYPE). + Build() exporter.ServiceConfig.Implement(exporter.metadataService) err := exporter.ServiceConfig.Export() diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 1fe775d9a5..7afaef61c2 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -78,8 +78,7 @@ func TestConfigurableExporter(t *testing.T) { // mockInitProviderWithSingleRegistry will init a mocked providerConfig func mockInitProviderWithSingleRegistry() { - providerConfig := config.GetProviderInstance( - config.WithProviderService("MockService", config.NewServiceConfig())) + providerConfig := config.NewProviderConfigBuilder().AddService("MockService", config.NewServiceConfigBuilder().Build()).Build() providerConfig.Services["MockService"].InitExported() config.SetRootConfig(config.RootConfig{ Application: &config.ApplicationConfig{ @@ -109,7 +108,7 @@ func mockInitProviderWithSingleRegistry() { Services: map[string]*config.ServiceConfig{ "MockService": { Interface: "com.MockService", - Protocol: []string{"mock"}, + Protocols: []string{"mock"}, Cluster: "failover", Loadbalance: "random", Retries: "3", diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 96ec3093ae..295d018e76 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -218,6 +218,7 @@ func newPrometheusReporter() metrics.Reporter { prom.DefaultRegisterer.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec, reporterInstance.consumerHistogramVec, reporterInstance.providerHistogramVec) + // todo open prometheus metrics service //metricsExporter, err := ocprom.NewExporter(ocprom.Options{ // Registry: prom.DefaultRegisterer.(*prom.Registry), //}) diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 5ba17651b3..1414740921 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -43,24 +43,19 @@ func (s *Server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, e // InitDubboServer creates global gRPC server. func InitDubboServer() { - serviceConfig := config.NewServiceConfig( - config.WithServiceInterface("org.apache.dubbo.DubboGreeterImpl"), - config.WithServiceProtocolKeys("tripleKey"), - ) + serviceConfig := config.NewServiceConfigBuilder(). + SetInterface("org.apache.dubbo.DubboGreeterImpl"). + SetProtocols("tripleKey").Build() - providerConfig := config.GetProviderInstance( - config.WithProviderService(common.GetReference(&Server{}), serviceConfig), - ) + providerConfig := config.NewProviderConfigBuilder().SetServices(map[string]*config.ServiceConfig{ + common.GetReference(&Server{}): serviceConfig, + }).Build() - protocolConfig := config.NewProtocolConfig( - config.WithProtocolName("tri"), - config.WithProtocolPort("20003"), - ) + protocolConfig := config.NewProtocolConfigBuilder().SetName("tri").SetPort("20003").Build() - rootConfig := config.GetInstance( - config.WithRootProviderConfig(providerConfig), - config.WithRootProtocolConfig("tripleKey", protocolConfig), - ) + rootConfig := config.NewRootConfigBuilder().SetProvider(providerConfig).SetProtocols(map[string]*config.ProtocolConfig{ + "tripleKey": protocolConfig, + }).Build() config.SetProviderService(&Server{}) rootConfig.Init() diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index d2d59a512d..9a01d8ba58 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -47,8 +47,8 @@ func doInitProvider() { Services: map[string]*config.ServiceConfig{ "GrpcGreeterImpl": { Interface: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", - Protocol: []string{"grpc"}, - Registry: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, + Protocols: []string{"grpc"}, + Registries: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, Cluster: "failover", Loadbalance: "random", Retries: "3", diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 37280c77b6..1d02e5b273 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -260,7 +260,7 @@ func registerServiceMap(invoker protocol.Invoker) error { _, err := common.ServiceMap.Register(serviceConfig.Interface, // FIXME - serviceConfig.Protocol[0], serviceConfig.Group, + serviceConfig.Protocols[0], serviceConfig.Group, serviceConfig.Version, rpcService) if err != nil { s := "reExport can not re register ServiceMap. Error message is " + err.Error() From f2948997d328028480dbb9fbfc4420fa8fed59a4 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 2 Oct 2021 15:55:40 +0800 Subject: [PATCH 134/148] fix: pass ut --- config/dubbo_bootstrap.go | 117 ------------------ config/logger_config.go | 9 -- config/root_config.go | 92 ++++++++++++++ config/testdata/application.yaml | 4 +- config/testdata/config/app/application.yaml | 2 +- .../testdata/config/provider/application.yaml | 4 +- .../config/provider/registry_application.yaml | 4 +- config/testdata/consumer_config.yml | 2 +- .../consumer_config_with_configcenter.yml | 2 +- .../consumer_config_withoutProtocol.yml | 2 +- config/testdata/provider_config.yml | 2 +- .../provider_config_withoutProtocol.yml | 2 +- .../exporter/configurable/exporter_test.go | 2 +- 13 files changed, 105 insertions(+), 139 deletions(-) delete mode 100644 config/dubbo_bootstrap.go diff --git a/config/dubbo_bootstrap.go b/config/dubbo_bootstrap.go deleted file mode 100644 index 1513d792e8..0000000000 --- a/config/dubbo_bootstrap.go +++ /dev/null @@ -1,117 +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 config - -import ( - "sync" -) - -import ( - hessian "github.com/apache/dubbo-go-hessian2" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/logger" -) - -var ( - startOnce sync.Once -) - -func registerPOJO() { - hessian.RegisterPOJO(&common.MetadataInfo{}) - hessian.RegisterPOJO(&common.ServiceInfo{}) - hessian.RegisterPOJO(&common.URL{}) -} - -func (rc *RootConfig) Init() error { - registerPOJO() - if err := rc.Logger.Init(); err != nil { - return err - } - if err := rc.ConfigCenter.Init(rc); err != nil { - logger.Warnf("config center doesn't start. error is %s", err) - } - if err := rc.Application.Init(); err != nil { - return err - } - - // init protocol - protocols := rc.Protocols - if len(protocols) <= 0 { - protocol := &ProtocolConfig{} - protocols = make(map[string]*ProtocolConfig, 1) - protocols[constant.DUBBO] = protocol - rc.Protocols = protocols - } - for _, protocol := range protocols { - if err := protocol.Init(); err != nil { - return err - } - } - - // init registry - registries := rc.Registries - if registries != nil { - for _, reg := range registries { - if err := reg.Init(); err != nil { - return err - } - } - } - - // init serviceDiscoveries - serviceDiscoveries := rc.ServiceDiscoveries - if serviceDiscoveries != nil { - for _, sd := range serviceDiscoveries { - if err := sd.Init(); err != nil { - return err - } - } - } - - if err := rc.MetadataReport.Init(rc); err != nil { - return err - } - if err := rc.Metric.Init(); err != nil { - return err - } - if err := initRouterConfig(rc); err != nil { - return err - } - // provider、consumer must last init - if err := rc.Provider.Init(rc); err != nil { - return err - } - if err := rc.Consumer.Init(rc); err != nil { - return err - } - - rc.Start() - return nil -} - -func (rc *RootConfig) Start() { - startOnce.Do(func() { - rc.Provider.Load() - rc.Consumer.Load() - registerServiceInstance() - }) -} diff --git a/config/logger_config.go b/config/logger_config.go index 0e7ec435ad..444bc38d01 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -72,16 +72,7 @@ func (LoggerConfig) Prefix() string { return constant.LoggerConfigPrefix } -func GetLoggerConfigInstance() *LoggerConfig { - lc := &LoggerConfig{} - return lc -} - func (lc *LoggerConfig) Init() error { - - if lc == nil { - lc = GetLoggerConfigInstance() - } err := lc.check() if err != nil { return err diff --git a/config/root_config.go b/config/root_config.go index 86e5ed0f16..c7f820566c 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -19,10 +19,21 @@ package config import ( _ "net/http/pprof" + "sync" ) import ( + hessian "github.com/apache/dubbo-go-hessian2" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/logger" +) + +var ( + startOnce sync.Once ) // RootConfig is the root config @@ -113,6 +124,86 @@ func (rc *RootConfig) getRegistryIds() []string { } return removeDuplicateElement(ids) } +func registerPOJO() { + hessian.RegisterPOJO(&common.MetadataInfo{}) + hessian.RegisterPOJO(&common.ServiceInfo{}) + hessian.RegisterPOJO(&common.URL{}) +} + +func (rc *RootConfig) Init() error { + registerPOJO() + if err := rc.Logger.Init(); err != nil { + return err + } + if err := rc.ConfigCenter.Init(rc); err != nil { + logger.Warnf("config center doesn't start. error is %s", err) + } + if err := rc.Application.Init(); err != nil { + return err + } + + // init protocol + protocols := rc.Protocols + if len(protocols) <= 0 { + protocol := &ProtocolConfig{} + protocols = make(map[string]*ProtocolConfig, 1) + protocols[constant.DUBBO] = protocol + rc.Protocols = protocols + } + for _, protocol := range protocols { + if err := protocol.Init(); err != nil { + return err + } + } + + // init registry + registries := rc.Registries + if registries != nil { + for _, reg := range registries { + if err := reg.Init(); err != nil { + return err + } + } + } + + // init serviceDiscoveries + serviceDiscoveries := rc.ServiceDiscoveries + if serviceDiscoveries != nil { + for _, sd := range serviceDiscoveries { + if err := sd.Init(); err != nil { + return err + } + } + } + + if err := rc.MetadataReport.Init(rc); err != nil { + return err + } + if err := rc.Metric.Init(); err != nil { + return err + } + if err := initRouterConfig(rc); err != nil { + return err + } + // provider、consumer must last init + if err := rc.Provider.Init(rc); err != nil { + return err + } + if err := rc.Consumer.Init(rc); err != nil { + return err + } + + rc.Start() + return nil +} + +func (rc *RootConfig) Start() { + startOnce.Do(func() { + rc.Provider.Load() + rc.Consumer.Load() + registerServiceInstance() + }) +} // newEmptyRootConfig get empty root config func newEmptyRootConfig() *RootConfig { @@ -126,6 +217,7 @@ func newEmptyRootConfig() *RootConfig { Provider: NewProviderConfigBuilder().Build(), Consumer: NewConsumerConfigBuilder().Build(), Metric: NewMetricConfigBuilder().Build(), + Logger: NewLoggerConfigBuilder().Build(), } return newRootConfig } diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index f0876a125d..2325e87313 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -26,10 +26,10 @@ dubbo: services: helloService: interface: org.dubbo.service.HelloService - registry: nacos,zk + registries: nacos,zk orderService: interface: org.dubbo.service.OrderService - registry: nacos + registries: nacos provider: register: true services: \ No newline at end of file diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml index 4cd30cc61e..418201f83d 100644 --- a/config/testdata/config/app/application.yaml +++ b/config/testdata/config/app/application.yaml @@ -14,7 +14,7 @@ dubbo: interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java provider: register: true - registry: nacos + registries: nacos services: helloService: protocol: dubbo diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml index 8816257a05..92f1de767a 100644 --- a/config/testdata/config/provider/application.yaml +++ b/config/testdata/config/provider/application.yaml @@ -6,12 +6,12 @@ dubbo: address: nacos://127.0.0.1:8848 provider: register: true - registry: + registries: - nacos - zk services: helloService: interface: org.dubbo.service.HelloService - registry: nacos,zk + registries: nacos,zk orderService: interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/provider/registry_application.yaml b/config/testdata/config/provider/registry_application.yaml index dd08a0d4fd..b00b854bd0 100644 --- a/config/testdata/config/provider/registry_application.yaml +++ b/config/testdata/config/provider/registry_application.yaml @@ -4,10 +4,10 @@ dubbo: timeout: 3s address: naocs://127.0.0.1:8848 provider: - registry: nacos + registries: nacos services: HelloService: interface: org.dubbo.service.HelloService - registry: nacos,zk + registries: nacos,zk OrderService: interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index c011c9e40b..118460b6fc 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -33,7 +33,7 @@ registries : references: "UserProvider": - registry: "hangzhouzk,shanghaizk" + registries: "hangzhouzk,shanghaizk" filter: "" protocol : "dubbo" version: "1.0" diff --git a/config/testdata/consumer_config_with_configcenter.yml b/config/testdata/consumer_config_with_configcenter.yml index fe979dacd4..f6352da838 100644 --- a/config/testdata/consumer_config_with_configcenter.yml +++ b/config/testdata/consumer_config_with_configcenter.yml @@ -7,7 +7,7 @@ config_center: address: "127.0.0.1" references: "UserProvider": - registry: "hangzhouzk,shanghaizk" + registries: "hangzhouzk,shanghaizk" filter: "" protocol : "dubbo" interface : "com.ikurento.user.UserProvider" diff --git a/config/testdata/consumer_config_withoutProtocol.yml b/config/testdata/consumer_config_withoutProtocol.yml index 6028a48db4..4efd21cbbe 100644 --- a/config/testdata/consumer_config_withoutProtocol.yml +++ b/config/testdata/consumer_config_withoutProtocol.yml @@ -33,7 +33,7 @@ registries : references: "UserProvider": - registry: "hangzhouzk,shanghaizk" + registries: "hangzhouzk,shanghaizk" filter: "" version: "1.0" group: "as" diff --git a/config/testdata/provider_config.yml b/config/testdata/provider_config.yml index 3c081c0168..10282dbb0d 100644 --- a/config/testdata/provider_config.yml +++ b/config/testdata/provider_config.yml @@ -27,7 +27,7 @@ registries : services: "UserProvider": - registry: "hangzhouzk,shanghaizk" + registries: "hangzhouzk,shanghaizk" filter: "" # the name of limiter tps.limiter: "default" diff --git a/config/testdata/provider_config_withoutProtocol.yml b/config/testdata/provider_config_withoutProtocol.yml index 651c2f4c6a..1636b0cd22 100644 --- a/config/testdata/provider_config_withoutProtocol.yml +++ b/config/testdata/provider_config_withoutProtocol.yml @@ -27,7 +27,7 @@ registries : services: "UserProvider": - registry: "hangzhouzk,shanghaizk" + registries: "hangzhouzk,shanghaizk" filter: "" # equivalent to interface of dubbo.xml interface : "com.ikurento.user.UserProvider" diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 7afaef61c2..3ec072c4fa 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -70,7 +70,7 @@ func TestConfigurableExporter(t *testing.T) { assert.Equal(t, false, exported.IsExported()) assert.NoError(t, exported.Export(registryURL)) assert.Equal(t, true, exported.IsExported()) - assert.Regexp(t, "dubbo://127.0.0.1:20005/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) + assert.Regexp(t, "dubbo://:20005/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) exported.Unexport() assert.Equal(t, false, exported.IsExported()) }) From e6afd5734af4062c7f17544f39df40a45c023bfb Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Sat, 2 Oct 2021 17:23:04 +0800 Subject: [PATCH 135/148] fix: update uuid version --- common/url.go | 2 +- config/service_config.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/url.go b/common/url.go index 26c4ebdb34..fc618ea7cf 100644 --- a/common/url.go +++ b/common/url.go @@ -210,7 +210,7 @@ func WithToken(token string) Option { if len(token) > 0 { value := token if strings.ToLower(token) == "true" || strings.ToLower(token) == "default" { - u := uuid.NewV4() + u, _ := uuid.NewV4() value = u.String() } url.SetParam(constant.TOKEN_KEY, value) diff --git a/config/service_config.go b/config/service_config.go index 32724dd84a..0b17a899db 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -450,8 +450,8 @@ func (pcb *ServiceConfigBuilder) SetRegistries(registries ...string) *ServiceCon return pcb } -func (pcb *ServiceConfigBuilder) SetProtocols(protocols ...string) *ServiceConfigBuilder { - pcb.serviceConfig.Protocols = protocols +func (pcb *ServiceConfigBuilder) SetProtocols(protocolNames ...string) *ServiceConfigBuilder { + pcb.serviceConfig.Protocols = protocolNames return pcb } diff --git a/go.mod b/go.mod index 4d2a899219..ea4b536592 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.0 github.com/prometheus/common v0.28.0 // indirect - github.com/satori/go.uuid v1.2.0 + github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b github.com/stretchr/testify v1.7.0 github.com/zouyx/agollo/v3 v3.4.5 go.etcd.io/etcd/api/v3 v3.5.0 diff --git a/go.sum b/go.sum index a4412af1f0..75e5d2af51 100644 --- a/go.sum +++ b/go.sum @@ -675,8 +675,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= +github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= From 0d03ae4fd70d7e5d14ae7d1ce4b7363989c935e5 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 4 Oct 2021 00:08:35 +0800 Subject: [PATCH 136/148] fix: change to IDs --- config/consumer_config.go | 12 ++--- config/provider_config.go | 22 ++++----- config/provider_config_test.go | 8 ++-- config/reference_config.go | 14 +++--- config/service_config.go | 46 +++++++++---------- config/testdata/application.yaml | 4 +- config/testdata/config/app/application.yaml | 2 +- .../testdata/config/provider/application.yaml | 4 +- .../config/provider/registry_application.yaml | 4 +- config/testdata/consumer_config.yml | 2 +- .../consumer_config_with_configcenter.yml | 2 +- .../consumer_config_withoutProtocol.yml | 2 +- config/testdata/provider_config.yml | 2 +- .../provider_config_withoutProtocol.yml | 2 +- .../exporter/configurable/exporter_test.go | 2 +- protocol/dubbo3/internal/server.go | 4 +- protocol/grpc/grpc_protocol_test.go | 4 +- registry/protocol/protocol.go | 2 +- 18 files changed, 70 insertions(+), 68 deletions(-) diff --git a/config/consumer_config.go b/config/consumer_config.go index c3924cc822..db34f45fe2 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -42,7 +42,7 @@ type ConsumerConfig struct { // ConnectTimeout will be remove in 3.0 config-enhance ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` // support string - Registries []string `yaml:"registries" json:"registries,omitempty" property:"registries"` + RegistryIDs []string `yaml:"registryIDs" json:"registryIDs,omitempty" property:"registryIDs"` RequestTimeout string `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"` ProxyFactory string `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"` @@ -64,9 +64,9 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error { if cc == nil { return nil } - cc.Registries = translateRegistryIds(cc.Registries) - if len(cc.Registries) <= 0 { - cc.Registries = rc.getRegistryIds() + cc.RegistryIDs = translateRegistryIds(cc.RegistryIDs) + if len(cc.RegistryIDs) <= 0 { + cc.RegistryIDs = rc.getRegistryIds() } for _, reference := range cc.References { if err := reference.Init(rc); err != nil { @@ -158,8 +158,8 @@ func (ccb *ConsumerConfigBuilder) SetFilter(filter string) *ConsumerConfigBuilde return ccb } -func (ccb *ConsumerConfigBuilder) SetRegistries(registryKeys ...string) *ConsumerConfigBuilder { - ccb.consumerConfig.Registries = registryKeys +func (ccb *ConsumerConfigBuilder) SetRegistryIDs(RegistryIDs ...string) *ConsumerConfigBuilder { + ccb.consumerConfig.RegistryIDs = RegistryIDs return ccb } diff --git a/config/provider_config.go b/config/provider_config.go index 7f805c4d68..abd4a2c870 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -35,8 +35,8 @@ type ProviderConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // Deprecated Register whether registration is required Register bool `yaml:"register" json:"register" property:"register"` - // Registries registry ids TODO Registries? - Registries []string `yaml:"registries" json:"registries" property:"registries"` + // RegistryIDs is registry ids list + RegistryIDs []string `yaml:"registryIDs" json:"registryIDs" property:"registryIDs"` // Services services Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"` @@ -63,9 +63,9 @@ func (c *ProviderConfig) Init(rc *RootConfig) error { if c == nil { return nil } - c.Registries = translateRegistryIds(c.Registries) - if len(c.Registries) <= 0 { - c.Registries = rc.getRegistryIds() + c.RegistryIDs = translateRegistryIds(c.RegistryIDs) + if len(c.RegistryIDs) <= 0 { + c.RegistryIDs = rc.getRegistryIds() } for _, service := range c.Services { if err := service.Init(rc); err != nil { @@ -97,8 +97,8 @@ func (c *ProviderConfig) Load() { // newEmptyProviderConfig returns ProviderConfig with default ApplicationConfig func newEmptyProviderConfig() *ProviderConfig { newProviderConfig := &ProviderConfig{ - Services: make(map[string]*ServiceConfig), - Registries: make([]string, 8), + Services: make(map[string]*ServiceConfig), + RegistryIDs: make([]string, 8), } return newProviderConfig } @@ -123,8 +123,8 @@ func (pcb *ProviderConfigBuilder) SetRegister(register bool) *ProviderConfigBuil } // nolint -func (pcb *ProviderConfigBuilder) SetRegistries(registryKeys ...string) *ProviderConfigBuilder { - pcb.providerConfig.Registries = registryKeys +func (pcb *ProviderConfigBuilder) SetRegistryIDs(RegistryIDs ...string) *ProviderConfigBuilder { + pcb.providerConfig.RegistryIDs = RegistryIDs return pcb } @@ -135,11 +135,11 @@ func (pcb *ProviderConfigBuilder) SetServices(services map[string]*ServiceConfig } // nolint -func (pcb *ProviderConfigBuilder) AddService(serviceName string, serviceConfig *ServiceConfig) *ProviderConfigBuilder { +func (pcb *ProviderConfigBuilder) AddService(serviceID string, serviceConfig *ServiceConfig) *ProviderConfigBuilder { if pcb.providerConfig.Services == nil { pcb.providerConfig.Services = make(map[string]*ServiceConfig) } - pcb.providerConfig.Services[serviceName] = serviceConfig + pcb.providerConfig.Services[serviceID] = serviceConfig return pcb } diff --git a/config/provider_config_test.go b/config/provider_config_test.go index 712c816dfa..b418bffe7f 100644 --- a/config/provider_config_test.go +++ b/config/provider_config_test.go @@ -29,8 +29,8 @@ func TestProviderConfigEmptyRegistry(t *testing.T) { err := Load(WithPath("./testdata/config/provider/empty_registry_application.yaml")) assert.Nil(t, err) provider := rootConfig.Provider - assert.Equal(t, 1, len(provider.Registries)) - assert.Equal(t, "nacos", provider.Registries[0]) + assert.Equal(t, 1, len(provider.RegistryIDs)) + assert.Equal(t, "nacos", provider.RegistryIDs[0]) } func TestProviderConfigRootRegistry(t *testing.T) { @@ -40,8 +40,8 @@ func TestProviderConfigRootRegistry(t *testing.T) { assert.NotNil(t, provider) assert.Equal(t, 2, len(provider.Services)) - assert.Equal(t, 2, len(provider.Services["HelloService"].Registries)) - assert.Equal(t, 1, len(provider.Services["OrderService"].Registries)) + assert.Equal(t, 2, len(provider.Services["HelloService"].RegistryIDs)) + assert.Equal(t, 1, len(provider.Services["OrderService"].RegistryIDs)) } // diff --git a/config/reference_config.go b/config/reference_config.go index f70c25bc1e..dca6db1ca1 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -50,7 +50,7 @@ type ReferenceConfig struct { URL string `yaml:"url" json:"url,omitempty" property:"url"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - Registries []string `yaml:"registries" json:"registries,omitempty" property:"registries"` + RegistryIDs []string `yaml:"registryIDs" json:"registryIDs,omitempty" property:"registryIDs"` Cluster string `yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"` @@ -90,9 +90,9 @@ func (rc *ReferenceConfig) Init(root *RootConfig) error { if root.Application != nil { rc.metaDataType = root.Application.MetadataType } - rc.Registries = translateRegistryIds(rc.Registries) - if len(rc.Registries) <= 0 { - rc.Registries = root.Consumer.Registries + rc.RegistryIDs = translateRegistryIds(rc.RegistryIDs) + if len(rc.RegistryIDs) <= 0 { + rc.RegistryIDs = root.Consumer.RegistryIDs } return verify(rc) } @@ -133,7 +133,7 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { } } else { // 2. assemble SubURL from register center's configuration mode - rc.urls = loadRegistries(rc.Registries, rc.rootConfig.Registries, common.CONSUMER) + rc.urls = loadRegistries(rc.RegistryIDs, rc.rootConfig.Registries, common.CONSUMER) // set url to regURLs for _, regURL := range rc.urls { @@ -344,8 +344,8 @@ func (pcb *ReferenceConfigBuilder) SetInterface(interfaceName string) *Reference return pcb } -func (pcb *ReferenceConfigBuilder) SetRegistries(registryKeys ...string) *ReferenceConfigBuilder { - pcb.referenceConfig.Registries = registryKeys +func (pcb *ReferenceConfigBuilder) SetRegistryIDs(registryIDs ...string) *ReferenceConfigBuilder { + pcb.referenceConfig.RegistryIDs = registryIDs return pcb } diff --git a/config/service_config.go b/config/service_config.go index 0b17a899db..c5d45bc4ab 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -50,9 +50,9 @@ import ( type ServiceConfig struct { id string Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - Protocols []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // multi protocol support, split by ',' + ProtocolIDs []string `default:"[\"dubbo\"]" validate:"required" yaml:"protocolIDs" json:"protocolIDs,omitempty" property:"protocolIDs"` // multi protocolIDs support, split by ',' Interface string `validate:"required" yaml:"interface" json:"interface,omitempty" property:"interface"` - Registries []string `yaml:"registries" json:"registry,omitempty" property:"registry"` + RegistryIDs []string `yaml:"registryIDs" json:"registryIDs,omitempty" property:"registryIDs"` Cluster string `default:"failover" yaml:"cluster" json:"cluster,omitempty" property:"cluster"` Loadbalance string `default:"random" yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"` Group string `yaml:"group" json:"group,omitempty" property:"group"` @@ -76,8 +76,8 @@ type ServiceConfig struct { Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"` GrpcMaxMessageSize int `default:"4" yaml:"max_message_size" json:"max_message_size,omitempty"` - RCProtocols map[string]*ProtocolConfig - RCRegistries map[string]*RegistryConfig + RCProtocolsMap map[string]*ProtocolConfig + RCRegistriesMap map[string]*RegistryConfig ProxyFactoryKey string unexported *atomic.Bool exported *atomic.Bool @@ -106,14 +106,14 @@ func (svc *ServiceConfig) Init(rc *RootConfig) error { svc.exported = atomic.NewBool(false) svc.metadataType = rc.Application.MetadataType svc.unexported = atomic.NewBool(false) - svc.RCRegistries = rc.Registries - svc.RCProtocols = rc.Protocols + svc.RCRegistriesMap = rc.Registries + svc.RCProtocolsMap = rc.Protocols if rc.Provider != nil { svc.ProxyFactoryKey = rc.Provider.ProxyFactory } - svc.Registries = translateRegistryIds(svc.Registries) - if len(svc.Registries) <= 0 { - svc.Registries = rc.Provider.Registries + svc.RegistryIDs = translateRegistryIds(svc.RegistryIDs) + if len(svc.RegistryIDs) <= 0 { + svc.RegistryIDs = rc.Provider.RegistryIDs } svc.export = true return verify(svc) @@ -160,11 +160,11 @@ func (svc *ServiceConfig) Export() error { return nil } - regUrls := loadRegistries(svc.Registries, svc.RCRegistries, common.PROVIDER) + regUrls := loadRegistries(svc.RegistryIDs, svc.RCRegistriesMap, common.PROVIDER) urlMap := svc.getUrlMap() - protocolConfigs := loadProtocol(svc.Protocols, svc.RCProtocols) + protocolConfigs := loadProtocol(svc.ProtocolIDs, svc.RCProtocolsMap) if len(protocolConfigs) == 0 { - logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs, Please check your configuration center and transfer protocol ", svc.Interface, svc.Protocols) + logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs, Please check your configuration center and transfer protocol ", svc.Interface, svc.ProtocolIDs) return nil } @@ -426,11 +426,11 @@ func (svc *ServiceConfig) postProcessConfig(url *common.URL) { // newEmptyServiceConfig returns default ServiceConfig func newEmptyServiceConfig() *ServiceConfig { newServiceConfig := &ServiceConfig{ - unexported: atomic.NewBool(false), - exported: atomic.NewBool(false), - export: true, - RCProtocols: make(map[string]*ProtocolConfig), - RCRegistries: make(map[string]*RegistryConfig), + unexported: atomic.NewBool(false), + exported: atomic.NewBool(false), + export: true, + RCProtocolsMap: make(map[string]*ProtocolConfig), + RCRegistriesMap: make(map[string]*RegistryConfig), } newServiceConfig.Params = make(map[string]string) newServiceConfig.Methods = make([]*MethodConfig, 0, 8) @@ -445,13 +445,13 @@ func NewServiceConfigBuilder() *ServiceConfigBuilder { return &ServiceConfigBuilder{serviceConfig: newEmptyServiceConfig()} } -func (pcb *ServiceConfigBuilder) SetRegistries(registries ...string) *ServiceConfigBuilder { - pcb.serviceConfig.Registries = registries +func (pcb *ServiceConfigBuilder) SetRegistries(registryIDs ...string) *ServiceConfigBuilder { + pcb.serviceConfig.RegistryIDs = registryIDs return pcb } -func (pcb *ServiceConfigBuilder) SetProtocols(protocolNames ...string) *ServiceConfigBuilder { - pcb.serviceConfig.Protocols = protocolNames +func (pcb *ServiceConfigBuilder) SetProtocols(protocolIDs ...string) *ServiceConfigBuilder { + pcb.serviceConfig.ProtocolIDs = protocolIDs return pcb } @@ -481,12 +481,12 @@ func (pcb *ServiceConfigBuilder) SetCluster(cluster string) *ServiceConfigBuilde } func (pcb *ServiceConfigBuilder) AddRCProtocol(protocolName string, protocolConfig *ProtocolConfig) *ServiceConfigBuilder { - pcb.serviceConfig.RCProtocols[protocolName] = protocolConfig + pcb.serviceConfig.RCProtocolsMap[protocolName] = protocolConfig return pcb } func (pcb *ServiceConfigBuilder) AddRCRegistry(registryName string, registryConfig *RegistryConfig) *ServiceConfigBuilder { - pcb.serviceConfig.RCRegistries[registryName] = registryConfig + pcb.serviceConfig.RCRegistriesMap[registryName] = registryConfig return pcb } diff --git a/config/testdata/application.yaml b/config/testdata/application.yaml index 2325e87313..e0ee9a27f8 100644 --- a/config/testdata/application.yaml +++ b/config/testdata/application.yaml @@ -26,10 +26,10 @@ dubbo: services: helloService: interface: org.dubbo.service.HelloService - registries: nacos,zk + registryIDs: nacos,zk orderService: interface: org.dubbo.service.OrderService - registries: nacos + registryIDs: nacos provider: register: true services: \ No newline at end of file diff --git a/config/testdata/config/app/application.yaml b/config/testdata/config/app/application.yaml index 418201f83d..336a0badb0 100644 --- a/config/testdata/config/app/application.yaml +++ b/config/testdata/config/app/application.yaml @@ -14,7 +14,7 @@ dubbo: interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java provider: register: true - registries: nacos + registryIDs: nacos services: helloService: protocol: dubbo diff --git a/config/testdata/config/provider/application.yaml b/config/testdata/config/provider/application.yaml index 92f1de767a..a30a8d3b2d 100644 --- a/config/testdata/config/provider/application.yaml +++ b/config/testdata/config/provider/application.yaml @@ -6,12 +6,12 @@ dubbo: address: nacos://127.0.0.1:8848 provider: register: true - registries: + registryIDs: - nacos - zk services: helloService: interface: org.dubbo.service.HelloService - registries: nacos,zk + registryIDs: nacos,zk orderService: interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/config/provider/registry_application.yaml b/config/testdata/config/provider/registry_application.yaml index b00b854bd0..98190567a0 100644 --- a/config/testdata/config/provider/registry_application.yaml +++ b/config/testdata/config/provider/registry_application.yaml @@ -4,10 +4,10 @@ dubbo: timeout: 3s address: naocs://127.0.0.1:8848 provider: - registries: nacos + registryIDs: nacos services: HelloService: interface: org.dubbo.service.HelloService - registries: nacos,zk + registryIDs: nacos,zk OrderService: interface: org.dubbo.service.OrderService \ No newline at end of file diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 118460b6fc..a9849eaf6a 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -33,7 +33,7 @@ registries : references: "UserProvider": - registries: "hangzhouzk,shanghaizk" + registryIDs: "hangzhouzk,shanghaizk" filter: "" protocol : "dubbo" version: "1.0" diff --git a/config/testdata/consumer_config_with_configcenter.yml b/config/testdata/consumer_config_with_configcenter.yml index f6352da838..f5a617a3f0 100644 --- a/config/testdata/consumer_config_with_configcenter.yml +++ b/config/testdata/consumer_config_with_configcenter.yml @@ -7,7 +7,7 @@ config_center: address: "127.0.0.1" references: "UserProvider": - registries: "hangzhouzk,shanghaizk" + registryIDs: "hangzhouzk,shanghaizk" filter: "" protocol : "dubbo" interface : "com.ikurento.user.UserProvider" diff --git a/config/testdata/consumer_config_withoutProtocol.yml b/config/testdata/consumer_config_withoutProtocol.yml index 4efd21cbbe..c5d399ea6b 100644 --- a/config/testdata/consumer_config_withoutProtocol.yml +++ b/config/testdata/consumer_config_withoutProtocol.yml @@ -33,7 +33,7 @@ registries : references: "UserProvider": - registries: "hangzhouzk,shanghaizk" + registryIDs: "hangzhouzk,shanghaizk" filter: "" version: "1.0" group: "as" diff --git a/config/testdata/provider_config.yml b/config/testdata/provider_config.yml index 10282dbb0d..92689e6129 100644 --- a/config/testdata/provider_config.yml +++ b/config/testdata/provider_config.yml @@ -27,7 +27,7 @@ registries : services: "UserProvider": - registries: "hangzhouzk,shanghaizk" + registryIDs: "hangzhouzk,shanghaizk" filter: "" # the name of limiter tps.limiter: "default" diff --git a/config/testdata/provider_config_withoutProtocol.yml b/config/testdata/provider_config_withoutProtocol.yml index 1636b0cd22..b2adb32e40 100644 --- a/config/testdata/provider_config_withoutProtocol.yml +++ b/config/testdata/provider_config_withoutProtocol.yml @@ -27,7 +27,7 @@ registries : services: "UserProvider": - registries: "hangzhouzk,shanghaizk" + registryIDs: "hangzhouzk,shanghaizk" filter: "" # equivalent to interface of dubbo.xml interface : "com.ikurento.user.UserProvider" diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 3ec072c4fa..772a8df8d8 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -108,7 +108,7 @@ func mockInitProviderWithSingleRegistry() { Services: map[string]*config.ServiceConfig{ "MockService": { Interface: "com.MockService", - Protocols: []string{"mock"}, + ProtocolIDs: []string{"mock"}, Cluster: "failover", Loadbalance: "random", Retries: "3", diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 1414740921..9946f81603 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -58,6 +58,8 @@ func InitDubboServer() { }).Build() config.SetProviderService(&Server{}) - rootConfig.Init() + if err := rootConfig.Init(); err != nil { + panic(err) + } rootConfig.Start() } diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 9a01d8ba58..9790843f95 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -47,8 +47,8 @@ func doInitProvider() { Services: map[string]*config.ServiceConfig{ "GrpcGreeterImpl": { Interface: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter", - Protocols: []string{"grpc"}, - Registries: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, + ProtocolIDs: []string{"grpc"}, + RegistryIDs: []string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"}, Cluster: "failover", Loadbalance: "random", Retries: "3", diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 1d02e5b273..add0c5d157 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -260,7 +260,7 @@ func registerServiceMap(invoker protocol.Invoker) error { _, err := common.ServiceMap.Register(serviceConfig.Interface, // FIXME - serviceConfig.Protocols[0], serviceConfig.Group, + serviceConfig.ProtocolIDs[0], serviceConfig.Group, serviceConfig.Version, rpcService) if err != nil { s := "reExport can not re register ServiceMap. Error message is " + err.Error() From 5d7930547f876ae42ba73805a527fefeae59c86e Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 4 Oct 2021 00:15:25 +0800 Subject: [PATCH 137/148] fix: change API to IDs --- config/reference_config.go | 4 ++-- config/service_config.go | 4 ++-- metadata/service/exporter/configurable/exporter.go | 4 ++-- protocol/dubbo3/internal/server.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index dca6db1ca1..f5aea2a3b8 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -349,8 +349,8 @@ func (pcb *ReferenceConfigBuilder) SetRegistryIDs(registryIDs ...string) *Refere return pcb } -func (pcb *ReferenceConfigBuilder) SetProtocol(protocolName string) *ReferenceConfigBuilder { - pcb.referenceConfig.Protocol = protocolName +func (pcb *ReferenceConfigBuilder) SetProtocol(protocol string) *ReferenceConfigBuilder { + pcb.referenceConfig.Protocol = protocol return pcb } diff --git a/config/service_config.go b/config/service_config.go index c5d45bc4ab..34faee0ab9 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -445,12 +445,12 @@ func NewServiceConfigBuilder() *ServiceConfigBuilder { return &ServiceConfigBuilder{serviceConfig: newEmptyServiceConfig()} } -func (pcb *ServiceConfigBuilder) SetRegistries(registryIDs ...string) *ServiceConfigBuilder { +func (pcb *ServiceConfigBuilder) SetRegistryIDs(registryIDs ...string) *ServiceConfigBuilder { pcb.serviceConfig.RegistryIDs = registryIDs return pcb } -func (pcb *ServiceConfigBuilder) SetProtocols(protocolIDs ...string) *ServiceConfigBuilder { +func (pcb *ServiceConfigBuilder) SetProtocolIDs(protocolIDs ...string) *ServiceConfigBuilder { pcb.serviceConfig.ProtocolIDs = protocolIDs return pcb } diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index dbe032cb81..551d79d56d 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -63,12 +63,12 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { defer exporter.lock.Unlock() exporter.ServiceConfig = config.NewServiceConfigBuilder(). SetServiceID(constant.SIMPLE_METADATA_SERVICE_NAME). - SetProtocols(constant.DEFAULT_PROTOCOL). + SetProtocolIDs(constant.DEFAULT_PROTOCOL). AddRCProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfigBuilder(). SetName(constant.DEFAULT_PROTOCOL). SetPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)). Build()). - SetRegistries("N/A"). + SetRegistryIDs("N/A"). SetInterface(constant.METADATA_SERVICE_NAME). SetGroup(config.GetApplicationConfig().Name). SetVersion(version). diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 9946f81603..97245dfa17 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -45,7 +45,7 @@ func (s *Server) SayHello(ctx context.Context, in *HelloRequest) (*HelloReply, e func InitDubboServer() { serviceConfig := config.NewServiceConfigBuilder(). SetInterface("org.apache.dubbo.DubboGreeterImpl"). - SetProtocols("tripleKey").Build() + SetProtocolIDs("tripleKey").Build() providerConfig := config.NewProviderConfigBuilder().SetServices(map[string]*config.ServiceConfig{ common.GetReference(&Server{}): serviceConfig, From b1fa50ad445c60806478eb439d6f03f534411e04 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 4 Oct 2021 13:24:12 +0800 Subject: [PATCH 138/148] fix: add SetSerialization api --- config/reference_config.go | 5 +++++ config/service_config.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/config/reference_config.go b/config/reference_config.go index f5aea2a3b8..319a64d1eb 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -349,6 +349,11 @@ func (pcb *ReferenceConfigBuilder) SetRegistryIDs(registryIDs ...string) *Refere return pcb } +func (pcb *ReferenceConfigBuilder) SetSerialization(serialization string) *ReferenceConfigBuilder { + pcb.referenceConfig.Serialization = serialization + return pcb +} + func (pcb *ReferenceConfigBuilder) SetProtocol(protocol string) *ReferenceConfigBuilder { pcb.referenceConfig.Protocol = protocol return pcb diff --git a/config/service_config.go b/config/service_config.go index 34faee0ab9..bb13e4b2f0 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -509,6 +509,11 @@ func (pcb *ServiceConfigBuilder) SetRPCService(service common.RPCService) *Servi return pcb } +func (pcb *ServiceConfigBuilder) SetSerialization(serialization string) *ServiceConfigBuilder { + pcb.serviceConfig.Serialization = serialization + return pcb +} + func (pcb *ServiceConfigBuilder) SetServiceID(id string) *ServiceConfigBuilder { pcb.serviceConfig.id = id return pcb From f7ecfb694ca0aaafa216ac51c3f259a87698d641 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 4 Oct 2021 14:14:29 +0800 Subject: [PATCH 139/148] fix: add more api --- config/reference_config.go | 17 +++++++++++++++++ config/root_config.go | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index 319a64d1eb..1055e75feb 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -90,6 +90,9 @@ func (rc *ReferenceConfig) Init(root *RootConfig) error { if root.Application != nil { rc.metaDataType = root.Application.MetadataType } + if rc.Cluster == "" { + rc.Cluster = "failover" + } rc.RegistryIDs = translateRegistryIds(rc.RegistryIDs) if len(rc.RegistryIDs) <= 0 { rc.RegistryIDs = root.Consumer.RegistryIDs @@ -349,6 +352,20 @@ func (pcb *ReferenceConfigBuilder) SetRegistryIDs(registryIDs ...string) *Refere return pcb } +func (pcb *ReferenceConfigBuilder) SetGeneric(generic bool) *ReferenceConfigBuilder { + if generic { + pcb.referenceConfig.Generic = "true" + } else { + pcb.referenceConfig.Generic = "false" + } + return pcb +} + +func (pcb *ReferenceConfigBuilder) SetCluster(cluster string) *ReferenceConfigBuilder { + pcb.referenceConfig.Cluster = cluster + return pcb +} + func (pcb *ReferenceConfigBuilder) SetSerialization(serialization string) *ReferenceConfigBuilder { pcb.referenceConfig.Serialization = serialization return pcb diff --git a/config/root_config.go b/config/root_config.go index c7f820566c..21adc42c97 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -235,13 +235,13 @@ func (rb *RootConfigBuilder) SetApplication(application *ApplicationConfig) *Roo return rb } -func (rb *RootConfigBuilder) AddProtocol(protocolKey string, protocolConfig *ProtocolConfig) *RootConfigBuilder { - rb.rootConfig.Protocols[protocolKey] = protocolConfig +func (rb *RootConfigBuilder) AddProtocol(protocolID string, protocolConfig *ProtocolConfig) *RootConfigBuilder { + rb.rootConfig.Protocols[protocolID] = protocolConfig return rb } -func (rb *RootConfigBuilder) AddRegistry(registryKey string, registryConfig *RegistryConfig) *RootConfigBuilder { - rb.rootConfig.Registries[registryKey] = registryConfig +func (rb *RootConfigBuilder) AddRegistry(registryID string, registryConfig *RegistryConfig) *RootConfigBuilder { + rb.rootConfig.Registries[registryID] = registryConfig return rb } From 412dfcccfa690f2cd1091a630cd105301068b973 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 20:16:36 +0800 Subject: [PATCH 140/148] build(deps): bump github.com/knadh/koanf from 1.2.3 to 1.2.4 (#1502) Bumps [github.com/knadh/koanf](https://github.com/knadh/koanf) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/knadh/koanf/releases) - [Commits](https://github.com/knadh/koanf/compare/v1.2.3...v1.2.4) --- updated-dependencies: - dependency-name: github.com/knadh/koanf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7035e4f3a9..81e3e8ff21 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hashicorp/vault/sdk v0.2.1 github.com/jinzhu/copier v0.3.2 - github.com/knadh/koanf v1.2.3 + github.com/knadh/koanf v1.2.4 github.com/magiconair/properties v1.8.5 github.com/mitchellh/mapstructure v1.4.2 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd diff --git a/go.sum b/go.sum index e152acaff6..1e8992da21 100644 --- a/go.sum +++ b/go.sum @@ -475,8 +475,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/knadh/koanf v1.2.3 h1:2Rkr0YhhYk+4QEOm800Q3Pu0Wi87svTxM6uuEb4WhYw= -github.com/knadh/koanf v1.2.3/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= +github.com/knadh/koanf v1.2.4 h1:AQYoGbNwphHd63E//SkDkqEGcogARxGspHWqoJw6O8k= +github.com/knadh/koanf v1.2.4/go.mod h1:xpPTwMhsA/aaQLAilyCCqfpEiY1gpa160AiCuWHJUjY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= From 0b8429731b79878af2888c46f67b2f6c6ddd7519 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 20:16:54 +0800 Subject: [PATCH 141/148] build(deps): bump github.com/creasty/defaults from 1.5.1 to 1.5.2 (#1501) Bumps [github.com/creasty/defaults](https://github.com/creasty/defaults) from 1.5.1 to 1.5.2. - [Release notes](https://github.com/creasty/defaults/releases) - [Commits](https://github.com/creasty/defaults/compare/v1.5.1...v1.5.2) --- updated-dependencies: - dependency-name: github.com/creasty/defaults dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 81e3e8ff21..9d1d2ee0ea 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/alibaba/sentinel-golang v1.0.2 github.com/apache/dubbo-getty v1.4.5 github.com/apache/dubbo-go-hessian2 v1.9.3 - github.com/creasty/defaults v1.5.1 + github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c diff --git a/go.sum b/go.sum index 1e8992da21..90f479b3df 100644 --- a/go.sum +++ b/go.sum @@ -160,8 +160,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr 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/creasty/defaults v1.5.2 h1:/VfB6uxpyp6h0fr7SPp7n8WJBoV8jfxQXPCnkVSjyls= +github.com/creasty/defaults v1.5.2/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From ef0cc7eafdabc8da4f8fab3fd6aea98644c625f5 Mon Sep 17 00:00:00 2001 From: alchemy-lee <2769566951@qq.com> Date: Wed, 6 Oct 2021 15:53:57 +0800 Subject: [PATCH 142/148] Fix the IsProvider check (#1500) * improve etcd version and change create to put (#1203) * fix: CONTRIBUTING.md url error. (#1303) * add lock (#1304) * Revert "add lock (#1304)" (#1329) This reverts commit a10996763e3e1ffa5cdbd80cb49319a4e3626994. * build(deps): bump github.com/dubbogo/gost from 1.11.14 to 1.11.16 (#1387) Bumps [github.com/dubbogo/gost](https://github.com/dubbogo/gost) from 1.11.14 to 1.11.16. - [Release notes](https://github.com/dubbogo/gost/releases) - [Commits](https://github.com/dubbogo/gost/compare/v1.11.14...v1.11.16) --- updated-dependencies: - dependency-name: github.com/dubbogo/gost dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.1 (#1386) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.26.0 to 1.27.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.26.0...v1.27.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump go.etcd.io/etcd/client/v3 from 3.5.0-alpha.0 to 3.5.0 (#1383) Bumps [go.etcd.io/etcd/client/v3](https://github.com/etcd-io/etcd) from 3.5.0-alpha.0 to 3.5.0. - [Release notes](https://github.com/etcd-io/etcd/releases) - [Changelog](https://github.com/etcd-io/etcd/blob/main/CHANGELOG-3.5.md) - [Commits](https://github.com/etcd-io/etcd/compare/v3.5.0-alpha.0...v3.5.0) --- updated-dependencies: - dependency-name: go.etcd.io/etcd/client/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix provider check * fix provider check * fix provider check Co-authored-by: AlexStocks Co-authored-by: randy Co-authored-by: LaurenceLiZhixin <382673304@qq.com> Co-authored-by: Zhiqiang Li Co-authored-by: tyltr <31768692+tylitianrui@users.noreply.github.com> Co-authored-by: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: yuyu.zx Co-authored-by: fangyincheng --- config/config_loader.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index ba9c4f5f17..600151fc50 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -174,6 +174,5 @@ func GetMetadataReportConfg() *MetadataReportConfig { } func IsProvider() bool { - // FixME - return rootConfig.Provider != nil + return len(rootConfig.Provider.Services) > 0 } From 07e6f44055458e648390c903378ea49814bf2fd2 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Thu, 7 Oct 2021 13:48:45 +0800 Subject: [PATCH 143/148] Fix: solve v3 zk/nacos service disc (#1505) * fix: solve v3 zk/nacos service disc * fix: add start back to init * fix: add missing return * fix --- common/extension/metadata_service_exporter.go | 46 ++++++++ config/config_loader.go | 9 +- config/config_resolver.go | 1 + config/metadata_report_config.go | 15 ++- config/provider_config.go | 4 +- config/root_config.go | 111 ++++++++++++------ config/service_config.go | 10 +- imports/imports.go | 1 + metadata/report/delegate/delegate_report.go | 2 +- .../service/exporter/configurable/exporter.go | 14 +-- .../exporter/configurable/exporter_test.go | 7 +- metadata/service/local/service.go | 3 + protocol/dubbo3/dubbo3_invoker_test.go | 1 + .../service_discovery_registry.go | 52 -------- 14 files changed, 146 insertions(+), 130 deletions(-) create mode 100644 common/extension/metadata_service_exporter.go diff --git a/common/extension/metadata_service_exporter.go b/common/extension/metadata_service_exporter.go new file mode 100644 index 0000000000..45e71e2a0e --- /dev/null +++ b/common/extension/metadata_service_exporter.go @@ -0,0 +1,46 @@ +/* + * 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 extension + +import ( + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/metadata/service" + "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter" +) + +type MetadataServiceExporterCreator func(service.MetadataService) exporter.MetadataServiceExporter + +var ( + metadataServiceExporterInsMap = make(map[string]MetadataServiceExporterCreator, 2) +) + +// SetMetadataServiceExporter will store the type => creator pair +func SetMetadataServiceExporter(key string, creator MetadataServiceExporterCreator) { + metadataServiceExporterInsMap[key] = creator +} + +// GetMetadataServiceExporter will create a MetadataServiceExporter instance +func GetMetadataServiceExporter(key string, s service.MetadataService) exporter.MetadataServiceExporter { + if key == "" { + key = constant.DEFAULT_KEY + } + if creator, ok := metadataServiceExporterInsMap[key]; ok { + return creator(s) + } + return nil +} diff --git a/config/config_loader.go b/config/config_loader.go index 600151fc50..1379b93c85 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -25,6 +25,7 @@ import ( import ( "github.com/knadh/koanf" + perrors "github.com/pkg/errors" ) @@ -51,7 +52,6 @@ func Load(opts ...LoaderConfOption) error { if err := rootConfig.Init(); err != nil { return err } - rootConfig.Start() return nil } @@ -96,13 +96,6 @@ func registerServiceInstance() { remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) } } - - if GetApplicationConfig().MetadataType == constant.REMOTE_METADATA_STORAGE_TYPE { - // publish metadata to remote - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil { - remoteMetadataService.PublishMetadata(GetApplicationConfig().Name) - } - } } // diff --git a/config/config_resolver.go b/config/config_resolver.go index a875756b3f..d170b36a72 100644 --- a/config/config_resolver.go +++ b/config/config_resolver.go @@ -23,6 +23,7 @@ import ( "github.com/knadh/koanf/parsers/toml" "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/rawbytes" + "github.com/pkg/errors" ) diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 22f1fcbb8f..f5740d19ae 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -17,10 +17,6 @@ package config -import ( - "fmt" -) - import ( perrors "github.com/pkg/errors" ) @@ -29,6 +25,7 @@ import ( "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/config/instance" ) @@ -89,6 +86,12 @@ func (mc *MetadataReportConfig) StartMetadataReport() error { } func publishServiceDefinition(url *common.URL) { + localService, err := extension.GetLocalMetadataService(constant.DEFAULT_Key) + if err != nil { + logger.Warnf("get local metadata service failed, please check if you have imported _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"") + return + } + localService.PublishServiceDefinition(url) if url.GetParam(constant.METADATATYPE_KEY, "") != constant.REMOTE_METADATA_STORAGE_TYPE { return } @@ -101,9 +104,9 @@ func publishServiceDefinition(url *common.URL) { // selectMetadataServiceExportedURL get already be exported url func selectMetadataServiceExportedURL() *common.URL { var selectedUrl *common.URL - metaDataService, err := extension.GetLocalMetadataService("") + metaDataService, err := extension.GetLocalMetadataService(constant.DEFAULT_Key) if err != nil { - fmt.Println("selectMetadataServiceExportedURL err = ", err) + logger.Warnf("get metadata service exporter failed, pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"") return nil } urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE) diff --git a/config/provider_config.go b/config/provider_config.go index abd4a2c870..ddf2cbc2ed 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -82,7 +82,9 @@ func (c *ProviderConfig) Load() { for key, svs := range c.Services { rpcService := GetProviderService(key) if rpcService == nil { - logger.Warnf("%s does not exist!", key) + logger.Warnf("Service reference key %s does not exist, please check if this key "+ + "matches your provider struct type name, or matches the returned valued of your provider struct's Reference() function."+ + "View https://www.yuque.com/u772707/eqpff0/pqfgz3#zxdw0 for details", key) continue } svs.id = key diff --git a/config/root_config.go b/config/root_config.go index 21adc42c97..0b88999222 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -24,16 +24,23 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" + + perrors "github.com/pkg/errors" + + "go.uber.org/atomic" ) import ( "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/metadata/service/exporter" ) var ( startOnce sync.Once + exporting = &atomic.Bool{} ) // RootConfig is the root config @@ -46,15 +53,9 @@ type RootConfig struct { // Registries registry config Registries map[string]*RegistryConfig `yaml:"registries" json:"registries" property:"registries"` - // Remotes to be remove in 3.0 config-enhance - Remotes map[string]*RemoteConfig `yaml:"remote" json:"remote,omitempty" property:"remote"` - // TODO ConfigCenter and CenterConfig? ConfigCenter *CenterConfig `yaml:"config-center" json:"config-center,omitempty"` - // ServiceDiscoveries to be remove in 3.0 config-enhance - ServiceDiscoveries map[string]*ServiceDiscoveryConfig `yaml:"service-discovery" json:"service-discovery,omitempty" property:"service-discovery"` - MetadataReport *MetadataReportConfig `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"` // provider config @@ -136,7 +137,7 @@ func (rc *RootConfig) Init() error { return err } if err := rc.ConfigCenter.Init(rc); err != nil { - logger.Warnf("config center doesn't start. error is %s", err) + logger.Infof("config center doesn't start, because %s", err) } if err := rc.Application.Init(); err != nil { return err @@ -166,16 +167,6 @@ func (rc *RootConfig) Init() error { } } - // init serviceDiscoveries - serviceDiscoveries := rc.ServiceDiscoveries - if serviceDiscoveries != nil { - for _, sd := range serviceDiscoveries { - if err := sd.Init(); err != nil { - return err - } - } - } - if err := rc.MetadataReport.Init(rc); err != nil { return err } @@ -192,7 +183,7 @@ func (rc *RootConfig) Init() error { if err := rc.Consumer.Init(rc); err != nil { return err } - + // todo if we can remove this from Init in the future? rc.Start() return nil } @@ -200,24 +191,26 @@ func (rc *RootConfig) Init() error { func (rc *RootConfig) Start() { startOnce.Do(func() { rc.Provider.Load() - rc.Consumer.Load() + // todo if register consumer instance or has exported services + exportMetadataService() registerServiceInstance() + + rc.Consumer.Load() }) } // newEmptyRootConfig get empty root config func newEmptyRootConfig() *RootConfig { newRootConfig := &RootConfig{ - ConfigCenter: NewConfigCenterConfigBuilder().Build(), - ServiceDiscoveries: make(map[string]*ServiceDiscoveryConfig), - MetadataReport: NewMetadataReportConfigBuilder().Build(), - Application: NewApplicationConfigBuilder().Build(), - Registries: make(map[string]*RegistryConfig), - Protocols: make(map[string]*ProtocolConfig), - Provider: NewProviderConfigBuilder().Build(), - Consumer: NewConsumerConfigBuilder().Build(), - Metric: NewMetricConfigBuilder().Build(), - Logger: NewLoggerConfigBuilder().Build(), + ConfigCenter: NewConfigCenterConfigBuilder().Build(), + MetadataReport: NewMetadataReportConfigBuilder().Build(), + Application: NewApplicationConfigBuilder().Build(), + Registries: make(map[string]*RegistryConfig), + Protocols: make(map[string]*ProtocolConfig), + Provider: NewProviderConfigBuilder().Build(), + Consumer: NewConsumerConfigBuilder().Build(), + Metric: NewMetricConfigBuilder().Build(), + Logger: NewLoggerConfigBuilder().Build(), } return newRootConfig } @@ -255,16 +248,6 @@ func (rb *RootConfigBuilder) SetRegistries(registries map[string]*RegistryConfig return rb } -func (rb *RootConfigBuilder) SetRemotes(remotes map[string]*RemoteConfig) *RootConfigBuilder { - rb.rootConfig.Remotes = remotes - return rb -} - -func (rb *RootConfigBuilder) SetServiceDiscoveries(serviceDiscoveries map[string]*ServiceDiscoveryConfig) *RootConfigBuilder { - rb.rootConfig.ServiceDiscoveries = serviceDiscoveries - return rb -} - func (rb *RootConfigBuilder) SetMetadataReport(metadataReport *MetadataReportConfig) *RootConfigBuilder { rb.rootConfig.MetadataReport = metadataReport return rb @@ -318,3 +301,53 @@ func (rb *RootConfigBuilder) SetConfigCenter(configCenterConfig *CenterConfig) * func (rb *RootConfigBuilder) Build() *RootConfig { return rb.rootConfig } + +func exportMetadataService() { + ms, err := extension.GetLocalMetadataService(constant.DEFAULT_Key) + if err != nil { + logger.Warnf("could not init metadata service", err) + return + } + + if !IsProvider() || exporting.Load() { + return + } + + // In theory, we can use sync.Once + // But sync.Once is not reentrant. + // Now the invocation chain is createRegistry -> tryInitMetadataService -> metadataServiceExporter.export + // -> createRegistry -> initMetadataService... + // So using sync.Once will result in dead lock + exporting.Store(true) + + expt := extension.GetMetadataServiceExporter(constant.DEFAULT_Key, ms) + if expt == nil { + logger.Warnf("get metadata service exporter failed, pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/exporter/configurable\"") + return + } + + err = expt.Export(nil) + if err != nil { + logger.Errorf("could not export the metadata service, err = %s", err.Error()) + return + } + + // report interface-app mapping + err = publishMapping(expt) + if err != nil { + logger.Errorf("Publish interface-application mapping failed, got error %#v", err) + } +} + +// OnEvent only handle ServiceConfigExportedEvent +func publishMapping(sc exporter.MetadataServiceExporter) error { + urls := sc.GetExportedURLs() + + for _, u := range urls { + err := extension.GetGlobalServiceNameMapping().Map(u) + if err != nil { + return perrors.WithMessage(err, "could not map the service: "+u.String()) + } + } + return nil +} diff --git a/config/service_config.go b/config/service_config.go index 3104831a2e..622c54c9a2 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -230,7 +230,8 @@ func (svc *ServiceConfig) Export() error { if ivkURL.GetParam(constant.INTERFACE_KEY, "") == constant.METADATA_SERVICE_NAME { ms, err := extension.GetLocalMetadataService("") if err != nil { - return err + logger.Warnf("export org.apache.dubbo.metadata.MetadataService failed beacause of %s ! pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"", err) + return nil } ms.SetMetadataServiceURL(ivkURL) } @@ -410,13 +411,6 @@ func (svc *ServiceConfig) GetExportedUrls() []*common.URL { return nil } -func (svc *ServiceConfig) publishServiceDefinition(url *common.URL) { - //svc.rootConfig.MetadataReport. - if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil { - remoteMetadataService.PublishServiceDefinition(url) - } -} - // postProcessConfig asks registered ConfigPostProcessor to post-process the current ServiceConfig. func (svc *ServiceConfig) postProcessConfig(url *common.URL) { for _, p := range extension.GetConfigPostProcessors() { diff --git a/imports/imports.go b/imports/imports.go index 60f238e982..c5f757c083 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -29,6 +29,7 @@ import ( _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/zookeeper" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter/configurable" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/local" _ "dubbo.apache.org/dubbo-go/v3/metadata/service/remote" _ "dubbo.apache.org/dubbo-go/v3/metrics/prometheus" diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go index db6310ee81..23765d7489 100644 --- a/metadata/report/delegate/delegate_report.go +++ b/metadata/report/delegate/delegate_report.go @@ -179,7 +179,7 @@ func (mr *MetadataReport) StoreProviderMetadata(identifier *identifier.MetadataI // storeMetadataTask will delegate to call remote metadata's sdk to store func (mr *MetadataReport) storeMetadataTask(role int, identifier *identifier.MetadataIdentifier, definer interface{}) { - logger.Infof("store provider metadata. Identifier :%v ; definition: %v .", identifier, definer) + logger.Infof("publish provider identifier and definition: Identifier :%v ; definition: %v .", identifier, definer) mr.allMetadataReportsLock.Lock() mr.allMetadataReports[identifier] = definer mr.allMetadataReportsLock.Unlock() diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go index 551d79d56d..5675b65e79 100644 --- a/metadata/service/exporter/configurable/exporter.go +++ b/metadata/service/exporter/configurable/exporter.go @@ -18,17 +18,13 @@ package configurable import ( - "strconv" "sync" ) -import ( - "github.com/pkg/errors" -) - import ( "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/config" _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata" @@ -45,6 +41,10 @@ type MetadataServiceExporter struct { metadataService service.MetadataService } +func init() { + extension.SetMetadataServiceExporter(constant.DEFAULT_Key, NewMetadataServiceExporter) +} + // NewMetadataServiceExporter will return a service_exporter.MetadataServiceExporter with the specified metadata service func NewMetadataServiceExporter(metadataService service.MetadataService) exporter.MetadataServiceExporter { return &MetadataServiceExporter{ @@ -55,9 +55,6 @@ func NewMetadataServiceExporter(metadataService service.MetadataService) exporte // Export will export the metadataService func (exporter *MetadataServiceExporter) Export(url *common.URL) error { if !exporter.IsExported() { - if url == nil || url.SubURL == nil { - return errors.New("metadata server url is nil, pls check your configuration") - } version, _ := exporter.metadataService.Version() exporter.lock.Lock() defer exporter.lock.Unlock() @@ -66,7 +63,6 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error { SetProtocolIDs(constant.DEFAULT_PROTOCOL). AddRCProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfigBuilder(). SetName(constant.DEFAULT_PROTOCOL). - SetPort(strconv.Itoa(constant.DEFAULT_METADATAPORT)). Build()). SetRegistryIDs("N/A"). SetInterface(constant.METADATA_SERVICE_NAME). diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go index 772a8df8d8..da42bf4165 100644 --- a/metadata/service/exporter/configurable/exporter_test.go +++ b/metadata/service/exporter/configurable/exporter_test.go @@ -58,11 +58,6 @@ func TestConfigurableExporter(t *testing.T) { metadataService, _ := local.GetLocalMetadataService() exported := NewMetadataServiceExporter(metadataService) - t.Run("configurableExporterUrlNil", func(t *testing.T) { - assert.Equal(t, false, exported.IsExported()) - assert.Error(t, exported.Export(nil), "metadata server url is nil, pls check your configuration") - }) - t.Run("configurableExporter", func(t *testing.T) { registryURL, _ := common.NewURL("service-discovery://localhost:12345") subURL, _ := common.NewURL("dubbo://localhost:20003") @@ -70,7 +65,7 @@ func TestConfigurableExporter(t *testing.T) { assert.Equal(t, false, exported.IsExported()) assert.NoError(t, exported.Export(registryURL)) assert.Equal(t, true, exported.IsExported()) - assert.Regexp(t, "dubbo://:20005/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) + assert.Regexp(t, "dubbo://:[0-9]{1,}/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String()) exported.Unexport() assert.Equal(t, false, exported.IsExported()) }) diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go index 794d463aff..c5c1418ded 100644 --- a/metadata/service/local/service.go +++ b/metadata/service/local/service.go @@ -194,6 +194,9 @@ func (mts *MetadataService) UnsubscribeURL(url *common.URL) error { // PublishServiceDefinition: publish url's service metadata info, and write into memory func (mts *MetadataService) PublishServiceDefinition(url *common.URL) error { + if common.RoleType(common.CONSUMER).Role() == url.GetParam(constant.SIDE_KEY, "") { + return nil + } interfaceName := url.GetParam(constant.INTERFACE_KEY, "") isGeneric := url.GetParamBool(constant.GENERIC_KEY, false) if len(interfaceName) > 0 && !isGeneric { diff --git a/protocol/dubbo3/dubbo3_invoker_test.go b/protocol/dubbo3/dubbo3_invoker_test.go index f1df040493..b39af5ba8f 100644 --- a/protocol/dubbo3/dubbo3_invoker_test.go +++ b/protocol/dubbo3/dubbo3_invoker_test.go @@ -30,6 +30,7 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/common" + _ "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter/configurable" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index 3c2a11235e..c1d9839d27 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -36,10 +36,8 @@ import ( "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/config" "dubbo.apache.org/dubbo-go/v3/metadata/mapping" "dubbo.apache.org/dubbo-go/v3/metadata/service" - "dubbo.apache.org/dubbo-go/v3/metadata/service/exporter/configurable" "dubbo.apache.org/dubbo-go/v3/metadata/service/local" "dubbo.apache.org/dubbo-go/v3/registry" "dubbo.apache.org/dubbo-go/v3/registry/event" @@ -69,9 +67,6 @@ type serviceDiscoveryRegistry struct { } func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) { - - tryInitMetadataService(url) - serviceDiscovery, err := creatServiceDiscovery(url) if err != nil { return nil, err @@ -303,50 +298,3 @@ func (s *serviceDiscoveryRegistry) findMappedServices(url *common.URL) *gxset.Ha var ( exporting = &atomic.Bool{} ) - -// tryInitMetadataService will try to initialize metadata service -// TODO (move to somewhere) -func tryInitMetadataService(url *common.URL) { - - ms, err := local.GetLocalMetadataService() - if err != nil { - logger.Errorf("could not init metadata service", err) - } - - if !config.IsProvider() || exporting.Load() { - return - } - - // In theory, we can use sync.Once - // But sync.Once is not reentrant. - // Now the invocation chain is createRegistry -> tryInitMetadataService -> metadataServiceExporter.export - // -> createRegistry -> initMetadataService... - // So using sync.Once will result in dead lock - exporting.Store(true) - - expt := configurable.NewMetadataServiceExporter(ms) - - err = expt.Export(url) - if err != nil { - logger.Errorf("could not export the metadata service", err) - } - - // report interface-app mapping - err = publishMapping(expt.(*configurable.MetadataServiceExporter).ServiceConfig) - if err != nil { - logger.Errorf("Publish interface-application mapping failed, got error %#v", err) - } -} - -// OnEvent only handle ServiceConfigExportedEvent -func publishMapping(sc *config.ServiceConfig) error { - urls := sc.GetExportedUrls() - - for _, u := range urls { - err := extension.GetGlobalServiceNameMapping().Map(u) - if err != nil { - return perrors.WithMessage(err, "could not map the service: "+u.String()) - } - } - return nil -} From f8bdd4556d7a2f8afdba622dbaa99164c8354e15 Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Thu, 7 Oct 2021 16:34:17 +0800 Subject: [PATCH 144/148] refactor(config): refactor Refer method of reference_config (#1504) * refactor(config): refactor Refer method of reference_config * style(config): go fmt * style(config): remove comments * style(config): go fmt * fix(config): fix array insertion bug --- config/reference_config.go | 107 +++++++++++++++---------------------- 1 file changed, 42 insertions(+), 65 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index 1055e75feb..4dc871ab92 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -114,91 +114,75 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { cfgURL.AddParam(constant.ForceUseTag, "true") } rc.postProcessConfig(cfgURL) - if rc.URL != "" { - // 1. user specified URL, could be peer-to-peer address, or register center's address. + + // retrieving urls from config, and appending the urls to rc.urls + if rc.URL != "" { // use user-specific urls + /* + Two types of URL are allowed for rc.URL: direct url and registry url, they will be handled in different ways. + For example, "tri://localhost:10000" is a direct url, and "registry://localhost:2181" is a registry url. + rc.URL: "tri://localhost:10000;tri://localhost:10001;registry://localhost:2181", + urlStrings = []string{"tri://localhost:10000", "tri://localhost:10001", "registry://localhost:2181"}. + */ urlStrings := gxstrings.RegSplit(rc.URL, "\\s*[;]+\\s*") for _, urlStr := range urlStrings { serviceURL, err := common.NewURL(urlStr) if err != nil { panic(fmt.Sprintf("url configuration error, please check your configuration, user specified URL %v refer error, error message is %v ", urlStr, err.Error())) } - if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { + if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { // URL stands for a registry protocol serviceURL.SubURL = cfgURL rc.urls = append(rc.urls, serviceURL) - } else { + } else { // URL stands for a direct address if serviceURL.Path == "" { serviceURL.Path = "/" + rc.InterfaceName } - // merge url need to do + // merge URL param with cfgURL, others are same as serviceURL newURL := common.MergeURL(serviceURL, cfgURL) rc.urls = append(rc.urls, newURL) } } - } else { - // 2. assemble SubURL from register center's configuration mode + } else { // use registry configs rc.urls = loadRegistries(rc.RegistryIDs, rc.rootConfig.Registries, common.CONSUMER) - // set url to regURLs for _, regURL := range rc.urls { regURL.SubURL = cfgURL } } - if len(rc.urls) == 1 { - if rc.urls[0].Protocol == constant.SERVICE_REGISTRY_PROTOCOL { - rc.invoker = extension.GetProtocol("registry").Refer(rc.urls[0]) + // Get invokers according to rc.urls + var ( + invoker protocol.Invoker + regURL *common.URL + ) + invokers := make([]protocol.Invoker, len(rc.urls)) + for i, u := range rc.urls { + if u.Protocol == constant.SERVICE_REGISTRY_PROTOCOL { + invoker = extension.GetProtocol("registry").Refer(u) } else { - rc.invoker = extension.GetProtocol(rc.urls[0].Protocol).Refer(rc.urls[0]) + invoker = extension.GetProtocol(u.Protocol).Refer(u) } - // c.URL != "" is direct call if rc.URL != "" { - //filter - rc.invoker = protocolwrapper.BuildInvokerChain(rc.invoker, constant.REFERENCE_FILTER_KEY) - - // cluster - invokers := make([]protocol.Invoker, 0, len(rc.urls)) - invokers = append(invokers, rc.invoker) - // TODO(decouple from directory, config should not depend on directory module) - var hitClu string - // not a registry url, must be direct invoke. - hitClu = constant.FAILOVER_CLUSTER_NAME - if len(invokers) > 0 { - u := invokers[0].GetURL() - if nil != &u { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) - } - } + invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) + } - cluster := extension.GetCluster(hitClu) - // If 'zone-aware' policy select, the invoker wrap sequence would be: - // ZoneAwareClusterInvoker(StaticDirectory) -> - // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - rc.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + invokers[i] = invoker + if u.Protocol == constant.REGISTRY_PROTOCOL { + regURL = u } - } else { - invokers := make([]protocol.Invoker, 0, len(rc.urls)) - var regURL *common.URL - for _, u := range rc.urls { - var invoker protocol.Invoker - if u.Protocol == constant.SERVICE_REGISTRY_PROTOCOL { - invoker = extension.GetProtocol("registry").Refer(u) - } else { - invoker = extension.GetProtocol(u.Protocol).Refer(u) - } + } - // c.URL != "" is direct call - if rc.URL != "" { - //filter - invoker = protocolwrapper.BuildInvokerChain(invoker, constant.REFERENCE_FILTER_KEY) - } - invokers = append(invokers, invoker) - if u.Protocol == constant.REGISTRY_PROTOCOL { - regURL = u + // TODO(hxmhlt): decouple from directory, config should not depend on directory module + if len(invokers) == 1 { + rc.invoker = invokers[0] + if rc.URL != "" { + hitClu := constant.FAILOVER_CLUSTER_NAME + if u := rc.invoker.GetURL(); u != nil { + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) } + rc.invoker = extension.GetCluster(hitClu).Join(directory.NewStaticDirectory(invokers)) } - - // TODO(decouple from directory, config should not depend on directory module) + } else { var hitClu string if regURL != nil { // for multi-subscription scenario, use 'zone-aware' policy by default @@ -206,20 +190,13 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { } else { // not a registry url, must be direct invoke. hitClu = constant.FAILOVER_CLUSTER_NAME - if len(invokers) > 0 { - u := invokers[0].GetURL() - if nil != &u { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) - } + if u := invokers[0].GetURL(); u != nil { + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) } } - - cluster := extension.GetCluster(hitClu) - // If 'zone-aware' policy select, the invoker wrap sequence would be: - // ZoneAwareClusterInvoker(StaticDirectory) -> - // FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker - rc.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + rc.invoker = extension.GetCluster(hitClu).Join(directory.NewStaticDirectory(invokers)) } + // publish consumer's metadata publishServiceDefinition(cfgURL) // create proxy From c22d9c3e529f05cfd5bfc064ff93bf423db39886 Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sat, 9 Oct 2021 20:55:08 +0800 Subject: [PATCH 145/148] fix: change service name from nacos instance service name to app name (#1508) --- registry/nacos/service_discovery.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index b820eb8ce5..68bcb6f245 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -160,8 +160,10 @@ func (n *nacosServiceDiscovery) GetInstances(serviceName string) []registry.Serv delete(metadata, idKey) res = append(res, ®istry.DefaultServiceInstance{ - ID: id, - ServiceName: ins.ServiceName, + ID: id, + // ins.ServiceName is nacos service name like 'DEFAULT_GROUP@@MyAppName", + // which is not the service name we wanted, so we use serviceName directly. + ServiceName: serviceName, Host: ins.Ip, Port: int(ins.Port), Enable: ins.Enable, From e213f97fda576a1193622ed8e41b7caca615bba2 Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Mon, 11 Oct 2021 12:53:21 +0800 Subject: [PATCH 146/148] refactor(cluster): refactor cluster package (#1507) * refactor(cluster): refactor cluster/cluster * refactor(cluster): refactor directory and loadbalance * fix(cluster): fix import cycles * style(cluster): go fmt * style(cluster): format code by 3-block style * style(cluster): go fmt * fix(cluster): fix key bugs * fix(cluster): fix apache license * fix(cluster): fix constant name * style(cluster): go fmt --- .../available/cluster.go} | 22 ++-- .../available/cluster_invoker.go} | 25 ++-- .../available/cluster_invoker_test.go} | 13 ++- .../base/cluster_invoker.go} | 79 ++++++------- .../base/cluster_invoker_test.go} | 33 +++--- .../broadcast/cluster.go} | 24 ++-- .../broadcast/cluster_invoker.go} | 23 ++-- .../broadcast/cluster_invoker_test.go} | 17 +-- cluster/{ => cluster}/cluster.go | 3 +- cluster/{ => cluster}/cluster_interceptor.go | 0 .../failback/cluster.go} | 24 ++-- .../failback/cluster_invoker.go} | 40 +++---- .../failback/cluster_test.go} | 29 ++--- .../failfast/cluster.go} | 24 ++-- .../failfast/cluster_invoker.go} | 27 ++--- .../failfast/cluster_test.go} | 23 ++-- .../failover/cluster.go} | 21 ++-- .../failover/cluster_invoker.go} | 34 +++--- .../failover/cluster_test.go} | 107 ++++-------------- .../failsafe/cluster.go} | 24 ++-- .../failsafe/cluster_invoker.go} | 24 ++-- .../failsafe/cluster_test.go} | 23 ++-- .../forking/cluster.go} | 24 ++-- .../forking/cluster_invoker.go} | 28 ++--- .../forking/cluster_test.go} | 21 ++-- .../interceptor_invoker.go | 45 +++++++- cluster/cluster/mock.go | 106 +++++++++++++++++ .../zoneaware/cluster.go} | 19 ++-- .../zoneaware/cluster_interceptor.go} | 12 +- .../zoneaware/cluster_invoker.go} | 26 ++--- .../zoneaware/cluster_invoker_test.go} | 33 +++--- .../{mock_cluster.go => import.go} | 29 ++--- .../{base_directory.go => base/directory.go} | 26 ++--- .../directory_test.go} | 16 +-- cluster/{ => directory}/directory.go | 2 +- .../directory.go} | 29 ++--- .../directory_test.go} | 6 +- .../consistenthashing/loadbalance.go | 80 +++++++++++++ .../loadbalance_test.go} | 12 +- .../selector.go} | 80 ++----------- .../loadbalance.go} | 25 ++-- .../loadbalance_test.go} | 6 +- cluster/{ => loadbalance}/loadbalance.go | 2 +- .../{random.go => random/loadbalance.go} | 25 ++-- .../loadbalance_test.go} | 28 ++--- .../loadbalance.go} | 34 +++--- .../loadbalance_test.go} | 6 +- common/constant/cluster.go | 11 +- common/constant/loadbalance.go | 25 ++++ common/extension/cluster.go | 2 +- common/extension/cluster_interceptor.go | 60 ---------- common/extension/loadbalance.go | 8 +- common/extension/registry_directory.go | 6 +- config/reference_config.go | 16 +-- filter/filter_impl/import.go | 3 +- imports/imports.go | 29 ++++- registry/directory/directory.go | 19 ++-- registry/protocol/protocol_test.go | 2 +- 58 files changed, 818 insertions(+), 722 deletions(-) rename cluster/{cluster_impl/available_cluster.go => cluster/available/cluster.go} (68%) rename cluster/{cluster_impl/available_cluster_invoker.go => cluster/available/cluster_invoker.go} (66%) rename cluster/{cluster_impl/available_cluster_invoker_test.go => cluster/available/cluster_invoker_test.go} (87%) rename cluster/{cluster_impl/base_cluster_invoker.go => cluster/base/cluster_invoker.go} (69%) rename cluster/{cluster_impl/base_cluster_invoker_test.go => cluster/base/cluster_invoker_test.go} (65%) rename cluster/{cluster_impl/broadcast_cluster.go => cluster/broadcast/cluster.go} (69%) rename cluster/{cluster_impl/broadcast_cluster_invoker.go => cluster/broadcast/cluster_invoker.go} (70%) rename cluster/{cluster_impl/broadcast_cluster_invoker_test.go => cluster/broadcast/cluster_invoker_test.go} (86%) rename cluster/{ => cluster}/cluster.go (90%) rename cluster/{ => cluster}/cluster_interceptor.go (100%) rename cluster/{cluster_impl/failback_cluster.go => cluster/failback/cluster.go} (68%) rename cluster/{cluster_impl/failback_cluster_invoker.go => cluster/failback/cluster_invoker.go} (82%) rename cluster/{cluster_impl/failback_cluster_test.go => cluster/failback/cluster_test.go} (89%) rename cluster/{cluster_impl/failfast_cluster.go => cluster/failfast/cluster.go} (68%) rename cluster/{cluster_impl/failfast_cluster_invoker.go => cluster/failfast/cluster_invoker.go} (60%) rename cluster/{cluster_impl/failfast_cluster_test.go => cluster/failfast/cluster_test.go} (83%) rename cluster/{cluster_impl/failover_cluster.go => cluster/failover/cluster.go} (71%) rename cluster/{cluster_impl/failover_cluster_invoker.go => cluster/failover/cluster_invoker.go} (79%) rename cluster/{cluster_impl/failover_cluster_test.go => cluster/failover/cluster_test.go} (59%) rename cluster/{cluster_impl/failsafe_cluster.go => cluster/failsafe/cluster.go} (67%) rename cluster/{cluster_impl/failsafe_cluster_invoker.go => cluster/failsafe/cluster_invoker.go} (76%) rename cluster/{cluster_impl/failsafe_cluster_test.go => cluster/failsafe/cluster_test.go} (83%) rename cluster/{cluster_impl/forking_cluster.go => cluster/forking/cluster.go} (69%) rename cluster/{cluster_impl/forking_cluster_invoker.go => cluster/forking/cluster_invoker.go} (76%) rename cluster/{cluster_impl/forking_cluster_test.go => cluster/forking/cluster_test.go} (86%) rename cluster/{cluster_impl => cluster}/interceptor_invoker.go (63%) create mode 100644 cluster/cluster/mock.go rename cluster/{cluster_impl/zone_aware_cluster.go => cluster/zoneaware/cluster.go} (73%) rename cluster/{cluster_impl/zone_aware_cluster_interceptor.go => cluster/zoneaware/cluster_interceptor.go} (80%) rename cluster/{cluster_impl/zone_aware_cluster_invoker.go => cluster/zoneaware/cluster_invoker.go} (82%) rename cluster/{cluster_impl/zone_aware_cluster_invoker_test.go => cluster/zoneaware/cluster_invoker_test.go} (88%) rename cluster/cluster_impl/{mock_cluster.go => import.go} (56%) rename cluster/directory/{base_directory.go => base/directory.go} (76%) rename cluster/directory/{base_directory_test.go => base/directory_test.go} (92%) rename cluster/{ => directory}/directory.go (98%) rename cluster/directory/{static_directory.go => static/directory.go} (76%) rename cluster/directory/{static_directory_test.go => static/directory_test.go} (94%) create mode 100644 cluster/loadbalance/consistenthashing/loadbalance.go rename cluster/loadbalance/{consistent_hash_test.go => consistenthashing/loadbalance_test.go} (94%) rename cluster/loadbalance/{consistent_hash.go => consistenthashing/selector.go} (52%) rename cluster/loadbalance/{least_active.go => leastactive/loadbalance.go} (81%) rename cluster/loadbalance/{least_active_test.go => leastactive/loadbalance_test.go} (95%) rename cluster/{ => loadbalance}/loadbalance.go (98%) rename cluster/loadbalance/{random.go => random/loadbalance.go} (75%) rename cluster/loadbalance/{random_test.go => random/loadbalance_test.go} (82%) rename cluster/loadbalance/{round_robin.go => roundrobin/loadbalance.go} (81%) rename cluster/loadbalance/{round_robin_test.go => roundrobin/loadbalance_test.go} (95%) create mode 100644 common/constant/loadbalance.go delete mode 100644 common/extension/cluster_interceptor.go diff --git a/cluster/cluster_impl/available_cluster.go b/cluster/cluster/available/cluster.go similarity index 68% rename from cluster/cluster_impl/available_cluster.go rename to cluster/cluster/available/cluster.go index 23a535eaa4..4320c18d7c 100644 --- a/cluster/cluster_impl/available_cluster.go +++ b/cluster/cluster/available/cluster.go @@ -15,30 +15,30 @@ * limitations under the License. */ -package cluster_impl +package available import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type availableCluster struct{} - -const available = "available" - func init() { - extension.SetCluster(available, NewAvailableCluster) + extension.SetCluster(constant.ClusterKeyAvailable, NewAvailableCluster) } +type cluster struct{} + // NewAvailableCluster returns a cluster instance // // Obtain available service providers -func NewAvailableCluster() cluster.Cluster { - return &availableCluster{} +func NewAvailableCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *availableCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(NewAvailableClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(NewClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/available_cluster_invoker.go b/cluster/cluster/available/cluster_invoker.go similarity index 66% rename from cluster/cluster_impl/available_cluster_invoker.go rename to cluster/cluster/available/cluster_invoker.go index a9c75ec75c..fc6dea3170 100644 --- a/cluster/cluster_impl/available_cluster_invoker.go +++ b/cluster/cluster/available/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package available import ( "context" @@ -27,29 +27,30 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type availableClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -// NewAvailableClusterInvoker returns a cluster invoker instance -func NewAvailableClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &availableClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +// NewClusterInvoker returns a cluster invoker instance +func NewClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } -func (invoker *availableClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) - err := invoker.checkInvokers(invokers, invocation) +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) + err := invoker.CheckInvokers(invokers, invocation) if err != nil { return &protocol.RPCResult{Err: err} } - err = invoker.checkWhetherDestroyed() + err = invoker.CheckWhetherDestroyed() if err != nil { return &protocol.RPCResult{Err: err} } diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster/available/cluster_invoker_test.go similarity index 87% rename from cluster/cluster_impl/available_cluster_invoker_test.go rename to cluster/cluster/available/cluster_invoker_test.go index c97f4f2652..22d6981136 100644 --- a/cluster/cluster_impl/available_cluster_invoker_test.go +++ b/cluster/cluster/available/cluster_invoker_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package available import ( "context" @@ -31,8 +31,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -45,14 +46,14 @@ var availableUrl, _ = common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) func registerAvailable(invoker *mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + extension.SetLoadbalance("random", random.NewLoadBalance) availableCluster := NewAvailableCluster() invokers := []protocol.Invoker{} invokers = append(invokers, invoker) invoker.EXPECT().GetUrl().Return(availableUrl) - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := availableCluster.Join(staticDir) return clusterInvoker } @@ -64,7 +65,7 @@ func TestAvailableClusterInvokerSuccess(t *testing.T) { invoker := mock.NewMockInvoker(ctrl) clusterInvoker := registerAvailable(invoker) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} invoker.EXPECT().IsAvailable().Return(true) invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster/base/cluster_invoker.go similarity index 69% rename from cluster/cluster_impl/base_cluster_invoker.go rename to cluster/cluster/base/cluster_invoker.go index 1d1f86636c..5b4958d753 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster/base/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package base import ( perrors "github.com/pkg/errors" @@ -24,7 +24,8 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -32,61 +33,61 @@ import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) -type baseClusterInvoker struct { - directory cluster.Directory - availablecheck bool - destroyed *atomic.Bool - stickyInvoker protocol.Invoker +type ClusterInvoker struct { + Directory directory.Directory + AvailableCheck bool + Destroyed *atomic.Bool + StickyInvoker protocol.Invoker } -func newBaseClusterInvoker(directory cluster.Directory) baseClusterInvoker { - return baseClusterInvoker{ - directory: directory, - availablecheck: true, - destroyed: atomic.NewBool(false), +func NewClusterInvoker(directory directory.Directory) ClusterInvoker { + return ClusterInvoker{ + Directory: directory, + AvailableCheck: true, + Destroyed: atomic.NewBool(false), } } -func (invoker *baseClusterInvoker) GetURL() *common.URL { - return invoker.directory.GetURL() +func (invoker *ClusterInvoker) GetURL() *common.URL { + return invoker.Directory.GetURL() } -func (invoker *baseClusterInvoker) Destroy() { +func (invoker *ClusterInvoker) Destroy() { // this is must atom operation - if invoker.destroyed.CAS(false, true) { - invoker.directory.Destroy() + if invoker.Destroyed.CAS(false, true) { + invoker.Directory.Destroy() } } -func (invoker *baseClusterInvoker) IsAvailable() bool { - if invoker.stickyInvoker != nil { - return invoker.stickyInvoker.IsAvailable() +func (invoker *ClusterInvoker) IsAvailable() bool { + if invoker.StickyInvoker != nil { + return invoker.StickyInvoker.IsAvailable() } - return invoker.directory.IsAvailable() + return invoker.Directory.IsAvailable() } -// check invokers availables -func (invoker *baseClusterInvoker) checkInvokers(invokers []protocol.Invoker, invocation protocol.Invocation) error { +// CheckInvokers checks invokers' status if is available or not +func (invoker *ClusterInvoker) CheckInvokers(invokers []protocol.Invoker, invocation protocol.Invocation) error { if len(invokers) == 0 { ip := common.GetLocalIp() return perrors.Errorf("Failed to invoke the method %v. No provider available for the service %v from "+ "registry %v on the consumer %v using the dubbo version %v .Please check if the providers have been started and registered.", - invocation.MethodName(), invoker.directory.GetURL().SubURL.Key(), invoker.directory.GetURL().String(), ip, constant.Version) + invocation.MethodName(), invoker.Directory.GetURL().SubURL.Key(), invoker.Directory.GetURL().String(), ip, constant.Version) } return nil } -// check cluster invoker is destroyed or not -func (invoker *baseClusterInvoker) checkWhetherDestroyed() error { - if invoker.destroyed.Load() { +// CheckWhetherDestroyed checks if cluster invoker was destroyed or not +func (invoker *ClusterInvoker) CheckWhetherDestroyed() error { + if invoker.Destroyed.Load() { ip := common.GetLocalIp() return perrors.Errorf("Rpc cluster invoker for %v on consumer %v use dubbo version %v is now destroyed! can not invoke any more. ", - invoker.directory.GetURL().Service(), ip, constant.Version) + invoker.Directory.GetURL().Service(), ip, constant.Version) } return nil } -func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { +func (invoker *ClusterInvoker) DoSelect(lb loadbalance.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { var selectedInvoker protocol.Invoker if len(invokers) <= 0 { return selectedInvoker @@ -97,24 +98,24 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p // Get the service method sticky config if have sticky = url.GetMethodParamBool(invocation.MethodName(), constant.STICKY_KEY, sticky) - if invoker.stickyInvoker != nil && !isInvoked(invoker.stickyInvoker, invokers) { - invoker.stickyInvoker = nil + if invoker.StickyInvoker != nil && !isInvoked(invoker.StickyInvoker, invokers) { + invoker.StickyInvoker = nil } - if sticky && invoker.availablecheck && - invoker.stickyInvoker != nil && invoker.stickyInvoker.IsAvailable() && - (invoked == nil || !isInvoked(invoker.stickyInvoker, invoked)) { - return invoker.stickyInvoker + if sticky && invoker.AvailableCheck && + invoker.StickyInvoker != nil && invoker.StickyInvoker.IsAvailable() && + (invoked == nil || !isInvoked(invoker.StickyInvoker, invoked)) { + return invoker.StickyInvoker } selectedInvoker = invoker.doSelectInvoker(lb, invocation, invokers, invoked) if sticky { - invoker.stickyInvoker = selectedInvoker + invoker.StickyInvoker = selectedInvoker } return selectedInvoker } -func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { +func (invoker *ClusterInvoker) doSelectInvoker(lb loadbalance.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { if len(invokers) == 0 { return nil } @@ -131,7 +132,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc selectedInvoker := lb.Select(invokers, invocation) // judge if the selected Invoker is invoked and available - if (!selectedInvoker.IsAvailable() && invoker.availablecheck) || isInvoked(selectedInvoker, invoked) { + if (!selectedInvoker.IsAvailable() && invoker.AvailableCheck) || isInvoked(selectedInvoker, invoked) { protocol.SetInvokerUnhealthyStatus(selectedInvoker) otherInvokers := getOtherInvokers(invokers, selectedInvoker) // do reselect @@ -170,7 +171,7 @@ func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) boo return false } -func getLoadBalance(invoker protocol.Invoker, invocation protocol.Invocation) cluster.LoadBalance { +func GetLoadBalance(invoker protocol.Invoker, invocation protocol.Invocation) loadbalance.LoadBalance { url := invoker.GetURL() methodName := invocation.MethodName() diff --git a/cluster/cluster_impl/base_cluster_invoker_test.go b/cluster/cluster/base/cluster_invoker_test.go similarity index 65% rename from cluster/cluster_impl/base_cluster_invoker_test.go rename to cluster/cluster/base/cluster_invoker_test.go index 81ce4905bf..fa24940e9e 100644 --- a/cluster/cluster_impl/base_cluster_invoker_test.go +++ b/cluster/cluster/base/cluster_invoker_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package base import ( "fmt" @@ -27,7 +27,8 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" @@ -39,20 +40,20 @@ const ( ) func TestStickyNormal(t *testing.T) { - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker for i := 0; i < 10; i++ { url, _ := common.NewURL(fmt.Sprintf(baseClusterInvokerFormat, i)) url.SetParam("sticky", "true") - invokers = append(invokers, NewMockInvoker(url, 1)) + invokers = append(invokers, clusterpkg.NewMockInvoker(url, 1)) } - base := &baseClusterInvoker{} - base.availablecheck = true - invoked := []protocol.Invoker{} + base := &ClusterInvoker{} + base.AvailableCheck = true + var invoked []protocol.Invoker - tmpRandomBalance := loadbalance.NewRandomLoadBalance() + tmpRandomBalance := random.NewLoadBalance() tmpInvocation := invocation.NewRPCInvocation(baseClusterInvokerMethodName, nil, nil) - result := base.doSelect(tmpRandomBalance, tmpInvocation, invokers, invoked) - result1 := base.doSelect(tmpRandomBalance, tmpInvocation, invokers, invoked) + result := base.DoSelect(tmpRandomBalance, tmpInvocation, invokers, invoked) + result1 := base.DoSelect(tmpRandomBalance, tmpInvocation, invokers, invoked) assert.Equal(t, result, result1) } @@ -61,14 +62,14 @@ func TestStickyNormalWhenError(t *testing.T) { for i := 0; i < 10; i++ { url, _ := common.NewURL(fmt.Sprintf(baseClusterInvokerFormat, i)) url.SetParam("sticky", "true") - invokers = append(invokers, NewMockInvoker(url, 1)) + invokers = append(invokers, clusterpkg.NewMockInvoker(url, 1)) } - base := &baseClusterInvoker{} - base.availablecheck = true + base := &ClusterInvoker{} + base.AvailableCheck = true - invoked := []protocol.Invoker{} - result := base.doSelect(loadbalance.NewRandomLoadBalance(), invocation.NewRPCInvocation(baseClusterInvokerMethodName, nil, nil), invokers, invoked) + var invoked []protocol.Invoker + result := base.DoSelect(random.NewLoadBalance(), invocation.NewRPCInvocation(baseClusterInvokerMethodName, nil, nil), invokers, invoked) invoked = append(invoked, result) - result1 := base.doSelect(loadbalance.NewRandomLoadBalance(), invocation.NewRPCInvocation(baseClusterInvokerMethodName, nil, nil), invokers, invoked) + result1 := base.DoSelect(random.NewLoadBalance(), invocation.NewRPCInvocation(baseClusterInvokerMethodName, nil, nil), invokers, invoked) assert.NotEqual(t, result, result1) } diff --git a/cluster/cluster_impl/broadcast_cluster.go b/cluster/cluster/broadcast/cluster.go similarity index 69% rename from cluster/cluster_impl/broadcast_cluster.go rename to cluster/cluster/broadcast/cluster.go index c2e8955b44..bc80550c17 100644 --- a/cluster/cluster_impl/broadcast_cluster.go +++ b/cluster/cluster/broadcast/cluster.go @@ -15,31 +15,31 @@ * limitations under the License. */ -package cluster_impl +package broadcast import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type broadcastCluster struct{} - -const broadcast = "broadcast" - func init() { - extension.SetCluster(broadcast, NewBroadcastCluster) + extension.SetCluster(constant.ClusterKeyBroadcast, NewCluster) } -// NewBroadcastCluster returns a broadcast cluster instance. +type cluster struct{} + +// NewCluster returns a broadcast cluster instance. // // Calling all providers' broadcast one by one. All errors will be reported. // It is usually used to notify all providers to update local resource information such as caches or logs. -func NewBroadcastCluster() cluster.Cluster { - return &broadcastCluster{} +func NewCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *broadcastCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newBroadcastClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/broadcast_cluster_invoker.go b/cluster/cluster/broadcast/cluster_invoker.go similarity index 70% rename from cluster/cluster_impl/broadcast_cluster_invoker.go rename to cluster/cluster/broadcast/cluster_invoker.go index 93a1b13637..50286068f8 100644 --- a/cluster/cluster_impl/broadcast_cluster_invoker.go +++ b/cluster/cluster/broadcast/cluster_invoker.go @@ -15,36 +15,37 @@ * limitations under the License. */ -package cluster_impl +package broadcast import ( "context" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type broadcastClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newBroadcastClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &broadcastClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } // nolint -func (invoker *broadcastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) - err := invoker.checkInvokers(invokers, invocation) +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) + err := invoker.CheckInvokers(invokers, invocation) if err != nil { return &protocol.RPCResult{Err: err} } - err = invoker.checkWhetherDestroyed() + err = invoker.CheckWhetherDestroyed() if err != nil { return &protocol.RPCResult{Err: err} } diff --git a/cluster/cluster_impl/broadcast_cluster_invoker_test.go b/cluster/cluster/broadcast/cluster_invoker_test.go similarity index 86% rename from cluster/cluster_impl/broadcast_cluster_invoker_test.go rename to cluster/cluster/broadcast/cluster_invoker_test.go index 678598e9a4..356151d78f 100644 --- a/cluster/cluster_impl/broadcast_cluster_invoker_test.go +++ b/cluster/cluster/broadcast/cluster_invoker_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package broadcast import ( "context" @@ -31,8 +31,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -45,7 +46,7 @@ var broadcastUrl, _ = common.NewURL( fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) func registerBroadcast(mockInvokers ...*mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) + extension.SetLoadbalance("random", random.NewLoadBalance) invokers := []protocol.Invoker{} for i, ivk := range mockInvokers { @@ -54,9 +55,9 @@ func registerBroadcast(mockInvokers ...*mock.MockInvoker) protocol.Invoker { ivk.EXPECT().GetUrl().Return(broadcastUrl) } } - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) - broadcastCluster := NewBroadcastCluster() + broadcastCluster := NewCluster() clusterInvoker := broadcastCluster.Join(staticDir) return clusterInvoker } @@ -67,7 +68,7 @@ func TestBroadcastInvokeSuccess(t *testing.T) { invokers := make([]*mock.MockInvoker, 0) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} for i := 0; i < 3; i++ { invoker := mock.NewMockInvoker(ctrl) invokers = append(invokers, invoker) @@ -86,7 +87,7 @@ func TestBroadcastInvokeFailed(t *testing.T) { invokers := make([]*mock.MockInvoker, 0) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} mockFailedResult := &protocol.RPCResult{Err: errors.New("just failed")} for i := 0; i < 10; i++ { invoker := mock.NewMockInvoker(ctrl) diff --git a/cluster/cluster.go b/cluster/cluster/cluster.go similarity index 90% rename from cluster/cluster.go rename to cluster/cluster/cluster.go index 1a528da41c..8f810c9cfa 100644 --- a/cluster/cluster.go +++ b/cluster/cluster/cluster.go @@ -18,11 +18,12 @@ package cluster import ( + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/protocol" ) // Cluster // Extension - Cluster type Cluster interface { - Join(Directory) protocol.Invoker + Join(directory.Directory) protocol.Invoker } diff --git a/cluster/cluster_interceptor.go b/cluster/cluster/cluster_interceptor.go similarity index 100% rename from cluster/cluster_interceptor.go rename to cluster/cluster/cluster_interceptor.go diff --git a/cluster/cluster_impl/failback_cluster.go b/cluster/cluster/failback/cluster.go similarity index 68% rename from cluster/cluster_impl/failback_cluster.go rename to cluster/cluster/failback/cluster.go index 766657079f..f3a942da96 100644 --- a/cluster/cluster_impl/failback_cluster.go +++ b/cluster/cluster/failback/cluster.go @@ -15,31 +15,31 @@ * limitations under the License. */ -package cluster_impl +package failback import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failbackCluster struct{} - -const failback = "failback" - func init() { - extension.SetCluster(failback, NewFailbackCluster) + extension.SetCluster(constant.ClusterKeyFailback, NewCluster) } -// NewFailbackCluster returns a failback cluster instance +type cluster struct{} + +// NewCluster returns a failback cluster instance // // Failure automatically restored, failed to record the background request, // regular retransmission. Usually used for message notification operations. -func NewFailbackCluster() cluster.Cluster { - return &failbackCluster{} +func NewCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *failbackCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newFailbackClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster/failback/cluster_invoker.go similarity index 82% rename from cluster/cluster_impl/failback_cluster_invoker.go rename to cluster/cluster/failback/cluster_invoker.go index 38bbd7a94c..4e677fa303 100644 --- a/cluster/cluster_impl/failback_cluster_invoker.go +++ b/cluster/cluster/failback/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failback import ( "context" @@ -29,7 +29,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" @@ -42,8 +44,8 @@ import ( * * Failback */ -type failbackClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker once sync.Once ticker *time.Ticker @@ -52,9 +54,9 @@ type failbackClusterInvoker struct { taskList *queue.Queue } -func newFailbackClusterInvoker(directory cluster.Directory) protocol.Invoker { - invoker := &failbackClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + invoker := &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } retriesConfig := invoker.GetURL().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) retries, err := strconv.Atoi(retriesConfig) @@ -72,11 +74,11 @@ func newFailbackClusterInvoker(directory cluster.Directory) protocol.Invoker { return invoker } -func (invoker *failbackClusterInvoker) tryTimerTaskProc(ctx context.Context, retryTask *retryTimerTask) { +func (invoker *clusterInvoker) tryTimerTaskProc(ctx context.Context, retryTask *retryTimerTask) { invoked := make([]protocol.Invoker, 0) invoked = append(invoked, retryTask.lastInvoker) - retryInvoker := invoker.doSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked) + retryInvoker := invoker.DoSelect(retryTask.loadbalance, retryTask.invocation, retryTask.invokers, invoked) result := retryInvoker.Invoke(ctx, retryTask.invocation) if result.Error() != nil { retryTask.lastInvoker = retryInvoker @@ -84,7 +86,7 @@ func (invoker *failbackClusterInvoker) tryTimerTaskProc(ctx context.Context, ret } } -func (invoker *failbackClusterInvoker) process(ctx context.Context) { +func (invoker *clusterInvoker) process(ctx context.Context) { invoker.ticker = time.NewTicker(time.Second * 1) for range invoker.ticker.C { // check each timeout task and re-run @@ -112,7 +114,7 @@ func (invoker *failbackClusterInvoker) process(ctx context.Context) { } } -func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err error) { +func (invoker *clusterInvoker) checkRetry(retryTask *retryTimerTask, err error) { logger.Errorf("Failed retry to invoke the method %v in the service %v, wait again. The exception: %v.\n", retryTask.invocation.MethodName(), invoker.GetURL().Service(), err.Error()) retryTask.retries++ @@ -129,9 +131,9 @@ func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err } // nolint -func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) - if err := invoker.checkInvokers(invokers, invocation); err != nil { +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) + if err := invoker.CheckInvokers(invokers, invocation); err != nil { logger.Errorf("Failed to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.\n", invocation.MethodName(), invoker.GetURL().Service(), err) return &protocol.RPCResult{} @@ -148,7 +150,7 @@ func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation pr loadBalance := extension.GetLoadbalance(lb) invoked := make([]protocol.Invoker, 0, len(invokers)) - ivk := invoker.doSelect(loadBalance, invocation, invokers, invoked) + ivk := invoker.DoSelect(loadBalance, invocation, invokers, invoked) // DO INVOKE result := ivk.Invoke(ctx, invocation) if result.Error() != nil { @@ -174,8 +176,8 @@ func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation pr return result } -func (invoker *failbackClusterInvoker) Destroy() { - invoker.baseClusterInvoker.Destroy() +func (invoker *clusterInvoker) Destroy() { + invoker.ClusterInvoker.Destroy() // stop ticker if invoker.ticker != nil { @@ -186,7 +188,7 @@ func (invoker *failbackClusterInvoker) Destroy() { } type retryTimerTask struct { - loadbalance cluster.LoadBalance + loadbalance loadbalance.LoadBalance invocation protocol.Invocation invokers []protocol.Invoker lastInvoker protocol.Invoker @@ -194,7 +196,7 @@ type retryTimerTask struct { lastT time.Time } -func newRetryTimerTask(loadbalance cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, +func newRetryTimerTask(loadbalance loadbalance.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, lastInvoker protocol.Invoker) *retryTimerTask { return &retryTimerTask{ loadbalance: loadbalance, diff --git a/cluster/cluster_impl/failback_cluster_test.go b/cluster/cluster/failback/cluster_test.go similarity index 89% rename from cluster/cluster_impl/failback_cluster_test.go rename to cluster/cluster/failback/cluster_test.go index f730c9d745..b43d196e90 100644 --- a/cluster/cluster_impl/failback_cluster_test.go +++ b/cluster/cluster/failback/cluster_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failback import ( "context" @@ -34,8 +34,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -49,15 +50,15 @@ var failbackUrl, _ = common.NewURL( // registerFailback register failbackCluster to cluster extension. func registerFailback(invoker *mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) - failbackCluster := NewFailbackCluster() + extension.SetLoadbalance("random", random.NewLoadBalance) + failbackCluster := NewCluster() - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker invokers = append(invokers, invoker) invoker.EXPECT().GetUrl().Return(failbackUrl) - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := failbackCluster.Join(staticDir) return clusterInvoker } @@ -68,13 +69,13 @@ func TestFailbackSuceess(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerFailback(invoker).(*failbackClusterInvoker) + clusterInvoker := registerFailback(invoker).(*clusterInvoker) invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() invoker.EXPECT().IsAvailable().Return(true) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{}) @@ -87,7 +88,7 @@ func TestFailbackRetryOneSuccess(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerFailback(invoker).(*failbackClusterInvoker) + clusterInvoker := registerFailback(invoker).(*clusterInvoker) invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() invoker.EXPECT().IsAvailable().Return(true) @@ -100,7 +101,7 @@ func TestFailbackRetryOneSuccess(t *testing.T) { var wg sync.WaitGroup wg.Add(1) now := time.Now() - mockSuccResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockSuccResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} invoker.EXPECT().IsAvailable().Return(true) invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(func(protocol.Invocation) protocol.Result { delta := time.Since(now).Nanoseconds() / int64(time.Second) @@ -132,7 +133,7 @@ func TestFailbackRetryFailed(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerFailback(invoker).(*failbackClusterInvoker) + clusterInvoker := registerFailback(invoker).(*clusterInvoker) invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() invoker.EXPECT().IsAvailable().Return(true).AnyTimes() @@ -179,7 +180,7 @@ func TestFailbackRetryFailed10Times(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerFailback(invoker).(*failbackClusterInvoker) + clusterInvoker := registerFailback(invoker).(*clusterInvoker) clusterInvoker.maxRetries = 10 invoker.EXPECT().IsAvailable().Return(true).AnyTimes() @@ -222,7 +223,7 @@ func TestFailbackOutOfLimit(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerFailback(invoker).(*failbackClusterInvoker) + clusterInvoker := registerFailback(invoker).(*clusterInvoker) clusterInvoker.failbackTasks = 1 invoker.EXPECT().GetUrl().Return(failbackUrl).AnyTimes() diff --git a/cluster/cluster_impl/failfast_cluster.go b/cluster/cluster/failfast/cluster.go similarity index 68% rename from cluster/cluster_impl/failfast_cluster.go rename to cluster/cluster/failfast/cluster.go index a8022d5f23..b7aa346d96 100644 --- a/cluster/cluster_impl/failfast_cluster.go +++ b/cluster/cluster/failfast/cluster.go @@ -15,31 +15,31 @@ * limitations under the License. */ -package cluster_impl +package failfast import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failfastCluster struct{} - -const failfast = "failfast" - func init() { - extension.SetCluster(failfast, NewFailFastCluster) + extension.SetCluster(constant.ClusterKeyFailfast, NewCluster) } -// NewFailFastCluster returns a failfast cluster instance. +type cluster struct{} + +// NewCluster returns a failfast cluster instance. // // Fast failure, only made a call, failure immediately error. Usually used for non-idempotent write operations, // such as adding records. -func NewFailFastCluster() cluster.Cluster { - return &failfastCluster{} +func NewCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *failfastCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newFailFastClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/failfast_cluster_invoker.go b/cluster/cluster/failfast/cluster_invoker.go similarity index 60% rename from cluster/cluster_impl/failfast_cluster_invoker.go rename to cluster/cluster/failfast/cluster_invoker.go index 1f62c7581c..306236255c 100644 --- a/cluster/cluster_impl/failfast_cluster_invoker.go +++ b/cluster/cluster/failfast/cluster_invoker.go @@ -15,42 +15,43 @@ * limitations under the License. */ -package cluster_impl +package failfast import ( "context" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failfastClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newFailFastClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &failfastClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } // nolint -func (invoker *failfastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) - err := invoker.checkInvokers(invokers, invocation) +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) + err := invoker.CheckInvokers(invokers, invocation) if err != nil { return &protocol.RPCResult{Err: err} } - loadbalance := getLoadBalance(invokers[0], invocation) + loadbalance := base.GetLoadBalance(invokers[0], invocation) - err = invoker.checkWhetherDestroyed() + err = invoker.CheckWhetherDestroyed() if err != nil { return &protocol.RPCResult{Err: err} } - ivk := invoker.doSelect(loadbalance, invocation, invokers, nil) + ivk := invoker.DoSelect(loadbalance, invocation, invokers, nil) return ivk.Invoke(ctx, invocation) } diff --git a/cluster/cluster_impl/failfast_cluster_test.go b/cluster/cluster/failfast/cluster_test.go similarity index 83% rename from cluster/cluster_impl/failfast_cluster_test.go rename to cluster/cluster/failfast/cluster_test.go index 74d570730a..a739dac78b 100644 --- a/cluster/cluster_impl/failfast_cluster_test.go +++ b/cluster/cluster/failfast/cluster_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failfast import ( "context" @@ -32,8 +32,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -47,16 +48,16 @@ var failfastUrl, _ = common.NewURL( // registerFailfast register failfastCluster to cluster extension. func registerFailfast(invoker *mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) - failfastCluster := NewFailFastCluster() + extension.SetLoadbalance("random", random.NewLoadBalance) + failfastCluster := NewCluster() - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker invokers = append(invokers, invoker) invoker.EXPECT().IsAvailable().Return(true).AnyTimes() invoker.EXPECT().GetUrl().Return(failfastUrl) - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := failfastCluster.Join(staticDir) return clusterInvoker } @@ -71,15 +72,15 @@ func TestFailfastInvokeSuccess(t *testing.T) { invoker.EXPECT().IsAvailable().Return(true).AnyTimes() invoker.EXPECT().GetUrl().Return(failfastUrl).AnyTimes() - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{}) assert.NoError(t, result.Error()) - res := result.Result().(rest) - assert.True(t, res.success) - assert.Equal(t, 0, res.tried) + res := result.Result().(clusterpkg.Rest) + assert.True(t, res.Success) + assert.Equal(t, 0, res.Tried) } func TestFailfastInvokeFail(t *testing.T) { diff --git a/cluster/cluster_impl/failover_cluster.go b/cluster/cluster/failover/cluster.go similarity index 71% rename from cluster/cluster_impl/failover_cluster.go rename to cluster/cluster/failover/cluster.go index 84dee3a3ae..56bc757cd6 100644 --- a/cluster/cluster_impl/failover_cluster.go +++ b/cluster/cluster/failover/cluster.go @@ -15,31 +15,32 @@ * limitations under the License. */ -package cluster_impl +package failover import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failoverCluster struct{} - func init() { - extension.SetCluster(constant.FAILOVER_CLUSTER_NAME, NewFailoverCluster) + extension.SetCluster(constant.ClusterKeyFailover, newCluster) } -// NewFailoverCluster returns a failover cluster instance +type cluster struct{} + +// newCluster returns a failover cluster instance // // Failure automatically switch, when there is a failure, // retry the other server (default). Usually used for read operations, // but retries can result in longer delays. -func NewFailoverCluster() cluster.Cluster { - return &failoverCluster{} +func newCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *failoverCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newFailoverClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster/failover/cluster_invoker.go similarity index 79% rename from cluster/cluster_impl/failover_cluster_invoker.go rename to cluster/cluster/failover/cluster_invoker.go index 44a938c5ea..6440627cd6 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster/failover/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failover import ( "context" @@ -28,25 +28,25 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failoverClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newFailoverClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &failoverClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } -// nolint -func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { var ( result protocol.Result invoked []protocol.Invoker @@ -54,29 +54,29 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr ivk protocol.Invoker ) - invokers := invoker.directory.List(invocation) - if err := invoker.checkInvokers(invokers, invocation); err != nil { + invokers := invoker.Directory.List(invocation) + if err := invoker.CheckInvokers(invokers, invocation); err != nil { return &protocol.RPCResult{Err: err} } methodName := invocation.MethodName() retries := getRetries(invokers, methodName) - loadBalance := getLoadBalance(invokers[0], invocation) + loadBalance := base.GetLoadBalance(invokers[0], invocation) for i := 0; i <= retries; i++ { // Reselect before retry to avoid a change of candidate `invokers`. // NOTE: if `invokers` changed, then `invoked` also lose accuracy. if i > 0 { - if err := invoker.checkWhetherDestroyed(); err != nil { + if err := invoker.CheckWhetherDestroyed(); err != nil { return &protocol.RPCResult{Err: err} } - invokers = invoker.directory.List(invocation) - if err := invoker.checkInvokers(invokers, invocation); err != nil { + invokers = invoker.Directory.List(invocation) + if err := invoker.CheckInvokers(invokers, invocation); err != nil { return &protocol.RPCResult{Err: err} } } - ivk = invoker.doSelect(loadBalance, invocation, invokers, invoked) + ivk = invoker.DoSelect(loadBalance, invocation, invokers, invoked) if ivk == nil { continue } @@ -91,7 +91,7 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr } ip := common.GetLocalIp() invokerSvc := invoker.GetURL().Service() - invokerUrl := invoker.directory.GetURL() + invokerUrl := invoker.Directory.GetURL() if ivk == nil { logger.Errorf("Failed to invoke the method %s of the service %s .No provider is available.", methodName, invokerSvc) return &protocol.RPCResult{ diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster/failover/cluster_test.go similarity index 59% rename from cluster/cluster_impl/failover_cluster_test.go rename to cluster/cluster/failover/cluster_test.go index eb29270f73..ad0aae36d8 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster/failover/cluster_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failover import ( "context" @@ -25,101 +25,32 @@ import ( ) import ( - perrors "github.com/pkg/errors" - "github.com/stretchr/testify/assert" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "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" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) -// nolint -type MockInvoker struct { - url *common.URL - available bool - destroyed bool - - successCount int -} - -// nolint -func NewMockInvoker(url *common.URL, successCount int) *MockInvoker { - return &MockInvoker{ - url: url, - available: true, - destroyed: false, - successCount: successCount, - } -} - -// nolint -func (bi *MockInvoker) GetURL() *common.URL { - return bi.url -} - -// nolint -func (bi *MockInvoker) IsAvailable() bool { - return bi.available -} - -// nolint -func (bi *MockInvoker) IsDestroyed() bool { - return bi.destroyed -} - -// nolint -type rest struct { - tried int - success bool -} - -// nolint -func (bi *MockInvoker) Invoke(c context.Context, invocation protocol.Invocation) protocol.Result { - count++ - var ( - success bool - err error - ) - if count >= bi.successCount { - success = true - } else { - err = perrors.New("error") - } - result := &protocol.RPCResult{Err: err, Rest: rest{tried: count, success: success}} - - return result -} - -// nolint -func (bi *MockInvoker) Destroy() { - logger.Infof("Destroy invoker: %v", bi.GetURL().String()) - bi.destroyed = true - bi.available = false -} - -// nolint -var count int - // nolint func normalInvoke(successCount int, urlParam url.Values, invocations ...*invocation.RPCInvocation) protocol.Result { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) - failoverCluster := NewFailoverCluster() + extension.SetLoadbalance("random", random.NewLoadBalance) + failoverCluster := newCluster() - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker for i := 0; i < 10; i++ { newUrl, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/com.ikurento.user.UserProvider", i), common.WithParams(urlParam)) - invokers = append(invokers, NewMockInvoker(newUrl, successCount)) + invokers = append(invokers, clusterpkg.NewMockInvoker(newUrl, successCount)) } - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := failoverCluster.Join(staticDir) if len(invocations) > 0 { return clusterInvoker.Invoke(context.Background(), invocations[0]) @@ -132,7 +63,7 @@ func TestFailoverInvokeSuccess(t *testing.T) { urlParams := url.Values{} result := normalInvoke(3, urlParams) assert.NoError(t, result.Error()) - count = 0 + clusterpkg.Count = 0 } // nolint @@ -140,7 +71,7 @@ func TestFailoverInvokeFail(t *testing.T) { urlParams := url.Values{} result := normalInvoke(4, urlParams) assert.Errorf(t, result.Error(), "error") - count = 0 + clusterpkg.Count = 0 } // nolint @@ -149,7 +80,7 @@ func TestFailoverInvoke1(t *testing.T) { urlParams.Set(constant.RETRIES_KEY, "3") result := normalInvoke(4, urlParams) assert.NoError(t, result.Error()) - count = 0 + clusterpkg.Count = 0 } // nolint @@ -161,26 +92,26 @@ func TestFailoverInvoke2(t *testing.T) { ivc := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test")) result := normalInvoke(4, urlParams, ivc) assert.NoError(t, result.Error()) - count = 0 + clusterpkg.Count = 0 } // nolint func TestFailoverDestroy(t *testing.T) { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) - failoverCluster := NewFailoverCluster() + extension.SetLoadbalance("random", random.NewLoadBalance) + failoverCluster := newCluster() invokers := []protocol.Invoker{} for i := 0; i < 10; i++ { - url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/com.ikurento.user.UserProvider", i)) - invokers = append(invokers, NewMockInvoker(url, 1)) + u, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/com.ikurento.user.UserProvider", i)) + invokers = append(invokers, clusterpkg.NewMockInvoker(u, 1)) } - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := failoverCluster.Join(staticDir) assert.Equal(t, true, clusterInvoker.IsAvailable()) result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{}) assert.NoError(t, result.Error()) - count = 0 + clusterpkg.Count = 0 clusterInvoker.Destroy() assert.Equal(t, false, clusterInvoker.IsAvailable()) } diff --git a/cluster/cluster_impl/failsafe_cluster.go b/cluster/cluster/failsafe/cluster.go similarity index 67% rename from cluster/cluster_impl/failsafe_cluster.go rename to cluster/cluster/failsafe/cluster.go index ac55e44b1d..048781b54d 100644 --- a/cluster/cluster_impl/failsafe_cluster.go +++ b/cluster/cluster/failsafe/cluster.go @@ -15,31 +15,31 @@ * limitations under the License. */ -package cluster_impl +package failsafe import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type failsafeCluster struct{} - -const failsafe = "failsafe" - func init() { - extension.SetCluster(failsafe, NewFailsafeCluster) + extension.SetCluster(constant.ClusterKeyFailsafe, newCluster) } -// NewFailsafeCluster returns a failsafe cluster instance. +type cluster struct{} + +// newCluster returns a failsafe cluster instance. // // Failure of security, anomalies, directly ignored. Usually it is // used to write audit logs and other operations. -func NewFailsafeCluster() cluster.Cluster { - return &failsafeCluster{} +func newCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *failsafeCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newFailsafeClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/failsafe_cluster_invoker.go b/cluster/cluster/failsafe/cluster_invoker.go similarity index 76% rename from cluster/cluster_impl/failsafe_cluster_invoker.go rename to cluster/cluster/failsafe/cluster_invoker.go index aea0858898..b9ba62f8b5 100644 --- a/cluster/cluster_impl/failsafe_cluster_invoker.go +++ b/cluster/cluster/failsafe/cluster_invoker.go @@ -15,14 +15,15 @@ * limitations under the License. */ -package cluster_impl +package failsafe import ( "context" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/common/logger" @@ -36,21 +37,20 @@ import ( * Fail-safe * */ -type failsafeClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newFailsafeClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &failsafeClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } -// nolint -func (invoker *failsafeClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) - err := invoker.checkInvokers(invokers, invocation) + err := invoker.CheckInvokers(invokers, invocation) if err != nil { return &protocol.RPCResult{} } @@ -68,7 +68,7 @@ func (invoker *failsafeClusterInvoker) Invoke(ctx context.Context, invocation pr invoked := make([]protocol.Invoker, 0) var result protocol.Result - ivk := invoker.doSelect(loadbalance, invocation, invokers, invoked) + ivk := invoker.DoSelect(loadbalance, invocation, invokers, invoked) // DO INVOKE result = ivk.Invoke(ctx, invocation) if result.Error() != nil { diff --git a/cluster/cluster_impl/failsafe_cluster_test.go b/cluster/cluster/failsafe/cluster_test.go similarity index 83% rename from cluster/cluster_impl/failsafe_cluster_test.go rename to cluster/cluster/failsafe/cluster_test.go index de67fddd49..275995a886 100644 --- a/cluster/cluster_impl/failsafe_cluster_test.go +++ b/cluster/cluster/failsafe/cluster_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package failsafe import ( "context" @@ -32,8 +32,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -47,16 +48,16 @@ var failsafeUrl, _ = common.NewURL( // registerFailsafe register failsafeCluster to cluster extension. func registerFailsafe(invoker *mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) - failsafeCluster := NewFailsafeCluster() + extension.SetLoadbalance("random", random.NewLoadBalance) + failsafeCluster := newCluster() - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker invokers = append(invokers, invoker) invoker.EXPECT().IsAvailable().Return(true).AnyTimes() - invoker.EXPECT().GetUrl().Return(failbackUrl) + invoker.EXPECT().GetUrl().Return(failsafeUrl) - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) clusterInvoker := failsafeCluster.Join(staticDir) return clusterInvoker } @@ -72,14 +73,14 @@ func TestFailSafeInvokeSuccess(t *testing.T) { invoker.EXPECT().GetUrl().Return(failsafeUrl).AnyTimes() - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} invoker.EXPECT().Invoke(gomock.Any()).Return(mockResult) result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{}) assert.NoError(t, result.Error()) - res := result.Result().(rest) - assert.True(t, res.success) + res := result.Result().(clusterpkg.Rest) + assert.True(t, res.Success) } func TestFailSafeInvokeFail(t *testing.T) { diff --git a/cluster/cluster_impl/forking_cluster.go b/cluster/cluster/forking/cluster.go similarity index 69% rename from cluster/cluster_impl/forking_cluster.go rename to cluster/cluster/forking/cluster.go index 7221d2df25..466fec2c0d 100644 --- a/cluster/cluster_impl/forking_cluster.go +++ b/cluster/cluster/forking/cluster.go @@ -15,31 +15,31 @@ * limitations under the License. */ -package cluster_impl +package forking import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type forkingCluster struct{} - -const forking = "forking" - func init() { - extension.SetCluster(forking, NewForkingCluster) + extension.SetCluster(constant.ClusterKeyForking, newCluster) } -// NewForkingCluster returns a forking cluster instance. +type cluster struct{} + +// newCluster returns a forking cluster instance. // // Multiple servers are invoked in parallel, returning as soon as one succeeds. // Usually it is used for real-time demanding read operations while wasting more service resources. -func NewForkingCluster() cluster.Cluster { - return &forkingCluster{} +func newCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a baseClusterInvoker instance -func (cluster *forkingCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newForkingClusterInvoker(directory)) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory)) } diff --git a/cluster/cluster_impl/forking_cluster_invoker.go b/cluster/cluster/forking/cluster_invoker.go similarity index 76% rename from cluster/cluster_impl/forking_cluster_invoker.go rename to cluster/cluster/forking/cluster_invoker.go index 5844f065d3..0b76ffb93c 100644 --- a/cluster/cluster_impl/forking_cluster_invoker.go +++ b/cluster/cluster/forking/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package forking import ( "context" @@ -28,30 +28,30 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type forkingClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newForkingClusterInvoker(directory cluster.Directory) protocol.Invoker { - return &forkingClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + return &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } } -// nolint -func (invoker *forkingClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - if err := invoker.checkWhetherDestroyed(); err != nil { +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + if err := invoker.CheckWhetherDestroyed(); err != nil { return &protocol.RPCResult{Err: err} } - invokers := invoker.directory.List(invocation) - if err := invoker.checkInvokers(invokers, invocation); err != nil { + invokers := invoker.Directory.List(invocation) + if err := invoker.CheckInvokers(invokers, invocation); err != nil { return &protocol.RPCResult{Err: err} } @@ -61,9 +61,9 @@ func (invoker *forkingClusterInvoker) Invoke(ctx context.Context, invocation pro if forks < 0 || forks > len(invokers) { selected = invokers } else { - loadBalance := getLoadBalance(invokers[0], invocation) + loadBalance := base.GetLoadBalance(invokers[0], invocation) for i := 0; i < forks; i++ { - if ivk := invoker.doSelect(loadBalance, invocation, invokers, selected); ivk != nil { + if ivk := invoker.DoSelect(loadBalance, invocation, invokers, selected); ivk != nil { selected = append(selected, ivk) } } diff --git a/cluster/cluster_impl/forking_cluster_test.go b/cluster/cluster/forking/cluster_test.go similarity index 86% rename from cluster/cluster_impl/forking_cluster_test.go rename to cluster/cluster/forking/cluster_test.go index bbb12bb9b4..c92bade090 100644 --- a/cluster/cluster_impl/forking_cluster_test.go +++ b/cluster/cluster/forking/cluster_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package forking import ( "context" @@ -33,8 +33,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" - "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/roundrobin" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -47,18 +48,18 @@ var forkingUrl, _ = common.NewURL( fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) func registerForking(mockInvokers ...*mock.MockInvoker) protocol.Invoker { - extension.SetLoadbalance(loadbalance.RoundRobin, loadbalance.NewRoundRobinLoadBalance) + extension.SetLoadbalance(constant.LoadBalanceKeyRoundRobin, roundrobin.NewLoadBalance) - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker for i, ivk := range mockInvokers { invokers = append(invokers, ivk) if i == 0 { ivk.EXPECT().GetUrl().Return(forkingUrl) } } - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) - forkingCluster := NewForkingCluster() + forkingCluster := newCluster() clusterInvoker := forkingCluster.Join(staticDir) return clusterInvoker } @@ -69,7 +70,7 @@ func TestForkingInvokeSuccess(t *testing.T) { invokers := make([]*mock.MockInvoker, 0) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) // forkingUrl.AddParam(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_TIMEOUT)) @@ -99,7 +100,7 @@ func TestForkingInvokeTimeout(t *testing.T) { invokers := make([]*mock.MockInvoker, 0) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) var wg sync.WaitGroup @@ -130,7 +131,7 @@ func TestForkingInvokeHalfTimeout(t *testing.T) { invokers := make([]*mock.MockInvoker, 0) - mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} + mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}} forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3)) var wg sync.WaitGroup diff --git a/cluster/cluster_impl/interceptor_invoker.go b/cluster/cluster/interceptor_invoker.go similarity index 63% rename from cluster/cluster_impl/interceptor_invoker.go rename to cluster/cluster/interceptor_invoker.go index a22695d74c..0cbe262dab 100644 --- a/cluster/cluster_impl/interceptor_invoker.go +++ b/cluster/cluster/interceptor_invoker.go @@ -15,23 +15,56 @@ * limitations under the License. */ -package cluster_impl +package cluster import ( "context" + "sync" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" "dubbo.apache.org/dubbo-go/v3/common" - "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) +var ( + lock sync.RWMutex + interceptors = make(map[string]func() Interceptor) +) + +// SetClusterInterceptor sets cluster interceptor so that user has chance to inject extra logics before and after +// cluster invoker +func SetClusterInterceptor(name string, fun func() Interceptor) { + lock.Lock() + defer lock.Unlock() + interceptors[name] = fun +} + +// GetClusterInterceptor returns the cluster interceptor instance with the given name +func GetClusterInterceptor(name string) Interceptor { + lock.RLock() + defer lock.RUnlock() + if interceptors[name] == nil { + panic("cluster_interceptor for " + name + " doesn't exist, make sure the corresponding package is imported") + } + return interceptors[name]() +} + +// GetClusterInterceptors returns all instances of registered cluster interceptors +func GetClusterInterceptors() []Interceptor { + lock.RLock() + defer lock.RUnlock() + ret := make([]Interceptor, 0, len(interceptors)) + for _, f := range interceptors { + ret = append(ret, f()) + } + return ret +} + // InterceptorInvoker mocks cluster interceptor as an invoker type InterceptorInvoker struct { next protocol.Invoker - interceptor cluster.Interceptor + interceptor Interceptor } // GetURL is used to get url from InterceptorInvoker @@ -54,10 +87,10 @@ func (i *InterceptorInvoker) Destroy() { i.next.Destroy() } -func buildInterceptorChain(invoker protocol.Invoker, builtins ...cluster.Interceptor) protocol.Invoker { +func BuildInterceptorChain(invoker protocol.Invoker, builtins ...Interceptor) protocol.Invoker { // The order of interceptors is from left to right, so loading from right to left next := invoker - interceptors := extension.GetClusterInterceptors() + interceptors := GetClusterInterceptors() if len(interceptors) != 0 { for i := len(interceptors) - 1; i >= 0; i-- { v := &InterceptorInvoker{next: next, interceptor: interceptors[i]} diff --git a/cluster/cluster/mock.go b/cluster/cluster/mock.go new file mode 100644 index 0000000000..77d3829d52 --- /dev/null +++ b/cluster/cluster/mock.go @@ -0,0 +1,106 @@ +/* + * 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 cluster + +import ( + "context" +) + +import ( + perrors "github.com/pkg/errors" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/common" + "dubbo.apache.org/dubbo-go/v3/common/logger" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +var Count int + +type Rest struct { + Tried int + Success bool +} + +type mockCluster struct{} + +// NewMockCluster returns a mock cluster instance. +// +// Mock cluster is usually used for service degradation, such as an authentication service. +// When the service provider is completely hung up, the client does not throw an exception, +// return an authorization failure through the Mock data instead. +func NewMockCluster() Cluster { + return &mockCluster{} +} + +func (cluster *mockCluster) Join(directory directory.Directory) protocol.Invoker { + return BuildInterceptorChain(protocol.NewBaseInvoker(directory.GetURL())) +} + +type MockInvoker struct { + url *common.URL + available bool + destroyed bool + + successCount int +} + +func NewMockInvoker(url *common.URL, successCount int) *MockInvoker { + return &MockInvoker{ + url: url, + available: true, + destroyed: false, + successCount: successCount, + } +} + +func (bi *MockInvoker) GetURL() *common.URL { + return bi.url +} + +func (bi *MockInvoker) IsAvailable() bool { + return bi.available +} + +func (bi *MockInvoker) IsDestroyed() bool { + return bi.destroyed +} + +func (bi *MockInvoker) Invoke(c context.Context, invocation protocol.Invocation) protocol.Result { + Count++ + var ( + success bool + err error + ) + if Count >= bi.successCount { + success = true + } else { + err = perrors.New("error") + } + result := &protocol.RPCResult{Err: err, Rest: Rest{Tried: Count, Success: success}} + + return result +} + +func (bi *MockInvoker) Destroy() { + logger.Infof("Destroy invoker: %v", bi.GetURL().String()) + bi.destroyed = true + bi.available = false +} diff --git a/cluster/cluster_impl/zone_aware_cluster.go b/cluster/cluster/zoneaware/cluster.go similarity index 73% rename from cluster/cluster_impl/zone_aware_cluster.go rename to cluster/cluster/zoneaware/cluster.go index a280ba9fb7..134583bc2d 100644 --- a/cluster/cluster_impl/zone_aware_cluster.go +++ b/cluster/cluster/zoneaware/cluster.go @@ -15,30 +15,31 @@ * limitations under the License. */ -package cluster_impl +package zoneaware import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type zoneAwareCluster struct{} - func init() { - extension.SetCluster(constant.ZONEAWARE_CLUSTER_NAME, NewZoneAwareCluster) + extension.SetCluster(constant.ClusterKeyZoneAware, newCluster) } +type cluster struct{} + // NewZoneAwareCluster returns a zoneaware cluster instance. // // More than one registry for subscription. // Usually it is used for choose between registries. -func NewZoneAwareCluster() cluster.Cluster { - return &zoneAwareCluster{} +func newCluster() clusterpkg.Cluster { + return &cluster{} } // Join returns a zoneAwareClusterInvoker instance -func (cluster *zoneAwareCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(newZoneAwareClusterInvoker(directory), getZoneAwareInterceptor()) +func (cluster *cluster) Join(directory directory.Directory) protocol.Invoker { + return clusterpkg.BuildInterceptorChain(newClusterInvoker(directory), newInterceptor()) } diff --git a/cluster/cluster_impl/zone_aware_cluster_interceptor.go b/cluster/cluster/zoneaware/cluster_interceptor.go similarity index 80% rename from cluster/cluster_impl/zone_aware_cluster_interceptor.go rename to cluster/cluster/zoneaware/cluster_interceptor.go index ea26c2ea2c..eabe4e5cb3 100644 --- a/cluster/cluster_impl/zone_aware_cluster_interceptor.go +++ b/cluster/cluster/zoneaware/cluster_interceptor.go @@ -15,22 +15,22 @@ * limitations under the License. */ -package cluster_impl +package zoneaware import ( "context" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type zoneAwareInterceptor struct { +type interceptor struct { } -func (z *zoneAwareInterceptor) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (z *interceptor) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { key := constant.REGISTRY_KEY + "." + constant.ZONE_FORCE_KEY force := ctx.Value(key) @@ -52,6 +52,6 @@ func (z *zoneAwareInterceptor) Invoke(ctx context.Context, invoker protocol.Invo return invoker.Invoke(ctx, invocation) } -func getZoneAwareInterceptor() cluster.Interceptor { - return &zoneAwareInterceptor{} +func newInterceptor() clusterpkg.Interceptor { + return &interceptor{} } diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker.go b/cluster/cluster/zoneaware/cluster_invoker.go similarity index 82% rename from cluster/cluster_impl/zone_aware_cluster_invoker.go rename to cluster/cluster/zoneaware/cluster_invoker.go index 1e04da555b..d6a72d14f0 100644 --- a/cluster/cluster_impl/zone_aware_cluster_invoker.go +++ b/cluster/cluster/zoneaware/cluster_invoker.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package zoneaware import ( "context" @@ -23,7 +23,8 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -35,22 +36,21 @@ import ( // 2. check the zone the current request belongs, pick the registry that has the same zone first. // 3. Evenly balance traffic between all registries based on each registry's weight. // 4. Pick anyone that's available. -type zoneAwareClusterInvoker struct { - baseClusterInvoker +type clusterInvoker struct { + base.ClusterInvoker } -func newZoneAwareClusterInvoker(directory cluster.Directory) protocol.Invoker { - invoker := &zoneAwareClusterInvoker{ - baseClusterInvoker: newBaseClusterInvoker(directory), +func newClusterInvoker(directory directory.Directory) protocol.Invoker { + invoker := &clusterInvoker{ + ClusterInvoker: base.NewClusterInvoker(directory), } return invoker } -// nolint -func (invoker *zoneAwareClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { - invokers := invoker.directory.List(invocation) +func (invoker *clusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { + invokers := invoker.Directory.List(invocation) - err := invoker.checkInvokers(invokers, invocation) + err := invoker.CheckInvokers(invokers, invocation) if err != nil { return &protocol.RPCResult{Err: err} } @@ -84,8 +84,8 @@ func (invoker *zoneAwareClusterInvoker) Invoke(ctx context.Context, invocation p } // load balance among all registries, with registry weight count in. - loadBalance := getLoadBalance(invokers[0], invocation) - ivk := invoker.doSelect(loadBalance, invocation, invokers, nil) + loadBalance := base.GetLoadBalance(invokers[0], invocation) + ivk := invoker.DoSelect(loadBalance, invocation, invokers, nil) if ivk != nil && ivk.IsAvailable() { return ivk.Invoke(ctx, invocation) } diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go b/cluster/cluster/zoneaware/cluster_invoker_test.go similarity index 88% rename from cluster/cluster_impl/zone_aware_cluster_invoker_test.go rename to cluster/cluster/zoneaware/cluster_invoker_test.go index 62433f3e01..084035badd 100644 --- a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go +++ b/cluster/cluster/zoneaware/cluster_invoker_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster_impl +package zoneaware import ( "context" @@ -30,9 +30,12 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" + clusterpkg "dubbo.apache.org/dubbo-go/v3/cluster/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" "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/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" "dubbo.apache.org/dubbo-go/v3/protocol/mock" @@ -46,7 +49,7 @@ func TestZoneWareInvokerWithPreferredSuccess(t *testing.T) { mockResult := &protocol.RPCResult{ Attrs: map[string]interface{}{constant.PREFERRED_KEY: "true"}, - Rest: rest{tried: 0, success: true}, + Rest: clusterpkg.Rest{Tried: 0, Success: true}, } var invokers []protocol.Invoker @@ -71,8 +74,8 @@ func TestZoneWareInvokerWithPreferredSuccess(t *testing.T) { invokers = append(invokers, invoker) } - zoneAwareCluster := NewZoneAwareCluster() - staticDir := directory.NewStaticDirectory(invokers) + zoneAwareCluster := newCluster() + staticDir := static.NewDirectory(invokers) clusterInvoker := zoneAwareCluster.Join(staticDir) result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{}) @@ -81,6 +84,8 @@ func TestZoneWareInvokerWithPreferredSuccess(t *testing.T) { } func TestZoneWareInvokerWithWeightSuccess(t *testing.T) { + extension.SetLoadbalance(constant.LoadBalanceKeyRandom, random.NewLoadBalance) + ctrl := gomock.NewController(t) // In Go versions 1.14+, if you pass a *testing.T // into gomock.NewController(t) you no longer need to call ctrl.Finish(). @@ -102,7 +107,7 @@ func TestZoneWareInvokerWithWeightSuccess(t *testing.T) { func(invocation protocol.Invocation) protocol.Result { return &protocol.RPCResult{ Attrs: map[string]interface{}{constant.WEIGHT_KEY: w1}, - Rest: rest{tried: 0, success: true}, + Rest: clusterpkg.Rest{Tried: 0, Success: true}, } }).MaxTimes(100) } else { @@ -111,15 +116,15 @@ func TestZoneWareInvokerWithWeightSuccess(t *testing.T) { func(invocation protocol.Invocation) protocol.Result { return &protocol.RPCResult{ Attrs: map[string]interface{}{constant.WEIGHT_KEY: w2}, - Rest: rest{tried: 0, success: true}, + Rest: clusterpkg.Rest{Tried: 0, Success: true}, } }).MaxTimes(100) } invokers = append(invokers, invoker) } - zoneAwareCluster := NewZoneAwareCluster() - staticDir := directory.NewStaticDirectory(invokers) + zoneAwareCluster := newCluster() + staticDir := static.NewDirectory(invokers) clusterInvoker := zoneAwareCluster.Join(staticDir) var w2Count, w1Count int @@ -159,14 +164,14 @@ func TestZoneWareInvokerWithZoneSuccess(t *testing.T) { func(invocation protocol.Invocation) protocol.Result { return &protocol.RPCResult{ Attrs: map[string]interface{}{constant.ZONE_KEY: zoneValue}, - Rest: rest{tried: 0, success: true}, + Rest: clusterpkg.Rest{Tried: 0, Success: true}, } }) invokers = append(invokers, invoker) } - zoneAwareCluster := NewZoneAwareCluster() - staticDir := directory.NewStaticDirectory(invokers) + zoneAwareCluster := newCluster() + staticDir := static.NewDirectory(invokers) clusterInvoker := zoneAwareCluster.Join(staticDir) inv := &invocation.RPCInvocation{} @@ -195,8 +200,8 @@ func TestZoneWareInvokerWithZoneForceFail(t *testing.T) { invokers = append(invokers, invoker) } - zoneAwareCluster := NewZoneAwareCluster() - staticDir := directory.NewStaticDirectory(invokers) + zoneAwareCluster := newCluster() + staticDir := static.NewDirectory(invokers) clusterInvoker := zoneAwareCluster.Join(staticDir) inv := &invocation.RPCInvocation{} diff --git a/cluster/cluster_impl/mock_cluster.go b/cluster/cluster_impl/import.go similarity index 56% rename from cluster/cluster_impl/mock_cluster.go rename to cluster/cluster_impl/import.go index 40d1c2bf5a..a7b16b4d40 100644 --- a/cluster/cluster_impl/mock_cluster.go +++ b/cluster/cluster_impl/import.go @@ -17,23 +17,18 @@ package cluster_impl +// This package is for being compatible with older dubbo-go, please use `imports` package. +// This package may be DEPRECATED OR REMOVED in the future. + import ( - "dubbo.apache.org/dubbo-go/v3/cluster" - "dubbo.apache.org/dubbo-go/v3/protocol" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/available" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/broadcast" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failback" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failfast" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failover" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failsafe" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/forking" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/zoneaware" ) -type mockCluster struct{} - -// NewMockCluster returns a mock cluster instance. -// -// Mock cluster is usually used for service degradation, such as an authentication service. -// When the service provider is completely hung up, the client does not throw an exception, -// return an authorization failure through the Mock data instead. -func NewMockCluster() cluster.Cluster { - return &mockCluster{} -} - -// nolint -func (cluster *mockCluster) Join(directory cluster.Directory) protocol.Invoker { - return buildInterceptorChain(protocol.NewBaseInvoker(directory.GetURL())) -} +func init() {} diff --git a/cluster/directory/base_directory.go b/cluster/directory/base/directory.go similarity index 76% rename from cluster/directory/base_directory.go rename to cluster/directory/base/directory.go index 44ab2d92e3..52445fcb03 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base/directory.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package directory +package base import ( "sync" @@ -32,8 +32,8 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/constant" ) -// BaseDirectory Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers -type BaseDirectory struct { +// Directory Abstract implementation of Directory: Invoker list returned from this Directory's list method have been filtered by Routers +type Directory struct { url *common.URL destroyed *atomic.Bool // this mutex for change the properties in BaseDirectory, like routerChain , destroyed etc @@ -41,9 +41,9 @@ type BaseDirectory struct { routerChain router.Chain } -// NewBaseDirectory Create BaseDirectory with URL -func NewBaseDirectory(url *common.URL) BaseDirectory { - return BaseDirectory{ +// NewDirectory Create BaseDirectory with URL +func NewDirectory(url *common.URL) Directory { + return Directory{ url: url, destroyed: atomic.NewBool(false), routerChain: &chain.RouterChain{}, @@ -51,28 +51,28 @@ func NewBaseDirectory(url *common.URL) BaseDirectory { } // RouterChain Return router chain in directory -func (dir *BaseDirectory) RouterChain() router.Chain { +func (dir *Directory) RouterChain() router.Chain { return dir.routerChain } // SetRouterChain Set router chain in directory -func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) { +func (dir *Directory) SetRouterChain(routerChain router.Chain) { dir.mutex.Lock() defer dir.mutex.Unlock() dir.routerChain = routerChain } // GetURL Get URL -func (dir *BaseDirectory) GetURL() *common.URL { +func (dir *Directory) GetURL() *common.URL { return dir.url } // GetDirectoryUrl Get URL instance -func (dir *BaseDirectory) GetDirectoryUrl() *common.URL { +func (dir *Directory) GetDirectoryUrl() *common.URL { return dir.url } -func (dir *BaseDirectory) isProperRouter(url *common.URL) bool { +func (dir *Directory) isProperRouter(url *common.URL) bool { app := url.GetParam(constant.APPLICATION_KEY, "") dirApp := dir.GetURL().GetParam(constant.APPLICATION_KEY, "") if len(dirApp) == 0 && dir.GetURL().SubURL != nil { @@ -92,7 +92,7 @@ func (dir *BaseDirectory) isProperRouter(url *common.URL) bool { } // Destroy Destroy -func (dir *BaseDirectory) Destroy(doDestroy func()) { +func (dir *Directory) Destroy(doDestroy func()) { if dir.destroyed.CAS(false, true) { dir.mutex.Lock() doDestroy() @@ -101,6 +101,6 @@ func (dir *BaseDirectory) Destroy(doDestroy func()) { } // IsAvailable Once directory init finish, it will change to true -func (dir *BaseDirectory) IsAvailable() bool { +func (dir *Directory) IsAvailable() bool { return !dir.destroyed.Load() } diff --git a/cluster/directory/base_directory_test.go b/cluster/directory/base/directory_test.go similarity index 92% rename from cluster/directory/base_directory_test.go rename to cluster/directory/base/directory_test.go index e465cea6f8..79cca2cbcd 100644 --- a/cluster/directory/base_directory_test.go +++ b/cluster/directory/base/directory_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package directory +package base import ( "encoding/base64" @@ -40,7 +40,7 @@ var ( ) func TestNewBaseDirectory(t *testing.T) { - dir := NewBaseDirectory(url) + dir := NewDirectory(url) assert.Equal(t, url, dir.GetURL()) assert.Equal(t, url, dir.GetDirectoryUrl()) } @@ -48,7 +48,7 @@ func TestNewBaseDirectory(t *testing.T) { func TestBuildRouterChain(t *testing.T) { regURL := url regURL.AddParam(constant.INTERFACE_KEY, "mock-app") - directory := NewBaseDirectory(regURL) + directory := NewDirectory(regURL) var err error directory.routerChain, err = chain.NewRouterChain(regURL) assert.Error(t, err) @@ -65,7 +65,7 @@ func getRouteURL(rule string, u *common.URL) *common.URL { func TestIsProperRouter(t *testing.T) { regURL := url regURL.AddParam(constant.APPLICATION_KEY, "mock-app") - d := NewBaseDirectory(regURL) + d := NewDirectory(regURL) localIP := common.GetLocalIp() rule := base64.URLEncoding.EncodeToString([]byte("true => " + " host = " + localIP)) routeURL := getRouteURL(rule, anyURL) @@ -75,7 +75,7 @@ func TestIsProperRouter(t *testing.T) { regURL.AddParam(constant.APPLICATION_KEY, "") regURL.AddParam(constant.INTERFACE_KEY, "com.foo.BarService") - d = NewBaseDirectory(regURL) + d = NewDirectory(regURL) routeURL = getRouteURL(rule, anyURL) routeURL.AddParam(constant.INTERFACE_KEY, "com.foo.BarService") rst = d.isProperRouter(routeURL) @@ -83,14 +83,14 @@ func TestIsProperRouter(t *testing.T) { regURL.AddParam(constant.APPLICATION_KEY, "") regURL.AddParam(constant.INTERFACE_KEY, "") - d = NewBaseDirectory(regURL) + d = NewDirectory(regURL) routeURL = getRouteURL(rule, anyURL) rst = d.isProperRouter(routeURL) assert.True(t, rst) regURL.SetParam(constant.APPLICATION_KEY, "") regURL.SetParam(constant.INTERFACE_KEY, "") - d = NewBaseDirectory(regURL) + d = NewDirectory(regURL) routeURL = getRouteURL(rule, anyURL) routeURL.AddParam(constant.APPLICATION_KEY, "mock-service") rst = d.isProperRouter(routeURL) @@ -98,7 +98,7 @@ func TestIsProperRouter(t *testing.T) { regURL.SetParam(constant.APPLICATION_KEY, "") regURL.SetParam(constant.INTERFACE_KEY, "") - d = NewBaseDirectory(regURL) + d = NewDirectory(regURL) routeURL = getRouteURL(rule, anyURL) routeURL.AddParam(constant.INTERFACE_KEY, "mock-service") rst = d.isProperRouter(routeURL) diff --git a/cluster/directory.go b/cluster/directory/directory.go similarity index 98% rename from cluster/directory.go rename to cluster/directory/directory.go index d89f0cfb46..257eb4a703 100644 --- a/cluster/directory.go +++ b/cluster/directory/directory.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster +package directory import ( "dubbo.apache.org/dubbo-go/v3/common" diff --git a/cluster/directory/static_directory.go b/cluster/directory/static/directory.go similarity index 76% rename from cluster/directory/static_directory.go rename to cluster/directory/static/directory.go index ac7690af8b..7e877e42ad 100644 --- a/cluster/directory/static_directory.go +++ b/cluster/directory/static/directory.go @@ -15,41 +15,42 @@ * limitations under the License. */ -package directory +package static import ( perrors "github.com/pkg/errors" ) import ( + "dubbo.apache.org/dubbo-go/v3/cluster/directory/base" "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/protocol" ) -type staticDirectory struct { - BaseDirectory +type directory struct { + base.Directory invokers []protocol.Invoker } -// NewStaticDirectory Create a new staticDirectory with invokers -func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory { +// NewDirectory Create a new staticDirectory with invokers +func NewDirectory(invokers []protocol.Invoker) *directory { var url *common.URL if len(invokers) > 0 { url = invokers[0].GetURL() } - dir := &staticDirectory{ - BaseDirectory: NewBaseDirectory(url), - invokers: invokers, + dir := &directory{ + Directory: base.NewDirectory(url), + invokers: invokers, } - dir.routerChain.SetInvokers(invokers) + dir.RouterChain().SetInvokers(invokers) return dir } // for-loop invokers ,if all invokers is available ,then it means directory is available -func (dir *staticDirectory) IsAvailable() bool { +func (dir *directory) IsAvailable() bool { if len(dir.invokers) == 0 { return false } @@ -62,7 +63,7 @@ func (dir *staticDirectory) IsAvailable() bool { } // List List invokers -func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invoker { +func (dir *directory) List(invocation protocol.Invocation) []protocol.Invoker { l := len(dir.invokers) invokers := make([]protocol.Invoker, l) copy(invokers, dir.invokers) @@ -76,8 +77,8 @@ func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invo } // Destroy Destroy -func (dir *staticDirectory) Destroy() { - dir.BaseDirectory.Destroy(func() { +func (dir *directory) Destroy() { + dir.Directory.Destroy(func() { for _, ivk := range dir.invokers { ivk.Destroy() } @@ -86,7 +87,7 @@ func (dir *staticDirectory) Destroy() { } // BuildRouterChain build router chain by invokers -func (dir *staticDirectory) BuildRouterChain(invokers []protocol.Invoker) error { +func (dir *directory) BuildRouterChain(invokers []protocol.Invoker) error { if len(invokers) == 0 { return perrors.Errorf("invokers == null") } diff --git a/cluster/directory/static_directory_test.go b/cluster/directory/static/directory_test.go similarity index 94% rename from cluster/directory/static_directory_test.go rename to cluster/directory/static/directory_test.go index b959f6d688..205d9364e7 100644 --- a/cluster/directory/static_directory_test.go +++ b/cluster/directory/static/directory_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package directory +package static import ( "fmt" @@ -39,7 +39,7 @@ func TestStaticDirList(t *testing.T) { invokers = append(invokers, protocol.NewBaseInvoker(url)) } - staticDir := NewStaticDirectory(invokers) + staticDir := NewDirectory(invokers) list := staticDir.List(&invocation.RPCInvocation{}) assert.Len(t, list, 10) @@ -52,7 +52,7 @@ func TestStaticDirDestroy(t *testing.T) { invokers = append(invokers, protocol.NewBaseInvoker(url)) } - staticDir := NewStaticDirectory(invokers) + staticDir := NewDirectory(invokers) assert.Equal(t, true, staticDir.IsAvailable()) staticDir.Destroy() assert.Equal(t, false, staticDir.IsAvailable()) diff --git a/cluster/loadbalance/consistenthashing/loadbalance.go b/cluster/loadbalance/consistenthashing/loadbalance.go new file mode 100644 index 0000000000..965f55d735 --- /dev/null +++ b/cluster/loadbalance/consistenthashing/loadbalance.go @@ -0,0 +1,80 @@ +/* + * 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 consistenthashing + +import ( + "encoding/json" + "hash/crc32" + "regexp" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + "dubbo.apache.org/dubbo-go/v3/common/constant" + "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +const ( + // HashNodes hash nodes + HashNodes = "hash.nodes" + // HashArguments key of hash arguments in url + HashArguments = "hash.arguments" +) + +var ( + selectors = make(map[string]*selector) + re = regexp.MustCompile(constant.COMMA_SPLIT_PATTERN) +) + +func init() { + extension.SetLoadbalance(constant.LoadBalanceKeyConsistentHashing, newLoadBalance) +} + +// loadBalance implementation of load balancing: using consistent hashing +type loadBalance struct{} + +// newLoadBalance creates NewConsistentHashLoadBalance +// +// The same parameters of the request is always sent to the same provider. +func newLoadBalance() loadbalance.LoadBalance { + return &loadBalance{} +} + +// Select gets invoker based on load balancing strategy +func (lb *loadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { + methodName := invocation.MethodName() + key := invokers[0].GetURL().ServiceKey() + "." + methodName + + // hash the invokers + var bs []byte + for _, invoker := range invokers { + b, err := json.Marshal(invoker) + if err != nil { + return nil + } + bs = append(bs, b...) + } + hashCode := crc32.ChecksumIEEE(bs) + selector, ok := selectors[key] + if !ok || selector.hashCode != hashCode { + selectors[key] = newSelector(invokers, methodName, hashCode) + selector = selectors[key] + } + return selector.Select(invocation) +} diff --git a/cluster/loadbalance/consistent_hash_test.go b/cluster/loadbalance/consistenthashing/loadbalance_test.go similarity index 94% rename from cluster/loadbalance/consistent_hash_test.go rename to cluster/loadbalance/consistenthashing/loadbalance_test.go index 72848b55e5..80b9b017ed 100644 --- a/cluster/loadbalance/consistent_hash_test.go +++ b/cluster/loadbalance/consistenthashing/loadbalance_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package loadbalance +package consistenthashing import ( "fmt" @@ -27,7 +27,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" @@ -52,14 +52,14 @@ func TestConsistentHashSelectorSuite(t *testing.T) { type consistentHashSelectorSuite struct { suite.Suite - selector *consistentHashSelector + selector *selector } func (s *consistentHashSelectorSuite) SetupTest() { var invokers []protocol.Invoker url, _ := common.NewURL(url20000) invokers = append(invokers, protocol.NewBaseInvoker(url)) - s.selector = newConsistentHashSelector(invokers, "echo", 999944) + s.selector = newSelector(invokers, "echo", 999944) } func (s *consistentHashSelectorSuite) TestToKey() { @@ -91,7 +91,7 @@ type consistentHashLoadBalanceSuite struct { invoker1 protocol.Invoker invoker2 protocol.Invoker invoker3 protocol.Invoker - lb cluster.LoadBalance + lb loadbalance.LoadBalance } func (s *consistentHashLoadBalanceSuite) SetupTest() { @@ -108,7 +108,7 @@ func (s *consistentHashLoadBalanceSuite) SetupTest() { s.invoker3 = protocol.NewBaseInvoker(s.url3) s.invokers = append(s.invokers, s.invoker1, s.invoker2, s.invoker3) - s.lb = NewConsistentHashLoadBalance() + s.lb = newLoadBalance() } func (s *consistentHashLoadBalanceSuite) TestSelect() { diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistenthashing/selector.go similarity index 52% rename from cluster/loadbalance/consistent_hash.go rename to cluster/loadbalance/consistenthashing/selector.go index 7f1414c8a4..55d37507f7 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistenthashing/selector.go @@ -15,14 +15,11 @@ * limitations under the License. */ -package loadbalance +package consistenthashing import ( "crypto/md5" - "encoding/json" "fmt" - "hash/crc32" - "regexp" "sort" "strconv" "strings" @@ -33,65 +30,11 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" - "dubbo.apache.org/dubbo-go/v3/common/constant" - "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -const ( - // ConsistentHash consistent hash - ConsistentHash = "consistenthash" - // HashNodes hash nodes - HashNodes = "hash.nodes" - // HashArguments key of hash arguments in url - HashArguments = "hash.arguments" -) - -var ( - selectors = make(map[string]*consistentHashSelector) - re = regexp.MustCompile(constant.COMMA_SPLIT_PATTERN) -) - -func init() { - extension.SetLoadbalance(ConsistentHash, NewConsistentHashLoadBalance) -} - -// consistentHashLoadBalance implementation of load balancing: using consistent hashing -type consistentHashLoadBalance struct{} - -// NewConsistentHashLoadBalance creates NewConsistentHashLoadBalance -// -// The same parameters of the request is always sent to the same provider. -func NewConsistentHashLoadBalance() cluster.LoadBalance { - return &consistentHashLoadBalance{} -} - -// Select gets invoker based on load balancing strategy -func (lb *consistentHashLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { - methodName := invocation.MethodName() - key := invokers[0].GetURL().ServiceKey() + "." + methodName - - // hash the invokers - bs := make([]byte, 0) - for _, invoker := range invokers { - b, err := json.Marshal(invoker) - if err != nil { - return nil - } - bs = append(bs, b...) - } - hashCode := crc32.ChecksumIEEE(bs) - selector, ok := selectors[key] - if !ok || selector.hashCode != hashCode { - selectors[key] = newConsistentHashSelector(invokers, methodName, hashCode) - selector = selectors[key] - } - return selector.Select(invocation) -} - -// consistentHashSelector implementation of Selector:get invoker based on load balancing strategy -type consistentHashSelector struct { +// selector implementation of Selector:get invoker based on load balancing strategy +type selector struct { hashCode uint32 replicaNum int virtualInvokers map[uint32]protocol.Invoker @@ -99,10 +42,10 @@ type consistentHashSelector struct { argumentIndex []int } -func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, - hashCode uint32) *consistentHashSelector { +func newSelector(invokers []protocol.Invoker, methodName string, + hashCode uint32) *selector { - selector := &consistentHashSelector{} + selector := &selector{} selector.virtualInvokers = make(map[uint32]protocol.Invoker) selector.hashCode = hashCode url := invokers[0].GetURL() @@ -132,23 +75,23 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, } // Select gets invoker based on load balancing strategy -func (c *consistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker { +func (c *selector) Select(invocation protocol.Invocation) protocol.Invoker { key := c.toKey(invocation.Arguments()) digest := md5.Sum([]byte(key)) return c.selectForKey(c.hash(digest, 0)) } -func (c *consistentHashSelector) toKey(args []interface{}) string { +func (c *selector) toKey(args []interface{}) string { var sb strings.Builder for i := range c.argumentIndex { if i >= 0 && i < len(args) { - fmt.Fprint(&sb, args[i].(string)) + _, _ = fmt.Fprint(&sb, args[i].(string)) } } return sb.String() } -func (c *consistentHashSelector) selectForKey(hash uint32) protocol.Invoker { +func (c *selector) selectForKey(hash uint32) protocol.Invoker { idx := sort.Search(len(c.keys), func(i int) bool { return c.keys[i] >= hash }) @@ -158,8 +101,7 @@ func (c *consistentHashSelector) selectForKey(hash uint32) protocol.Invoker { return c.virtualInvokers[c.keys[idx]] } -// nolint -func (c *consistentHashSelector) hash(digest [16]byte, i int) uint32 { +func (c *selector) hash(digest [16]byte, i int) uint32 { return (uint32(digest[3+i*4]&0xFF) << 24) | (uint32(digest[2+i*4]&0xFF) << 16) | (uint32(digest[1+i*4]&0xFF) << 8) | uint32(digest[i*4]&0xFF)&0xFFFFFFF } diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/leastactive/loadbalance.go similarity index 81% rename from cluster/loadbalance/least_active.go rename to cluster/loadbalance/leastactive/loadbalance.go index 59767408fd..317982bc81 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/leastactive/loadbalance.go @@ -15,38 +15,39 @@ * limitations under the License. */ -package loadbalance +package leastactive import ( "math/rand" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) const ( - // LeastActive is used to set the load balance extension - LeastActive = "leastactive" + // Key is used to set the load balance extension + Key = "leastactive" ) func init() { - extension.SetLoadbalance(LeastActive, NewLeastActiveLoadBalance) + extension.SetLoadbalance(constant.LoadBalanceKeyLeastActive, newLoadBalance) } -type leastActiveLoadBalance struct{} +type loadBalance struct{} -// NewLeastActiveLoadBalance returns a least active load balance. +// newLoadBalance returns a least active load balance. // // A random mechanism based on actives, actives means the number of a consumer's requests have been sent to provider but not yet got response. -func NewLeastActiveLoadBalance() cluster.LoadBalance { - return &leastActiveLoadBalance{} +func newLoadBalance() loadbalance.LoadBalance { + return &loadBalance{} } // Select gets invoker based on least active load balancing strategy -func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { +func (lb *loadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { count := len(invokers) if count == 0 { return nil @@ -69,7 +70,7 @@ func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation // Active number active := protocol.GetMethodStatus(invoker.GetURL(), invocation.MethodName()).GetActive() // current weight (maybe in warmUp) - weight := GetWeight(invoker, invocation) + weight := loadbalance.GetWeight(invoker, invocation) // There are smaller active services if leastActive == -1 || active < leastActive { leastActive = active @@ -97,7 +98,7 @@ func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation offsetWeight := rand.Int63n(totalWeight) + 1 for i := 0; i < leastCount; i++ { leastIndex := leastIndexes[i] - offsetWeight -= GetWeight(invokers[i], invocation) + offsetWeight -= loadbalance.GetWeight(invokers[i], invocation) if offsetWeight <= 0 { return invokers[leastIndex] } diff --git a/cluster/loadbalance/least_active_test.go b/cluster/loadbalance/leastactive/loadbalance_test.go similarity index 95% rename from cluster/loadbalance/least_active_test.go rename to cluster/loadbalance/leastactive/loadbalance_test.go index 5d6a50fa52..223692bdd3 100644 --- a/cluster/loadbalance/least_active_test.go +++ b/cluster/loadbalance/leastactive/loadbalance_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package loadbalance +package leastactive import ( "fmt" @@ -34,7 +34,7 @@ import ( ) func TestLeastActiveSelect(t *testing.T) { - loadBalance := NewLeastActiveLoadBalance() + loadBalance := newLoadBalance() var invokers []protocol.Invoker @@ -51,7 +51,7 @@ func TestLeastActiveSelect(t *testing.T) { } func TestLeastActiveByWeight(t *testing.T) { - loadBalance := NewLeastActiveLoadBalance() + loadBalance := newLoadBalance() var invokers []protocol.Invoker loop := 3 diff --git a/cluster/loadbalance.go b/cluster/loadbalance/loadbalance.go similarity index 98% rename from cluster/loadbalance.go rename to cluster/loadbalance/loadbalance.go index b66c18c6d2..d8a5dcd6e7 100644 --- a/cluster/loadbalance.go +++ b/cluster/loadbalance/loadbalance.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package cluster +package loadbalance import ( "dubbo.apache.org/dubbo-go/v3/protocol" diff --git a/cluster/loadbalance/random.go b/cluster/loadbalance/random/loadbalance.go similarity index 75% rename from cluster/loadbalance/random.go rename to cluster/loadbalance/random/loadbalance.go index 86c34448b7..c3a7fb5d68 100644 --- a/cluster/loadbalance/random.go +++ b/cluster/loadbalance/random/loadbalance.go @@ -15,36 +15,33 @@ * limitations under the License. */ -package loadbalance +package random import ( "math/rand" ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) -const ( - name = "random" -) - func init() { - extension.SetLoadbalance(name, NewRandomLoadBalance) + extension.SetLoadbalance(constant.LoadBalanceKeyRandom, NewLoadBalance) } -type randomLoadBalance struct{} +type loadBalance struct{} -// NewRandomLoadBalance returns a random load balance instance. +// NewLoadBalance returns a random load balance instance. // // Set random probabilities by weight, and the request will be sent to provider randomly. -func NewRandomLoadBalance() cluster.LoadBalance { - return &randomLoadBalance{} +func NewLoadBalance() loadbalance.LoadBalance { + return &loadBalance{} } -func (lb *randomLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { +func (lb *loadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { var length int if length = len(invokers); length == 1 { return invokers[0] @@ -52,12 +49,12 @@ func (lb *randomLoadBalance) Select(invokers []protocol.Invoker, invocation prot sameWeight := true weights := make([]int64, length) - firstWeight := GetWeight(invokers[0], invocation) + firstWeight := loadbalance.GetWeight(invokers[0], invocation) totalWeight := firstWeight weights[0] = firstWeight for i := 1; i < length; i++ { - weight := GetWeight(invokers[i], invocation) + weight := loadbalance.GetWeight(invokers[i], invocation) weights[i] = weight totalWeight += weight diff --git a/cluster/loadbalance/random_test.go b/cluster/loadbalance/random/loadbalance_test.go similarity index 82% rename from cluster/loadbalance/random_test.go rename to cluster/loadbalance/random/loadbalance_test.go index de8ce1ead1..37ad2642d1 100644 --- a/cluster/loadbalance/random_test.go +++ b/cluster/loadbalance/random/loadbalance_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package loadbalance +package random import ( "fmt" @@ -43,29 +43,29 @@ const ( ) func TestRandomlbSelect(t *testing.T) { - randomlb := NewRandomLoadBalance() + randomlb := NewLoadBalance() - invokers := []protocol.Invoker{} + var invokers []protocol.Invoker - url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, 0)) - invokers = append(invokers, protocol.NewBaseInvoker(url)) + u, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, 0)) + invokers = append(invokers, protocol.NewBaseInvoker(u)) i := randomlb.Select(invokers, &invocation.RPCInvocation{}) - assert.True(t, i.GetURL().URLEqual(url)) + assert.True(t, i.GetURL().URLEqual(u)) for i := 1; i < 10; i++ { - url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) - invokers = append(invokers, protocol.NewBaseInvoker(url)) + u, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) + invokers = append(invokers, protocol.NewBaseInvoker(u)) } randomlb.Select(invokers, &invocation.RPCInvocation{}) } func TestRandomlbSelectWeight(t *testing.T) { - randomlb := NewRandomLoadBalance() + randomlb := NewLoadBalance() invokers := []protocol.Invoker{} for i := 0; i < 10; i++ { - url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) - invokers = append(invokers, protocol.NewBaseInvoker(url)) + u, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) + invokers = append(invokers, protocol.NewBaseInvoker(u)) } urlParams := url.Values{} @@ -92,12 +92,12 @@ func TestRandomlbSelectWeight(t *testing.T) { } func TestRandomlbSelectWarmup(t *testing.T) { - randomlb := NewRandomLoadBalance() + randomlb := NewLoadBalance() invokers := []protocol.Invoker{} for i := 0; i < 10; i++ { - url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) - invokers = append(invokers, protocol.NewBaseInvoker(url)) + u, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) + invokers = append(invokers, protocol.NewBaseInvoker(u)) } urlParams := url.Values{} diff --git a/cluster/loadbalance/round_robin.go b/cluster/loadbalance/roundrobin/loadbalance.go similarity index 81% rename from cluster/loadbalance/round_robin.go rename to cluster/loadbalance/roundrobin/loadbalance.go index e52e031350..80665d1645 100644 --- a/cluster/loadbalance/round_robin.go +++ b/cluster/loadbalance/roundrobin/loadbalance.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package loadbalance +package roundrobin import ( "math" @@ -25,42 +25,38 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" "dubbo.apache.org/dubbo-go/v3/protocol" ) const ( - // RoundRobin load balancing way - RoundRobin = "roundrobin" - - // nolint - COMPLETE = 0 - // nolint - UPDATING = 1 + Complete = 0 + Updating = 1 ) var ( methodWeightMap sync.Map // [string]invokers - state = int32(COMPLETE) // update lock acquired ? + state = int32(Complete) // update lock acquired ? recyclePeriod = 60 * time.Second.Nanoseconds() ) func init() { - extension.SetLoadbalance(RoundRobin, NewRoundRobinLoadBalance) + extension.SetLoadbalance(constant.LoadBalanceKeyRoundRobin, NewLoadBalance) } -type roundRobinLoadBalance struct{} +type loadBalance struct{} -// NewRoundRobinLoadBalance returns a round robin load balance +// NewLoadBalance returns a round robin load balance // // Use the weight's common advisory to determine round robin ratio -func NewRoundRobinLoadBalance() cluster.LoadBalance { - return &roundRobinLoadBalance{} +func NewLoadBalance() loadbalance.LoadBalance { + return &loadBalance{} } // Select gets invoker based on round robin load balancing strategy -func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { +func (lb *loadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { count := len(invokers) if count == 0 { return nil @@ -83,7 +79,7 @@ func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation ) for _, invoker := range invokers { - weight := GetWeight(invoker, invocation) + weight := loadbalance.GetWeight(invoker, invocation) if weight < 0 { weight = 0 } @@ -122,8 +118,8 @@ func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation } func cleanIfRequired(clean bool, invokers *cachedInvokers, now *time.Time) { - if clean && atomic.CompareAndSwapInt32(&state, COMPLETE, UPDATING) { - defer atomic.CompareAndSwapInt32(&state, UPDATING, COMPLETE) + if clean && atomic.CompareAndSwapInt32(&state, Complete, Updating) { + defer atomic.CompareAndSwapInt32(&state, Updating, Complete) invokers.Range(func(identify, robin interface{}) bool { weightedRoundRobin := robin.(*weightedRoundRobin) elapsed := now.Sub(*weightedRoundRobin.lastUpdate).Nanoseconds() diff --git a/cluster/loadbalance/round_robin_test.go b/cluster/loadbalance/roundrobin/loadbalance_test.go similarity index 95% rename from cluster/loadbalance/round_robin_test.go rename to cluster/loadbalance/roundrobin/loadbalance_test.go index 015c49aeca..fea54858e3 100644 --- a/cluster/loadbalance/round_robin_test.go +++ b/cluster/loadbalance/roundrobin/loadbalance_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package loadbalance +package roundrobin import ( "fmt" @@ -35,7 +35,7 @@ import ( ) func TestRoundRobinSelect(t *testing.T) { - loadBalance := NewRoundRobinLoadBalance() + loadBalance := NewLoadBalance() var invokers []protocol.Invoker @@ -53,7 +53,7 @@ func TestRoundRobinSelect(t *testing.T) { } func TestRoundRobinByWeight(t *testing.T) { - loadBalance := NewRoundRobinLoadBalance() + loadBalance := NewLoadBalance() var invokers []protocol.Invoker loop := 10 diff --git a/common/constant/cluster.go b/common/constant/cluster.go index 6894f3595e..14f3375317 100644 --- a/common/constant/cluster.go +++ b/common/constant/cluster.go @@ -17,8 +17,13 @@ package constant -// nolint const ( - FAILOVER_CLUSTER_NAME = "failover" - ZONEAWARE_CLUSTER_NAME = "zoneAware" + ClusterKeyAvailable = "available" + ClusterKeyBroadcast = "broadcast" + ClusterKeyFailback = "failback" + ClusterKeyFailfast = "failfast" + ClusterKeyFailover = "failover" + ClusterKeyFailsafe = "failsafe" + ClusterKeyForking = "forking" + ClusterKeyZoneAware = "zoneAware" ) diff --git a/common/constant/loadbalance.go b/common/constant/loadbalance.go new file mode 100644 index 0000000000..7b1d8ea195 --- /dev/null +++ b/common/constant/loadbalance.go @@ -0,0 +1,25 @@ +/* + * 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 constant + +const ( + LoadBalanceKeyConsistentHashing = "consistenthashing" + LoadBalanceKeyLeastActive = "leastactive" + LoadBalanceKeyRandom = "random" + LoadBalanceKeyRoundRobin = "roundrobin" +) diff --git a/common/extension/cluster.go b/common/extension/cluster.go index 7c91c5e452..d3614ba1b1 100644 --- a/common/extension/cluster.go +++ b/common/extension/cluster.go @@ -18,7 +18,7 @@ package extension import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster" ) var clusters = make(map[string]func() cluster.Cluster) diff --git a/common/extension/cluster_interceptor.go b/common/extension/cluster_interceptor.go deleted file mode 100644 index e4372597e4..0000000000 --- a/common/extension/cluster_interceptor.go +++ /dev/null @@ -1,60 +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 extension - -import ( - "sync" -) - -import ( - "dubbo.apache.org/dubbo-go/v3/cluster" -) - -var ( - lock sync.RWMutex - interceptors = make(map[string]func() cluster.Interceptor) -) - -// SetClusterInterceptor sets cluster interceptor so that user has chance to inject extra logics before and after -// cluster invoker -func SetClusterInterceptor(name string, fun func() cluster.Interceptor) { - lock.Lock() - defer lock.Unlock() - interceptors[name] = fun -} - -// GetClusterInterceptor returns the cluster interceptor instance with the given name -func GetClusterInterceptor(name string) cluster.Interceptor { - lock.RLock() - defer lock.RUnlock() - if interceptors[name] == nil { - panic("cluster_interceptor for " + name + " doesn't exist, make sure the corresponding package is imported") - } - return interceptors[name]() -} - -// GetClusterInterceptors returns all instances of registered cluster interceptors -func GetClusterInterceptors() []cluster.Interceptor { - lock.RLock() - defer lock.RUnlock() - ret := make([]cluster.Interceptor, 0, len(interceptors)) - for _, f := range interceptors { - ret = append(ret, f()) - } - return ret -} diff --git a/common/extension/loadbalance.go b/common/extension/loadbalance.go index 2a8fcf4e10..3308b405d8 100644 --- a/common/extension/loadbalance.go +++ b/common/extension/loadbalance.go @@ -18,19 +18,19 @@ package extension import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" ) -var loadbalances = make(map[string]func() cluster.LoadBalance) +var loadbalances = make(map[string]func() loadbalance.LoadBalance) // SetLoadbalance sets the loadbalance extension with @name // For example: random/round_robin/consistent_hash/least_active/... -func SetLoadbalance(name string, fcn func() cluster.LoadBalance) { +func SetLoadbalance(name string, fcn func() loadbalance.LoadBalance) { loadbalances[name] = fcn } // GetLoadbalance finds the loadbalance extension with @name -func GetLoadbalance(name string) cluster.LoadBalance { +func GetLoadbalance(name string) loadbalance.LoadBalance { if loadbalances[name] == nil { panic("loadbalance for " + name + " is not existing, make sure you have import the package.") } diff --git a/common/extension/registry_directory.go b/common/extension/registry_directory.go index e810659cb6..ae2fef3af3 100644 --- a/common/extension/registry_directory.go +++ b/common/extension/registry_directory.go @@ -18,12 +18,12 @@ package extension import ( - "dubbo.apache.org/dubbo-go/v3/cluster" + "dubbo.apache.org/dubbo-go/v3/cluster/directory" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/registry" ) -type registryDirectory func(url *common.URL, registry registry.Registry) (cluster.Directory, error) +type registryDirectory func(url *common.URL, registry registry.Registry) (directory.Directory, error) var defaultRegistry registryDirectory @@ -33,7 +33,7 @@ func SetDefaultRegistryDirectory(v registryDirectory) { } // GetDefaultRegistryDirectory finds the registryDirectory with url and registry -func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (cluster.Directory, error) { +func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (directory.Directory, error) { if defaultRegistry == nil { panic("registry directory is not existing, make sure you have import the package.") } diff --git a/config/reference_config.go b/config/reference_config.go index 4dc871ab92..d67f641297 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -31,7 +31,7 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" "dubbo.apache.org/dubbo-go/v3/common/extension" @@ -176,25 +176,25 @@ func (rc *ReferenceConfig) Refer(srv interface{}) { if len(invokers) == 1 { rc.invoker = invokers[0] if rc.URL != "" { - hitClu := constant.FAILOVER_CLUSTER_NAME + hitClu := constant.ClusterKeyFailover if u := rc.invoker.GetURL(); u != nil { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ClusterKeyZoneAware) } - rc.invoker = extension.GetCluster(hitClu).Join(directory.NewStaticDirectory(invokers)) + rc.invoker = extension.GetCluster(hitClu).Join(static.NewDirectory(invokers)) } } else { var hitClu string if regURL != nil { // for multi-subscription scenario, use 'zone-aware' policy by default - hitClu = constant.ZONEAWARE_CLUSTER_NAME + hitClu = constant.ClusterKeyZoneAware } else { // not a registry url, must be direct invoke. - hitClu = constant.FAILOVER_CLUSTER_NAME + hitClu = constant.ClusterKeyFailover if u := invokers[0].GetURL(); u != nil { - hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) + hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ClusterKeyZoneAware) } } - rc.invoker = extension.GetCluster(hitClu).Join(directory.NewStaticDirectory(invokers)) + rc.invoker = extension.GetCluster(hitClu).Join(static.NewDirectory(invokers)) } // publish consumer's metadata diff --git a/filter/filter_impl/import.go b/filter/filter_impl/import.go index 8782cd4dfc..457e3cdde6 100644 --- a/filter/filter_impl/import.go +++ b/filter/filter_impl/import.go @@ -17,8 +17,7 @@ package filter_impl -// This package is for being compatible with older dubbo-go, please refer to https://github.com/dubbogo/imports to see -// the recommended import ways. +// This package is for being compatible with older dubbo-go, please use `imports` package. // This package may be DEPRECATED OR REMOVED in the future. import ( diff --git a/imports/imports.go b/imports/imports.go index c5f757c083..078be19ae9 100644 --- a/imports/imports.go +++ b/imports/imports.go @@ -18,13 +18,36 @@ package imports import ( - _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" - _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/available" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/broadcast" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failback" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failfast" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failover" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/failsafe" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/forking" + _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/zoneaware" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/consistenthashing" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/leastactive" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random" + _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/roundrobin" _ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory" _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" _ "dubbo.apache.org/dubbo-go/v3/config_center/nacos" _ "dubbo.apache.org/dubbo-go/v3/config_center/zookeeper" - _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" + _ "dubbo.apache.org/dubbo-go/v3/filter/accesslog" + _ "dubbo.apache.org/dubbo-go/v3/filter/active" + _ "dubbo.apache.org/dubbo-go/v3/filter/auth" + _ "dubbo.apache.org/dubbo-go/v3/filter/echo" + _ "dubbo.apache.org/dubbo-go/v3/filter/execlmt" + _ "dubbo.apache.org/dubbo-go/v3/filter/generic" + _ "dubbo.apache.org/dubbo-go/v3/filter/gshutdown" + _ "dubbo.apache.org/dubbo-go/v3/filter/hystrix" + _ "dubbo.apache.org/dubbo-go/v3/filter/metrics" + _ "dubbo.apache.org/dubbo-go/v3/filter/seata" + _ "dubbo.apache.org/dubbo-go/v3/filter/sentinel" + _ "dubbo.apache.org/dubbo-go/v3/filter/token" + _ "dubbo.apache.org/dubbo-go/v3/filter/tps" + _ "dubbo.apache.org/dubbo-go/v3/filter/tracing" _ "dubbo.apache.org/dubbo-go/v3/metadata/mapping/metadata" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/etcd" _ "dubbo.apache.org/dubbo-go/v3/metadata/report/nacos" diff --git a/registry/directory/directory.go b/registry/directory/directory.go index eb22597b68..b8a4b674b0 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -29,8 +29,9 @@ import ( ) import ( - "dubbo.apache.org/dubbo-go/v3/cluster" "dubbo.apache.org/dubbo-go/v3/cluster/directory" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/base" + "dubbo.apache.org/dubbo-go/v3/cluster/directory/static" "dubbo.apache.org/dubbo-go/v3/cluster/router/chain" "dubbo.apache.org/dubbo-go/v3/common" "dubbo.apache.org/dubbo-go/v3/common/constant" @@ -52,7 +53,7 @@ func init() { // RegistryDirectory implementation of Directory: // Invoker list returned from this Directory's list method have been filtered by Routers type RegistryDirectory struct { - directory.BaseDirectory + base.Directory cacheInvokers []protocol.Invoker invokersLock sync.RWMutex serviceType string @@ -69,13 +70,13 @@ type RegistryDirectory struct { } // NewRegistryDirectory will create a new RegistryDirectory -func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.Directory, error) { +func NewRegistryDirectory(url *common.URL, registry registry.Registry) (directory.Directory, error) { if url.SubURL == nil { return nil, perrors.Errorf("url is invalid, suburl can not be nil") } logger.Debugf("new RegistryDirectory for service :%s.", url.Key()) dir := &RegistryDirectory{ - BaseDirectory: directory.NewBaseDirectory(url), + Directory: base.NewDirectory(url), cacheInvokers: []protocol.Invoker{}, cacheInvokersMap: &sync.Map{}, serviceType: url.SubURL.Service(), @@ -85,7 +86,7 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster. dir.consumerURL = dir.getConsumerUrl(url.SubURL) if routerChain, err := chain.NewRouterChain(dir.consumerURL); err == nil { - dir.BaseDirectory.SetRouterChain(routerChain) + dir.Directory.SetRouterChain(routerChain) } else { logger.Warnf("fail to create router chain with url: %s, err is: %v", url.SubURL, err) } @@ -302,7 +303,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { } } else { for _, invokers := range groupInvokersMap { - staticDir := directory.NewStaticDirectory(invokers) + staticDir := static.NewDirectory(invokers) cst := extension.GetCluster(dir.GetURL().SubURL.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) err = staticDir.BuildRouterChain(invokers) if err != nil { @@ -400,8 +401,8 @@ func (dir *RegistryDirectory) List(invocation protocol.Invocation) []protocol.In // IsAvailable whether the directory is available func (dir *RegistryDirectory) IsAvailable() bool { - if !dir.BaseDirectory.IsAvailable() { - return dir.BaseDirectory.IsAvailable() + if !dir.Directory.IsAvailable() { + return dir.Directory.IsAvailable() } for _, ivk := range dir.cacheInvokers { @@ -416,7 +417,7 @@ func (dir *RegistryDirectory) IsAvailable() bool { // Destroy method func (dir *RegistryDirectory) Destroy() { // TODO:unregister & unsubscribe - dir.BaseDirectory.Destroy(func() { + dir.Directory.Destroy(func() { invokers := dir.cacheInvokers dir.cacheInvokers = []protocol.Invoker{} for _, ivk := range invokers { diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index 686a77db23..8c57db09c7 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -29,7 +29,7 @@ import ( ) import ( - cluster "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl" + "dubbo.apache.org/dubbo-go/v3/cluster/cluster" "dubbo.apache.org/dubbo-go/v3/common" common_cfg "dubbo.apache.org/dubbo-go/v3/common/config" "dubbo.apache.org/dubbo-go/v3/common/constant" From 4b1746f0cf3c3498eb265818de68e54c1e576a2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Oct 2021 18:13:19 +0800 Subject: [PATCH 147/148] build(deps): bump github.com/emicklei/go-restful/v3 from 3.7.0 to 3.7.1 (#1514) Bumps [github.com/emicklei/go-restful/v3](https://github.com/emicklei/go-restful) from 3.7.0 to 3.7.1. - [Release notes](https://github.com/emicklei/go-restful/releases) - [Changelog](https://github.com/emicklei/go-restful/blob/v3.7.1/CHANGES.md) - [Commits](https://github.com/emicklei/go-restful/compare/v3.7.0...v3.7.1) --- updated-dependencies: - dependency-name: github.com/emicklei/go-restful/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9d1d2ee0ea..371523d5a7 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.17 github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c - github.com/emicklei/go-restful/v3 v3.7.0 + github.com/emicklei/go-restful/v3 v3.7.1 github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 github.com/go-co-op/gocron v0.1.1 diff --git a/go.sum b/go.sum index 90f479b3df..7f88042e2e 100644 --- a/go.sum +++ b/go.sum @@ -197,8 +197,8 @@ github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.7.0 h1:j0vVy2jEc6pJb7dBZkkqXP0mvggYEVUA9upClUMsCts= -github.com/emicklei/go-restful/v3 v3.7.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.7.1 h1:R5iagkkTsfFpe1nce6Yniw3wmSx0Qw5YP469YzRFNEs= +github.com/emicklei/go-restful/v3 v3.7.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= From 0aac960e6219d4138ac2f72ea19ad0d45857784d Mon Sep 17 00:00:00 2001 From: Laurence <45508533+LaurenceLiZhixin@users.noreply.github.com> Date: Sun, 17 Oct 2021 12:31:58 +0800 Subject: [PATCH 148/148] Update triple and some relies version, add consumer registry timeout configuration item (#1516) * fix: update triple and consumer wait for regitry logic * fix: linter * fix: add config api for max wait time * fix: ut * fix: logger config can't read from config center * fix: logger level * fix: level param * update relies version --- common/logger/logger.go | 2 +- config/config_loader.go | 1 - config/consumer_config.go | 20 ++++++++++++++++---- config/root_config.go | 7 ++++++- go.mod | 6 +++--- go.sum | 17 +++++++++-------- metadata/report/delegate/delegate_report.go | 6 +++--- protocol/jsonrpc/jsonrpc_protocol_test.go | 1 - 8 files changed, 38 insertions(+), 22 deletions(-) diff --git a/common/logger/logger.go b/common/logger/logger.go index 6d4f207cd9..bc19e4617c 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -142,7 +142,7 @@ func initZapLoggerWithSyncer(conf *Config) *zap.Logger { core := zapcore.NewCore( conf.getEncoder(), conf.getLogWriter(), - zap.NewAtomicLevelAt(zap.DebugLevel), + zap.NewAtomicLevelAt(conf.ZapConfig.Level.Level()), ) return zap.New(core, zap.AddCallerSkip(1)) diff --git a/config/config_loader.go b/config/config_loader.go index 1379b93c85..a4ca6857ab 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -38,7 +38,6 @@ import ( var ( rootConfig = NewRootConfigBuilder().Build() - maxWait = 3 ) func Load(opts ...LoaderConfOption) error { diff --git a/config/consumer_config.go b/config/consumer_config.go index db34f45fe2..749ea78057 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -39,8 +39,6 @@ const ( // ConsumerConfig is Consumer default configuration type ConsumerConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` - // ConnectTimeout will be remove in 3.0 config-enhance - ConnectTimeout string `default:"3s" yaml:"connect-timeout" json:"connect-timeout,omitempty" property:"connect-timeout"` // support string RegistryIDs []string `yaml:"registryIDs" json:"registryIDs,omitempty" property:"registryIDs"` @@ -50,7 +48,8 @@ type ConsumerConfig struct { References map[string]*ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"` - FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` + FilterConf interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"` + MaxWaitTimeForServiceDiscovery string `default:"3s" yaml:"max-wait-time-for-service-discovery" json:"max-wait-time-for-service-discovery,omitempty" property:"max-wait-time-for-service-discovery"` rootConfig *RootConfig } @@ -99,6 +98,15 @@ func (cc *ConsumerConfig) Load() { ref.Implement(rpcService) } + var maxWait int + + if maxWaitDuration, err := time.ParseDuration(cc.MaxWaitTimeForServiceDiscovery); err != nil { + logger.Warnf("Invalid consumer max wait time for service discovery: %s, fallback to 3s", cc.MaxWaitTimeForServiceDiscovery) + maxWait = 3 + } else { + maxWait = int(maxWaitDuration.Seconds()) + } + // wait for invoker is available, if wait over default 3s, then panic var count int for { @@ -138,7 +146,6 @@ func SetConsumerConfig(c ConsumerConfig) { func newEmptyConsumerConfig() *ConsumerConfig { newConsumerConfig := &ConsumerConfig{ References: make(map[string]*ReferenceConfig, 8), - ConnectTimeout: "3s", RequestTimeout: "3s", Check: true, } @@ -168,6 +175,11 @@ func (ccb *ConsumerConfigBuilder) SetRequestTimeout(requestTimeout string) *Cons return ccb } +func (ccb *ConsumerConfigBuilder) SetMaxWaitTimeForServiceDiscovery(maxWaitTimeForServiceDiscovery string) *ConsumerConfigBuilder { + ccb.consumerConfig.MaxWaitTimeForServiceDiscovery = maxWaitTimeForServiceDiscovery + return ccb +} + func (ccb *ConsumerConfigBuilder) SetProxyFactory(proxyFactory string) *ConsumerConfigBuilder { ccb.consumerConfig.ProxyFactory = proxyFactory return ccb diff --git a/config/root_config.go b/config/root_config.go index 0b88999222..7db0a341da 100644 --- a/config/root_config.go +++ b/config/root_config.go @@ -133,12 +133,17 @@ func registerPOJO() { func (rc *RootConfig) Init() error { registerPOJO() - if err := rc.Logger.Init(); err != nil { + if err := rc.Logger.Init(); err != nil { // init default logger return err } if err := rc.ConfigCenter.Init(rc); err != nil { logger.Infof("config center doesn't start, because %s", err) + } else { + if err := rc.Logger.Init(); err != nil { // init logger using config from config center again + return err + } } + if err := rc.Application.Init(); err != nil { return err } diff --git a/go.mod b/go.mod index 371523d5a7..31add86781 100644 --- a/go.mod +++ b/go.mod @@ -11,12 +11,12 @@ require ( github.com/apache/dubbo-go-hessian2 v1.9.3 github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 - github.com/dubbogo/gost v1.11.17 - github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c + github.com/dubbogo/gost v1.11.18 + github.com/dubbogo/triple v1.0.7 github.com/emicklei/go-restful/v3 v3.7.1 github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 - github.com/go-co-op/gocron v0.1.1 + github.com/go-co-op/gocron v1.9.0 github.com/go-playground/validator/v10 v10.9.0 github.com/go-resty/resty/v2 v2.3.0 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect diff --git a/go.sum b/go.sum index 7f88042e2e..13f8523270 100644 --- a/go.sum +++ b/go.sum @@ -177,14 +177,13 @@ github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl8 github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.11.16/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.11.17 h1:Dwaoqv/G21nYsGkeQoLbCAOryRPl6B7pEsZSJcr55nE= -github.com/dubbogo/gost v1.11.17/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= +github.com/dubbogo/gost v1.11.18 h1:e9WRvDQut6cePYcQEOUC15vGSfftO7q9G2+Vw2s4CHE= +github.com/dubbogo/gost v1.11.18/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= -github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c h1:/Qrdqo2JVrywDANk04DHrvdfREdIApAWZ6stbYZfNaM= -github.com/dubbogo/triple v1.0.6-0.20210909153707-3620c8d2d97c/go.mod h1:KbfU/uZDv+fJEqXYK3qI8m1iuBQ309QxiC0tvTf2pog= +github.com/dubbogo/triple v1.0.7 h1:rPRtf5QNQO2FqXckMugn8KmQyhXQPZyImrEJ/OKAB7o= +github.com/dubbogo/triple v1.0.7/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -231,8 +230,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-co-op/gocron v0.1.1 h1:OfDmkqkCguFtFMsm6Eaayci3DADLa8pXvdmOlPU/JcU= -github.com/go-co-op/gocron v0.1.1/go.mod h1:Y9PWlYqDChf2Nbgg7kfS+ZsXHDTZbMZYPEQ0MILqH+M= +github.com/go-co-op/gocron v1.9.0 h1:+V+DDenw3ryB7B+tK1bAIC5p0ruw4oX9IqAsdRnGIf0= +github.com/go-co-op/gocron v1.9.0/go.mod h1:DbJm9kdgr1sEvWpHCA7dFFs/PGHPMil9/97EXCRPr4k= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -263,7 +262,6 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.9.0 h1:NgTtmN58D0m8+UuxtYmGztBJB7VnPgjj221I1QHci2A= github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -671,6 +669,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -933,6 +933,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go index 23765d7489..536da6b357 100644 --- a/metadata/report/delegate/delegate_report.go +++ b/metadata/report/delegate/delegate_report.go @@ -73,7 +73,7 @@ func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func( retryTimesIfNonFail: 600, } - newJob, err := mrr.scheduler.Every(uint64(mrr.retryPeriod)).Seconds().Do( + newJob, err := mrr.scheduler.Every(int(mrr.retryPeriod)).Seconds().Do( func() { mrr.retryCounter.Inc() logger.Infof("start to retry task for metadata report. retry times: %v", mrr.retryCounter.Load()) @@ -91,7 +91,7 @@ func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func( // startRetryTask will make scheduler with retry task run func (mrr *metadataReportRetry) startRetryTask() { mrr.scheduler.StartAt(time.Now().Add(500 * time.Millisecond)) - mrr.scheduler.Start() + mrr.scheduler.StartAsync() } // MetadataReport is a absolute delegate for MetadataReport @@ -145,7 +145,7 @@ func NewMetadataReport() (*MetadataReport, error) { return nil, err } scheduler.StartAt(time.Now().Add(500 * time.Millisecond)) - scheduler.Start() + scheduler.StartAsync() } return bmr, nil } diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index b714678a94..feb070a7af 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -74,7 +74,6 @@ func TestJsonrpcProtocolRefer(t *testing.T) { "side=provider&timeout=3000×tamp=1556509797245") assert.NoError(t, err) con := config.ConsumerConfig{ - ConnectTimeout: "5s", RequestTimeout: "5s", } config.SetConsumerConfig(con)