This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch 3.1 in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit 4deb951d769d8aef26215ae68a5fc2311c669d81 Merge: 3c420b5bb 9f822e6e2 Author: chickenlj <[email protected]> AuthorDate: Fri Feb 24 16:31:12 2023 +0800 Merge branch '3.0' into 3.1 # Conflicts: # .asf.yaml # common/constant/env.go # common/url.go # config/registry_config.go # config/service_config.go # config/service_config_test.go .asf.yaml | 86 ++- .github/PULL_REQUEST_TEMPLATE.md | 1 - .github/workflows/github-actions.yml | 16 +- .github/workflows/golangci-lint.yml | 6 +- CHANGELOG.md | 82 ++- README.md | 42 +- README_CN.md | 15 +- cluster/cluster/available/cluster_invoker_test.go | 6 +- cluster/cluster/broadcast/cluster_invoker_test.go | 10 +- cluster/cluster/failback/cluster_test.go | 28 +- cluster/cluster/failfast/cluster_test.go | 10 +- cluster/cluster/failsafe/cluster_test.go | 10 +- cluster/cluster/forking/cluster_test.go | 18 +- cluster/cluster/zoneaware/cluster_invoker_test.go | 28 +- cluster/loadbalance/leastactive/loadbalance.go | 2 +- .../router/polaris/default.go | 13 +- .../router/polaris/factory.go | 19 +- cluster/router/polaris/router.go | 331 +++++++++ common/constant/env.go | 4 + common/constant/file/suffix.go | 5 + common/constant/key.go | 22 +- common/constant/{env.go => polaris_key.go} | 31 +- common/constant/version.go | 4 +- common/host_util.go | 34 + common/host_util_test.go | 45 ++ common/url.go | 43 +- common/url_test.go | 2 +- config/config_loader.go | 2 +- config/config_loader_options.go | 10 +- config/config_resolver.go | 50 +- config/config_resolver_test.go | 48 ++ config/consumer_config.go | 4 +- config/graceful_shutdown.go | 2 +- config/logger_config.go | 11 + config/metric_config.go | 13 + config/provider_config.go | 4 +- config/reference_config.go | 70 ++ config/registry_config.go | 2 +- config/registry_config_test.go | 13 + config/root_config.go | 7 + config/service_config.go | 2 +- config/ssl_config.go | 6 + config/testdata/config/resolver/application.yaml | 36 + config/tls_config.go | 93 +++ config_center/nacos/impl_test.go | 5 + filter/active/filter_test.go | 6 +- filter/adaptivesvc/limiter_mapper.go | 3 +- filter/auth/consumer_sign_filter_test.go | 4 +- filter/auth/provider_auth_filter_test.go | 4 +- filter/filter_impl/import.go | 1 + filter/generic/filter_test.go | 12 +- filter/generic/service_filter_test.go | 12 +- .../polaris/limit/default.go | 16 +- filter/polaris/limit/limiter.go | 173 +++++ go.mod | 49 +- go.sum | 166 +++-- imports/imports.go | 2 + metadata/definition/definition.go | 30 +- metadata/identifier/base_metadata_identifier.go | 8 + metadata/report/delegate/delegate_report.go | 2 +- metadata/report/nacos/report_test.go | 4 + metadata/service/local/service_proxy.go | 2 + metadata/service/local/service_test.go | 8 +- metadata/service/local_service.go | 7 +- metadata/service/remote/service_test.go | 9 +- metrics/prometheus/reporter.go | 88 ++- protocol/dubbo3/dubbo3_invoker.go | 24 +- protocol/dubbo3/dubbo3_invoker_test.go | 32 + protocol/dubbo3/dubbo3_protocol.go | 11 +- protocol/grpc/client.go | 20 +- protocol/grpc/server.go | 25 +- protocol/mock/mock_invoker.go | 80 ++- registry/base_registry.go | 9 +- registry/directory/directory.go | 16 +- registry/directory/directory_test.go | 2 +- registry/etcdv3/registry.go | 5 + .../service_instances_changed_listener_impl.go | 66 +- registry/mock_registry.go | 5 + registry/nacos/registry.go | 40 +- registry/nacos/registry_test.go | 4 + registry/nacos/service_discovery_test.go | 3 + registry/polaris/core.go | 11 +- registry/polaris/listener.go | 32 +- registry/polaris/registry.go | 231 +++--- registry/polaris/service_discovery.go | 90 +-- registry/polaris/utils.go | 12 +- registry/protocol/protocol.go | 6 +- registry/protocol/protocol_test.go | 6 +- registry/registry.go | 6 + .../servicediscovery/service_discovery_registry.go | 32 + registry/xds/registry.go | 5 + registry/zookeeper/listener.go | 2 +- registry/zookeeper/registry.go | 5 + registry/zookeeper/service_discovery.go | 4 +- remoting/getty/config.go | 6 + remoting/getty/getty_client.go | 14 +- remoting/getty/getty_server.go | 20 +- remoting/getty/pool.go | 9 +- remoting/nacos/builder_test.go | 2 +- remoting/polaris/builder.go | 111 ++- remoting/polaris/builder_test.go | 65 +- remoting/polaris/parser/parser.go | 125 ++++ remoting/polaris/parser/parser_test.go | 168 +++++ remoting/polaris/polaris.yaml | 15 +- remoting/xds/client_test.go | 799 --------------------- remoting/zookeeper/listener.go | 27 +- tools/dubbo-go-schema/README.md | 31 + tools/dubbo-go-schema/application.yaml | 25 + tools/dubbo-go-schema/dubbo-go.json | 746 +++++++++++++++++++ tools/dubbo-go-schema/images/img.png | Bin 0 -> 675226 bytes tools/dubbo-go-schema/images/img_1.png | Bin 0 -> 301760 bytes tools/dubbo-go-schema/images/vs-code.png | Bin 0 -> 45673 bytes tools/dubbogo-cli/Makefile | 2 + tools/dubbogo-cli/README.md | 450 ++++++++++++ tools/dubbogo-cli/README_CN.md | 445 ++++++++++++ tools/dubbogo-cli/cmd/call.go | 94 +++ .../dubbogo-cli/cmd/gen.go | 32 +- tools/dubbogo-cli/cmd/gen_test.go | 82 +++ tools/dubbogo-cli/cmd/hessian.go | 71 ++ tools/dubbogo-cli/cmd/install.go | 120 ++++ .../dubbogo-cli/cmd/new_demo.go | 32 +- tools/dubbogo-cli/cmd/root.go | 75 ++ tools/dubbogo-cli/cmd/show.go | 108 +++ .../cmd/testGenCode/template/newApp/.gitignore | 1 + .../cmd/testGenCode/template/newApp/Makefile | 45 ++ .../cmd/testGenCode/template/newApp/api/api.pb.go | 257 +++++++ .../cmd/testGenCode/template/newApp/api/api.proto | 30 +- .../template/newApp/api/api_triple.pb.go | 261 +++++++ .../testGenCode/template/newApp/build/Dockerfile | 10 + .../template/newApp/chart/app/Chart.yaml | 24 + .../newApp/chart/app/templates/_helpers.tpl | 75 ++ .../newApp/chart/app/templates/deployment.yaml | 62 ++ .../newApp/chart/app/templates/service.yaml | 21 + .../newApp/chart/app/templates/serviceaccount.yaml | 12 + .../template/newApp/chart/app/values.yaml | 74 ++ .../template/newApp/chart/nacos_env/Chart.yaml | 24 + .../newApp/chart/nacos_env/templates/_helpers.tpl | 75 ++ .../chart/nacos_env/templates/deployment.yaml | 62 ++ .../newApp/chart/nacos_env/templates/service.yaml | 21 + .../template/newApp/chart/nacos_env/values.yaml | 58 ++ .../cmd/testGenCode/template/newApp/cmd/app.go | 15 +- .../testGenCode/template/newApp/conf/dubbogo.yaml | 13 + .../cmd/testGenCode/template/newApp/go.mod | 11 + .../template/newApp/pkg/service/service.go | 24 +- .../template/newDemo/api/samples_api.pb.go | 255 +++++++ .../template/newDemo/api/samples_api.proto | 29 +- .../template/newDemo/api/samples_api_triple.pb.go | 261 +++++++ .../template/newDemo/go-client/cmd/client.go | 32 +- .../template/newDemo/go-client/conf/dubbogo.yaml | 7 + .../template/newDemo/go-server/cmd/server.go | 30 +- .../template/newDemo/go-server/conf/dubbogo.yaml | 9 + .../cmd/testGenCode/template/newDemo/go.mod | 10 + .../dubbogo-cli/cmd/version.go | 27 +- .../dubbogo-cli/constant/constant.go | 4 +- tools/dubbogo-cli/generator/application/api.go | 551 ++++++++++++++ .../dubbogo-cli/generator/application/build.go | 28 +- tools/dubbogo-cli/generator/application/chart.go | 448 ++++++++++++ .../dubbogo-cli/generator/application/cmd.go | 31 +- .../dubbogo-cli/generator/application/conf.go | 31 +- .../dubbogo-cli/generator/application/generator.go | 74 ++ .../dubbogo-cli/generator/application/gitignore.go | 19 +- .../dubbogo-cli/generator/application/gomod.go | 29 +- .../dubbogo-cli/generator/application/makefile.go | 75 ++ .../dubbogo-cli/generator/application/pkg.go | 36 +- tools/dubbogo-cli/generator/sample/api.go | 268 +++++++ tools/dubbogo-cli/generator/sample/api_tripe.go | 272 +++++++ tools/dubbogo-cli/generator/sample/constants.go | 39 + .../dubbogo-cli/generator/sample/gen_c_conf.go | 24 +- tools/dubbogo-cli/generator/sample/gen_client.go | 63 ++ .../dubbogo-cli/generator/sample/gen_s_conf.go | 26 +- tools/dubbogo-cli/generator/sample/gen_server.go | 62 ++ tools/dubbogo-cli/generator/sample/generator.go | 74 ++ .../generator/sample/hessian/constant.go | 32 +- .../generator/sample/hessian/file_scanner.go | 32 +- .../generator/sample/hessian/generator.go | 282 ++++++++ .../dubbogo-cli/generator/sample/hessian/logger.go | 32 +- .../dubbogo-cli/generator/sample/hessian/pool.go | 39 +- .../generator/sample/hessian_generator.go | 22 +- .../dubbogo-cli/generator/sample/mod.go | 28 +- .../dubbogo-cli/generator/sample/proto.go | 44 +- tools/dubbogo-cli/go.mod | 53 ++ go.sum => tools/dubbogo-cli/go.sum | 568 +++++++++------ tools/dubbogo-cli/internal/client/client.go | 196 +++++ .../dubbogo-cli/internal/common/protocol.go | 19 +- .../dubbogo-cli/internal/common/tool.go | 23 +- .../internal/json_register/json_register.go | 67 ++ tools/dubbogo-cli/internal/protocol/dubbo/codec.go | 123 ++++ .../internal/protocol/dubbo/dubbo_protocol.go | 112 +++ .../dubbogo-cli/internal/protocol/dubbo3/codec.go | 123 ++++ .../internal/protocol/dubbo3/dubbo_protocol.go | 112 +++ .../dubbogo-cli/internal/protocol/protocol.go | 20 +- .../host_util_test.go => tools/dubbogo-cli/main.go | 12 +- .../dubbogo-cli/metadata/metadata.go | 36 +- tools/dubbogo-cli/metadata/zookeeper/zookeeper.go | 156 ++++ xds/balancer/cdsbalancer/cdsbalancer.go | 2 +- xds/client/bootstrap/bootstrap.go | 6 +- xds/credentials/cert_manager.go | 271 +++++++ xds/credentials/certgenerate/crypto.go | 166 +++++ .../credentials/certgenerate/dual_use.go | 27 +- xds/credentials/certgenerate/generate_cert.go | 440 ++++++++++++ xds/credentials/certgenerate/generate_csr.go | 137 ++++ xds/credentials/certgenerate/san.go | 213 ++++++ xds/credentials/certprovider/distributor.go | 121 ++++ xds/credentials/certprovider/pemfile/builder.go | 105 +++ xds/credentials/certprovider/pemfile/watcher.go | 265 +++++++ xds/credentials/certprovider/provider.go | 104 +++ .../certprovider/remote/istioca_client.go | 210 ++++++ .../certprovider/remote/v1alpha1/ca.pb.go | 287 ++++++++ .../certprovider/remote/v1alpha1/ca_grpc.pb.go | 128 ++++ xds/credentials/certprovider/store.go | 161 +++++ xds/credentials/env.go | 51 ++ .../credentials/token_provider.go | 42 +- xds/server/conn_wrapper.go | 5 +- xds/utils/credentials/xds/handshake_info.go | 3 +- 214 files changed, 13132 insertions(+), 2087 deletions(-) diff --cc .asf.yaml index 10e852b4c,2c7272d53..6a9639dec --- a/.asf.yaml +++ b/.asf.yaml @@@ -1,31 -1,31 +1,55 @@@ - notifications: - commits: [email protected] - issues: [email protected] - pullrequests: [email protected] - jira_options: link label link label - github: - homepage: https://dubbo.apache.org/ - description: "Go Implementation For Apache Dubbo ." - labels: - - go - - rpc - - microservices - - http2 - - service-mesh - features: - # Enable wiki for documentation - wiki: true - # Enable issue management - issues: true - # Enable projects for project management boards - projects: true - protected_branches: - master: - # only disable force push - foo: bar - 3.0: - # only disable force push - foo: bar - 3.1: - # only disable force push - foo: bar + # + # 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. + # + -github: - enabled_merge_buttons: - # enable squash button: - squash: true - # enable merge button: - merge: false - # disable rebase button: - rebase: false - + notifications: + commits: [email protected] + issues: [email protected] + pullrequests: [email protected] + jira_options: link label link label ++github: ++ homepage: https://dubbo.apache.org/ ++ description: "Go Implementation For Apache Dubbo ." ++ labels: ++ - go ++ - rpc ++ - microservices ++ - http2 ++ - service-mesh ++ features: ++ # Enable wiki for documentation ++ wiki: true ++ # Enable issue management ++ issues: true ++ # Enable projects for project management boards ++ projects: true ++ protected_branches: ++ master: ++ # only disable force push ++ foo: bar ++ 3.0: ++ # only disable force push ++ foo: bar ++ 3.1: ++ # only disable force push ++ foo: bar ++ enabled_merge_buttons: ++ # enable squash button: ++ squash: true ++ # enable merge button: ++ merge: false ++ # disable rebase button: ++ rebase: false diff --cc common/constant/env.go index 89bb95ce7,920bebe06..b5e4acaff --- a/common/constant/env.go +++ b/common/constant/env.go @@@ -19,13 -19,12 +19,17 @@@ package constan // nolint const ( - ConfigFileEnvKey = "DUBBO_GO_CONFIG_PATH" // key of environment variable dubbogo configure file path - AppLogConfFile = "AppLogConfFile" - PodNameEnvKey = "POD_NAME" - PodNamespaceEnvKey = "POD_NAMESPACE" + ConfigFileEnvKey = "DUBBO_GO_CONFIG_PATH" // key of environment variable dubbogo configure file path + AppLogConfFile = "AppLogConfFile" + PodNameEnvKey = "POD_NAME" + PodNamespaceEnvKey = "POD_NAMESPACE" + ClusterDomainKey = "CLUSTER_DOMAIN" + DefaultClusterDomain = "cluster.local" + DefaultNamespace = "default" + SVC = "svc" + DefaultMeshPort = 80 + + DubboIpToRegistryKey = "DUBBO_IP_TO_REGISTRY" + DubboPortToRegistryKey = "DUBBO_PORT_TO_REGISTRY" + DubboDefaultPortToRegistry = "80" ) diff --cc common/url.go index cb5a46543,e0ef856f5..cdd31a699 --- a/common/url.go +++ b/common/url.go @@@ -721,18 -692,17 +720,17 @@@ func MergeURL(serviceURL *URL, referenc // iterator the referenceURL if serviceURL not have the key ,merge in // referenceURL usually will not changed. so change RangeParams to GetParams to avoid the string value copy.// Group get group for key, value := range referenceURL.GetParams() { - if v := mergedURL.GetParam(key, ""); len(v) == 0 && len(value) > 0 { - if params == nil { - params = url.Values{} + if _, ok := mergedURL.GetNonDefaultParam(key); !ok { + if len(value) > 0 { + params[key] = value } + params[key] = make([]string, len(value)) + copy(params[key], value) } } - // loadBalance,cluster,retries strategy config - methodConfigMergeFcn := mergeNormalParam(params, referenceURL, []string{constant.LoadbalanceKey, constant.ClusterKey, constant.RetriesKey, constant.TimeoutKey}) - // remote timestamp - if v := serviceURL.GetParam(constant.TimestampKey, ""); len(v) > 0 { + if v, ok := serviceURL.GetNonDefaultParam(constant.TimestampKey); !ok { params[constant.RemoteTimestampKey] = []string{v} params[constant.TimestampKey] = []string{referenceURL.GetParam(constant.TimestampKey, "")} } diff --cc config/registry_config.go index 55f61642d,f7a1168d1..b7b0790b0 --- a/config/registry_config.go +++ b/config/registry_config.go @@@ -41,22 -41,20 +41,22 @@@ 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:"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:"15m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` - 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"` - Preferred bool `yaml:"preferred" json:"preferred,omitempty" property:"preferred"` // Always use this registry first if set to true, useful when subscribe to multiple registriesConfig - Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"` // The region where the registry belongs, usually used to isolate traffics - Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` // Affects traffic distribution among registriesConfig, useful when subscribe to multiple registriesConfig Take effect only when no preferred registry is specified. - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` - RegistryType string `yaml:"registry-type"` + Protocol string `validate:"required" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` + 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:"10s" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute ++ TTL string `default:"15m" yaml:"ttl" json:"ttl,omitempty" property:"ttl"` // unit: minute + 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"` + Preferred bool `yaml:"preferred" json:"preferred,omitempty" property:"preferred"` // Always use this registry first if set to true, useful when subscribe to multiple registriesConfig + Zone string `yaml:"zone" json:"zone,omitempty" property:"zone"` // The region where the registry belongs, usually used to isolate traffics + Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"` // Affects traffic distribution among registriesConfig, useful when subscribe to multiple registriesConfig Take effect only when no preferred registry is specified. + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + RegistryType string `yaml:"registry-type"` + UseAsMetaReport bool `default:"true" yaml:"use-as-meta-report" json:"use-as-meta-report,omitempty" property:"use-as-meta-report"` + UseAsConfigCenter bool `default:"true" yaml:"use-as-config-center" json:"use-as-config-center,omitempty" property:"use-as-config-center"` } // Prefix dubbo.registries diff --cc registry/directory/directory.go index ecac8bac2,b975462c0..7ba8ace94 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@@ -91,15 -91,20 +91,19 @@@ func NewRegistryDirectory(url *common.U } dir.consumerConfigurationListener = newConsumerConfigurationListener(dir) + dir.consumerConfigurationListener.addNotifyListener(dir) + dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) + + if err := dir.registry.LoadSubscribeInstances(url.SubURL, dir); err != nil { + return nil, err + } - go dir.subscribe(url.SubURL) return dir, nil } // subscribe from registry -func (dir *RegistryDirectory) subscribe(url *common.URL) { +func (dir *RegistryDirectory) Subscribe(url *common.URL) { logger.Debugf("subscribe service :%s for RegistryDirectory.", url.Key()) - dir.consumerConfigurationListener.addNotifyListener(dir) - dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) if err := dir.registry.Subscribe(url, dir); err != nil { logger.Error("registry.Subscribe(url:%v, dir:%v) = error:%v", url, dir, err) }
