From 4af92822756089e5a84a46fe76687a855b09fc74 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Tue, 25 Feb 2020 11:42:20 +0800 Subject: [PATCH 001/167] Add:metadata report config --- common/constant/key.go | 8 +++ config/application_config.go | 1 + config/consumer_config.go | 14 +++++ config/metadata_report_config.go | 79 +++++++++++++++++++++++++++ config/metadata_report_config_test.go | 26 +++++++++ config/registry_config.go | 4 +- 6 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 config/metadata_report_config.go create mode 100644 config/metadata_report_config_test.go diff --git a/common/constant/key.go b/common/constant/key.go index eff704371c..b2afb01626 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -120,6 +120,7 @@ const ( ProviderConfigPrefix = "dubbo.provider." ConsumerConfigPrefix = "dubbo.consumer." ShutdownConfigPrefix = "dubbo.shutdown." + MetadataReportPrefix = "dubbo.metadata-report." ) const ( @@ -159,3 +160,10 @@ const ( ACCESS_KEY_ID_KEY = "accessKeyId" SECRET_ACCESS_KEY_KEY = "secretAccessKey" ) + +// metadata report + +const ( + METACONFIG_REMOTE = "remote" + METACONFIG_LOCAL = "local" +) diff --git a/config/application_config.go b/config/application_config.go index 23ab7d34ac..33b47c81dd 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -33,6 +33,7 @@ type ApplicationConfig struct { 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"` + MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` //field for metadata report } // Prefix ... diff --git a/config/consumer_config.go b/config/consumer_config.go index 98917ebca2..0d9c9585c5 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -45,6 +45,9 @@ type ConsumerConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // application ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` + // metadata-report + MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` + // client Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` ConnectTimeout time.Duration @@ -152,3 +155,14 @@ func configCenterRefreshConsumer() error { } return err } + +// StartMetadataReport: The entry of metadata report start +func startMetadataReport() error { + metadataConfig := consumerConfig.ApplicationConfig.MetadataType + if metadataConfig == constant.METACONFIG_REMOTE && consumerConfig.MetadataReportConfig == nil { + return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.") + } else if metadataConfig == constant.METACONFIG_REMOTE && len(consumerConfig.MetadataReportConfig.Address) == 0 { + return perrors.New("MetadataConfig address can not be empty.") + } + return nil +} diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go new file mode 100644 index 0000000000..3f170606e7 --- /dev/null +++ b/config/metadata_report_config.go @@ -0,0 +1,79 @@ +/* + * 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 ( + "net/url" +) +import ( + "github.com/creasty/defaults" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" +) + +// MethodConfig ... +type MetadataReportConfig struct { + Address string `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"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second + Group string `yaml:"group" json:"group,omitempty" property:"group"` +} + +// Prefix ... +func (c *MetadataReportConfig) Prefix() string { + return constant.MetadataReportPrefix +} + +// UnmarshalYAML ... +func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { + if err := defaults.Set(c); err != nil { + return err + } + type plain MetadataReportConfig + if err := unmarshal((*plain)(c)); err != nil { + return err + } + return nil +} + +// ToUrl ... +func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { + urlMap := url.Values{} + + for k, v := range c.Params { + urlMap.Set(k, v) + } + + url, err := common.NewURL(c.Address, + common.WithParams(urlMap), + common.WithUsername(c.Username), + common.WithPassword(c.Password), + common.WithLocation(c.Address), + ) + if err != nil { + return nil, perrors.New("Invalid MetadataReportConfig.") + } + url.SetParam("metadata", url.Protocol) + return &url, nil +} diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go new file mode 100644 index 0000000000..322d50c107 --- /dev/null +++ b/config/metadata_report_config_test.go @@ -0,0 +1,26 @@ +package config + +import "testing" + +import ( + "github.com/stretchr/testify/assert" +) + +func TestMetadataReportConfig_ToUrl(t *testing.T) { + metadataReportConfig := MetadataReportConfig{ + Address: "mock://127.0.0.1", + Username: "test", + Password: "test", + TimeoutStr: "3s", + Params: map[string]string{ + "k": "v", + }, + } + url, error := metadataReportConfig.ToUrl() + assert.NoError(t, error) + assert.Equal(t, "mock", url.Protocol) + 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/registry_config.go b/config/registry_config.go index 4e4b6e97d7..f3d22311b8 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -93,7 +93,7 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf addresses := strings.Split(registryConf.Address, ",") address := addresses[0] - address = traslateRegistryConf(address, registryConf) + address = translateRegistryConf(address, registryConf) url, err = common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, common.WithParams(registryConf.getUrlMap(roleType)), common.WithUsername(registryConf.Username), @@ -127,7 +127,7 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { return urlMap } -func traslateRegistryConf(address string, registryConf *RegistryConfig) string { +func translateRegistryConf(address string, registryConf *RegistryConfig) string { if strings.Contains(address, "://") { translatedUrl, err := url.Parse(address) if err != nil { From 5ce2598810af53272b13224f7d09db1247c67c8a Mon Sep 17 00:00:00 2001 From: flycash Date: Sun, 1 Mar 2020 22:23:08 +0800 Subject: [PATCH 002/167] Add necessary interface definition --- go.mod | 2 + registry/event.go | 48 +++++++++++++++++- registry/event_listener.go | 42 ++++++++++++++++ registry/service_discovery.go | 95 +++++++++++++++++++++++++++++++++++ registry/service_instance.go | 43 ++++++++++++++++ 5 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 registry/event_listener.go create mode 100644 registry/service_discovery.go create mode 100644 registry/service_instance.go diff --git a/go.mod b/go.mod index 54b39d322e..d1ee5568db 100644 --- a/go.mod +++ b/go.mod @@ -56,4 +56,6 @@ require ( gopkg.in/yaml.v2 v2.2.2 ) +replace github.com/dubbogo/gost => /Users/mindeng/git/apache-dubbo/gost + go 1.13 diff --git a/registry/event.go b/registry/event.go index 37d863d216..0500cc7018 100644 --- a/registry/event.go +++ b/registry/event.go @@ -32,9 +32,9 @@ func init() { rand.Seed(time.Now().UnixNano()) } -////////////////////////////////////////// +// //////////////////////////////////////// // service event -////////////////////////////////////////// +// //////////////////////////////////////// // ServiceEvent ... type ServiceEvent struct { @@ -45,3 +45,47 @@ type ServiceEvent struct { func (e ServiceEvent) String() string { return fmt.Sprintf("ServiceEvent{Action{%s}, Path{%s}}", e.Action, e.Service) } + +// Event is align with Event interface in Java. +// it's the top abstraction +// Align with 2.7.5 +type Event interface { + fmt.Stringer + GetSource() interface{} + GetTimestamp() time.Time +} + +// baseEvent is the base implementation of Event +// You should never use it directly +type baseEvent struct { + source interface{} + timestamp time.Time +} + +// GetSource return the source +func (b *baseEvent) GetSource() interface{} { + return b.source +} + +// GetTimestamp return the timestamp when the event is created +func (b *baseEvent) GetTimestamp() time.Time { + return b.timestamp +} + +// String return a human readable string representing this event +func (b *baseEvent) String() string { + return fmt.Sprintf("baseEvent[source = %#v]", b.source) +} + +func newBaseEvent(source interface{}) *baseEvent { + return &baseEvent{ + source: source, + timestamp: time.Now(), + } +} + +// ServiceInstancesChangedEvent represents service instances make some changing +type ServiceInstancesChangedEvent struct { + fmt.Stringer + baseEvent +} diff --git a/registry/event_listener.go b/registry/event_listener.go new file mode 100644 index 0000000000..4bfec5d841 --- /dev/null +++ b/registry/event_listener.go @@ -0,0 +1,42 @@ +/* + * 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 registry + +import ( + gxsort "github.com/dubbogo/gost/sort" +) + +// EventListener is an new interface used to align with dubbo 2.7.5 +// It contains the Prioritized means that the listener has its priority +type EventListener interface { + gxsort.Prioritized + // OnEvent handle this event + OnEvent(e Event) error +} + +// ConditionalEventListener only handle the event which it can handle +type ConditionalEventListener interface { + EventListener + // Accept will make the decision whether it should handle this event + Accept(e Event) bool +} + +// TODO (implement ConditionalEventListener) +type ServiceInstancesChangedListener struct { + +} diff --git a/registry/service_discovery.go b/registry/service_discovery.go new file mode 100644 index 0000000000..11b059c389 --- /dev/null +++ b/registry/service_discovery.go @@ -0,0 +1,95 @@ +/* + * 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 registry + +import ( + "fmt" +) + +import ( + gxset "github.com/dubbogo/gost/container/set" + gxpage "github.com/dubbogo/gost/page" +) + +import ( + "github.com/apache/dubbo-go/common" +) + +type ServiceDiscovery interface { + + fmt.Stringer + + // ----------------- lifecycle ------------------- + + // Initialize will initialize the service discovery instance + // if initialize failed, it will return the error + Initialize(url common.URL) error + + // Destroy will destroy the service discovery. + // If the discovery cannot be destroy, it will return an error. + Destroy() error + + + // ----------------- registration ---------------- + + // Register will register an instance of ServiceInstance to registry + Register(instance ServiceInstance) error + + // Update will update the data of the instance in registry + Update(instance ServiceInstance) error + + // Unregister will unregister this instance from registry + Unregister(instance ServiceInstance) error + + + // ----------------- discovery ------------------- + // GetDefaultPageSize will return the default page size + GetDefaultPageSize() int + + // GetServices will return the all service names. + GetServices() gxset.HashSet + + // GetInstances will return all service instances with serviceName + GetInstances(serviceName string) []ServiceInstance + + // GetInstancesByPage will return a page containing instances of ServiceInstance with the serviceName + // the page will start at offset + GetInstancesByPage(serviceName string, offset int, pageSize int) gxpage.Pager + + // GetHealthyInstancesByPage will return a page containing instances of ServiceInstance. + // The param healthy indices that the instance should be healthy or not. + // The page will start at offset + GetHealthyInstancesByPage(serviceName string, offset int, pageSize int, healthy bool) gxpage.Pager + + // Batch get all instances by the specified service names + GetRequestInstances(serviceNames []string, offset int, requestedSize int) map[string]gxpage.Pager + + + // ----------------- event ---------------------- + // AddListener adds a new ServiceInstancesChangedListener + 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/service_instance.go b/registry/service_instance.go new file mode 100644 index 0000000000..d27ed8accf --- /dev/null +++ b/registry/service_instance.go @@ -0,0 +1,43 @@ +/* + * 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 registry + +type ServiceInstance interface { + + // GetId will return this instance's id. It should be unique. + GetId() string + + // GetServiceName will return the serviceName + GetServiceName() string + + // GetHost will return the hostname + GetHost() string + + // GetPort will return the port. + // if the port is not present, return error + GetPort() (int, error) + + // IsEnable will return the enable status of this instance + IsEnable() bool + + // IsHealthy will return the value represent the instance whether healthy or not + IsHealthy() bool + + // GetMetadata will return the metadata + GetMetadata() map[string]string +} From 23e1268fffdec24f97806e8ea356c31729267ab6 Mon Sep 17 00:00:00 2001 From: flycash Date: Tue, 3 Mar 2020 19:09:11 +0800 Subject: [PATCH 003/167] Upgrade gost --- go.mod | 4 +--- go.sum | 2 ++ registry/event_listener.go | 3 +-- registry/service_discovery.go | 4 ---- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index d1ee5568db..a815bc2af4 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/creasty/defaults v1.3.0 github.com/dubbogo/getty v1.3.2 github.com/dubbogo/go-zookeeper v1.0.0 - github.com/dubbogo/gost v1.5.2 + github.com/dubbogo/gost v1.7.0 github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/go-errors/errors v1.0.1 // indirect github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect @@ -56,6 +56,4 @@ require ( gopkg.in/yaml.v2 v2.2.2 ) -replace github.com/dubbogo/gost => /Users/mindeng/git/apache-dubbo/gost - go 1.13 diff --git a/go.sum b/go.sum index 0461f29653..31d15259fd 100644 --- a/go.sum +++ b/go.sum @@ -110,6 +110,8 @@ github.com/dubbogo/gost v1.5.1 h1:oG5dzaWf1KYynBaBoUIOkgT+YD0niHV6xxI0Odq7hDg= github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +github.com/dubbogo/gost v1.7.0 h1:lWNBIE2hk1Aj2be2uXkyRTpZG0RQZj0/xbXnkIq6EHE= +github.com/dubbogo/gost v1.7.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0 h1:ZoRgc53qJCfSLimXqJDrmBhnt5GChDsExMCK7t48o0Y= diff --git a/registry/event_listener.go b/registry/event_listener.go index 4bfec5d841..810420319b 100644 --- a/registry/event_listener.go +++ b/registry/event_listener.go @@ -24,7 +24,7 @@ import ( // EventListener is an new interface used to align with dubbo 2.7.5 // It contains the Prioritized means that the listener has its priority type EventListener interface { - gxsort.Prioritized + gxsort.Prioritizer // OnEvent handle this event OnEvent(e Event) error } @@ -38,5 +38,4 @@ type ConditionalEventListener interface { // TODO (implement ConditionalEventListener) type ServiceInstancesChangedListener struct { - } diff --git a/registry/service_discovery.go b/registry/service_discovery.go index 11b059c389..5577f52930 100644 --- a/registry/service_discovery.go +++ b/registry/service_discovery.go @@ -31,7 +31,6 @@ import ( ) type ServiceDiscovery interface { - fmt.Stringer // ----------------- lifecycle ------------------- @@ -44,7 +43,6 @@ type ServiceDiscovery interface { // If the discovery cannot be destroy, it will return an error. Destroy() error - // ----------------- registration ---------------- // Register will register an instance of ServiceInstance to registry @@ -56,7 +54,6 @@ type ServiceDiscovery interface { // Unregister will unregister this instance from registry Unregister(instance ServiceInstance) error - // ----------------- discovery ------------------- // GetDefaultPageSize will return the default page size GetDefaultPageSize() int @@ -79,7 +76,6 @@ type ServiceDiscovery interface { // Batch get all instances by the specified service names GetRequestInstances(serviceNames []string, offset int, requestedSize int) map[string]gxpage.Pager - // ----------------- event ---------------------- // AddListener adds a new ServiceInstancesChangedListener AddListener(listener *ServiceInstancesChangedListener) error From dd2abb94e880cc433f6a6f053bc649b70239085c Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Sat, 14 Mar 2020 21:42:11 +0800 Subject: [PATCH 004/167] Add:interface definition of metadata --- common/constant/key.go | 8 +- common/extension/metadata_report_factory.go | 39 ++++++++ config/consumer_config.go | 16 +--- config/metadata_report_config.go | 23 +++++ config/metadata_report_config_test.go | 6 +- config/provider_config.go | 5 +- metadata/definition/definition.go | 41 +++++++++ metadata/exporter.go | 27 ++++++ .../identifier/base_metadata_identifier.go | 92 +++++++++++++++++++ metadata/identifier/metadata_identifier.go | 33 +++++++ .../identifier/service_metadata_identifier.go | 36 ++++++++ .../subscribe_metadata_identifier.go | 16 ++++ metadata/instance.go | 40 ++++++++ metadata/report.go | 35 +++++++ metadata/report_factory.go | 28 ++++++ metadata/service.go | 37 ++++++++ 16 files changed, 467 insertions(+), 15 deletions(-) create mode 100644 common/extension/metadata_report_factory.go create mode 100644 metadata/definition/definition.go create mode 100644 metadata/exporter.go create mode 100644 metadata/identifier/base_metadata_identifier.go create mode 100644 metadata/identifier/metadata_identifier.go create mode 100644 metadata/identifier/service_metadata_identifier.go create mode 100644 metadata/identifier/subscribe_metadata_identifier.go create mode 100644 metadata/instance.go create mode 100644 metadata/report.go create mode 100644 metadata/report_factory.go create mode 100644 metadata/service.go diff --git a/common/constant/key.go b/common/constant/key.go index b2afb01626..4794842bc7 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -164,6 +164,10 @@ const ( // metadata report const ( - METACONFIG_REMOTE = "remote" - METACONFIG_LOCAL = "local" + METACONFIG_REMOTE = "remote" + METACONFIG_LOCAL = "local" + KEY_SEPARATOR = ":" + DEFAULT_PATH_TAG = "metadata" + PATH_SEPARATOR = "/" + KEY_REVISON_PREFIX = "revision" ) diff --git a/common/extension/metadata_report_factory.go b/common/extension/metadata_report_factory.go new file mode 100644 index 0000000000..a28eb2e3c1 --- /dev/null +++ b/common/extension/metadata_report_factory.go @@ -0,0 +1,39 @@ +/* + * 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 ( + "github.com/apache/dubbo-go/metadata" +) + +var ( + metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory) +) + +// SetMetadataReportFactory ... +func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFactory) { + metaDataReportFactories[name] = v +} + +// GetConfigCenterFactory ... +func GetMetadataReportFactory(name string) metadata.MetadataReportFactory { + if metaDataReportFactories[name] == nil { + panic("metadata report for " + name + " is not existing, make sure you have import the package.") + } + return metaDataReportFactories[name]() +} diff --git a/config/consumer_config.go b/config/consumer_config.go index 0d9c9585c5..e853fc1b11 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -129,6 +129,11 @@ func ConsumerInit(confConFile string) error { return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) } } + + //start the metadata report if config set + if err := startMetadataReport(); err != nil { + return perrors.WithMessagef(err, "Consumer start metadata report error ,error is {%#v}", err) + } logger.Debugf("consumer config{%#v}\n", consumerConfig) return nil } @@ -155,14 +160,3 @@ func configCenterRefreshConsumer() error { } return err } - -// StartMetadataReport: The entry of metadata report start -func startMetadataReport() error { - metadataConfig := consumerConfig.ApplicationConfig.MetadataType - if metadataConfig == constant.METACONFIG_REMOTE && consumerConfig.MetadataReportConfig == nil { - return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.") - } else if metadataConfig == constant.METACONFIG_REMOTE && len(consumerConfig.MetadataReportConfig.Address) == 0 { - return perrors.New("MetadataConfig address can not be empty.") - } - return nil -} diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 3f170606e7..6616cf192a 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -18,6 +18,7 @@ package config import ( + "github.com/apache/dubbo-go/metadata" "net/url" ) import ( @@ -32,6 +33,7 @@ import ( // MethodConfig ... type MetadataReportConfig struct { + Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` Address string `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"` @@ -70,6 +72,7 @@ func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { common.WithUsername(c.Username), common.WithPassword(c.Password), common.WithLocation(c.Address), + common.WithProtocol(c.Protocol), ) if err != nil { return nil, perrors.New("Invalid MetadataReportConfig.") @@ -77,3 +80,23 @@ func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { url.SetParam("metadata", url.Protocol) return &url, nil } + +// StartMetadataReport: The entry of metadata report start +func startMetadataReport() error { + metadataConfig := consumerConfig.ApplicationConfig.MetadataType + if consumerConfig.MetadataReportConfig == nil { + return nil + } else { + if metadataConfig == constant.METACONFIG_REMOTE { + return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.") + } else if metadataConfig == constant.METACONFIG_REMOTE && len(consumerConfig.MetadataReportConfig.Address) == 0 { + return perrors.New("MetadataConfig address can not be empty.") + } + if url, err := consumerConfig.MetadataReportConfig.ToUrl(); err == nil { + metadata.Init(url) + } else { + return perrors.New("MetadataConfig is invalid!") + } + } + return nil +} diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go index 322d50c107..d6b08d5fb0 100644 --- a/config/metadata_report_config_test.go +++ b/config/metadata_report_config_test.go @@ -8,7 +8,8 @@ import ( func TestMetadataReportConfig_ToUrl(t *testing.T) { metadataReportConfig := MetadataReportConfig{ - Address: "mock://127.0.0.1", + Protocol: "mock", + Address: "127.0.0.1:2181", Username: "test", Password: "test", TimeoutStr: "3s", @@ -19,6 +20,9 @@ func TestMetadataReportConfig_ToUrl(t *testing.T) { url, error := metadataReportConfig.ToUrl() assert.NoError(t, error) 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", "")) diff --git a/config/provider_config.go b/config/provider_config.go index 2967ecad3a..2265f5954a 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -103,7 +103,10 @@ func ProviderInit(confProFile string) error { n.InterfaceId = k } } - + //start the metadata report if config set + if err := startMetadataReport(); err != nil { + return perrors.WithMessagef(err, "Provider start metadata report error ,error is {%#v}", err) + } logger.Debugf("provider config{%#v}\n", providerConfig) return nil diff --git a/metadata/definition/definition.go b/metadata/definition/definition.go new file mode 100644 index 0000000000..ead984345e --- /dev/null +++ b/metadata/definition/definition.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 definition + +type ServiceDefinition struct { + CanonicalName string + CodeSource string + Methods []MethodDefinition + Types []TypeDefinition +} + +type MethodDefinition struct { + Name string + ParameterTypes []string + ReturnType string + Parameters []TypeDefinition +} + +type TypeDefinition struct { + Id string + Type string + Items []TypeDefinition + Enums []string + Properties map[string]TypeDefinition + TypeBuilderName string +} diff --git a/metadata/exporter.go b/metadata/exporter.go new file mode 100644 index 0000000000..a5693613c3 --- /dev/null +++ b/metadata/exporter.go @@ -0,0 +1,27 @@ +/* + * 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 metadata + +import "github.com/apache/dubbo-go/common" + +type MetadataExporter interface { + Export() MetadataExporter + Unexport() MetadataExporter + GetExportedURLs() []*common.URL + IsExported() bool +} diff --git a/metadata/identifier/base_metadata_identifier.go b/metadata/identifier/base_metadata_identifier.go new file mode 100644 index 0000000000..c29dcf97df --- /dev/null +++ b/metadata/identifier/base_metadata_identifier.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 identifier + +import ( + "encoding/base64" +) + +import ( + "github.com/apache/dubbo-go/common/constant" +) + +type BaseMetadataIdentifier interface { + getFilePathKey(params ...string) string + getIdentifierKey(params ...string) string +} + +type BaseServiceMetadataIdentifier struct { + serviceInterface string + version string + group string + side string +} + +// joinParams... +func joinParams(joinChar string, params []string) string { + var joinedStr string + for _, param := range params { + joinedStr += joinChar + joinedStr += param + } + return joinedStr +} + +// getIdentifierKey... +func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) string { + return mdi.serviceInterface + + constant.KEY_SEPARATOR + mdi.version + + constant.KEY_SEPARATOR + mdi.group + + constant.KEY_SEPARATOR + mdi.side + + joinParams(constant.KEY_SEPARATOR, params) +} + +// getIdentifierKey... +func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) string { + path := serviceToPath(mdi.serviceInterface) + + return constant.DEFAULT_PATH_TAG + + withPathSeparator(path) + + withPathSeparator(mdi.version) + + withPathSeparator(mdi.group) + + withPathSeparator(mdi.side) + + joinParams(constant.PATH_SEPARATOR, params) + +} + +// serviceToPath... +func serviceToPath(serviceInterface string) string { + if serviceInterface == constant.ANY_VALUE { + return "" + } else { + decoded, err := base64.URLEncoding.DecodeString(serviceInterface) + if err != nil { + return "" + } + return string(decoded) + } + +} + +//withPathSeparator... +func withPathSeparator(path string) string { + if len(path) != 0 { + path = constant.PATH_SEPARATOR + path + } + return path +} diff --git a/metadata/identifier/metadata_identifier.go b/metadata/identifier/metadata_identifier.go new file mode 100644 index 0000000000..f3df8f3654 --- /dev/null +++ b/metadata/identifier/metadata_identifier.go @@ -0,0 +1,33 @@ +/* + * 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 identifier + +type MetadataIdentifier struct { + application string + BaseMetadataIdentifier +} + +// getIdentifierKey... +func (mdi *MetadataIdentifier) getIdentifierKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.application) +} + +// getIdentifierKey... +func (mdi *MetadataIdentifier) getFilePathKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.application) +} diff --git a/metadata/identifier/service_metadata_identifier.go b/metadata/identifier/service_metadata_identifier.go new file mode 100644 index 0000000000..157b9c54af --- /dev/null +++ b/metadata/identifier/service_metadata_identifier.go @@ -0,0 +1,36 @@ +/* + * 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 identifier + +import "github.com/apache/dubbo-go/common/constant" + +type ServiceMetadataIdentifier struct { + revision string + protocol string + BaseMetadataIdentifier +} + +// getIdentifierKey... +func (mdi *ServiceMetadataIdentifier) getIdentifierKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision) +} + +// getIdentifierKey... +func (mdi *ServiceMetadataIdentifier) getFilePathKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.protocol + constant.KEY_REVISON_PREFIX + mdi.revision) +} diff --git a/metadata/identifier/subscribe_metadata_identifier.go b/metadata/identifier/subscribe_metadata_identifier.go new file mode 100644 index 0000000000..fd3a290b41 --- /dev/null +++ b/metadata/identifier/subscribe_metadata_identifier.go @@ -0,0 +1,16 @@ +package identifier + +type SubscriberMetadataIdentifier struct { + revision string + BaseMetadataIdentifier +} + +// getIdentifierKey... +func (mdi *SubscriberMetadataIdentifier) getIdentifierKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.revision) +} + +// getIdentifierKey... +func (mdi *SubscriberMetadataIdentifier) getFilePathKey(params ...string) string { + return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.revision) +} diff --git a/metadata/instance.go b/metadata/instance.go new file mode 100644 index 0000000000..10de0451fd --- /dev/null +++ b/metadata/instance.go @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package metadata + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "sync" +) + +var ( + instance MetadataReport + once sync.Once +) + +// GetEnvInstance ... +func Init(url *common.URL) { + once.Do(func() { + instance = extension.GetMetadataReportFactory(url.Protocol).createMetadataReport(url) + }) +} + +func GetMetadataReportInstance() MetadataReport { + return instance +} diff --git a/metadata/report.go b/metadata/report.go new file mode 100644 index 0000000000..3fcc712414 --- /dev/null +++ b/metadata/report.go @@ -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. + */ + +package metadata + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/metadata/definition" + "github.com/apache/dubbo-go/metadata/identifier" +) + +type MetadataReport interface { + StoreProviderMetadata(*identifier.MetadataIdentifier, *definition.ServiceDefinition) + StoreConsumeretadata(*identifier.MetadataIdentifier, map[string]string) + SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) + RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) + GetExportedURLs(*identifier.ServiceMetadataIdentifier) []string + SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, []*common.URL) + GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) []string + GetServiceDefinition(*identifier.MetadataIdentifier) +} diff --git a/metadata/report_factory.go b/metadata/report_factory.go new file mode 100644 index 0000000000..60b0b2b572 --- /dev/null +++ b/metadata/report_factory.go @@ -0,0 +1,28 @@ +/* + * 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 metadata + +import "github.com/apache/dubbo-go/common" + +var ( + MetadataReportInstance MetadataReport +) + +type MetadataReportFactory interface { + createMetadataReport(*common.URL) MetadataReport +} diff --git a/metadata/service.go b/metadata/service.go new file mode 100644 index 0000000000..d85703c95a --- /dev/null +++ b/metadata/service.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 metadata + +import ( + "github.com/apache/dubbo-go/common" + gxset "github.com/dubbogo/gost/container/set" +) + +type MetadataService interface { + ServiceName() string + ExportURL(url *common.URL) bool + UnexportURL(url *common.URL) bool + RefreshMetadata(exportedRevision string, subscribedRevision string) bool + SubscribeURL(url *common.URL) bool + UnsubscribeURL(url *common.URL) bool + PublishServiceDefinition(url *common.URL) + + GetExportedURLs(serviceInterface string, group string, version string, protocol string) gxset.HashSet + GetServiceDefinition(interfaceName string, version string, group string) string + GetServiceDefinitionByServiceKey(serviceKey string) string +} From 1f5bd64ca2ed57a4892933e35e2e82d5d2831dd7 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Sat, 14 Mar 2020 22:07:47 +0800 Subject: [PATCH 005/167] Mod:recycle refer --- .../instance/metedata_report.go | 19 ++++++++++--------- config/metadata_report_config.go | 5 +++-- metadata/report_factory.go | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) rename metadata/instance.go => config/instance/metedata_report.go (78%) diff --git a/metadata/instance.go b/config/instance/metedata_report.go similarity index 78% rename from metadata/instance.go rename to config/instance/metedata_report.go index 10de0451fd..cd54b0a794 100644 --- a/metadata/instance.go +++ b/config/instance/metedata_report.go @@ -15,26 +15,27 @@ * limitations under the License. */ -package metadata +package instance + +import ( + "sync" +) import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/extension" - "sync" + "github.com/apache/dubbo-go/metadata" ) var ( - instance MetadataReport + instance metadata.MetadataReport once sync.Once ) -// GetEnvInstance ... -func Init(url *common.URL) { +// GetMetadataReportInstance ... +func GetMetadataReportInstance(url *common.URL) metadata.MetadataReport { once.Do(func() { - instance = extension.GetMetadataReportFactory(url.Protocol).createMetadataReport(url) + instance = extension.GetMetadataReportFactory(url.Protocol).CreateMetadataReport(url) }) -} - -func GetMetadataReportInstance() MetadataReport { return instance } diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 6616cf192a..bf1af51345 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -18,9 +18,9 @@ package config import ( - "github.com/apache/dubbo-go/metadata" "net/url" ) + import ( "github.com/creasty/defaults" perrors "github.com/pkg/errors" @@ -29,6 +29,7 @@ import ( import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/config/instance" ) // MethodConfig ... @@ -93,7 +94,7 @@ func startMetadataReport() error { return perrors.New("MetadataConfig address can not be empty.") } if url, err := consumerConfig.MetadataReportConfig.ToUrl(); err == nil { - metadata.Init(url) + instance.GetMetadataReportInstance(url) } else { return perrors.New("MetadataConfig is invalid!") } diff --git a/metadata/report_factory.go b/metadata/report_factory.go index 60b0b2b572..97faee1309 100644 --- a/metadata/report_factory.go +++ b/metadata/report_factory.go @@ -24,5 +24,5 @@ var ( ) type MetadataReportFactory interface { - createMetadataReport(*common.URL) MetadataReport + CreateMetadataReport(*common.URL) MetadataReport } From 28bcd48652fdc4358ca0541511c8210de370b55d Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Sat, 14 Mar 2020 22:56:59 +0800 Subject: [PATCH 006/167] Mod:resolve ci --- common/extension/metadata_report_factory.go | 4 +- config/consumer_config.go | 6 --- config/metadata_report_config.go | 45 +++++++++++-------- config/provider_config.go | 6 ++- metadata/exporter.go | 4 +- .../identifier/base_metadata_identifier.go | 2 +- .../identifier/service_metadata_identifier.go | 4 +- metadata/report_factory.go | 4 +- 8 files changed, 42 insertions(+), 33 deletions(-) diff --git a/common/extension/metadata_report_factory.go b/common/extension/metadata_report_factory.go index a28eb2e3c1..0ae0793bb4 100644 --- a/common/extension/metadata_report_factory.go +++ b/common/extension/metadata_report_factory.go @@ -22,7 +22,7 @@ import ( ) var ( - metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory) + metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory, 8) ) // SetMetadataReportFactory ... @@ -30,7 +30,7 @@ func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFacto metaDataReportFactories[name] = v } -// GetConfigCenterFactory ... +// GetMetadataReportFactory ... func GetMetadataReportFactory(name string) metadata.MetadataReportFactory { if metaDataReportFactories[name] == nil { panic("metadata report for " + name + " is not existing, make sure you have import the package.") diff --git a/config/consumer_config.go b/config/consumer_config.go index e853fc1b11..3950f3ba0c 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -45,8 +45,6 @@ type ConsumerConfig struct { Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` // application ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` - // metadata-report - MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` // client Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"` @@ -130,10 +128,6 @@ func ConsumerInit(confConFile string) error { } } - //start the metadata report if config set - if err := startMetadataReport(); err != nil { - return perrors.WithMessagef(err, "Consumer start metadata report error ,error is {%#v}", err) - } logger.Debugf("consumer config{%#v}\n", consumerConfig) return nil } diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index bf1af51345..41fb6b4769 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -51,21 +51,23 @@ func (c *MetadataReportConfig) Prefix() string { // UnmarshalYAML ... func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { - return err + return perrors.WithStack(err) } type plain MetadataReportConfig if err := unmarshal((*plain)(c)); err != nil { - return err + return perrors.WithStack(err) } return nil } // ToUrl ... func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { - urlMap := url.Values{} + urlMap := make(url.Values) - for k, v := range c.Params { - urlMap.Set(k, v) + if c.Params != nil { + for k, v := range c.Params { + urlMap.Set(k, v) + } } url, err := common.NewURL(c.Address, @@ -75,29 +77,34 @@ func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { common.WithLocation(c.Address), common.WithProtocol(c.Protocol), ) - if err != nil { + if err != nil || len(url.Protocol) == 0 { return nil, perrors.New("Invalid MetadataReportConfig.") } url.SetParam("metadata", url.Protocol) return &url, nil } +func (c *MetadataReportConfig) IsValid() bool { + return len(c.Protocol) != 0 +} + // StartMetadataReport: The entry of metadata report start -func startMetadataReport() error { - metadataConfig := consumerConfig.ApplicationConfig.MetadataType - if consumerConfig.MetadataReportConfig == nil { +func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error { + if metadataReportConfig == nil || metadataReportConfig.IsValid() { return nil + } + + if metadataType == constant.METACONFIG_REMOTE { + return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.") + } else if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.Address) == 0 { + return perrors.New("MetadataConfig address can not be empty.") + } + + if url, err := metadataReportConfig.ToUrl(); err == nil { + instance.GetMetadataReportInstance(url) } else { - if metadataConfig == constant.METACONFIG_REMOTE { - return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.") - } else if metadataConfig == constant.METACONFIG_REMOTE && len(consumerConfig.MetadataReportConfig.Address) == 0 { - return perrors.New("MetadataConfig address can not be empty.") - } - if url, err := consumerConfig.MetadataReportConfig.ToUrl(); err == nil { - instance.GetMetadataReportInstance(url) - } else { - return perrors.New("MetadataConfig is invalid!") - } + return perrors.New("MetadataConfig is invalid!") } + return nil } diff --git a/config/provider_config.go b/config/provider_config.go index 2265f5954a..ff836d7dda 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -42,6 +42,8 @@ type ProviderConfig struct { BaseConfig `yaml:",inline"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"` + // metadata-report + MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"` ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"` Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"` @@ -104,8 +106,8 @@ func ProviderInit(confProFile string) error { } } //start the metadata report if config set - if err := startMetadataReport(); err != nil { - return perrors.WithMessagef(err, "Provider start metadata report error ,error is {%#v}", err) + if err := startMetadataReport(providerConfig.ApplicationConfig.MetadataType, providerConfig.MetadataReportConfig); err != nil { + return perrors.WithMessagef(err, "Provider starts metadata report error, and the error is {%#v}", err) } logger.Debugf("provider config{%#v}\n", providerConfig) diff --git a/metadata/exporter.go b/metadata/exporter.go index a5693613c3..5d47f8bd80 100644 --- a/metadata/exporter.go +++ b/metadata/exporter.go @@ -17,7 +17,9 @@ package metadata -import "github.com/apache/dubbo-go/common" +import ( + "github.com/apache/dubbo-go/common" +) type MetadataExporter interface { Export() MetadataExporter diff --git a/metadata/identifier/base_metadata_identifier.go b/metadata/identifier/base_metadata_identifier.go index c29dcf97df..a314671055 100644 --- a/metadata/identifier/base_metadata_identifier.go +++ b/metadata/identifier/base_metadata_identifier.go @@ -56,7 +56,7 @@ func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) str joinParams(constant.KEY_SEPARATOR, params) } -// getIdentifierKey... +// getFilePathKey... func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) string { path := serviceToPath(mdi.serviceInterface) diff --git a/metadata/identifier/service_metadata_identifier.go b/metadata/identifier/service_metadata_identifier.go index 157b9c54af..373df0130d 100644 --- a/metadata/identifier/service_metadata_identifier.go +++ b/metadata/identifier/service_metadata_identifier.go @@ -17,7 +17,9 @@ package identifier -import "github.com/apache/dubbo-go/common/constant" +import ( + "github.com/apache/dubbo-go/common/constant" +) type ServiceMetadataIdentifier struct { revision string diff --git a/metadata/report_factory.go b/metadata/report_factory.go index 97faee1309..19b1004eee 100644 --- a/metadata/report_factory.go +++ b/metadata/report_factory.go @@ -17,7 +17,9 @@ package metadata -import "github.com/apache/dubbo-go/common" +import ( + "github.com/apache/dubbo-go/common" +) var ( MetadataReportInstance MetadataReport From 42447f845090cdd4f0ab50606ae06c7bbc0b663e Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Sat, 21 Mar 2020 00:01:59 +0800 Subject: [PATCH 007/167] add license --- cluster/cluster_impl/available_cluster.go | 30 +++++++++---------- .../cluster_impl/available_cluster_invoker.go | 30 +++++++++---------- .../available_cluster_invoker_test.go | 30 +++++++++---------- cluster/cluster_impl/broadcast_cluster.go | 30 +++++++++---------- .../cluster_impl/broadcast_cluster_invoker.go | 30 +++++++++---------- .../broadcast_cluster_invoker_test.go | 30 +++++++++---------- cluster/cluster_impl/failback_cluster_test.go | 30 +++++++++---------- cluster/cluster_impl/failfast_cluster.go | 30 +++++++++---------- .../cluster_impl/failfast_cluster_invoker.go | 30 +++++++++---------- cluster/cluster_impl/failfast_cluster_test.go | 30 +++++++++---------- cluster/cluster_impl/failsafe_cluster_test.go | 30 +++++++++---------- cluster/cluster_impl/forking_cluster.go | 30 +++++++++---------- .../cluster_impl/forking_cluster_invoker.go | 30 +++++++++---------- cluster/cluster_impl/forking_cluster_test.go | 30 +++++++++---------- common/extension/auth.go | 17 +++++++++++ config/interfaces/config_reader.go | 17 +++++++++++ config_center/apollo/factory.go | 30 +++++++++---------- config_center/apollo/impl.go | 30 +++++++++---------- config_center/apollo/listener.go | 30 +++++++++---------- filter/filter_impl/active_filter_test.go | 17 +++++++++++ filter/filter_impl/token_filter.go | 30 +++++++++---------- filter/filter_impl/token_filter_test.go | 30 +++++++++---------- .../tps/tps_limit_strategy_mock.go | 17 +++++++++++ filter/filter_impl/tps/tps_limiter_mock.go | 17 +++++++++++ .../rejected_execution_handler_mock.go | 17 +++++++++++ protocol/grpc/client.go | 30 +++++++++---------- protocol/grpc/client_test.go | 30 +++++++++---------- protocol/grpc/common_test.go | 30 +++++++++---------- protocol/grpc/grpc_exporter.go | 30 +++++++++---------- protocol/grpc/grpc_invoker.go | 30 +++++++++---------- protocol/grpc/grpc_invoker_test.go | 30 +++++++++---------- protocol/grpc/grpc_protocol.go | 30 +++++++++---------- protocol/grpc/grpc_protocol_test.go | 30 +++++++++---------- protocol/grpc/internal/client.go | 30 +++++++++---------- protocol/grpc/internal/doc.go | 30 +++++++++---------- protocol/grpc/internal/helloworld.pb.go | 30 +++++++++---------- protocol/grpc/internal/server.go | 30 +++++++++---------- .../examples/helloworld.pb.go | 30 +++++++++---------- protocol/grpc/protoc-gen-dubbo/main.go | 30 +++++++++---------- .../grpc/protoc-gen-dubbo/plugin/dubbo/doc.go | 30 +++++++++---------- .../protoc-gen-dubbo/plugin/dubbo/dubbo.go | 30 +++++++++---------- protocol/grpc/server.go | 30 +++++++++---------- protocol/mock/mock_invoker.go | 17 +++++++++++ protocol/rpc_status_test.go | 17 +++++++++++ 44 files changed, 676 insertions(+), 540 deletions(-) diff --git a/cluster/cluster_impl/available_cluster.go b/cluster/cluster_impl/available_cluster.go index 2ad140b93e..e041d91edb 100644 --- a/cluster/cluster_impl/available_cluster.go +++ b/cluster/cluster_impl/available_cluster.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/available_cluster_invoker.go b/cluster/cluster_impl/available_cluster_invoker.go index 6f6d2dffbb..e69f8b9f47 100644 --- a/cluster/cluster_impl/available_cluster_invoker.go +++ b/cluster/cluster_impl/available_cluster_invoker.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster_impl/available_cluster_invoker_test.go index dc0666d5af..c2cebd3843 100644 --- a/cluster/cluster_impl/available_cluster_invoker_test.go +++ b/cluster/cluster_impl/available_cluster_invoker_test.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/broadcast_cluster.go b/cluster/cluster_impl/broadcast_cluster.go index 9b27a4ce37..a1692e96c5 100644 --- a/cluster/cluster_impl/broadcast_cluster.go +++ b/cluster/cluster_impl/broadcast_cluster.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/broadcast_cluster_invoker.go b/cluster/cluster_impl/broadcast_cluster_invoker.go index 1b49e9a115..3a97d3d9b4 100644 --- a/cluster/cluster_impl/broadcast_cluster_invoker.go +++ b/cluster/cluster_impl/broadcast_cluster_invoker.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/broadcast_cluster_invoker_test.go b/cluster/cluster_impl/broadcast_cluster_invoker_test.go index 1de5270265..9b5733e98b 100644 --- a/cluster/cluster_impl/broadcast_cluster_invoker_test.go +++ b/cluster/cluster_impl/broadcast_cluster_invoker_test.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/failback_cluster_test.go b/cluster/cluster_impl/failback_cluster_test.go index 4571fccec5..69418bc3b8 100644 --- a/cluster/cluster_impl/failback_cluster_test.go +++ b/cluster/cluster_impl/failback_cluster_test.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/failfast_cluster.go b/cluster/cluster_impl/failfast_cluster.go index e0b80ded04..1e85485f71 100644 --- a/cluster/cluster_impl/failfast_cluster.go +++ b/cluster/cluster_impl/failfast_cluster.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/failfast_cluster_invoker.go b/cluster/cluster_impl/failfast_cluster_invoker.go index 49e7c7689f..3b4dc9b721 100644 --- a/cluster/cluster_impl/failfast_cluster_invoker.go +++ b/cluster/cluster_impl/failfast_cluster_invoker.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/failfast_cluster_test.go b/cluster/cluster_impl/failfast_cluster_test.go index 38e258199e..c5ab7cd541 100644 --- a/cluster/cluster_impl/failfast_cluster_test.go +++ b/cluster/cluster_impl/failfast_cluster_test.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/failsafe_cluster_test.go b/cluster/cluster_impl/failsafe_cluster_test.go index 2e35de8da9..0bfeb576bd 100644 --- a/cluster/cluster_impl/failsafe_cluster_test.go +++ b/cluster/cluster_impl/failsafe_cluster_test.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/forking_cluster.go b/cluster/cluster_impl/forking_cluster.go index 6b0572b150..a6f7a7b454 100644 --- a/cluster/cluster_impl/forking_cluster.go +++ b/cluster/cluster_impl/forking_cluster.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/forking_cluster_invoker.go b/cluster/cluster_impl/forking_cluster_invoker.go index 058d7fefd6..732569416d 100644 --- a/cluster/cluster_impl/forking_cluster_invoker.go +++ b/cluster/cluster_impl/forking_cluster_invoker.go @@ -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. -*/ + * 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_impl diff --git a/cluster/cluster_impl/forking_cluster_test.go b/cluster/cluster_impl/forking_cluster_test.go index 9797ecbd04..526b137d71 100644 --- a/cluster/cluster_impl/forking_cluster_test.go +++ b/cluster/cluster_impl/forking_cluster_test.go @@ -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. -*/ + * 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_impl diff --git a/common/extension/auth.go b/common/extension/auth.go index a35fc509da..d7900045d3 100644 --- a/common/extension/auth.go +++ b/common/extension/auth.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 import ( diff --git a/config/interfaces/config_reader.go b/config/interfaces/config_reader.go index 23f2225e1b..8b79a17d89 100644 --- a/config/interfaces/config_reader.go +++ b/config/interfaces/config_reader.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 import "bytes" diff --git a/config_center/apollo/factory.go b/config_center/apollo/factory.go index a5a69e1215..f975ce13d8 100644 --- a/config_center/apollo/factory.go +++ b/config_center/apollo/factory.go @@ -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. -*/ + * 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 apollo diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 4dc1981784..3b5d1f4ebe 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -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. -*/ + * 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 apollo diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go index 820d02fb48..fb257a4828 100644 --- a/config_center/apollo/listener.go +++ b/config_center/apollo/listener.go @@ -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. -*/ + * 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 apollo diff --git a/filter/filter_impl/active_filter_test.go b/filter/filter_impl/active_filter_test.go index 8917e9141c..d5a51d50d9 100644 --- a/filter/filter_impl/active_filter_test.go +++ b/filter/filter_impl/active_filter_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 filter_impl import ( diff --git a/filter/filter_impl/token_filter.go b/filter/filter_impl/token_filter.go index 4605416c40..8ec3929b6d 100644 --- a/filter/filter_impl/token_filter.go +++ b/filter/filter_impl/token_filter.go @@ -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. -*/ + * 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 filter_impl diff --git a/filter/filter_impl/token_filter_test.go b/filter/filter_impl/token_filter_test.go index 672082c729..d7a7f20a5d 100644 --- a/filter/filter_impl/token_filter_test.go +++ b/filter/filter_impl/token_filter_test.go @@ -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. -*/ + * 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 filter_impl diff --git a/filter/filter_impl/tps/tps_limit_strategy_mock.go b/filter/filter_impl/tps/tps_limit_strategy_mock.go index 72c658fb9a..18809fccc9 100644 --- a/filter/filter_impl/tps/tps_limit_strategy_mock.go +++ b/filter/filter_impl/tps/tps_limit_strategy_mock.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. + */ + // 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. diff --git a/filter/filter_impl/tps/tps_limiter_mock.go b/filter/filter_impl/tps/tps_limiter_mock.go index 463b0988ac..131a2e5121 100644 --- a/filter/filter_impl/tps/tps_limiter_mock.go +++ b/filter/filter_impl/tps/tps_limiter_mock.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. + */ + // 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. diff --git a/filter/handler/rejected_execution_handler_mock.go b/filter/handler/rejected_execution_handler_mock.go index a5bef63b37..469c06b6b9 100644 --- a/filter/handler/rejected_execution_handler_mock.go +++ b/filter/handler/rejected_execution_handler_mock.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. + */ + // 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. diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index 6026f0991b..0c7499a179 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/client_test.go b/protocol/grpc/client_test.go index 56ec766f70..099f03e429 100644 --- a/protocol/grpc/client_test.go +++ b/protocol/grpc/client_test.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/common_test.go b/protocol/grpc/common_test.go index 3d0823b106..33c2fc617d 100644 --- a/protocol/grpc/common_test.go +++ b/protocol/grpc/common_test.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/grpc_exporter.go b/protocol/grpc/grpc_exporter.go index 3c38ef974c..1acd2fec39 100644 --- a/protocol/grpc/grpc_exporter.go +++ b/protocol/grpc/grpc_exporter.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/grpc_invoker.go b/protocol/grpc/grpc_invoker.go index 26bc86f3aa..78439fcd9b 100644 --- a/protocol/grpc/grpc_invoker.go +++ b/protocol/grpc/grpc_invoker.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go index 368c1392ec..3054ada133 100644 --- a/protocol/grpc/grpc_invoker_test.go +++ b/protocol/grpc/grpc_invoker_test.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go index 0f5625c152..cc4aba10bf 100644 --- a/protocol/grpc/grpc_protocol.go +++ b/protocol/grpc/grpc_protocol.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index d0206a0fd9..d028f8ef42 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/grpc/internal/client.go b/protocol/grpc/internal/client.go index d236e3046a..3ce0f570b7 100644 --- a/protocol/grpc/internal/client.go +++ b/protocol/grpc/internal/client.go @@ -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. -*/ + * 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 internal diff --git a/protocol/grpc/internal/doc.go b/protocol/grpc/internal/doc.go index f2ef2ebd5e..b70fc24e72 100644 --- a/protocol/grpc/internal/doc.go +++ b/protocol/grpc/internal/doc.go @@ -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. -*/ + * 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. + */ // just for test, never use internal for production. package internal diff --git a/protocol/grpc/internal/helloworld.pb.go b/protocol/grpc/internal/helloworld.pb.go index 79b74ac650..82537f553b 100644 --- a/protocol/grpc/internal/helloworld.pb.go +++ b/protocol/grpc/internal/helloworld.pb.go @@ -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. -*/ + * 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 diff --git a/protocol/grpc/internal/server.go b/protocol/grpc/internal/server.go index a0759f757d..a6b861cac6 100644 --- a/protocol/grpc/internal/server.go +++ b/protocol/grpc/internal/server.go @@ -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. -*/ + * 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 internal diff --git a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go index f5d3a49b09..702391b299 100644 --- a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go +++ b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go @@ -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. -*/ + * 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 diff --git a/protocol/grpc/protoc-gen-dubbo/main.go b/protocol/grpc/protoc-gen-dubbo/main.go index b2f0e82f74..fbcfa6f9d4 100644 --- a/protocol/grpc/protoc-gen-dubbo/main.go +++ b/protocol/grpc/protoc-gen-dubbo/main.go @@ -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. -*/ + * 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 diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go index 064c738a53..76fbf64724 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go +++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/doc.go @@ -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. -*/ + * 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 diff --git a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go index e84a7d0cc9..83d28519f6 100644 --- a/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go +++ b/protocol/grpc/protoc-gen-dubbo/plugin/dubbo/dubbo.go @@ -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. -*/ + * 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 diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index cc184bf3cf..63783040f9 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -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. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package grpc diff --git a/protocol/mock/mock_invoker.go b/protocol/mock/mock_invoker.go index 5c5b476b7b..f22b803e75 100644 --- a/protocol/mock/mock_invoker.go +++ b/protocol/mock/mock_invoker.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. + */ + // 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. diff --git a/protocol/rpc_status_test.go b/protocol/rpc_status_test.go index 5a07f44eab..611b7cba6e 100644 --- a/protocol/rpc_status_test.go +++ b/protocol/rpc_status_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 protocol import ( From 0dcd48f55104ec9fc43621271855b1b67f06d556 Mon Sep 17 00:00:00 2001 From: flycash Date: Sat, 21 Mar 2020 20:50:59 +0800 Subject: [PATCH 008/167] Publish Config --- config_center/apollo/impl.go | 6 ++ config_center/dynamic_configuration.go | 4 + config_center/mock_dynamic_config.go | 4 + config_center/nacos/impl.go | 111 ++++++++++++++++--------- config_center/nacos/impl_test.go | 17 ++-- config_center/nacos/listener.go | 10 +-- config_center/zookeeper/impl.go | 27 +++++- config_center/zookeeper/impl_test.go | 12 +++ remoting/zookeeper/client.go | 14 +++- 9 files changed, 151 insertions(+), 54 deletions(-) diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 4dc1981784..d9c9ad2c30 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -128,6 +128,12 @@ func (c *apolloConfiguration) GetRule(key string, opts ...cc.Option) (string, er return c.GetInternalProperty(key, opts...) } +// PublishConfig will publish the config with the (key, group, value) pair +func (c *apolloConfiguration) PublishConfig(string, string, string) error { + // todo(@zouyx) + return nil +} + 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: diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index d6c3b06b32..e5284e89eb 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -50,6 +50,10 @@ type DynamicConfiguration interface { //GetInternalProperty get value by key in Default properties file(dubbo.properties) GetInternalProperty(string, ...Option) (string, error) + + // PublishConfig will publish the config with the (key, group, value) pair + PublishConfig(string, string, string) error + } // Options ... diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 4d972b629a..9f5bbe934c 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -81,6 +81,10 @@ func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(_ *common.URL) } +func (c *MockDynamicConfiguration) PublishConfig(string, string, string) error { + return nil +} + // MockDynamicConfiguration ... type MockDynamicConfiguration struct { parser parser.ConfigurationParser diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 60ab89b003..a1f9ff8cc6 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -18,6 +18,8 @@ package nacos import ( + "errors" + "strings" "sync" ) @@ -65,101 +67,130 @@ func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, } // AddListener Add listener -func (n *nacosDynamicConfiguration) AddListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { - n.addListener(key, listener) +func (nacos *nacosDynamicConfiguration) AddListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { + nacos.addListener(key, listener) } // RemoveListener Remove listener -func (n *nacosDynamicConfiguration) RemoveListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { - n.removeListener(key, listener) +func (nacos *nacosDynamicConfiguration) RemoveListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { + nacos.removeListener(key, listener) } -//nacos distinguishes configuration files based on group and dataId. defalut group = "dubbo" and dataId = key -func (n *nacosDynamicConfiguration) GetProperties(key string, opts ...config_center.Option) (string, error) { - return n.GetRule(key, opts...) +// GetProperties nacos distinguishes configuration files based on group and dataId. defalut group = "dubbo" and dataId = key +func (nacos *nacosDynamicConfiguration) GetProperties(key string, opts ...config_center.Option) (string, error) { + return nacos.GetRule(key, opts...) } // GetInternalProperty Get properties value by key -func (n *nacosDynamicConfiguration) GetInternalProperty(key string, opts ...config_center.Option) (string, error) { - return n.GetProperties(key, opts...) +func (nacos *nacosDynamicConfiguration) GetInternalProperty(key string, opts ...config_center.Option) (string, error) { + return nacos.GetProperties(key, opts...) +} + +// PublishConfig will publish the config with the (key, group, value) pair +func (nacos *nacosDynamicConfiguration) PublishConfig(key string, group string, value string) error { + + group = nacos.resolvedGroup(group) + + ok, err := (*nacos.client.Client()).PublishConfig(vo.ConfigParam{ + DataId: key, + Group: group, + Content: value, + }) + + if err != nil { + return err + } + if !ok { + return errors.New("publish config to Nocos failed") + } + return nil } // GetRule Get router rule -func (n *nacosDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { +func (nacos *nacosDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { tmpOpts := &config_center.Options{} for _, opt := range opts { opt(tmpOpts) } - content, err := (*n.client.Client()).GetConfig(vo.ConfigParam{ + content, err := (*nacos.client.Client()).GetConfig(vo.ConfigParam{ DataId: key, - Group: tmpOpts.Group, + Group: nacos.resolvedGroup(tmpOpts.Group), }) if err != nil { return "", perrors.WithStack(err) } else { - return string(content), nil + return content, nil } } // Parser Get Parser -func (n *nacosDynamicConfiguration) Parser() parser.ConfigurationParser { - return n.parser +func (nacos *nacosDynamicConfiguration) Parser() parser.ConfigurationParser { + return nacos.parser } // SetParser Set Parser -func (n *nacosDynamicConfiguration) SetParser(p parser.ConfigurationParser) { - n.parser = p +func (nacos *nacosDynamicConfiguration) SetParser(p parser.ConfigurationParser) { + nacos.parser = p } // NacosClient Get Nacos Client -func (n *nacosDynamicConfiguration) NacosClient() *NacosClient { - return n.client +func (nacos *nacosDynamicConfiguration) NacosClient() *NacosClient { + return nacos.client } // SetNacosClient Set Nacos Client -func (n *nacosDynamicConfiguration) SetNacosClient(client *NacosClient) { - n.cltLock.Lock() - n.client = client - n.cltLock.Unlock() +func (nacos *nacosDynamicConfiguration) SetNacosClient(client *NacosClient) { + nacos.cltLock.Lock() + nacos.client = client + nacos.cltLock.Unlock() } // WaitGroup for wait group control, zk client listener & zk client container -func (n *nacosDynamicConfiguration) WaitGroup() *sync.WaitGroup { - return &n.wg +func (nacos *nacosDynamicConfiguration) WaitGroup() *sync.WaitGroup { + return &nacos.wg } // GetDone For nacos client control RestartCallBack() bool -func (n *nacosDynamicConfiguration) GetDone() chan struct{} { - return n.done +func (nacos *nacosDynamicConfiguration) GetDone() chan struct{} { + return nacos.done } // GetUrl Get Url -func (n *nacosDynamicConfiguration) GetUrl() common.URL { - return *n.url +func (nacos *nacosDynamicConfiguration) GetUrl() common.URL { + return *nacos.url } // Destroy Destroy configuration instance -func (n *nacosDynamicConfiguration) Destroy() { - close(n.done) - n.wg.Wait() - n.closeConfigs() +func (nacos *nacosDynamicConfiguration) Destroy() { + close(nacos.done) + nacos.wg.Wait() + nacos.closeConfigs() +} + +// resolvedGroup will regular the group. Now, it will replace the '/' with '-'. +// '/' is a special character for nacos +func (nacos *nacosDynamicConfiguration) resolvedGroup(group string) string { + if len(group) <=0 { + return group + } + return strings.ReplaceAll(group, "/", "-") } // IsAvailable Get available status -func (n *nacosDynamicConfiguration) IsAvailable() bool { +func (nacos *nacosDynamicConfiguration) IsAvailable() bool { select { - case <-n.done: + case <-nacos.done: return false default: return true } } -func (r *nacosDynamicConfiguration) closeConfigs() { - r.cltLock.Lock() - client := r.client - r.client = nil - r.cltLock.Unlock() +func (nacos *nacosDynamicConfiguration) closeConfigs() { + nacos.cltLock.Lock() + client := nacos.client + nacos.client = nil + nacos.cltLock.Unlock() // Close the old client first to close the tmp node client.Close() logger.Infof("begin to close provider nacos client") diff --git a/config_center/nacos/impl_test.go b/config_center/nacos/impl_test.go index b4e6f1d025..4032c91cda 100644 --- a/config_center/nacos/impl_test.go +++ b/config_center/nacos/impl_test.go @@ -60,12 +60,7 @@ func runMockConfigServer(configHandler func(http.ResponseWriter, *http.Request), func mockCommonNacosServer() *httptest.Server { return runMockConfigServer(func(writer http.ResponseWriter, request *http.Request) { - data := ` - dubbo.service.com.ikurento.user.UserProvider.cluster=failback - dubbo.service.com.ikurento.user.UserProvider.protocol=myDubbo1 - dubbo.protocols.myDubbo.port=20000 - dubbo.protocols.myDubbo.name=dubbo -` + data := "true" fmt.Fprintf(writer, "%s", data) }, func(writer http.ResponseWriter, request *http.Request) { data := `dubbo.properties%02dubbo%02dubbo.service.com.ikurento.user.UserProvider.cluster=failback` @@ -93,6 +88,16 @@ func Test_GetConfig(t *testing.T) { assert.NoError(t, err) } +func TestNacosDynamicConfiguration_PublishConfig(t *testing.T) { + nacos, err := initNacosData(t) + assert.Nil(t, err) + key := "myKey" + group := "/custom/a/b" + value := "MyValue" + err = nacos.PublishConfig(key, group, value) + assert.Nil(t, err) +} + func Test_AddListener(t *testing.T) { nacos, err := initNacosData(t) assert.NoError(t, err) diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go index 25c586586c..0f16727b60 100644 --- a/config_center/nacos/listener.go +++ b/config_center/nacos/listener.go @@ -35,11 +35,11 @@ func callback(listener config_center.ConfigurationListener, namespace, group, da listener.Process(&config_center.ConfigChangeEvent{Key: dataId, Value: data, ConfigType: remoting.EventTypeUpdate}) } -func (l *nacosDynamicConfiguration) addListener(key string, listener config_center.ConfigurationListener) { - _, loaded := l.keyListeners.Load(key) +func (nacos *nacosDynamicConfiguration) addListener(key string, listener config_center.ConfigurationListener) { + _, loaded := nacos.keyListeners.Load(key) if !loaded { _, cancel := context.WithCancel(context.Background()) - err := (*l.client.Client()).ListenConfig(vo.ConfigParam{ + err := (*nacos.client.Client()).ListenConfig(vo.ConfigParam{ DataId: key, Group: "dubbo", OnChange: func(namespace, group, dataId, data string) { @@ -49,14 +49,14 @@ func (l *nacosDynamicConfiguration) addListener(key string, listener config_cent logger.Errorf("nacos : listen config fail, error:%v ", err) newListener := make(map[config_center.ConfigurationListener]context.CancelFunc) newListener[listener] = cancel - l.keyListeners.Store(key, newListener) + nacos.keyListeners.Store(key, newListener) } else { // TODO check goroutine alive, but this version of go_nacos_sdk is not support. logger.Infof("profile:%s. this profile is already listening", key) } } -func (l *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) { +func (nacos *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) { // TODO: not supported in current go_nacos_sdk version logger.Warn("not supported in current go_nacos_sdk version") } diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 404243d475..f8263e47c7 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -41,6 +41,7 @@ const ( // ZkClient //zookeeper client name ZkClient = "zk config_center" + pathSeparator = "/" ) type zookeeperDynamicConfiguration struct { @@ -143,11 +144,21 @@ func (c *zookeeperDynamicConfiguration) GetProperties(key string, opts ...config return string(content), nil } -//For zookeeper, getConfig and getConfigs have the same meaning. +// GetInternalProperty For zookeeper, getConfig and getConfigs have the same meaning. func (c *zookeeperDynamicConfiguration) GetInternalProperty(key string, opts ...config_center.Option) (string, error) { return c.GetProperties(key, 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)) + if err != nil { + return perrors.WithStack(err) + } + return nil +} + func (c *zookeeperDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { return c.GetProperties(key, opts...) } @@ -214,3 +225,17 @@ func (c *zookeeperDynamicConfiguration) closeConfigs() { func (c *zookeeperDynamicConfiguration) RestartCallBack() bool { return true } + +func (c *zookeeperDynamicConfiguration) getPath(key string, group string) string { + if len(key) <= 0 { + return c.buildPath(group) + } + return c.buildPath(group) + pathSeparator + key +} + +func (c *zookeeperDynamicConfiguration) buildPath(group string) string { + if len(group) <= 0 { + group = config_center.DEFAULT_GROUP + } + return c.rootPath + pathSeparator + group +} diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go index 22e15193cb..e6349d4c3d 100644 --- a/config_center/zookeeper/impl_test.go +++ b/config_center/zookeeper/impl_test.go @@ -156,6 +156,18 @@ func Test_RemoveListener(t *testing.T) { assert.Equal(t, "", listener.event) } +func TestZookeeperDynamicConfiguration_PublishConfig(t *testing.T) { + value := "Test Data" + customGroup := "Custom Group" + ts, zk := initZkData(config_center.DEFAULT_GROUP, t) + defer ts.Stop() + err := zk.PublishConfig("myKey", customGroup, value) + assert.Nil(t, err) + result, err := zk.GetInternalProperty("myKey", config_center.WithGroup(customGroup)) + assert.Nil(t, err) + assert.Equal(t, value, result) +} + type mockDataListener struct { wg sync.WaitGroup event string diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 21486aab59..936b3b5acf 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -392,8 +392,16 @@ func (z *ZookeeperClient) Close() { logger.Warnf("zkClient{name:%s, zk addr:%s} exit now.", z.name, z.ZkAddrs) } -// Create ... +// Create will create the node recursively, which means that if the parent node is absent, +// it will create parent node first. +// And the value for the basePath is "" func (z *ZookeeperClient) Create(basePath string) error { + return z.CreateWithValue(basePath, []byte("")) +} + +// Create will create the node recursively, which means that if the parent node is absent, +// it will create parent node first. +func (z *ZookeeperClient) CreateWithValue(basePath string, value []byte) error { var ( err error tmpPath string @@ -407,7 +415,7 @@ func (z *ZookeeperClient) Create(basePath string) error { conn := z.Conn z.Unlock() if conn != nil { - _, err = conn.Create(tmpPath, []byte(""), 0, zk.WorldACL(zk.PermAll)) + _, err = conn.Create(tmpPath, value, 0, zk.WorldACL(zk.PermAll)) } if err != nil { @@ -423,6 +431,8 @@ func (z *ZookeeperClient) Create(basePath string) error { return nil } + + // Delete ... func (z *ZookeeperClient) Delete(basePath string) error { var ( From 16274df7acf6406b939aeb66e26f0bb83821fb8c Mon Sep 17 00:00:00 2001 From: flycash Date: Sat, 21 Mar 2020 21:01:39 +0800 Subject: [PATCH 009/167] Fix import --- config_center/apollo/impl.go | 3 +-- config_center/dynamic_configuration.go | 1 - config_center/nacos/impl.go | 11 +++++------ config_center/zookeeper/impl.go | 4 ++-- remoting/zookeeper/client.go | 2 -- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index d9c9ad2c30..1df3bedded 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -130,8 +130,7 @@ func (c *apolloConfiguration) GetRule(key string, opts ...cc.Option) (string, er // PublishConfig will publish the config with the (key, group, value) pair func (c *apolloConfiguration) PublishConfig(string, string, string) error { - // todo(@zouyx) - return nil + return errors.New("unsupport operation") } func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (string, error) { diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index e5284e89eb..e643e011fb 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -53,7 +53,6 @@ type DynamicConfiguration interface { // PublishConfig will publish the config with the (key, group, value) pair PublishConfig(string, string, string) error - } // Options ... diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index a1f9ff8cc6..752bec7fc9 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -18,7 +18,6 @@ package nacos import ( - "errors" "strings" "sync" ) @@ -92,16 +91,16 @@ func (nacos *nacosDynamicConfiguration) PublishConfig(key string, group string, group = nacos.resolvedGroup(group) ok, err := (*nacos.client.Client()).PublishConfig(vo.ConfigParam{ - DataId: key, - Group: group, - Content: value, + DataId: key, + Group: group, + Content: value, }) if err != nil { return err } if !ok { - return errors.New("publish config to Nocos failed") + return perrors.New("publish config to Nocos failed") } return nil } @@ -170,7 +169,7 @@ func (nacos *nacosDynamicConfiguration) Destroy() { // resolvedGroup will regular the group. Now, it will replace the '/' with '-'. // '/' is a special character for nacos func (nacos *nacosDynamicConfiguration) resolvedGroup(group string) string { - if len(group) <=0 { + if len(group) <= 0 { return group } return strings.ReplaceAll(group, "/", "-") diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index f8263e47c7..38b0057d3a 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -40,7 +40,7 @@ import ( const ( // ZkClient //zookeeper client name - ZkClient = "zk config_center" + ZkClient = "zk config_center" pathSeparator = "/" ) @@ -228,7 +228,7 @@ func (c *zookeeperDynamicConfiguration) RestartCallBack() bool { func (c *zookeeperDynamicConfiguration) getPath(key string, group string) string { if len(key) <= 0 { - return c.buildPath(group) + return c.buildPath(group) } return c.buildPath(group) + pathSeparator + key } diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 936b3b5acf..aeb249b301 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -431,8 +431,6 @@ func (z *ZookeeperClient) CreateWithValue(basePath string, value []byte) error { return nil } - - // Delete ... func (z *ZookeeperClient) Delete(basePath string) error { var ( From d7b02cd7ebf6beb743b1456077010133d29f752d Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Sun, 22 Mar 2020 21:52:41 +0800 Subject: [PATCH 010/167] Mod: readme.md & change.md --- CHANGE.md | 1 + README.md | 11 ++++++++++- README_CN.md | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index ad8bc594cd..00b074d284 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -8,6 +8,7 @@ - [Context support](https://github.com/apache/dubbo-go/pull/330) - [Opentracing & transfer context end to end for jsonrpc protocol](https://github.com/apache/dubbo-go/pull/335) - [Opentracing & transfer context end to end for dubbo protocol](https://github.com/apache/dubbo-go/pull/344) +- [Grpc tracing for client and server](https://github.com/apache/dubbo-go/pull/397) - [Nacos config center](https://github.com/apache/dubbo-go/pull/357) - [Prometheus support](https://github.com/apache/dubbo-go/pull/342) - [Support sign and auth for request](https://github.com/apache/dubbo-go/pull/323) diff --git a/README.md b/README.md index e43b1e9aed..2035aeed41 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Finished List: - Router * [Condition router](https://github.com/apache/dubbo-go/pull/294) + * [Health check router](https://github.com/apache/dubbo-go/pull/389) - Registry * ZooKeeper @@ -91,13 +92,21 @@ Finished List: * [TpsLimitFilter](https://github.com/apache/dubbo-go/pull/237) * [ExecuteLimitFilter](https://github.com/apache/dubbo-go/pull/246) * [GenericServiceFilter](https://github.com/apache/dubbo-go/pull/291) + * [Auth/Sign](https://github.com/apache/dubbo-go/pull/323) + * [Metrics filter](https://github.com/apache/dubbo-go/pull/342) + * [Tracing filter](https://github.com/apache/dubbo-go/pull/335) - Invoke * [generic invoke](https://github.com/apache/dubbo-go/pull/122) - Monitor * Opentracing API - * Prometheus + * [Prometheus](https://github.com/apache/dubbo-go/pull/342) + +- Tracing + * [For jsonrpc](https://github.com/apache/dubbo-go/pull/335) + * [For dubbo](https://github.com/apache/dubbo-go/pull/344) + * [For grpc](https://github.com/apache/dubbo-go/pull/397) - Others: * start check diff --git a/README_CN.md b/README_CN.md index e70e678631..9fe34074f3 100644 --- a/README_CN.md +++ b/README_CN.md @@ -55,6 +55,7 @@ Apache License, Version 2.0 - 路由器 * [Condition router](https://github.com/apache/dubbo-go/pull/294) + * [Health check router](https://github.com/apache/dubbo-go/pull/389) - 注册中心 * ZooKeeper @@ -89,13 +90,21 @@ Apache License, Version 2.0 * [AccessLogFilter](https://github.com/apache/dubbo-go/pull/214) * [TpsLimitFilter](https://github.com/apache/dubbo-go/pull/237) * [ExecuteLimitFilter](https://github.com/apache/dubbo-go/pull/246) + * [Auth/Sign](https://github.com/apache/dubbo-go/pull/323) + * [Metrics filter](https://github.com/apache/dubbo-go/pull/342) + * [Tracing filter](https://github.com/apache/dubbo-go/pull/335) - 调用 * [泛化调用](https://github.com/apache/dubbo-go/pull/122) - 监控 * Opentracing API - * Prometheus + * [Prometheus](https://github.com/apache/dubbo-go/pull/342) + +- Tracing + * [For jsonrpc](https://github.com/apache/dubbo-go/pull/335) + * [For dubbo](https://github.com/apache/dubbo-go/pull/344) + * [For grpc](https://github.com/apache/dubbo-go/pull/397) - 其他功能支持: * 启动时检查 From b9a94e577f3b13a8961d81fdcd0726078bdb325e Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Sun, 22 Mar 2020 22:33:06 +0800 Subject: [PATCH 011/167] Mod: release note --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2035aeed41..fd4b936d4d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Apache License, Version 2.0 ## Release note ## +[v1.4.0-rc1 - Mar 17, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1) + [v1.3.0 - Mar 1, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.3.0) [v1.2.0 - Nov 15, 2019](https://github.com/apache/dubbo-go/releases/tag/v1.2.0) From 39098b8328414ff1d2e112685ddc416c4201a342 Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Sun, 22 Mar 2020 22:45:03 +0800 Subject: [PATCH 012/167] Del: delete osx in .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f30febe7b..ba30c9d010 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: go os: - linux - - osx go: - "1.13" From ffc8f7b32d30ed7c923f0be643ff1e5ff6bb12dc Mon Sep 17 00:00:00 2001 From: flycash Date: Mon, 23 Mar 2020 15:22:43 +0800 Subject: [PATCH 013/167] Fix review --- config_center/nacos/impl.go | 88 ++++++++++++++++----------------- config_center/nacos/listener.go | 12 ++--- config_center/zookeeper/impl.go | 2 +- remoting/zookeeper/client.go | 2 +- 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 752bec7fc9..54523cae71 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -66,38 +66,38 @@ func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, } // AddListener Add listener -func (nacos *nacosDynamicConfiguration) AddListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { - nacos.addListener(key, listener) +func (n *nacosDynamicConfiguration) AddListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { + n.addListener(key, listener) } // RemoveListener Remove listener -func (nacos *nacosDynamicConfiguration) RemoveListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { - nacos.removeListener(key, listener) +func (n *nacosDynamicConfiguration) RemoveListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) { + n.removeListener(key, listener) } // GetProperties nacos distinguishes configuration files based on group and dataId. defalut group = "dubbo" and dataId = key -func (nacos *nacosDynamicConfiguration) GetProperties(key string, opts ...config_center.Option) (string, error) { - return nacos.GetRule(key, opts...) +func (n *nacosDynamicConfiguration) GetProperties(key string, opts ...config_center.Option) (string, error) { + return n.GetRule(key, opts...) } // GetInternalProperty Get properties value by key -func (nacos *nacosDynamicConfiguration) GetInternalProperty(key string, opts ...config_center.Option) (string, error) { - return nacos.GetProperties(key, opts...) +func (n *nacosDynamicConfiguration) GetInternalProperty(key string, opts ...config_center.Option) (string, error) { + return n.GetProperties(key, opts...) } // PublishConfig will publish the config with the (key, group, value) pair -func (nacos *nacosDynamicConfiguration) PublishConfig(key string, group string, value string) error { +func (n *nacosDynamicConfiguration) PublishConfig(key string, group string, value string) error { - group = nacos.resolvedGroup(group) + group = n.resolvedGroup(group) - ok, err := (*nacos.client.Client()).PublishConfig(vo.ConfigParam{ + ok, err := (*n.client.Client()).PublishConfig(vo.ConfigParam{ DataId: key, Group: group, Content: value, }) if err != nil { - return err + return perrors.WithStack(err) } if !ok { return perrors.New("publish config to Nocos failed") @@ -106,14 +106,14 @@ func (nacos *nacosDynamicConfiguration) PublishConfig(key string, group string, } // GetRule Get router rule -func (nacos *nacosDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { +func (n *nacosDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { tmpOpts := &config_center.Options{} for _, opt := range opts { opt(tmpOpts) } - content, err := (*nacos.client.Client()).GetConfig(vo.ConfigParam{ + content, err := (*n.client.Client()).GetConfig(vo.ConfigParam{ DataId: key, - Group: nacos.resolvedGroup(tmpOpts.Group), + Group: n.resolvedGroup(tmpOpts.Group), }) if err != nil { return "", perrors.WithStack(err) @@ -123,52 +123,52 @@ func (nacos *nacosDynamicConfiguration) GetRule(key string, opts ...config_cente } // Parser Get Parser -func (nacos *nacosDynamicConfiguration) Parser() parser.ConfigurationParser { - return nacos.parser +func (n *nacosDynamicConfiguration) Parser() parser.ConfigurationParser { + return n.parser } // SetParser Set Parser -func (nacos *nacosDynamicConfiguration) SetParser(p parser.ConfigurationParser) { - nacos.parser = p +func (n *nacosDynamicConfiguration) SetParser(p parser.ConfigurationParser) { + n.parser = p } // NacosClient Get Nacos Client -func (nacos *nacosDynamicConfiguration) NacosClient() *NacosClient { - return nacos.client +func (n *nacosDynamicConfiguration) NacosClient() *NacosClient { + return n.client } // SetNacosClient Set Nacos Client -func (nacos *nacosDynamicConfiguration) SetNacosClient(client *NacosClient) { - nacos.cltLock.Lock() - nacos.client = client - nacos.cltLock.Unlock() +func (n *nacosDynamicConfiguration) SetNacosClient(client *NacosClient) { + n.cltLock.Lock() + n.client = client + n.cltLock.Unlock() } // WaitGroup for wait group control, zk client listener & zk client container -func (nacos *nacosDynamicConfiguration) WaitGroup() *sync.WaitGroup { - return &nacos.wg +func (n *nacosDynamicConfiguration) WaitGroup() *sync.WaitGroup { + return &n.wg } // GetDone For nacos client control RestartCallBack() bool -func (nacos *nacosDynamicConfiguration) GetDone() chan struct{} { - return nacos.done +func (n *nacosDynamicConfiguration) GetDone() chan struct{} { + return n.done } // GetUrl Get Url -func (nacos *nacosDynamicConfiguration) GetUrl() common.URL { - return *nacos.url +func (n *nacosDynamicConfiguration) GetUrl() common.URL { + return *n.url } // Destroy Destroy configuration instance -func (nacos *nacosDynamicConfiguration) Destroy() { - close(nacos.done) - nacos.wg.Wait() - nacos.closeConfigs() +func (n *nacosDynamicConfiguration) Destroy() { + close(n.done) + n.wg.Wait() + n.closeConfigs() } // resolvedGroup will regular the group. Now, it will replace the '/' with '-'. // '/' is a special character for nacos -func (nacos *nacosDynamicConfiguration) resolvedGroup(group string) string { +func (n *nacosDynamicConfiguration) resolvedGroup(group string) string { if len(group) <= 0 { return group } @@ -176,21 +176,21 @@ func (nacos *nacosDynamicConfiguration) resolvedGroup(group string) string { } // IsAvailable Get available status -func (nacos *nacosDynamicConfiguration) IsAvailable() bool { +func (n *nacosDynamicConfiguration) IsAvailable() bool { select { - case <-nacos.done: + case <-n.done: return false default: return true } } -func (nacos *nacosDynamicConfiguration) closeConfigs() { - nacos.cltLock.Lock() - client := nacos.client - nacos.client = nil - nacos.cltLock.Unlock() +func (n *nacosDynamicConfiguration) closeConfigs() { + n.cltLock.Lock() + client := n.client + n.client = nil + n.cltLock.Unlock() // Close the old client first to close the tmp node client.Close() - logger.Infof("begin to close provider nacos client") + logger.Infof("begin to close provider n client") } diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go index 0f16727b60..1d63facbe3 100644 --- a/config_center/nacos/listener.go +++ b/config_center/nacos/listener.go @@ -35,28 +35,28 @@ func callback(listener config_center.ConfigurationListener, namespace, group, da listener.Process(&config_center.ConfigChangeEvent{Key: dataId, Value: data, ConfigType: remoting.EventTypeUpdate}) } -func (nacos *nacosDynamicConfiguration) addListener(key string, listener config_center.ConfigurationListener) { - _, loaded := nacos.keyListeners.Load(key) +func (n *nacosDynamicConfiguration) addListener(key string, listener config_center.ConfigurationListener) { + _, loaded := n.keyListeners.Load(key) if !loaded { _, cancel := context.WithCancel(context.Background()) - err := (*nacos.client.Client()).ListenConfig(vo.ConfigParam{ + err := (*n.client.Client()).ListenConfig(vo.ConfigParam{ DataId: key, Group: "dubbo", OnChange: func(namespace, group, dataId, data string) { go callback(listener, namespace, group, dataId, data) }, }) - logger.Errorf("nacos : listen config fail, error:%v ", err) + logger.Errorf("n : listen config fail, error:%v ", err) newListener := make(map[config_center.ConfigurationListener]context.CancelFunc) newListener[listener] = cancel - nacos.keyListeners.Store(key, newListener) + n.keyListeners.Store(key, newListener) } else { // TODO check goroutine alive, but this version of go_nacos_sdk is not support. logger.Infof("profile:%s. this profile is already listening", key) } } -func (nacos *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) { +func (n *nacosDynamicConfiguration) removeListener(key string, listener config_center.ConfigurationListener) { // TODO: not supported in current go_nacos_sdk version logger.Warn("not supported in current go_nacos_sdk version") } diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 38b0057d3a..fc87eaee5f 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -227,7 +227,7 @@ func (c *zookeeperDynamicConfiguration) RestartCallBack() bool { } func (c *zookeeperDynamicConfiguration) getPath(key string, group string) string { - if len(key) <= 0 { + if len(key) == 0 { return c.buildPath(group) } return c.buildPath(group) + pathSeparator + key diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index aeb249b301..7dac6146fa 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -399,7 +399,7 @@ func (z *ZookeeperClient) Create(basePath string) error { return z.CreateWithValue(basePath, []byte("")) } -// Create will create the node recursively, which means that if the parent node is absent, +// CreateWithValue will create the node recursively, which means that if the parent node is absent, // it will create parent node first. func (z *ZookeeperClient) CreateWithValue(basePath string, value []byte) error { var ( From c12ca7ade4b14a398cbd42eb6705749ee17da4ac Mon Sep 17 00:00:00 2001 From: flycash Date: Mon, 23 Mar 2020 21:36:13 +0800 Subject: [PATCH 014/167] Fix Review --- config_center/apollo/impl.go | 8 ++++---- config_center/nacos/listener.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index 1df3bedded..bc8538f2e7 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -25,7 +25,7 @@ import ( ) import ( - "github.com/pkg/errors" + perrors "github.com/pkg/errors" "github.com/zouyx/agollo" ) @@ -119,7 +119,7 @@ func getNamespaceName(namespace string, configFileFormat agollo.ConfigFileFormat func (c *apolloConfiguration) GetInternalProperty(key string, opts ...cc.Option) (string, error) { config := agollo.GetConfig(c.appConf.NamespaceName) if config == nil { - return "", errors.New(fmt.Sprintf("nothing in namespace:%s ", key)) + return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) } return config.GetStringValue(key, ""), nil } @@ -130,7 +130,7 @@ func (c *apolloConfiguration) GetRule(key string, opts ...cc.Option) (string, er // PublishConfig will publish the config with the (key, group, value) pair func (c *apolloConfiguration) PublishConfig(string, string, string) error { - return errors.New("unsupport operation") + return perrors.New("unsupport operation") } func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (string, error) { @@ -140,7 +140,7 @@ func (c *apolloConfiguration) GetProperties(key string, opts ...cc.Option) (stri */ config := agollo.GetConfig(key) if config == nil { - return "", errors.New(fmt.Sprintf("nothing in namespace:%s ", key)) + return "", perrors.New(fmt.Sprintf("nothing in namespace:%s ", key)) } return config.GetContent(agollo.Properties), nil } diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go index 1d63facbe3..de74cff8f6 100644 --- a/config_center/nacos/listener.go +++ b/config_center/nacos/listener.go @@ -46,7 +46,7 @@ func (n *nacosDynamicConfiguration) addListener(key string, listener config_cent go callback(listener, namespace, group, dataId, data) }, }) - logger.Errorf("n : listen config fail, error:%v ", err) + logger.Errorf("nacos : listen config fail, error:%v ", err) newListener := make(map[config_center.ConfigurationListener]context.CancelFunc) newListener[listener] = cancel n.keyListeners.Store(key, newListener) From 4657f3d111116c43b1d0ce9612699fc2b9eb3bfd Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Tue, 24 Mar 2020 02:25:31 +0800 Subject: [PATCH 015/167] Add: GetInterface for rpc_service.go --- common/rpc_service.go | 45 ++++++++++++++++--- common/rpc_service_test.go | 22 ++++----- config/config_loader.go | 2 +- config/config_loader_test.go | 7 +-- config/service_config.go | 2 +- .../generic_service_filter_test.go | 2 +- protocol/dubbo/client_test.go | 2 +- protocol/dubbo/dubbo_exporter.go | 3 +- protocol/grpc/grpc_exporter.go | 3 +- protocol/jsonrpc/http_test.go | 2 +- protocol/jsonrpc/jsonrpc_exporter.go | 3 +- protocol/jsonrpc/jsonrpc_invoker_test.go | 2 +- protocol/rest/rest_exporter.go | 3 +- protocol/rest/rest_invoker_test.go | 4 +- protocol/rest/rest_protocol_test.go | 4 +- 15 files changed, 73 insertions(+), 33 deletions(-) diff --git a/common/rpc_service.go b/common/rpc_service.go index b235c32abc..d05f527a61 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -71,7 +71,8 @@ var ( // ServiceMap ... // todo: lowerecas? ServiceMap = &serviceMap{ - serviceMap: make(map[string]map[string]*Service), + serviceMap: make(map[string]map[string]*Service), + interfaceMap: make(map[string][]*Service), } ) @@ -147,8 +148,9 @@ func (s *Service) Rcvr() reflect.Value { ////////////////////////// type serviceMap struct { - mutex sync.RWMutex // protects the serviceMap - serviceMap map[string]map[string]*Service // protocol -> service name -> service + mutex sync.RWMutex // protects the serviceMap + serviceMap map[string]map[string]*Service // protocol -> service name -> service + interfaceMap map[string][]*Service // interface -> service } func (sm *serviceMap) GetService(protocol, name string) *Service { @@ -163,10 +165,23 @@ func (sm *serviceMap) GetService(protocol, name string) *Service { return nil } -func (sm *serviceMap) Register(protocol string, rcvr RPCService) (string, error) { +// GetInterface get an interface defination by interface name +func (sm *serviceMap) GetInterface(interfaceName string) []*Service { + sm.mutex.RLock() + defer sm.mutex.RUnlock() + if s, ok := sm.interfaceMap[interfaceName]; ok { + return s + } + return nil +} + +func (sm *serviceMap) Register(interfaceName, protocol string, rcvr RPCService) (string, error) { if sm.serviceMap[protocol] == nil { sm.serviceMap[protocol] = make(map[string]*Service) } + if sm.interfaceMap[interfaceName] == nil { + sm.interfaceMap[interfaceName] = make([]*Service, 0, 16) + } s := new(Service) s.rcvrType = reflect.TypeOf(rcvr) @@ -201,12 +216,13 @@ func (sm *serviceMap) Register(protocol string, rcvr RPCService) (string, error) } sm.mutex.Lock() sm.serviceMap[protocol][s.name] = s + sm.interfaceMap[interfaceName] = append(sm.interfaceMap[interfaceName], s) sm.mutex.Unlock() return strings.TrimSuffix(methods, ","), nil } -func (sm *serviceMap) UnRegister(protocol, serviceId string) error { +func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) error { if protocol == "" || serviceId == "" { return perrors.New("protocol or serviceName is nil") } @@ -216,15 +232,32 @@ func (sm *serviceMap) UnRegister(protocol, serviceId string) error { sm.mutex.RUnlock() return perrors.New("no services for " + protocol) } - _, ok = svcs[serviceId] + s, ok := svcs[serviceId] if !ok { sm.mutex.RUnlock() return perrors.New("no service for " + serviceId) } + svrs, ok := sm.interfaceMap[interfaceName] + if !ok { + sm.mutex.RUnlock() + return perrors.New("no service for " + interfaceName) + } + index := -1 + for i, svr := range svrs { + if svr == s { + index = i + } + } sm.mutex.RUnlock() sm.mutex.Lock() defer sm.mutex.Unlock() + sm.interfaceMap[interfaceName] = make([]*Service, 0, len(svrs)) + for i, _ := range svrs { + if i != index { + sm.interfaceMap[interfaceName] = append(sm.interfaceMap[interfaceName], svrs[i]) + } + } delete(svcs, serviceId) delete(sm.serviceMap, protocol) diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go index 8c9b9d15cd..2311205d0e 100644 --- a/common/rpc_service_test.go +++ b/common/rpc_service_test.go @@ -77,46 +77,48 @@ func TestServiceMap_Register(t *testing.T) { // lowercase s0 := &testService{} // methods, err := ServiceMap.Register("testporotocol", s0) - _, err := ServiceMap.Register("testporotocol", s0) + _, err := ServiceMap.Register("testService", "testporotocol", s0) assert.EqualError(t, err, "type testService is not exported") // succ s := &TestService{} - methods, err := ServiceMap.Register("testporotocol", s) + methods, err := ServiceMap.Register("testService", "testporotocol", s) assert.NoError(t, err) assert.Equal(t, "MethodOne,MethodThree,methodTwo", methods) // repeat - _, err = ServiceMap.Register("testporotocol", s) + _, err = ServiceMap.Register("testService", "testporotocol", s) assert.EqualError(t, err, "service already defined: com.test.Path") // no method s1 := &TestService1{} - _, err = ServiceMap.Register("testporotocol", s1) + _, err = ServiceMap.Register("testService", "testporotocol", s1) assert.EqualError(t, err, "type com.test.Path1 has no exported methods of suitable type") ServiceMap = &serviceMap{ - serviceMap: make(map[string]map[string]*Service), + serviceMap: make(map[string]map[string]*Service), + interfaceMap: make(map[string][]*Service), } } func TestServiceMap_UnRegister(t *testing.T) { s := &TestService{} - _, err := ServiceMap.Register("testprotocol", s) + _, err := ServiceMap.Register("TestService", "testprotocol", s) assert.NoError(t, err) assert.NotNil(t, ServiceMap.GetService("testprotocol", "com.test.Path")) + assert.Equal(t, 1, len(ServiceMap.GetInterface("TestService"))) - err = ServiceMap.UnRegister("", "com.test.Path") + err = ServiceMap.UnRegister("", "", "com.test.Path") assert.EqualError(t, err, "protocol or serviceName is nil") - err = ServiceMap.UnRegister("protocol", "com.test.Path") + err = ServiceMap.UnRegister("", "protocol", "com.test.Path") assert.EqualError(t, err, "no services for protocol") - err = ServiceMap.UnRegister("testprotocol", "com.test.Path1") + err = ServiceMap.UnRegister("", "testprotocol", "com.test.Path1") assert.EqualError(t, err, "no service for com.test.Path1") // succ - err = ServiceMap.UnRegister("testprotocol", "com.test.Path") + err = ServiceMap.UnRegister("TestService", "testprotocol", "com.test.Path") assert.NoError(t, err) } diff --git a/config/config_loader.go b/config/config_loader.go index c0687d8fc1..61cb49457b 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -199,7 +199,7 @@ func Load() { svs.id = key svs.Implement(rpcService) if err := svs.Export(); err != nil { - panic(fmt.Sprintf("service %s export failed! ", key)) + panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } } diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 498f826780..6368fcbd2c 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -82,7 +82,8 @@ func TestLoad(t *testing.T) { conServices = map[string]common.RPCService{} proServices = map[string]common.RPCService{} - common.ServiceMap.UnRegister("mock", "MockService") + err := common.ServiceMap.UnRegister("com.MockService", "mock", "MockService") + assert.Nil(t, err) consumerConfig = nil providerConfig = nil } @@ -110,7 +111,7 @@ func TestLoadWithSingleReg(t *testing.T) { conServices = map[string]common.RPCService{} proServices = map[string]common.RPCService{} - common.ServiceMap.UnRegister("mock", "MockService") + common.ServiceMap.UnRegister("com.MockService", "mock", "MockService") consumerConfig = nil providerConfig = nil } @@ -139,7 +140,7 @@ func TestWithNoRegLoad(t *testing.T) { conServices = map[string]common.RPCService{} proServices = map[string]common.RPCService{} - common.ServiceMap.UnRegister("mock", "MockService") + common.ServiceMap.UnRegister("com.MockService", "mock", "MockService") consumerConfig = nil providerConfig = nil } diff --git a/config/service_config.go b/config/service_config.go index faa8dc9f81..61d24ced74 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -128,7 +128,7 @@ func (c *ServiceConfig) Export() error { } for _, proto := range protocolConfigs { // registry the service reflect - methods, err := common.ServiceMap.Register(proto.Name, c.rpcService) + methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.rpcService) if err != nil { err := perrors.Errorf("The service %v export the protocol %v error! Error message is %v .", c.InterfaceName, proto.Name, err.Error()) logger.Errorf(err.Error()) diff --git a/filter/filter_impl/generic_service_filter_test.go b/filter/filter_impl/generic_service_filter_test.go index 37c6af7450..2a911659f0 100644 --- a/filter/filter_impl/generic_service_filter_test.go +++ b/filter/filter_impl/generic_service_filter_test.go @@ -96,7 +96,7 @@ func TestGenericServiceFilter_Invoke(t *testing.T) { hessian.Object("222")}, } s := &TestService{} - _, _ = common.ServiceMap.Register("testprotocol", s) + _, _ = common.ServiceMap.Register("TestService", "testprotocol", s) rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil) filter := GetGenericServiceFilter() url, _ := common.NewURL("testprotocol://127.0.0.1:20000/com.test.Path") diff --git a/protocol/dubbo/client_test.go b/protocol/dubbo/client_test.go index 1e0a73fac1..744ffa80d6 100644 --- a/protocol/dubbo/client_test.go +++ b/protocol/dubbo/client_test.go @@ -162,7 +162,7 @@ func InitTest(t *testing.T) (protocol.Protocol, common.URL) { hessian.RegisterPOJO(&User{}) - methods, err := common.ServiceMap.Register("dubbo", &UserProvider{}) + 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) diff --git a/protocol/dubbo/dubbo_exporter.go b/protocol/dubbo/dubbo_exporter.go index f4cd0cc123..1c45c40056 100644 --- a/protocol/dubbo/dubbo_exporter.go +++ b/protocol/dubbo/dubbo_exporter.go @@ -43,8 +43,9 @@ func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Ma // Unexport ... func (de *DubboExporter) Unexport() { serviceId := de.GetInvoker().GetUrl().GetParam(constant.BEAN_NAME_KEY, "") + interfaceName := de.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") de.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(DUBBO, serviceId) + err := common.ServiceMap.UnRegister(interfaceName, DUBBO, serviceId) if err != nil { logger.Errorf("[DubboExporter.Unexport] error: %v", err) } diff --git a/protocol/grpc/grpc_exporter.go b/protocol/grpc/grpc_exporter.go index 3c38ef974c..5b7ff36c1a 100644 --- a/protocol/grpc/grpc_exporter.go +++ b/protocol/grpc/grpc_exporter.go @@ -43,8 +43,9 @@ func NewGrpcExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map // Unexport ... func (gg *GrpcExporter) Unexport() { serviceId := gg.GetInvoker().GetUrl().GetParam(constant.BEAN_NAME_KEY, "") + interfaceName := gg.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") gg.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(GRPC, serviceId) + err := common.ServiceMap.UnRegister(interfaceName, GRPC, serviceId) if err != nil { logger.Errorf("[GrpcExporter.Unexport] error: %v", err) } diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index 0cb88b36a8..f8480bf32e 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -50,7 +50,7 @@ type ( func TestHTTPClient_Call(t *testing.T) { - methods, err := common.ServiceMap.Register("jsonrpc", &UserProvider{}) + 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) diff --git a/protocol/jsonrpc/jsonrpc_exporter.go b/protocol/jsonrpc/jsonrpc_exporter.go index 7f8fd49185..c61cf9adae 100644 --- a/protocol/jsonrpc/jsonrpc_exporter.go +++ b/protocol/jsonrpc/jsonrpc_exporter.go @@ -43,8 +43,9 @@ func NewJsonrpcExporter(key string, invoker protocol.Invoker, exporterMap *sync. // Unexport ... func (je *JsonrpcExporter) Unexport() { serviceId := je.GetInvoker().GetUrl().GetParam(constant.BEAN_NAME_KEY, "") + interfaceName := je.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") je.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(JSONRPC, serviceId) + err := common.ServiceMap.UnRegister(interfaceName, JSONRPC, serviceId) if err != nil { logger.Errorf("[JsonrpcExporter.Unexport] error: %v", err) } diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go index 9e08eed2b4..0f14ba11e2 100644 --- a/protocol/jsonrpc/jsonrpc_invoker_test.go +++ b/protocol/jsonrpc/jsonrpc_invoker_test.go @@ -36,7 +36,7 @@ import ( func TestJsonrpcInvoker_Invoke(t *testing.T) { - methods, err := common.ServiceMap.Register("jsonrpc", &UserProvider{}) + methods, err := common.ServiceMap.Register("UserProvider", "jsonrpc", &UserProvider{}) assert.NoError(t, err) assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) diff --git a/protocol/rest/rest_exporter.go b/protocol/rest/rest_exporter.go index 470d525ad8..1ee208615e 100644 --- a/protocol/rest/rest_exporter.go +++ b/protocol/rest/rest_exporter.go @@ -40,8 +40,9 @@ func NewRestExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map func (re *RestExporter) Unexport() { serviceId := re.GetInvoker().GetUrl().GetParam(constant.BEAN_NAME_KEY, "") + interfaceName := re.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") re.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(REST, serviceId) + err := common.ServiceMap.UnRegister(interfaceName, REST, serviceId) if err != nil { logger.Errorf("[RestExporter.Unexport] error: %v", err) } diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index e44c5d9a21..2ea260c58d 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -61,7 +61,7 @@ func TestRestInvoker_Invoke(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) - _, err = common.ServiceMap.Register(url.Protocol, &UserProvider{}) + _, err = common.ServiceMap.Register("UserProvider", url.Protocol, &UserProvider{}) assert.NoError(t, err) con := config.ProviderConfig{} config.SetProviderConfig(con) @@ -206,6 +206,6 @@ func TestRestInvoker_Invoke(t *testing.T) { assert.Error(t, res.Error(), "test error") assert.Equal(t, filterNum, 12) - err = common.ServiceMap.UnRegister(url.Protocol, "com.ikurento.user.UserProvider") + err = common.ServiceMap.UnRegister("UserProvider", url.Protocol, "com.ikurento.user.UserProvider") assert.NoError(t, err) } diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 8af73a1839..9117148777 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -80,7 +80,7 @@ func TestRestProtocol_Export(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) - _, err = common.ServiceMap.Register(url.Protocol, &UserProvider{}) + _, err = common.ServiceMap.Register("UserProvider", url.Protocol, &UserProvider{}) assert.NoError(t, err) con := config.ProviderConfig{} config.SetProviderConfig(con) @@ -128,7 +128,7 @@ func TestRestProtocol_Export(t *testing.T) { proto.Destroy() _, ok = proto.(*RestProtocol).serverMap[url.Location] assert.False(t, ok) - err = common.ServiceMap.UnRegister(url.Protocol, "com.ikurento.user.UserProvider") + err = common.ServiceMap.UnRegister("UserProvider", url.Protocol, "com.ikurento.user.UserProvider") assert.NoError(t, err) } From 0f1784730d2d13294c0ed2b31179ca9c3e57f3e0 Mon Sep 17 00:00:00 2001 From: flycash Date: Tue, 24 Mar 2020 16:30:40 +0800 Subject: [PATCH 016/167] service name mapping support --- config_center/apollo/impl.go | 6 ++ config_center/dynamic_configuration.go | 17 ++-- config_center/mock_dynamic_config.go | 7 ++ config_center/nacos/impl.go | 8 ++ config_center/zookeeper/impl.go | 23 ++++- config_center/zookeeper/impl_test.go | 11 ++- .../dynamic_mapping/service_name_mapping.go | 87 +++++++++++++++++++ .../service_name_mapping_test.go | 60 +++++++++++++ metadata/in_memory/service_name_mapping.go | 36 ++++++++ metadata/service_name_mapping.go | 32 +++++++ 10 files changed, 278 insertions(+), 9 deletions(-) create mode 100644 metadata/dynamic_mapping/service_name_mapping.go create mode 100644 metadata/dynamic_mapping/service_name_mapping_test.go create mode 100644 metadata/in_memory/service_name_mapping.go create mode 100644 metadata/service_name_mapping.go diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go index bc8538f2e7..9045c28649 100644 --- a/config_center/apollo/impl.go +++ b/config_center/apollo/impl.go @@ -25,6 +25,7 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" perrors "github.com/pkg/errors" "github.com/zouyx/agollo" ) @@ -133,6 +134,11 @@ func (c *apolloConfiguration) PublishConfig(string, string, string) error { return perrors.New("unsupport operation") } +// GetConfigKeysByGroup will return all keys with the group +func (c *apolloConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet, error) { + return nil, perrors.New("unsupport operation") +} + 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: diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index e643e011fb..bcaf54ba13 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -22,13 +22,15 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" + "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/config_center/parser" ) -////////////////////////////////////////// +// //////////////////////////////////////// // DynamicConfiguration -////////////////////////////////////////// +// //////////////////////////////////////// const ( // DEFAULT_GROUP: default group DEFAULT_GROUP = "dubbo" @@ -42,17 +44,20 @@ type DynamicConfiguration interface { SetParser(parser.ConfigurationParser) AddListener(string, ConfigurationListener, ...Option) RemoveListener(string, ConfigurationListener, ...Option) - //GetProperties get properties file + // GetProperties get properties file GetProperties(string, ...Option) (string, error) - //GetRule get Router rule properties file + // GetRule get Router rule properties file GetRule(string, ...Option) (string, error) - //GetInternalProperty get value by key in Default properties file(dubbo.properties) + // GetInternalProperty get value by key in Default properties file(dubbo.properties) GetInternalProperty(string, ...Option) (string, error) // PublishConfig will publish the config with the (key, group, value) pair PublishConfig(string, string, string) error + + // GetConfigKeysByGroup will return all keys with the group + GetConfigKeysByGroup(group string) (*gxset.HashSet, error) } // Options ... @@ -78,7 +83,7 @@ func WithTimeout(time time.Duration) Option { } } -//GetRuleKey The format is '{interfaceName}:[version]:[group]' +// GetRuleKey The format is '{interfaceName}:[version]:[group]' func GetRuleKey(url common.URL) string { return url.ColonSeparatedKey() } diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 9f5bbe934c..59c788b65b 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -22,6 +22,7 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" "gopkg.in/yaml.v2" ) @@ -81,10 +82,16 @@ func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(_ *common.URL) } +// PublishConfig will publish the config with the (key, group, value) pair func (c *MockDynamicConfiguration) PublishConfig(string, string, string) error { return nil } +// GetConfigKeysByGroup will return all keys with the group +func (c *MockDynamicConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet, error) { + return gxset.NewSet(c.content), nil +} + // MockDynamicConfiguration ... type MockDynamicConfiguration struct { parser parser.ConfigurationParser diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 54523cae71..007b8be142 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -23,6 +23,7 @@ import ( ) import ( + gxset "github.com/dubbogo/gost/container/set" "github.com/nacos-group/nacos-sdk-go/vo" perrors "github.com/pkg/errors" ) @@ -105,6 +106,13 @@ func (n *nacosDynamicConfiguration) PublishConfig(key string, group string, valu return nil } +// GetConfigKeysByGroup will return all keys with the group +func (n *nacosDynamicConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet, error) { + // TODO (the golang client of nacos does not support batch API) + // we should build a issue and then think about how to resolve this problem + return nil, perrors.New("unsupport operation, wait for implement") +} + // GetRule Get router rule func (n *nacosDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { tmpOpts := &config_center.Options{} diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index fc87eaee5f..5cc74e4616 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -25,6 +25,7 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxset "github.com/dubbogo/gost/container/set" perrors "github.com/pkg/errors" ) @@ -39,7 +40,7 @@ import ( const ( // ZkClient - //zookeeper client name + // zookeeper client name ZkClient = "zk config_center" pathSeparator = "/" ) @@ -159,6 +160,24 @@ func (c *zookeeperDynamicConfiguration) PublishConfig(key string, group string, return nil } +// GetConfigKeysByGroup will return all keys with the group +func (c *zookeeperDynamicConfiguration) GetConfigKeysByGroup(group string) (*gxset.HashSet, error) { + path := c.getPath("", group) + result, err := c.client.GetChildren(path) + if err != nil { + return nil, perrors.WithStack(err) + } + + if len(result) == 0 { + return nil, perrors.New("could not find keys with group: " + group) + } + set := gxset.NewSet() + for _, ele := range result { + set.Add(ele) + } + return set, nil +} + func (c *zookeeperDynamicConfiguration) GetRule(key string, opts ...config_center.Option) (string, error) { return c.GetProperties(key, opts...) } @@ -234,7 +253,7 @@ func (c *zookeeperDynamicConfiguration) getPath(key string, group string) string } func (c *zookeeperDynamicConfiguration) buildPath(group string) string { - if len(group) <= 0 { + if len(group) == 0 { group = config_center.DEFAULT_GROUP } return c.rootPath + pathSeparator + group diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go index e6349d4c3d..30389122a3 100644 --- a/config_center/zookeeper/impl_test.go +++ b/config_center/zookeeper/impl_test.go @@ -24,6 +24,7 @@ import ( import ( "github.com/dubbogo/go-zookeeper/zk" + gxset "github.com/dubbogo/gost/container/set" "github.com/stretchr/testify/assert" ) @@ -159,13 +160,21 @@ func Test_RemoveListener(t *testing.T) { func TestZookeeperDynamicConfiguration_PublishConfig(t *testing.T) { value := "Test Data" customGroup := "Custom Group" + key := "myKey" ts, zk := initZkData(config_center.DEFAULT_GROUP, t) defer ts.Stop() - err := zk.PublishConfig("myKey", customGroup, value) + err := zk.PublishConfig(key, customGroup, value) assert.Nil(t, err) result, err := zk.GetInternalProperty("myKey", config_center.WithGroup(customGroup)) assert.Nil(t, err) assert.Equal(t, value, result) + + var keys *gxset.HashSet + keys, err = zk.GetConfigKeysByGroup(customGroup) + assert.Nil(t, err) + assert.Equal(t, 1, keys.Size()) + assert.True(t, keys.Contains(key)) + } type mockDataListener struct { diff --git a/metadata/dynamic_mapping/service_name_mapping.go b/metadata/dynamic_mapping/service_name_mapping.go new file mode 100644 index 0000000000..32d5c2f211 --- /dev/null +++ b/metadata/dynamic_mapping/service_name_mapping.go @@ -0,0 +1,87 @@ +/* + * 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_mapping + +import ( + "strconv" + "time" +) + +import ( + "github.com/dubbogo/gost/container/set" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/config_center" + "github.com/apache/dubbo-go/metadata" +) + +const ( + defaultGroup = config_center.DEFAULT_GROUP + slash = "/" + + // metadata service is the admin service, should not be mapped + metadataService = "org.apache.dubbo.metadata.MetadataService" +) + +// DynamicConfigurationServiceNameMapping is the implementation based on config center +type DynamicConfigurationServiceNameMapping struct { + dc config_center.DynamicConfiguration +} + +// Map will map the service to this application-level service +func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error { + if metadataService == serviceInterface { + return perrors.New("try to map the metadata service, will be ignored") + } + + appName := config.GetApplicationConfig().Name + value := time.Now().UnixNano() + + err := d.dc.PublishConfig(appName, + d.buildGroup(serviceInterface, group, version, protocol), + strconv.FormatInt(value, 10)) + if err != nil { + return perrors.WithStack(err) + } + return nil +} + +// 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, group, version, protocol)) +} + +// buildGroup will return group, now it looks like defaultGroup/serviceInterface +func (d *DynamicConfigurationServiceNameMapping) buildGroup( + serviceInterface string, + group string, + version string, + protocol string) string { + // the issue : https://github.com/apache/dubbo/issues/4671 + // so other params are ignored + return defaultGroup + slash + serviceInterface +} + +// NewServiceNameMapping will create an instance of DynamicConfigurationServiceNameMapping +func NewServiceNameMapping(dc config_center.DynamicConfiguration) metadata.ServiceNameMapping { + return &DynamicConfigurationServiceNameMapping{dc: dc} +} diff --git a/metadata/dynamic_mapping/service_name_mapping_test.go b/metadata/dynamic_mapping/service_name_mapping_test.go new file mode 100644 index 0000000000..d1d637a3b1 --- /dev/null +++ b/metadata/dynamic_mapping/service_name_mapping_test.go @@ -0,0 +1,60 @@ +/* + * 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_mapping + +import ( + "testing" +) + +import ( + gxset "github.com/dubbogo/gost/container/set" + "github.com/stretchr/testify/assert" +) + +import ( + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/config_center" +) + +func TestDynamicConfigurationServiceNameMapping(t *testing.T) { + + // mock data + appName := "myApp" + dc, err := (&config_center.MockDynamicConfigurationFactory{ + Content: appName, + }).GetDynamicConfiguration(nil) + config.GetApplicationConfig().Name = appName + + mapping := NewServiceNameMapping(dc) + intf := metadataService + group := "myGroup" + version := "myVersion" + protocol := "myProtocol" + + err = mapping.Map(intf, group, version, protocol) + assert.NotNil(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/in_memory/service_name_mapping.go b/metadata/in_memory/service_name_mapping.go new file mode 100644 index 0000000000..ecb360dbe0 --- /dev/null +++ b/metadata/in_memory/service_name_mapping.go @@ -0,0 +1,36 @@ +/* + * 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 in_memory + +import ( + gxset "github.com/dubbogo/gost/container/set" +) + +import ( + "github.com/apache/dubbo-go/config" +) + +type InMemoryServiceNameMapping struct{} + +func (i InMemoryServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error { + return nil +} + +func (i InMemoryServiceNameMapping) Get(serviceInterface string, group string, version string, protocol string) (*gxset.HashSet, error) { + return gxset.NewSet(config.GetApplicationConfig().Name), nil +} diff --git a/metadata/service_name_mapping.go b/metadata/service_name_mapping.go new file mode 100644 index 0000000000..c14e8ce2e7 --- /dev/null +++ b/metadata/service_name_mapping.go @@ -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. + */ + +package metadata + +import ( + gxset "github.com/dubbogo/gost/container/set" +) + +// 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 + + // Get will return the application-level services + Get(serviceInterface string, group string, version string, protocol string) (*gxset.HashSet, error) +} From 21512be26ca1413b07a6e66187c240e8cf1a4235 Mon Sep 17 00:00:00 2001 From: flycash Date: Wed, 25 Mar 2020 09:59:54 +0800 Subject: [PATCH 017/167] Fix Review --- config_center/dynamic_configuration.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index bcaf54ba13..9013d7140e 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -23,7 +23,9 @@ import ( import ( gxset "github.com/dubbogo/gost/container/set" +) +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/config_center/parser" ) From 1167e74bdeeaf61404784582d529e3eb903a19ec Mon Sep 17 00:00:00 2001 From: flycash Date: Fri, 27 Mar 2020 17:33:47 +0800 Subject: [PATCH 018/167] Fix review --- config_center/zookeeper/impl.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 5cc74e4616..937c56eef0 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -172,8 +172,8 @@ func (c *zookeeperDynamicConfiguration) GetConfigKeysByGroup(group string) (*gxs return nil, perrors.New("could not find keys with group: " + group) } set := gxset.NewSet() - for _, ele := range result { - set.Add(ele) + for _, e := range result { + set.Add(e) } return set, nil } From 04ee0b96053681ece25f48ab350cfdead81e583c Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Sat, 28 Mar 2020 12:32:05 +0800 Subject: [PATCH 019/167] Mod: fix comments --- common/rpc_service.go | 57 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/common/rpc_service.go b/common/rpc_service.go index d05f527a61..b138b4f300 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -153,6 +153,7 @@ type serviceMap struct { interfaceMap map[string][]*Service // interface -> service } +// GetService get a service defination by protocol and name func (sm *serviceMap) GetService(protocol, name string) *Service { sm.mutex.RLock() defer sm.mutex.RUnlock() @@ -175,6 +176,7 @@ func (sm *serviceMap) GetInterface(interfaceName string) []*Service { return nil } +// Register register a service by @interfaceName and @protocol func (sm *serviceMap) Register(interfaceName, protocol string, rcvr RPCService) (string, error) { if sm.serviceMap[protocol] == nil { sm.serviceMap[protocol] = make(map[string]*Service) @@ -222,33 +224,46 @@ func (sm *serviceMap) Register(interfaceName, protocol string, rcvr RPCService) return strings.TrimSuffix(methods, ","), nil } +// UnRegister cancel a service by @interfaceName, @protocol and @serviceId func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) error { if protocol == "" || serviceId == "" { return perrors.New("protocol or serviceName is nil") } - sm.mutex.RLock() - svcs, ok := sm.serviceMap[protocol] - if !ok { - sm.mutex.RUnlock() - return perrors.New("no services for " + protocol) - } - s, ok := svcs[serviceId] - if !ok { - sm.mutex.RUnlock() - return perrors.New("no service for " + serviceId) - } - svrs, ok := sm.interfaceMap[interfaceName] - if !ok { - sm.mutex.RUnlock() - return perrors.New("no service for " + interfaceName) - } - index := -1 - for i, svr := range svrs { - if svr == s { - index = i + + var ( + err error + index = -1 + svcs map[string]*Service + svrs []*Service + ok bool + ) + + f := func() error { + sm.mutex.RLock() + defer sm.mutex.RUnlock() + svcs, ok = sm.serviceMap[protocol] + if !ok { + return perrors.New("no services for " + protocol) } + s, ok := svcs[serviceId] + if !ok { + return perrors.New("no service for " + serviceId) + } + svrs, ok = sm.interfaceMap[interfaceName] + if !ok { + return perrors.New("no service for " + interfaceName) + } + for i, svr := range svrs { + if svr == s { + index = i + } + } + return nil + } + + if err = f(); err != nil { + return err } - sm.mutex.RUnlock() sm.mutex.Lock() defer sm.mutex.Unlock() From e3e0ba90b3015c13246cc3f85acb64ae56ddea92 Mon Sep 17 00:00:00 2001 From: flycash Date: Sun, 29 Mar 2020 23:16:43 +0800 Subject: [PATCH 020/167] implement the NacosServiceDiscovery --- common/constant/key.go | 6 + common/extension/service_discovery.go | 39 ++++ registry/event_listener.go | 2 + registry/nacos/base_registry.go | 96 ++++++++++ registry/nacos/registry.go | 65 +------ registry/nacos/service_discovery.go | 244 ++++++++++++++++++++++++++ registry/service_discovery.go | 12 +- registry/service_instance.go | 50 +++++- 8 files changed, 446 insertions(+), 68 deletions(-) create mode 100644 common/extension/service_discovery.go create mode 100644 registry/nacos/base_registry.go create mode 100644 registry/nacos/service_discovery.go diff --git a/common/constant/key.go b/common/constant/key.go index 5769ccfe6c..324c0259e8 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -238,3 +238,9 @@ const ( // The default time window of circuit-tripped in millisecond if not specfied MAX_CIRCUIT_TRIPPED_TIMEOUT_IN_MS = 30000 ) + +// service discovery + +const ( + NACOS_GROUP = "nacos.group" +) \ No newline at end of file diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go new file mode 100644 index 0000000000..355e922d6b --- /dev/null +++ b/common/extension/service_discovery.go @@ -0,0 +1,39 @@ +/* + * 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 ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/registry" +) + +var( + discoveryCreatorMap = make(map[string]func(url *common.URL)(registry.ServiceDiscovery, error), 4) +) + +func SetServiceDiscovery(name string, creator func(url *common.URL)(registry.ServiceDiscovery, error)) { + discoveryCreatorMap[name] = creator +} + +func GetServiceDiscovery(name string, url *common.URL) (registry.ServiceDiscovery, error) { + creator, ok := discoveryCreatorMap[name] + if !ok { + panic("Could not find the service discovery with name: " + name) + } + return creator(url) +} diff --git a/registry/event_listener.go b/registry/event_listener.go index 810420319b..cca3238215 100644 --- a/registry/event_listener.go +++ b/registry/event_listener.go @@ -38,4 +38,6 @@ type ConditionalEventListener interface { // TODO (implement ConditionalEventListener) type ServiceInstancesChangedListener struct { + ServiceName string } + diff --git a/registry/nacos/base_registry.go b/registry/nacos/base_registry.go new file mode 100644 index 0000000000..b6ce09bc71 --- /dev/null +++ b/registry/nacos/base_registry.go @@ -0,0 +1,96 @@ +/* + * 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 nacos + +import ( + "net" + "strconv" + "strings" + "time" + + "github.com/nacos-group/nacos-sdk-go/clients" + "github.com/nacos-group/nacos-sdk-go/clients/naming_client" + nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" + perrors "github.com/pkg/errors" + + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" +) + +// baseRegistry is the parent of both interface-level registry +// and service discovery(related to application-level registry) +type baseRegistry struct { + *common.URL + namingClient naming_client.INamingClient +} + +func newBaseRegistry(url *common.URL) (baseRegistry, error) { + nacosConfig, err := getNacosConfig(url) + if err != nil { + return baseRegistry{}, err + } + client, err := clients.CreateNamingClient(nacosConfig) + if err != nil { + return baseRegistry{}, err + } + registry := baseRegistry{ + URL: url, + namingClient: client, + } + return registry, nil +} + +func getNacosConfig(url *common.URL) (map[string]interface{}, error) { + if url == nil { + return nil, perrors.New("url is empty!") + } + if len(url.Location) == 0 { + return nil, perrors.New("url.location is empty!") + } + configMap := make(map[string]interface{}, 2) + + addresses := strings.Split(url.Location, ",") + serverConfigs := make([]nacosConstant.ServerConfig, 0, len(addresses)) + for _, addr := range addresses { + ip, portStr, err := net.SplitHostPort(addr) + if err != nil { + return nil, perrors.WithMessagef(err, "split [%s] ", addr) + } + port, _ := strconv.Atoi(portStr) + serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{ + IpAddr: ip, + Port: uint64(port), + }) + } + configMap["serverConfigs"] = serverConfigs + + var clientConfig nacosConstant.ClientConfig + timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + if err != nil { + return nil, err + } + clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000) + clientConfig.ListenInterval = 2 * clientConfig.TimeoutMs + clientConfig.CacheDir = url.GetParam(constant.NACOS_CACHE_DIR_KEY, "") + clientConfig.LogDir = url.GetParam(constant.NACOS_LOG_DIR_KEY, "") + clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "") + clientConfig.NotLoadCacheAtStart = true + configMap["clientConfig"] = clientConfig + + return configMap, nil +} diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 965e91e894..e7e6b39bd7 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -19,7 +19,6 @@ package nacos import ( "bytes" - "net" "strconv" "strings" "time" @@ -27,9 +26,6 @@ import ( import ( gxnet "github.com/dubbogo/gost/net" - "github.com/nacos-group/nacos-sdk-go/clients" - "github.com/nacos-group/nacos-sdk-go/clients/naming_client" - nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" "github.com/nacos-group/nacos-sdk-go/vo" perrors "github.com/pkg/errors" ) @@ -57,64 +53,17 @@ func init() { } type nacosRegistry struct { - *common.URL - namingClient naming_client.INamingClient -} - -func getNacosConfig(url *common.URL) (map[string]interface{}, error) { - if url == nil { - return nil, perrors.New("url is empty!") - } - if len(url.Location) == 0 { - return nil, perrors.New("url.location is empty!") - } - configMap := make(map[string]interface{}, 2) - - addresses := strings.Split(url.Location, ",") - serverConfigs := make([]nacosConstant.ServerConfig, 0, len(addresses)) - for _, addr := range addresses { - ip, portStr, err := net.SplitHostPort(addr) - if err != nil { - return nil, perrors.WithMessagef(err, "split [%s] ", addr) - } - port, _ := strconv.Atoi(portStr) - serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{ - IpAddr: ip, - Port: uint64(port), - }) - } - configMap["serverConfigs"] = serverConfigs - - var clientConfig nacosConstant.ClientConfig - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) - if err != nil { - return nil, err - } - clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000) - clientConfig.ListenInterval = 2 * clientConfig.TimeoutMs - clientConfig.CacheDir = url.GetParam(constant.NACOS_CACHE_DIR_KEY, "") - clientConfig.LogDir = url.GetParam(constant.NACOS_LOG_DIR_KEY, "") - clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "") - clientConfig.NotLoadCacheAtStart = true - configMap["clientConfig"] = clientConfig - - return configMap, nil + baseRegistry } func newNacosRegistry(url *common.URL) (registry.Registry, error) { - nacosConfig, err := getNacosConfig(url) + base, err := newBaseRegistry(url) if err != nil { - return nil, err + return nil, perrors.WithStack(err) } - client, err := clients.CreateNamingClient(nacosConfig) - if err != nil { - return nil, err - } - registry := nacosRegistry{ - URL: url, - namingClient: client, - } - return ®istry, nil + return &nacosRegistry{ + base, + }, nil } func getCategory(url common.URL) string { @@ -234,4 +183,4 @@ func (nr *nacosRegistry) IsAvailable() bool { func (nr *nacosRegistry) Destroy() { return -} +} \ No newline at end of file diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go new file mode 100644 index 0000000000..9f22b8fab8 --- /dev/null +++ b/registry/nacos/service_discovery.go @@ -0,0 +1,244 @@ +/* + * 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 nacos + +import ( + "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/page" + "github.com/nacos-group/nacos-sdk-go/model" + "github.com/nacos-group/nacos-sdk-go/vo" + perrors "github.com/pkg/errors" + + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" +) + +const ( + defaultGroup = "DEFAULT_GROUP" + idKey = "id" +) + +func init() { + extension.SetServiceDiscovery(constant.NACOS_KEY, newNacosServiceDiscovery) +} + +// nacosServiceDiscovery is the implementation of service discovery based on nacos. +// There is a problem, the go client for nacos does not support the id field. +// we will use the metadata to store the id of ServiceInstance +type nacosServiceDiscovery struct { + baseRegistry + group string +} + +// Destroy will close the service discovery. +// Actually, it only marks the naming client as null and then return +func (n *nacosServiceDiscovery) Destroy() error { + n.namingClient = nil + return nil +} + +// Register will register the service to nacos +func (n *nacosServiceDiscovery) Register(instance registry.ServiceInstance) error { + ins := n.toRegisterInstance(instance) + ok, err := n.namingClient.RegisterInstance(ins) + if err != nil || !ok { + return perrors.WithMessage(err, "Could not register the instance. "+instance.GetServiceName()) + } + return nil +} + +// Update will update the information +// However, because nacos client doesn't support the update API, +// so we should unregister the instance and then register it again. +// the error handling is hard to implement +func (n *nacosServiceDiscovery) Update(instance registry.ServiceInstance) error { + // The + err := n.Unregister(instance) + if err != nil { + return perrors.WithStack(err) + } + return n.Register(instance) +} + +// Unregister will unregister the instance +func (n *nacosServiceDiscovery) Unregister(instance registry.ServiceInstance) error { + ok, err := n.namingClient.DeregisterInstance(n.toDeregisterInstance(instance)) + if err != nil || !ok { + return perrors.WithMessage(err, "Could not unregister the instance. "+instance.GetServiceName()) + } + return nil +} + +// GetDefaultPageSize will return the constant registry.DefaultPageSize +func (n *nacosServiceDiscovery) GetDefaultPageSize() int { + return registry.DefaultPageSize +} + +// GetServices will return the all services +func (n *nacosServiceDiscovery) GetServices() *gxset.HashSet { + services, err := n.namingClient.GetAllServicesInfo(vo.GetAllServiceInfoParam{ + GroupName: n.group, + }) + + res := gxset.NewSet() + if err != nil { + logger.Errorf("Could not query the services: %v", err) + return res + } + + for _, e := range services { + res.Add(e) + } + return res +} + +// GetInstances will return the instances of serviceName and the group +func (n *nacosServiceDiscovery) GetInstances(serviceName string) []registry.ServiceInstance { + instances, err := n.namingClient.SelectAllInstances(vo.SelectAllInstancesParam{ + ServiceName: serviceName, + GroupName: n.group, + }) + if err != nil { + logger.Errorf("Could not query the instances for service: " + serviceName + ", group: " + n.group) + return make([]registry.ServiceInstance, 0, 0) + } + res := make([]registry.ServiceInstance, 0, len(instances)) + for _, ins := range instances { + metadata := ins.Metadata + id := metadata[idKey] + + delete(metadata, idKey) + + res = append(res, ®istry.DefaultServiceInstance{ + Id: id, + ServiceName: ins.ServiceName, + Host: ins.Ip, + Port: int(ins.Port), + Enable: ins.Enable, + Healthy: ins.Healthy, + Metadata: metadata, + }) + } + + return res +} + +// GetInstancesByPage will return the instances +// Due to nacos client does not support pagination, so we have to query all instances and then return part of them +func (n *nacosServiceDiscovery) GetInstancesByPage(serviceName string, offset int, pageSize int) gxpage.Pager { + all := n.GetInstances(serviceName) + res := make([]interface{}, 0, pageSize) + // could not use res = all[a:b] here because the res should be []interface{}, not []ServiceInstance + for i := offset; i < len(all) && i < offset+pageSize; i++ { + res = append(res, all[i]) + } + return gxpage.New(offset, pageSize, res, len(all)) +} + +// GetHealthyInstancesByPage will return the instance +// The nacos client has an API SelectInstances, which has a parameter call HealthyOnly. +// However, the healthy parameter in this method maybe false. So we can not use that API. +// Thus, we must query all instances and then do filter +func (n *nacosServiceDiscovery) GetHealthyInstancesByPage(serviceName string, offset int, pageSize int, healthy bool) gxpage.Pager { + all := n.GetInstances(serviceName) + res := make([]interface{}, 0, pageSize) + // could not use res = all[a:b] here because the res should be []interface{}, not []ServiceInstance + var ( + i = offset + count = 0 + ) + for ; i < len(all) && count < pageSize; { + ins := all[i] + if ins.IsHealthy() == healthy { + res = append(res, all[i]) + count++ + } + i++ + } + return gxpage.New(offset, pageSize, res, len(all)) +} + +// GetRequestInstances will return the instances +// The nacos client doesn't have batch API, so we should query those serviceNames one by one. +func (n *nacosServiceDiscovery) GetRequestInstances(serviceNames []string, offset int, requestedSize int) map[string]gxpage.Pager { + res := make(map[string]gxpage.Pager, len(serviceNames)) + for _, name := range serviceNames { + res[name] = n.GetInstancesByPage(name, offset, requestedSize) + } + return res +} + +// AddListener will add a listener +func (n *nacosServiceDiscovery) AddListener(listener *registry.ServiceInstancesChangedListener) error { + // return n.namingClient.Subscribe(&vo.SubscribeParam{ + // ServiceName:listener.ServiceName, + // SubscribeCallback: func(services []model.SubscribeService, err error) { + // services[0].InstanceId + // n.DispatchEventForInstances() + // }, + // }) +} + +func (n *nacosServiceDiscovery) DispatchEventByServiceName(serviceName string) error { + panic("implement me") +} + +func (n *nacosServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { + panic("implement me") +} + +func (n *nacosServiceDiscovery) DispatchEvent(event registry.ServiceInstancesChangedEvent) error { + panic("implement me") +} + +func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInstance) vo.RegisterInstanceParam { + metadata := instance.GetMetadata() + metadata[idKey] = instance.GetId() + return vo.RegisterInstanceParam{ + ServiceName: instance.GetServiceName(), + Ip: instance.GetHost(), + Port: uint64(instance.GetPort()), + Metadata: metadata, + Enable: instance.IsEnable(), + Healthy: instance.IsHealthy(), + GroupName: n.group, + } +} + +func (n *nacosServiceDiscovery) toDeregisterInstance(instance registry.ServiceInstance) vo.DeregisterInstanceParam { + return vo.DeregisterInstanceParam{ + ServiceName: instance.GetServiceName(), + Ip: instance.GetHost(), + Port: uint64(instance.GetPort()), + GroupName: n.group, + } +} + +func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { + base, err := newBaseRegistry(url) + if err != nil { + return nil, perrors.WithStack(err) + } + return &nacosServiceDiscovery{ + baseRegistry: base, + group: url.GetParam(constant.NACOS_GROUP, defaultGroup), + }, nil +} diff --git a/registry/service_discovery.go b/registry/service_discovery.go index 5577f52930..c38d48d44e 100644 --- a/registry/service_discovery.go +++ b/registry/service_discovery.go @@ -26,19 +26,13 @@ import ( gxpage "github.com/dubbogo/gost/page" ) -import ( - "github.com/apache/dubbo-go/common" -) +const DefaultPageSize = 100 type ServiceDiscovery interface { fmt.Stringer // ----------------- lifecycle ------------------- - // Initialize will initialize the service discovery instance - // if initialize failed, it will return the error - Initialize(url common.URL) error - // Destroy will destroy the service discovery. // If the discovery cannot be destroy, it will return an error. Destroy() error @@ -59,7 +53,7 @@ type ServiceDiscovery interface { GetDefaultPageSize() int // GetServices will return the all service names. - GetServices() gxset.HashSet + GetServices() *gxset.HashSet // GetInstances will return all service instances with serviceName GetInstances(serviceName string) []ServiceInstance @@ -89,3 +83,5 @@ type ServiceDiscovery interface { // DispatchEvent dispatches the event DispatchEvent(event ServiceInstancesChangedEvent) error } + + diff --git a/registry/service_instance.go b/registry/service_instance.go index d27ed8accf..2cc229ee3b 100644 --- a/registry/service_instance.go +++ b/registry/service_instance.go @@ -29,8 +29,7 @@ type ServiceInstance interface { GetHost() string // GetPort will return the port. - // if the port is not present, return error - GetPort() (int, error) + GetPort() int // IsEnable will return the enable status of this instance IsEnable() bool @@ -41,3 +40,50 @@ type ServiceInstance interface { // GetMetadata will return the metadata GetMetadata() map[string]string } + +// DefaultServiceInstance the default implementation of ServiceInstance +// or change the ServiceInstance to be struct??? +type DefaultServiceInstance struct { + Id string + ServiceName string + Host string + Port int + Enable bool + Healthy bool + Metadata map[string]string +} + +// GetId will return this instance's id. It should be unique. +func (d *DefaultServiceInstance) GetId() string { + return d.Id +} + +// GetServiceName will return the serviceName +func (d *DefaultServiceInstance) GetServiceName() string { + return d.ServiceName +} + +// GetHost will return the hostname +func (d *DefaultServiceInstance) GetHost() string { + return d.Host +} + +// GetPort will return the port. +func (d *DefaultServiceInstance) GetPort() int { + return d.Port +} + +// IsEnable will return the enable status of this instance +func (d *DefaultServiceInstance) IsEnable() bool { + return d.Enable +} + +// IsHealthy will return the value represent the instance whether healthy or not +func (d *DefaultServiceInstance) IsHealthy() bool { + return d.Healthy +} + +// GetMetadata will return the metadata +func (d *DefaultServiceInstance) GetMetadata() map[string]string { + return d.Metadata +} From c25cfeea85b287461b1294f3cc49d83802a5fbea Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 31 Mar 2020 19:58:13 +0800 Subject: [PATCH 021/167] optimized code --- .../rest/server/server_impl/go_restful_server.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 69f36a5c80..812699b3b6 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -81,29 +81,28 @@ func (grs *GoRestfulServer) Start(url common.URL) { } func (grs *GoRestfulServer) Deploy(invoker protocol.Invoker, restMethodConfig map[string]*config.RestMethodConfig) { - svc := common.ServiceMap.GetService(invoker.GetUrl().Protocol, strings.TrimPrefix(invoker.GetUrl().Path, "/")) for methodName, config := range restMethodConfig { - // get method - method := svc.Method()[methodName] - argsTypes := method.ArgsType() - replyType := method.ReplyType() ws := new(restful.WebService) ws.Path(config.Path). Produces(strings.Split(config.Produces, ",")...). Consumes(strings.Split(config.Consumes, ",")...). - Route(ws.Method(config.MethodType).To(getFunc(methodName, invoker, argsTypes, replyType, config))) + Route(ws.Method(config.MethodType).To(getFunc(methodName, invoker, config))) grs.container.Add(ws) } } -func getFunc(methodName string, invoker protocol.Invoker, argsTypes []reflect.Type, - replyType reflect.Type, config *config.RestMethodConfig) func(req *restful.Request, resp *restful.Response) { +func getFunc(methodName string, invoker protocol.Invoker, config *config.RestMethodConfig) func(req *restful.Request, resp *restful.Response) { return func(req *restful.Request, resp *restful.Response) { var ( err error args []interface{} ) + svc := common.ServiceMap.GetService(invoker.GetUrl().Protocol, strings.TrimPrefix(invoker.GetUrl().Path, "/")) + // get method + method := svc.Method()[methodName] + argsTypes := method.ArgsType() + replyType := method.ReplyType() if (len(argsTypes) == 1 || len(argsTypes) == 2 && replyType == nil) && argsTypes[0].String() == "[]interface {}" { args = getArgsInterfaceFromRequest(req, config) From 1aaeb4c24d767296a4ae1535ef425fc61955e79f Mon Sep 17 00:00:00 2001 From: flycash Date: Tue, 31 Mar 2020 20:29:09 +0800 Subject: [PATCH 022/167] Fix Review --- .../dynamic}/service_name_mapping.go | 2 +- .../dynamic}/service_name_mapping_test.go | 2 +- .../{in_memory => namemapping/memory}/service_name_mapping.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename metadata/{dynamic_mapping => namemapping/dynamic}/service_name_mapping.go (99%) rename metadata/{dynamic_mapping => namemapping/dynamic}/service_name_mapping_test.go (98%) rename metadata/{in_memory => namemapping/memory}/service_name_mapping.go (98%) diff --git a/metadata/dynamic_mapping/service_name_mapping.go b/metadata/namemapping/dynamic/service_name_mapping.go similarity index 99% rename from metadata/dynamic_mapping/service_name_mapping.go rename to metadata/namemapping/dynamic/service_name_mapping.go index 32d5c2f211..dfa672e95b 100644 --- a/metadata/dynamic_mapping/service_name_mapping.go +++ b/metadata/namemapping/dynamic/service_name_mapping.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package dynamic_mapping +package dynamic import ( "strconv" diff --git a/metadata/dynamic_mapping/service_name_mapping_test.go b/metadata/namemapping/dynamic/service_name_mapping_test.go similarity index 98% rename from metadata/dynamic_mapping/service_name_mapping_test.go rename to metadata/namemapping/dynamic/service_name_mapping_test.go index d1d637a3b1..81fe350bcf 100644 --- a/metadata/dynamic_mapping/service_name_mapping_test.go +++ b/metadata/namemapping/dynamic/service_name_mapping_test.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package dynamic_mapping +package dynamic import ( "testing" diff --git a/metadata/in_memory/service_name_mapping.go b/metadata/namemapping/memory/service_name_mapping.go similarity index 98% rename from metadata/in_memory/service_name_mapping.go rename to metadata/namemapping/memory/service_name_mapping.go index ecb360dbe0..8a891491bd 100644 --- a/metadata/in_memory/service_name_mapping.go +++ b/metadata/namemapping/memory/service_name_mapping.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package in_memory +package memory import ( gxset "github.com/dubbogo/gost/container/set" From fce412decafdb7537aecd9c736b56ad9f3bfbd15 Mon Sep 17 00:00:00 2001 From: flycash Date: Tue, 31 Mar 2020 21:13:46 +0800 Subject: [PATCH 023/167] test nacos service discovery --- common/constant/key.go | 2 +- common/extension/service_discovery.go | 6 +-- registry/event.go | 18 ++++++++- registry/event_listener.go | 1 - registry/nacos/registry.go | 2 +- registry/nacos/service_discovery.go | 50 ++++++++++++++++++------ registry/nacos/service_discovery_test.go | 47 ++++++++++++++++++++++ registry/service_discovery.go | 5 +-- 8 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 registry/nacos/service_discovery_test.go diff --git a/common/constant/key.go b/common/constant/key.go index 324c0259e8..9f2fe14786 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -243,4 +243,4 @@ const ( const ( NACOS_GROUP = "nacos.group" -) \ No newline at end of file +) diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go index 355e922d6b..4398dec39a 100644 --- a/common/extension/service_discovery.go +++ b/common/extension/service_discovery.go @@ -22,11 +22,11 @@ import ( "github.com/apache/dubbo-go/registry" ) -var( - discoveryCreatorMap = make(map[string]func(url *common.URL)(registry.ServiceDiscovery, error), 4) +var ( + discoveryCreatorMap = make(map[string]func(url *common.URL) (registry.ServiceDiscovery, error), 4) ) -func SetServiceDiscovery(name string, creator func(url *common.URL)(registry.ServiceDiscovery, error)) { +func SetServiceDiscovery(name string, creator func(url *common.URL) (registry.ServiceDiscovery, error)) { discoveryCreatorMap[name] = creator } diff --git a/registry/event.go b/registry/event.go index 0500cc7018..da66ccb33d 100644 --- a/registry/event.go +++ b/registry/event.go @@ -86,6 +86,22 @@ func newBaseEvent(source interface{}) *baseEvent { // ServiceInstancesChangedEvent represents service instances make some changing type ServiceInstancesChangedEvent struct { - fmt.Stringer baseEvent + ServiceName string + Instances []ServiceInstance +} + +func (s *ServiceInstancesChangedEvent) String() string { + return fmt.Sprintf("ServiceInstancesChangedEvent[source=%s]", s.ServiceName) +} + +func NewServiceInstancesChangedEvent(serviceName string, instances []ServiceInstance) *ServiceInstancesChangedEvent { + return &ServiceInstancesChangedEvent{ + baseEvent: baseEvent{ + source: serviceName, + timestamp: time.Now(), + }, + ServiceName: serviceName, + Instances: instances, + } } diff --git a/registry/event_listener.go b/registry/event_listener.go index cca3238215..b8d6148442 100644 --- a/registry/event_listener.go +++ b/registry/event_listener.go @@ -40,4 +40,3 @@ type ConditionalEventListener interface { type ServiceInstancesChangedListener struct { ServiceName string } - diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index e7e6b39bd7..697cbbeb83 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -183,4 +183,4 @@ func (nr *nacosRegistry) IsAvailable() bool { func (nr *nacosRegistry) Destroy() { return -} \ No newline at end of file +} diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 9f22b8fab8..2f8eb7706f 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -165,7 +165,7 @@ func (n *nacosServiceDiscovery) GetHealthyInstancesByPage(serviceName string, of i = offset count = 0 ) - for ; i < len(all) && count < pageSize; { + for i < len(all) && count < pageSize { ins := all[i] if ins.IsHealthy() == healthy { res = append(res, all[i]) @@ -188,25 +188,51 @@ func (n *nacosServiceDiscovery) GetRequestInstances(serviceNames []string, offse // AddListener will add a listener func (n *nacosServiceDiscovery) AddListener(listener *registry.ServiceInstancesChangedListener) error { - // return n.namingClient.Subscribe(&vo.SubscribeParam{ - // ServiceName:listener.ServiceName, - // SubscribeCallback: func(services []model.SubscribeService, err error) { - // services[0].InstanceId - // n.DispatchEventForInstances() - // }, - // }) + return n.namingClient.Subscribe(&vo.SubscribeParam{ + ServiceName: listener.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."+ + " service name: %s, err: %v", listener.ServiceName, err) + } + instances := make([]registry.ServiceInstance, 0, len(services)) + for _, service := range services { + // we won't use the nacos instance id here but use our instance id + metadata := service.Metadata + id := metadata[idKey] + + delete(metadata, idKey) + + instances = append(instances, ®istry.DefaultServiceInstance{ + Id: id, + ServiceName: service.ServiceName, + Host: service.Ip, + Port: int(service.Port), + Enable: service.Enable, + Healthy: true, + Metadata: metadata, + }) + } + + e := n.DispatchEventForInstances(listener.ServiceName, instances) + if e != nil { + logger.Errorf("Dispatching event got exception, service name: %s, err: %v", listener.ServiceName, err) + } + }, + }) } func (n *nacosServiceDiscovery) DispatchEventByServiceName(serviceName string) error { - panic("implement me") + return n.DispatchEventForInstances(serviceName, n.GetInstances(serviceName)) } func (n *nacosServiceDiscovery) DispatchEventForInstances(serviceName string, instances []registry.ServiceInstance) error { - panic("implement me") + return n.DispatchEvent(registry.NewServiceInstancesChangedEvent(serviceName, instances)) } -func (n *nacosServiceDiscovery) DispatchEvent(event registry.ServiceInstancesChangedEvent) error { - panic("implement me") +func (n *nacosServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesChangedEvent) error { + // TODO(waiting for event dispatcher, another task) + return nil } func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInstance) vo.RegisterInstanceParam { diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go new file mode 100644 index 0000000000..dbe9b88fe0 --- /dev/null +++ b/registry/nacos/service_discovery_test.go @@ -0,0 +1,47 @@ +/* + * 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 nacos + +import ( + "net/url" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" +) + +func TestNacosServiceDiscovery_Destroy(t *testing.T) { + serviceDiscovry, err := extension.GetServiceDiscovery(constant.NACOS_KEY, mockUrl()) + assert.Nil(t, err) + assert.NotNil(t, serviceDiscovry) +} + +func mockUrl() *common.URL { + urlMap := url.Values{} + urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") + urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) + urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") + urlMap.Set(constant.VERSION_KEY, "1.0.0") + urlMap.Set(constant.CLUSTER_KEY, "mock") + url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + return &url +} diff --git a/registry/service_discovery.go b/registry/service_discovery.go index c38d48d44e..a8228a4abe 100644 --- a/registry/service_discovery.go +++ b/registry/service_discovery.go @@ -72,6 +72,7 @@ type ServiceDiscovery interface { // ----------------- event ---------------------- // AddListener adds a new ServiceInstancesChangedListener + // see addServiceInstancesChangedListener in Java AddListener(listener *ServiceInstancesChangedListener) error // DispatchEventByServiceName dispatches the ServiceInstancesChangedEvent to service instance whose name is serviceName @@ -81,7 +82,5 @@ type ServiceDiscovery interface { DispatchEventForInstances(serviceName string, instances []ServiceInstance) error // DispatchEvent dispatches the event - DispatchEvent(event ServiceInstancesChangedEvent) error + DispatchEvent(event *ServiceInstancesChangedEvent) error } - - From cf0961c3d77aab051c3c4f8201fe813ddfd476e8 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 31 Mar 2020 23:10:40 +0800 Subject: [PATCH 024/167] use adapter model to modify restServer --- .../rest/client/client_impl/resty_client.go | 2 +- protocol/rest/client/rest_client.go | 4 +- protocol/rest/rest_invoker.go | 3 +- protocol/rest/rest_protocol.go | 4 +- protocol/rest/server/rest_server.go | 261 +++++++++++++++- .../server/server_impl/go_restful_server.go | 287 +++++------------- 6 files changed, 335 insertions(+), 226 deletions(-) diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index aa6c23137d..af9637ea91 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -65,7 +65,7 @@ func NewRestyClient(restOption *client.RestOptions) client.RestClient { } } -func (rc *RestyClient) Do(restRequest *client.RestRequest, res interface{}) error { +func (rc *RestyClient) Do(restRequest *client.RestClientRequest, res interface{}) error { r, err := rc.client.R(). SetHeader("Content-Type", restRequest.Consumes). SetHeader("Accept", restRequest.Produces). diff --git a/protocol/rest/client/rest_client.go b/protocol/rest/client/rest_client.go index 7d020abc81..3acccb53ae 100644 --- a/protocol/rest/client/rest_client.go +++ b/protocol/rest/client/rest_client.go @@ -26,7 +26,7 @@ type RestOptions struct { ConnectTimeout time.Duration } -type RestRequest struct { +type RestClientRequest struct { Location string Path string Produces string @@ -39,5 +39,5 @@ type RestRequest struct { } type RestClient interface { - Do(request *RestRequest, res interface{}) error + Do(request *RestClientRequest, res interface{}) error } diff --git a/protocol/rest/rest_invoker.go b/protocol/rest/rest_invoker.go index 0c82035ac5..c8e3feaff6 100644 --- a/protocol/rest/rest_invoker.go +++ b/protocol/rest/rest_invoker.go @@ -78,8 +78,7 @@ func (ri *RestInvoker) Invoke(ctx context.Context, invocation protocol.Invocatio if len(inv.Arguments()) > methodConfig.Body && methodConfig.Body >= 0 { body = inv.Arguments()[methodConfig.Body] } - - req := &client.RestRequest{ + req := &client.RestClientRequest{ Location: ri.GetUrl().Location, Produces: methodConfig.Produces, Consumes: methodConfig.Consumes, diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index 47ecb6093b..e15eeb39d7 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -75,7 +75,9 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter { } rp.SetExporterMap(serviceKey, exporter) restServer := rp.getServer(url, restServiceConfig.Server) - restServer.Deploy(invoker, restServiceConfig.RestMethodConfigsMap) + for _, methodConfig := range restServiceConfig.RestMethodConfigsMap { + restServer.Deploy(methodConfig, server.GetRouteFunc(invoker, methodConfig)) + } return exporter } diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index c10c98a7b6..b7eb555625 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -17,15 +17,270 @@ package server +import ( + "context" + "net/http" + "reflect" + "strconv" + "strings" +) + +import ( + perrors "github.com/pkg/errors" +) + import ( "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/protocol" - "github.com/apache/dubbo-go/protocol/rest/config" + "github.com/apache/dubbo-go/protocol/invocation" + rest_config "github.com/apache/dubbo-go/protocol/rest/config" ) type RestServer interface { Start(url common.URL) - Deploy(invoker protocol.Invoker, restMethodConfig map[string]*config.RestMethodConfig) - UnDeploy(restMethodConfig map[string]*config.RestMethodConfig) + Deploy(restMethodConfig *rest_config.RestMethodConfig, routeFunc func(request RestServerRequest, response RestServerResponse)) + UnDeploy(restMethodConfig *rest_config.RestMethodConfig) Destroy() } + +// RestServerRequest interface +type RestServerRequest interface { + PathParameter(name string) string + PathParameters() map[string]string + QueryParameter(name string) string + QueryParameters(name string) []string + BodyParameter(name string) (string, error) + HeaderParameter(name string) string + ReadEntity(entityPointer interface{}) error +} + +// RestServerResponse interface +type RestServerResponse interface { + WriteError(httpStatus int, err error) (writeErr error) + WriteEntity(value interface{}) error +} + +func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethodConfig) func(req RestServerRequest, resp RestServerResponse) { + return func(req RestServerRequest, resp RestServerResponse) { + var ( + err error + args []interface{} + ) + svc := common.ServiceMap.GetService(invoker.GetUrl().Protocol, strings.TrimPrefix(invoker.GetUrl().Path, "/")) + // get method + method := svc.Method()[methodConfig.MethodName] + argsTypes := method.ArgsType() + replyType := method.ReplyType() + if (len(argsTypes) == 1 || len(argsTypes) == 2 && replyType == nil) && + argsTypes[0].String() == "[]interface {}" { + args = getArgsInterfaceFromRequest(req, methodConfig) + } else { + args = getArgsFromRequest(req, argsTypes, methodConfig) + } + result := invoker.Invoke(context.Background(), invocation.NewRPCInvocation(methodConfig.MethodName, args, make(map[string]string))) + if result.Error() != nil { + err = resp.WriteError(http.StatusInternalServerError, result.Error()) + if err != nil { + logger.Errorf("[Go Restful] WriteError error:%v", err) + } + return + } + err = resp.WriteEntity(result.Result()) + if err != nil { + logger.Errorf("[Go Restful] WriteEntity error:%v", err) + } + } +} + +// when service function like GetUser(req []interface{}, rsp *User) error +// use this method to get arguments +func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_config.RestMethodConfig) []interface{} { + argsMap := make(map[int]interface{}, 8) + maxKey := 0 + for k, v := range methodConfig.PathParamsMap { + if maxKey < k { + maxKey = k + } + argsMap[k] = req.PathParameter(v) + } + for k, v := range methodConfig.QueryParamsMap { + if maxKey < k { + maxKey = k + } + params := req.QueryParameters(v) + if len(params) == 1 { + argsMap[k] = params[0] + } else { + argsMap[k] = params + } + } + for k, v := range methodConfig.HeadersMap { + if maxKey < k { + maxKey = k + } + argsMap[k] = req.HeaderParameter(v) + } + if methodConfig.Body >= 0 { + if maxKey < methodConfig.Body { + maxKey = methodConfig.Body + } + m := make(map[string]interface{}) + // TODO read as a slice + if err := req.ReadEntity(&m); err != nil { + logger.Warnf("[Go restful] Read body entity as map[string]interface{} error:%v", perrors.WithStack(err)) + } else { + argsMap[methodConfig.Body] = m + } + } + args := make([]interface{}, maxKey+1) + for k, v := range argsMap { + if k >= 0 { + args[k] = v + } + } + return args +} + +// get arguments from server.RestServerRequest +func getArgsFromRequest(req RestServerRequest, argsTypes []reflect.Type, methodConfig *rest_config.RestMethodConfig) []interface{} { + argsLength := len(argsTypes) + args := make([]interface{}, argsLength) + for i, t := range argsTypes { + args[i] = reflect.Zero(t).Interface() + } + assembleArgsFromPathParams(methodConfig, argsLength, argsTypes, req, args) + assembleArgsFromQueryParams(methodConfig, argsLength, argsTypes, req, args) + assembleArgsFromBody(methodConfig, argsTypes, req, args) + assembleArgsFromHeaders(methodConfig, req, argsLength, argsTypes, args) + return args +} + +// assemble arguments from headers +func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req RestServerRequest, argsLength int, argsTypes []reflect.Type, args []interface{}) { + for k, v := range methodConfig.HeadersMap { + param := req.HeaderParameter(v) + if k < 0 || k >= argsLength { + logger.Errorf("[Go restful] Header param parse error, the args:%v doesn't exist", k) + continue + } + t := argsTypes[k] + if t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() == reflect.String { + args[k] = param + } else { + logger.Errorf("[Go restful] Header param parse error, the args:%v of type isn't string", k) + } + } +} + +// assemble arguments from body +func assembleArgsFromBody(methodConfig *rest_config.RestMethodConfig, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { + if methodConfig.Body >= 0 && methodConfig.Body < len(argsTypes) { + t := argsTypes[methodConfig.Body] + kind := t.Kind() + if kind == reflect.Ptr { + t = t.Elem() + } + var ni interface{} + if t.String() == "[]interface {}" { + ni = make([]map[string]interface{}, 0) + } else if t.String() == "interface {}" { + ni = make(map[string]interface{}) + } else { + n := reflect.New(t) + if n.CanInterface() { + ni = n.Interface() + } + } + if err := req.ReadEntity(&ni); err != nil { + logger.Errorf("[Go restful] Read body entity error:%v", err) + } else { + args[methodConfig.Body] = ni + } + } +} + +// assemble arguments from query params +func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { + var ( + err error + param interface{} + i64 int64 + ) + for k, v := range methodConfig.QueryParamsMap { + if k < 0 || k >= argsLength { + logger.Errorf("[Go restful] Query param parse error, the args:%v doesn't exist", k) + continue + } + t := argsTypes[k] + kind := t.Kind() + if kind == reflect.Ptr { + t = t.Elem() + } + if kind == reflect.Slice { + param = req.QueryParameters(v) + } else if kind == reflect.String { + param = req.QueryParameter(v) + } else if kind == reflect.Int { + param, err = strconv.Atoi(req.QueryParameter(v)) + } else if kind == reflect.Int32 { + i64, err = strconv.ParseInt(req.QueryParameter(v), 10, 32) + if err == nil { + param = int32(i64) + } + } else if kind == reflect.Int64 { + param, err = strconv.ParseInt(req.QueryParameter(v), 10, 64) + } else { + logger.Errorf("[Go restful] Query param parse error, the args:%v of type isn't int or string or slice", k) + continue + } + if err != nil { + logger.Errorf("[Go restful] Query param parse error, error is %v", err) + continue + } + args[k] = param + } +} + +// assemble arguments from path params +func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { + var ( + err error + param interface{} + i64 int64 + ) + for k, v := range methodConfig.PathParamsMap { + if k < 0 || k >= argsLength { + logger.Errorf("[Go restful] Path param parse error, the args:%v doesn't exist", k) + continue + } + t := argsTypes[k] + kind := t.Kind() + if kind == reflect.Ptr { + t = t.Elem() + } + if kind == reflect.Int { + param, err = strconv.Atoi(req.PathParameter(v)) + } else if kind == reflect.Int32 { + i64, err = strconv.ParseInt(req.PathParameter(v), 10, 32) + if err == nil { + param = int32(i64) + } + } else if kind == reflect.Int64 { + param, err = strconv.ParseInt(req.PathParameter(v), 10, 64) + } else if kind == reflect.String { + param = req.PathParameter(v) + } else { + logger.Warnf("[Go restful] Path param parse error, the args:%v of type isn't int or string", k) + continue + } + if err != nil { + logger.Errorf("[Go restful] Path param parse error, error is %v", err) + continue + } + args[k] = param + } +} diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 812699b3b6..3c81fe0bfd 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -22,8 +22,6 @@ import ( "fmt" "net" "net/http" - "reflect" - "strconv" "strings" "time" ) @@ -38,8 +36,6 @@ import ( "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/common/logger" - "github.com/apache/dubbo-go/protocol" - "github.com/apache/dubbo-go/protocol/invocation" "github.com/apache/dubbo-go/protocol/rest/config" "github.com/apache/dubbo-go/protocol/rest/server" ) @@ -80,57 +76,27 @@ func (grs *GoRestfulServer) Start(url common.URL) { }() } -func (grs *GoRestfulServer) Deploy(invoker protocol.Invoker, restMethodConfig map[string]*config.RestMethodConfig) { - for methodName, config := range restMethodConfig { - ws := new(restful.WebService) - ws.Path(config.Path). - Produces(strings.Split(config.Produces, ",")...). - Consumes(strings.Split(config.Consumes, ",")...). - Route(ws.Method(config.MethodType).To(getFunc(methodName, invoker, config))) - grs.container.Add(ws) +func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) { + ws := new(restful.WebService) + rf := func(req *restful.Request, resp *restful.Response) { + respAdapter := NewGoRestfulResponseAdapter(resp) + reqAdapter := NewGoRestfulRequestAdapter(req) + routeFunc(reqAdapter, respAdapter) } + ws.Path(restMethodConfig.Path). + Produces(strings.Split(restMethodConfig.Produces, ",")...). + Consumes(strings.Split(restMethodConfig.Consumes, ",")...). + Route(ws.Method(restMethodConfig.MethodType).To(rf)) + grs.container.Add(ws) } -func getFunc(methodName string, invoker protocol.Invoker, config *config.RestMethodConfig) func(req *restful.Request, resp *restful.Response) { - return func(req *restful.Request, resp *restful.Response) { - var ( - err error - args []interface{} - ) - svc := common.ServiceMap.GetService(invoker.GetUrl().Protocol, strings.TrimPrefix(invoker.GetUrl().Path, "/")) - // get method - method := svc.Method()[methodName] - argsTypes := method.ArgsType() - replyType := method.ReplyType() - if (len(argsTypes) == 1 || len(argsTypes) == 2 && replyType == nil) && - argsTypes[0].String() == "[]interface {}" { - args = getArgsInterfaceFromRequest(req, config) - } else { - args = getArgsFromRequest(req, argsTypes, config) - } - result := invoker.Invoke(context.Background(), invocation.NewRPCInvocation(methodName, args, make(map[string]string))) - if result.Error() != nil { - err = resp.WriteError(http.StatusInternalServerError, result.Error()) - if err != nil { - logger.Errorf("[Go Restful] WriteError error:%v", err) - } - return - } - err = resp.WriteEntity(result.Result()) - if err != nil { - logger.Error("[Go Restful] WriteEntity error:%v", err) - } - } -} -func (grs *GoRestfulServer) UnDeploy(restMethodConfig map[string]*config.RestMethodConfig) { - for _, config := range restMethodConfig { - ws := new(restful.WebService) - ws.Path(config.Path) - err := grs.container.Remove(ws) - if err != nil { - logger.Warnf("[Go restful] Remove web service error:%v", err) - } +func (grs *GoRestfulServer) UnDeploy(restMethodConfig *config.RestMethodConfig) { + ws := new(restful.WebService) + ws.Path(restMethodConfig.Path) + err := grs.container.Remove(ws) + if err != nil { + logger.Warnf("[Go restful] Remove web service error:%v", err) } } @@ -143,179 +109,66 @@ func (grs *GoRestfulServer) Destroy() { logger.Infof("[Go Restful] Server exiting") } -func getArgsInterfaceFromRequest(req *restful.Request, config *config.RestMethodConfig) []interface{} { - argsMap := make(map[int]interface{}, 8) - maxKey := 0 - for k, v := range config.PathParamsMap { - if maxKey < k { - maxKey = k - } - argsMap[k] = req.PathParameter(v) - } - for k, v := range config.QueryParamsMap { - if maxKey < k { - maxKey = k - } - params := req.QueryParameters(v) - if len(params) == 1 { - argsMap[k] = params[0] - } else { - argsMap[k] = params - } - } - for k, v := range config.HeadersMap { - if maxKey < k { - maxKey = k - } - argsMap[k] = req.HeaderParameter(v) - } - if config.Body >= 0 { - if maxKey < config.Body { - maxKey = config.Body - } - m := make(map[string]interface{}) - // TODO read as a slice - if err := req.ReadEntity(&m); err != nil { - logger.Warnf("[Go restful] Read body entity as map[string]interface{} error:%v", perrors.WithStack(err)) - } else { - argsMap[config.Body] = m - } - } - args := make([]interface{}, maxKey+1) - for k, v := range argsMap { - if k >= 0 { - args[k] = v - } - } - return args +func GetNewGoRestfulServer() server.RestServer { + return NewGoRestfulServer() } -func getArgsFromRequest(req *restful.Request, argsTypes []reflect.Type, config *config.RestMethodConfig) []interface{} { - argsLength := len(argsTypes) - args := make([]interface{}, argsLength) - for i, t := range argsTypes { - args[i] = reflect.Zero(t).Interface() - } - var ( - err error - param interface{} - i64 int64 - ) - for k, v := range config.PathParamsMap { - if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Path param parse error, the args:%v doesn't exist", k) - continue - } - t := argsTypes[k] - kind := t.Kind() - if kind == reflect.Ptr { - t = t.Elem() - } - if kind == reflect.Int { - param, err = strconv.Atoi(req.PathParameter(v)) - } else if kind == reflect.Int32 { - i64, err = strconv.ParseInt(req.PathParameter(v), 10, 32) - if err == nil { - param = int32(i64) - } - } else if kind == reflect.Int64 { - param, err = strconv.ParseInt(req.PathParameter(v), 10, 64) - } else if kind == reflect.String { - param = req.PathParameter(v) - } else { - logger.Warnf("[Go restful] Path param parse error, the args:%v of type isn't int or string", k) - continue - } - if err != nil { - logger.Errorf("[Go restful] Path param parse error, error is %v", err) - continue - } - args[k] = param - } - for k, v := range config.QueryParamsMap { - if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Query param parse error, the args:%v doesn't exist", k) - continue - } - t := argsTypes[k] - kind := t.Kind() - if kind == reflect.Ptr { - t = t.Elem() - } - if kind == reflect.Slice { - param = req.QueryParameters(v) - } else if kind == reflect.String { - param = req.QueryParameter(v) - } else if kind == reflect.Int { - param, err = strconv.Atoi(req.QueryParameter(v)) - } else if kind == reflect.Int32 { - i64, err = strconv.ParseInt(req.QueryParameter(v), 10, 32) - if err == nil { - param = int32(i64) - } - } else if kind == reflect.Int64 { - param, err = strconv.ParseInt(req.QueryParameter(v), 10, 64) - } else { - logger.Errorf("[Go restful] Query param parse error, the args:%v of type isn't int or string or slice", k) - continue - } - if err != nil { - logger.Errorf("[Go restful] Query param parse error, error is %v", err) - continue - } - args[k] = param - } +// Let user addFilter +// addFilter should before config.Load() +func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { + filterSlice = append(filterSlice, filterFuc) +} - if config.Body >= 0 && config.Body < len(argsTypes) { - t := argsTypes[config.Body] - kind := t.Kind() - if kind == reflect.Ptr { - t = t.Elem() - } - var ni interface{} - if t.String() == "[]interface {}" { - ni = make([]map[string]interface{}, 0) - } else if t.String() == "interface {}" { - ni = make(map[string]interface{}) - } else { - n := reflect.New(t) - if n.CanInterface() { - ni = n.Interface() - } - } - if err := req.ReadEntity(&ni); err != nil { - logger.Errorf("[Go restful] Read body entity error:%v", err) - } else { - args[config.Body] = ni - } - } +// Go Restful Request adapt to RestServerRequest +type GoRestfulRequestAdapter struct { + rawRequest *restful.Request +} - for k, v := range config.HeadersMap { - param := req.HeaderParameter(v) - if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Header param parse error, the args:%v doesn't exist", k) - continue - } - t := argsTypes[k] - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - if t.Kind() == reflect.String { - args[k] = param - } else { - logger.Errorf("[Go restful] Header param parse error, the args:%v of type isn't string", k) - } - } +func (gra *GoRestfulRequestAdapter) PathParameter(name string) string { + return gra.rawRequest.PathParameter(name) +} - return args +func (gra *GoRestfulRequestAdapter) PathParameters() map[string]string { + return gra.rawRequest.PathParameters() } -func GetNewGoRestfulServer() server.RestServer { - return NewGoRestfulServer() +func (gra *GoRestfulRequestAdapter) QueryParameter(name string) string { + return gra.rawRequest.QueryParameter(name) } -// Let user addFilter -// addFilter should before config.Load() -func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { - filterSlice = append(filterSlice, filterFuc) +func (gra *GoRestfulRequestAdapter) QueryParameters(name string) []string { + return gra.rawRequest.QueryParameters(name) +} + +func (gra *GoRestfulRequestAdapter) BodyParameter(name string) (string, error) { + return gra.rawRequest.BodyParameter(name) +} + +func (gra *GoRestfulRequestAdapter) HeaderParameter(name string) string { + return gra.rawRequest.HeaderParameter(name) +} + +func (gra *GoRestfulRequestAdapter) ReadEntity(entityPointer interface{}) error { + return gra.rawRequest.ReadEntity(entityPointer) +} + +func NewGoRestfulRequestAdapter(rawRequest *restful.Request) server.RestServerRequest { + return &GoRestfulRequestAdapter{rawRequest: rawRequest} +} + +// Go Restful Request adapt to RestClientRequest +type GoRestfulResponseAdapter struct { + rawResponse *restful.Response +} + +func (grsa *GoRestfulResponseAdapter) WriteError(httpStatus int, err error) (writeErr error) { + return grsa.rawResponse.WriteError(httpStatus, err) +} + +func (grsa *GoRestfulResponseAdapter) WriteEntity(value interface{}) error { + return grsa.rawResponse.WriteEntity(value) +} + +func NewGoRestfulResponseAdapter(rawResponse *restful.Response) server.RestServerResponse { + return &GoRestfulResponseAdapter{rawResponse: rawResponse} } From f8e2978037c3ab20ab27cdbea5f5a239ab95791f Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 01:40:18 +0800 Subject: [PATCH 025/167] remove adapter --- .../server/server_impl/go_restful_server.go | 58 +------------------ 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 3c81fe0bfd..81043c8a72 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -79,9 +79,7 @@ func (grs *GoRestfulServer) Start(url common.URL) { func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) { ws := new(restful.WebService) rf := func(req *restful.Request, resp *restful.Response) { - respAdapter := NewGoRestfulResponseAdapter(resp) - reqAdapter := NewGoRestfulRequestAdapter(req) - routeFunc(reqAdapter, respAdapter) + routeFunc(req, resp) } ws.Path(restMethodConfig.Path). Produces(strings.Split(restMethodConfig.Produces, ",")...). @@ -118,57 +116,3 @@ func GetNewGoRestfulServer() server.RestServer { func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { filterSlice = append(filterSlice, filterFuc) } - -// Go Restful Request adapt to RestServerRequest -type GoRestfulRequestAdapter struct { - rawRequest *restful.Request -} - -func (gra *GoRestfulRequestAdapter) PathParameter(name string) string { - return gra.rawRequest.PathParameter(name) -} - -func (gra *GoRestfulRequestAdapter) PathParameters() map[string]string { - return gra.rawRequest.PathParameters() -} - -func (gra *GoRestfulRequestAdapter) QueryParameter(name string) string { - return gra.rawRequest.QueryParameter(name) -} - -func (gra *GoRestfulRequestAdapter) QueryParameters(name string) []string { - return gra.rawRequest.QueryParameters(name) -} - -func (gra *GoRestfulRequestAdapter) BodyParameter(name string) (string, error) { - return gra.rawRequest.BodyParameter(name) -} - -func (gra *GoRestfulRequestAdapter) HeaderParameter(name string) string { - return gra.rawRequest.HeaderParameter(name) -} - -func (gra *GoRestfulRequestAdapter) ReadEntity(entityPointer interface{}) error { - return gra.rawRequest.ReadEntity(entityPointer) -} - -func NewGoRestfulRequestAdapter(rawRequest *restful.Request) server.RestServerRequest { - return &GoRestfulRequestAdapter{rawRequest: rawRequest} -} - -// Go Restful Request adapt to RestClientRequest -type GoRestfulResponseAdapter struct { - rawResponse *restful.Response -} - -func (grsa *GoRestfulResponseAdapter) WriteError(httpStatus int, err error) (writeErr error) { - return grsa.rawResponse.WriteError(httpStatus, err) -} - -func (grsa *GoRestfulResponseAdapter) WriteEntity(value interface{}) error { - return grsa.rawResponse.WriteEntity(value) -} - -func NewGoRestfulResponseAdapter(rawResponse *restful.Response) server.RestServerResponse { - return &GoRestfulResponseAdapter{rawResponse: rawResponse} -} From baa1125d7d2903f4285444ad3bfc3f0994a8a9b5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 19:05:58 +0800 Subject: [PATCH 026/167] optimize header transmit in RestClient and RestServer --- .../rest/client/client_impl/resty_client.go | 11 +++-- protocol/rest/client/rest_client.go | 5 +-- protocol/rest/rest_invoker.go | 23 +++++++--- protocol/rest/server/rest_server.go | 4 ++ .../server/server_impl/go_restful_server.go | 44 ++++++++++++++++++- 5 files changed, 72 insertions(+), 15 deletions(-) diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index af9637ea91..9e0c80ccd2 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -66,20 +66,19 @@ func NewRestyClient(restOption *client.RestOptions) client.RestClient { } func (rc *RestyClient) Do(restRequest *client.RestClientRequest, res interface{}) error { - r, err := rc.client.R(). - SetHeader("Content-Type", restRequest.Consumes). - SetHeader("Accept", restRequest.Produces). + req := rc.client.R() + req.Header = restRequest.Header + resp, err := req. SetPathParams(restRequest.PathParams). SetQueryParams(restRequest.QueryParams). - SetHeaders(restRequest.Headers). SetBody(restRequest.Body). SetResult(res). Execute(restRequest.Method, "http://"+path.Join(restRequest.Location, restRequest.Path)) if err != nil { return perrors.WithStack(err) } - if r.IsError() { - return perrors.New(r.String()) + if resp.IsError() { + return perrors.New(resp.String()) } return nil } diff --git a/protocol/rest/client/rest_client.go b/protocol/rest/client/rest_client.go index 3acccb53ae..5be4bb3be3 100644 --- a/protocol/rest/client/rest_client.go +++ b/protocol/rest/client/rest_client.go @@ -18,6 +18,7 @@ package client import ( + "net/http" "time" ) @@ -27,15 +28,13 @@ type RestOptions struct { } type RestClientRequest struct { + Header http.Header Location string Path string - Produces string - Consumes string Method string PathParams map[string]string QueryParams map[string]string Body interface{} - Headers map[string]string } type RestClient interface { diff --git a/protocol/rest/rest_invoker.go b/protocol/rest/rest_invoker.go index c8e3feaff6..121d1217ef 100644 --- a/protocol/rest/rest_invoker.go +++ b/protocol/rest/rest_invoker.go @@ -20,6 +20,7 @@ package rest import ( "context" "fmt" + "net/http" ) import ( @@ -56,7 +57,7 @@ func (ri *RestInvoker) Invoke(ctx context.Context, invocation protocol.Invocatio body interface{} pathParams map[string]string queryParams map[string]string - headers map[string]string + header http.Header err error ) if methodConfig == nil { @@ -71,7 +72,7 @@ func (ri *RestInvoker) Invoke(ctx context.Context, invocation protocol.Invocatio result.Err = err return &result } - if headers, err = restStringMapTransform(methodConfig.HeadersMap, inv.Arguments()); err != nil { + if header, err = getRestHttpHeader(methodConfig, inv.Arguments()); err != nil { result.Err = err return &result } @@ -80,14 +81,12 @@ func (ri *RestInvoker) Invoke(ctx context.Context, invocation protocol.Invocatio } req := &client.RestClientRequest{ Location: ri.GetUrl().Location, - Produces: methodConfig.Produces, - Consumes: methodConfig.Consumes, Method: methodConfig.MethodType, Path: methodConfig.Path, PathParams: pathParams, QueryParams: queryParams, Body: body, - Headers: headers, + Header: header, } result.Err = ri.client.Do(req, inv.Reply()) if result.Err == nil { @@ -106,3 +105,17 @@ func restStringMapTransform(paramsMap map[int]string, args []interface{}) (map[s } return resMap, nil } + +func getRestHttpHeader(methodConfig *config.RestMethodConfig, args []interface{}) (http.Header, error) { + header := http.Header{} + headersMap := methodConfig.HeadersMap + header.Set("Content-Type", methodConfig.Consumes) + header.Set("Accept", methodConfig.Produces) + for k, v := range headersMap { + if k >= len(args) || k < 0 { + return nil, perrors.Errorf("[Rest Invoke] Index %v is out of bundle", k) + } + header.Set(v, fmt.Sprint(args[k])) + } + return header, nil +} diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index b7eb555625..7fb0560ff2 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -46,6 +46,7 @@ type RestServer interface { // RestServerRequest interface type RestServerRequest interface { + RawRequest() *http.Request PathParameter(name string) string PathParameters() map[string]string QueryParameter(name string) string @@ -57,6 +58,9 @@ type RestServerRequest interface { // RestServerResponse interface type RestServerResponse interface { + Header() http.Header + Write([]byte) (int, error) + WriteHeader(statusCode int) WriteError(httpStatus int, err error) (writeErr error) WriteEntity(value interface{}) error } diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 81043c8a72..9163d3aed7 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -79,7 +79,7 @@ func (grs *GoRestfulServer) Start(url common.URL) { func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) { ws := new(restful.WebService) rf := func(req *restful.Request, resp *restful.Response) { - routeFunc(req, resp) + routeFunc(NewGoRestfulRequestAdapter(req), resp) } ws.Path(restMethodConfig.Path). Produces(strings.Split(restMethodConfig.Produces, ",")...). @@ -116,3 +116,45 @@ func GetNewGoRestfulServer() server.RestServer { func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { filterSlice = append(filterSlice, filterFuc) } + +// Adapter about RestServerRequest +type GoRestfulRequestAdapter struct { + server.RestServerRequest + request *restful.Request +} + +func NewGoRestfulRequestAdapter(request *restful.Request) *GoRestfulRequestAdapter { + return &GoRestfulRequestAdapter{request: request} +} + +func (grra *GoRestfulRequestAdapter) RawRequest() *http.Request { + return grra.request.Request +} + +func (grra *GoRestfulRequestAdapter) PathParameter(name string) string { + return grra.request.PathParameter(name) +} + +func (grra *GoRestfulRequestAdapter) PathParameters() map[string]string { + return grra.request.PathParameters() +} + +func (grra *GoRestfulRequestAdapter) QueryParameter(name string) string { + return grra.request.QueryParameter(name) +} + +func (grra *GoRestfulRequestAdapter) QueryParameters(name string) []string { + return grra.request.QueryParameters(name) +} + +func (grra *GoRestfulRequestAdapter) BodyParameter(name string) (string, error) { + return grra.request.BodyParameter(name) +} + +func (grra *GoRestfulRequestAdapter) HeaderParameter(name string) string { + return grra.request.HeaderParameter(name) +} + +func (grra *GoRestfulRequestAdapter) ReadEntity(entityPointer interface{}) error { + return grra.request.ReadEntity(entityPointer) +} From dacdada3974a9580f82ae163561e060ed10b48a5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 20:04:31 +0800 Subject: [PATCH 027/167] add some comments --- .../rest/client/client_impl/resty_client.go | 1 + protocol/rest/client/rest_client.go | 3 +++ protocol/rest/server/rest_server.go | 20 +++++++++++--- .../server/server_impl/go_restful_server.go | 27 ++++++++++++++----- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index 9e0c80ccd2..bfd74455bc 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -40,6 +40,7 @@ func init() { extension.SetRestClient(constant.DEFAULT_REST_CLIENT, NewRestyClient) } +// A rest client implement by Resty type RestyClient struct { client *resty.Client } diff --git a/protocol/rest/client/rest_client.go b/protocol/rest/client/rest_client.go index 5be4bb3be3..47d17c6943 100644 --- a/protocol/rest/client/rest_client.go +++ b/protocol/rest/client/rest_client.go @@ -22,11 +22,13 @@ import ( "time" ) +// Some rest options type RestOptions struct { RequestTimeout time.Duration ConnectTimeout time.Duration } +// Client request type RestClientRequest struct { Header http.Header Location string @@ -37,6 +39,7 @@ type RestClientRequest struct { Body interface{} } +// User can implement this client interface to send request type RestClient interface { Do(request *RestClientRequest, res interface{}) error } diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 7fb0560ff2..60f0dab942 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -38,33 +38,47 @@ import ( ) type RestServer interface { + // start rest server Start(url common.URL) + // deploy a http api Deploy(restMethodConfig *rest_config.RestMethodConfig, routeFunc func(request RestServerRequest, response RestServerResponse)) + // unDeploy a http api UnDeploy(restMethodConfig *rest_config.RestMethodConfig) + // destroy rest server Destroy() } // RestServerRequest interface type RestServerRequest interface { + // Get the Ptr of http.Request RawRequest() *http.Request + // Get the path parameter by name PathParameter(name string) string + // Get the map of the path parameters PathParameters() map[string]string + // Get the query parameter by name QueryParameter(name string) string + // Get the map of query parameters QueryParameters(name string) []string + // Get the body parameter of name BodyParameter(name string) (string, error) + // Get the header parameter of name HeaderParameter(name string) string + // ReadEntity checks the Accept header and reads the content into the entityPointer. ReadEntity(entityPointer interface{}) error } // RestServerResponse interface type RestServerResponse interface { - Header() http.Header - Write([]byte) (int, error) - WriteHeader(statusCode int) + http.ResponseWriter + // WriteError writes the http status and the error string on the response. err can be nil. + // Return an error if writing was not succesful. WriteError(httpStatus int, err error) (writeErr error) + // WriteEntity marshals the value using the representation denoted by the Accept Header. WriteEntity(value interface{}) error } +// A route function will be invoked by http server func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethodConfig) func(req RestServerRequest, resp RestServerResponse) { return func(req RestServerRequest, resp RestServerResponse) { var ( diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 9163d3aed7..00b644f208 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -41,20 +41,24 @@ import ( ) func init() { - extension.SetRestServer(constant.DEFAULT_REST_SERVER, GetNewGoRestfulServer) + extension.SetRestServer(constant.DEFAULT_REST_SERVER, NewGoRestfulServer) } var filterSlice []restful.FilterFunction +// A rest server implement by go-restful type GoRestfulServer struct { srv *http.Server container *restful.Container } -func NewGoRestfulServer() *GoRestfulServer { +// A constructor of GoRestfulServer +func NewGoRestfulServer() server.RestServer { return &GoRestfulServer{} } +// Start go-restful server +// It will add all go-restful filters func (grs *GoRestfulServer) Start(url common.URL) { grs.container = restful.NewContainer() for _, filter := range filterSlice { @@ -76,6 +80,8 @@ func (grs *GoRestfulServer) Start(url common.URL) { }() } +// Publish a http api in go-restful server +// The routeFunc should be invoked when the server receive a request func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) { ws := new(restful.WebService) rf := func(req *restful.Request, resp *restful.Response) { @@ -89,6 +95,7 @@ func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, ro } +// Delete a http api in go-restful server func (grs *GoRestfulServer) UnDeploy(restMethodConfig *config.RestMethodConfig) { ws := new(restful.WebService) ws.Path(restMethodConfig.Path) @@ -98,6 +105,7 @@ func (grs *GoRestfulServer) UnDeploy(restMethodConfig *config.RestMethodConfig) } } +// Destroy the go-restful server func (grs *GoRestfulServer) Destroy() { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() @@ -107,11 +115,7 @@ func (grs *GoRestfulServer) Destroy() { logger.Infof("[Go Restful] Server exiting") } -func GetNewGoRestfulServer() server.RestServer { - return NewGoRestfulServer() -} - -// Let user addFilter +// Let user add the http server of go-restful // addFilter should before config.Load() func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { filterSlice = append(filterSlice, filterFuc) @@ -123,38 +127,47 @@ type GoRestfulRequestAdapter struct { request *restful.Request } +// A constructor of GoRestfulRequestAdapter func NewGoRestfulRequestAdapter(request *restful.Request) *GoRestfulRequestAdapter { return &GoRestfulRequestAdapter{request: request} } +// A adapter function of server.RestServerRequest's RawRequest func (grra *GoRestfulRequestAdapter) RawRequest() *http.Request { return grra.request.Request } +// A adapter function of server.RestServerRequest's PathParameter func (grra *GoRestfulRequestAdapter) PathParameter(name string) string { return grra.request.PathParameter(name) } +// A adapter function of server.RestServerRequest's QueryParameter func (grra *GoRestfulRequestAdapter) PathParameters() map[string]string { return grra.request.PathParameters() } +// A adapter function of server.RestServerRequest's QueryParameters func (grra *GoRestfulRequestAdapter) QueryParameter(name string) string { return grra.request.QueryParameter(name) } +// A adapter function of server.RestServerRequest's QueryParameters func (grra *GoRestfulRequestAdapter) QueryParameters(name string) []string { return grra.request.QueryParameters(name) } +// A adapter function of server.RestServerRequest's BodyParameter func (grra *GoRestfulRequestAdapter) BodyParameter(name string) (string, error) { return grra.request.BodyParameter(name) } +// A adapter function of server.RestServerRequest's HeaderParameter func (grra *GoRestfulRequestAdapter) HeaderParameter(name string) string { return grra.request.HeaderParameter(name) } +// A adapter func of server.RestServerRequest's ReadEntity func (grra *GoRestfulRequestAdapter) ReadEntity(entityPointer interface{}) error { return grra.request.ReadEntity(entityPointer) } From 6c44338f271f5cc829b8cfddf3ca091f1b383139 Mon Sep 17 00:00:00 2001 From: flycash Date: Wed, 1 Apr 2020 22:58:29 +0800 Subject: [PATCH 028/167] Test CRUD for instance methods --- go.mod | 4 +- go.sum | 3 + registry/nacos/service_discovery.go | 6 +- registry/nacos/service_discovery_test.go | 91 +++++++++++++++++++++--- 4 files changed, 92 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index be84af853a..54d532eac0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/creasty/defaults v1.3.0 github.com/dubbogo/getty v1.3.3 github.com/dubbogo/go-zookeeper v1.0.0 - github.com/dubbogo/gost v1.7.0 + github.com/dubbogo/gost v1.8.0 github.com/emicklei/go-restful/v3 v3.0.0 github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/go-errors/errors v1.0.1 // indirect @@ -38,7 +38,7 @@ require ( github.com/magiconair/properties v1.8.1 github.com/mitchellh/mapstructure v1.1.2 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd - github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb + github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c github.com/opentracing/opentracing-go v1.1.0 github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.1.0 diff --git a/go.sum b/go.sum index d4f8a367b0..ed0bb84d82 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,8 @@ github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.7.0 h1:lWNBIE2hk1Aj2be2uXkyRTpZG0RQZj0/xbXnkIq6EHE= github.com/dubbogo/gost v1.7.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +github.com/dubbogo/gost v1.8.0 h1:9ACbQe5OwMjqtinQcNJC5xp16kky27OsfSGw5L9A6vw= +github.com/dubbogo/gost v1.8.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0 h1:ZoRgc53qJCfSLimXqJDrmBhnt5GChDsExMCK7t48o0Y= @@ -385,6 +387,7 @@ 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/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb h1:lbmvw8r9W55w+aQgWn35W1nuleRIECMoqUrmwAOAvoI= github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= +github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= github.com/oklog/run v0.0.0-20180308005104-6934b124db28 h1:Hbr3fbVPXea52oPQeP7KLSxP52g6SFaNY1IqAmUyEW0= diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 2f8eb7706f..746ab7088b 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -70,7 +70,7 @@ func (n *nacosServiceDiscovery) Register(instance registry.ServiceInstance) erro // so we should unregister the instance and then register it again. // the error handling is hard to implement func (n *nacosServiceDiscovery) Update(instance registry.ServiceInstance) error { - // The + // TODO(wait for nacos support) err := n.Unregister(instance) if err != nil { return perrors.WithStack(err) @@ -237,6 +237,9 @@ func (n *nacosServiceDiscovery) DispatchEvent(event *registry.ServiceInstancesCh func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInstance) vo.RegisterInstanceParam { metadata := instance.GetMetadata() + if metadata == nil { + metadata = make(map[string]string, 1) + } metadata[idKey] = instance.GetId() return vo.RegisterInstanceParam{ ServiceName: instance.GetServiceName(), @@ -246,6 +249,7 @@ func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInst Enable: instance.IsEnable(), Healthy: instance.IsHealthy(), GroupName: n.group, + Ephemeral: true, } } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index dbe9b88fe0..6d59b4ad89 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -18,7 +18,6 @@ package nacos import ( - "net/url" "strconv" "testing" @@ -27,21 +26,95 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/registry" ) func TestNacosServiceDiscovery_Destroy(t *testing.T) { serviceDiscovry, err := extension.GetServiceDiscovery(constant.NACOS_KEY, mockUrl()) assert.Nil(t, err) assert.NotNil(t, serviceDiscovry) + err = serviceDiscovry.Destroy() + assert.Nil(t, err) + assert.Nil(t, serviceDiscovry.(*nacosServiceDiscovery).namingClient) +} + +func TestNacosServiceDiscovery_CRUD(t *testing.T) { + serviceName := "service-name" + 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 + + serviceDiscovry, _ := extension.GetServiceDiscovery(constant.NACOS_KEY, mockUrl()) + + // clean data for local test + serviceDiscovry.Unregister(®istry.DefaultServiceInstance{ + Id: id, + ServiceName: serviceName, + Host: host, + Port: port, + }) + + // serviceDiscovry.Unregister(®istry.DefaultServiceInstance{ + // Id: id, + // ServiceName: serviceName, + // Host: host, + // Port: 321, + // }) + // + // serviceDiscovry.Unregister(®istry.DefaultServiceInstance{ + // Id: id, + // ServiceName: serviceName, + // Host: "my.c", + // Port: 321, + // }) + + err := serviceDiscovry.Register(instance) + assert.Nil(t, err) + + page := serviceDiscovry.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) + assert.NotNil(t, instance) + assert.Equal(t, id, instance.GetId()) + assert.Equal(t, host, instance.GetHost()) + assert.Equal(t, port, instance.GetPort()) + assert.Equal(t, serviceName, instance.GetServiceName()) + assert.Equal(t, 0, len(instance.GetMetadata())) + + + instance.Metadata["a"] = "b" + + err = serviceDiscovry.Update(instance) + assert.Nil(t, err) + + pageMap := serviceDiscovry.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, _ := instance.Metadata["a"] + assert.Equal(t, "b", v) } func mockUrl() *common.URL { - urlMap := url.Values{} - urlMap.Set(constant.GROUP_KEY, "guangzhou-idc") - urlMap.Set(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)) - urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") - urlMap.Set(constant.VERSION_KEY, "1.0.0") - urlMap.Set(constant.CLUSTER_KEY, "mock") - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) - return &url + regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) + return ®url } From 54d05095dfed4419fe08fcf3156b84b69a19e0ee Mon Sep 17 00:00:00 2001 From: flycash Date: Wed, 1 Apr 2020 23:02:06 +0800 Subject: [PATCH 029/167] Fix Review --- common/constant/key.go | 3 +++ .../dynamic/service_name_mapping.go | 19 +++++++------------ .../dynamic/service_name_mapping_test.go | 3 ++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/common/constant/key.go b/common/constant/key.go index 5769ccfe6c..27b77879b3 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -215,6 +215,9 @@ const ( KEY_SEPARATOR = ":" DEFAULT_PATH_TAG = "metadata" KEY_REVISON_PREFIX = "revision" + + // metadata service + METADATA_SERVICE_NAME = "org.apache.dubbo.metadata.MetadataService" ) // HealthCheck Router diff --git a/metadata/namemapping/dynamic/service_name_mapping.go b/metadata/namemapping/dynamic/service_name_mapping.go index dfa672e95b..e93c256fe0 100644 --- a/metadata/namemapping/dynamic/service_name_mapping.go +++ b/metadata/namemapping/dynamic/service_name_mapping.go @@ -28,6 +28,7 @@ import ( ) import ( + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/config_center" "github.com/apache/dubbo-go/metadata" @@ -36,9 +37,6 @@ import ( const ( defaultGroup = config_center.DEFAULT_GROUP slash = "/" - - // metadata service is the admin service, should not be mapped - metadataService = "org.apache.dubbo.metadata.MetadataService" ) // DynamicConfigurationServiceNameMapping is the implementation based on config center @@ -48,7 +46,8 @@ type DynamicConfigurationServiceNameMapping struct { // Map will map the service to this application-level service func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error { - if metadataService == serviceInterface { + // metadata service is admin service, should not be mapped + if constant.METADATA_SERVICE_NAME == serviceInterface { return perrors.New("try to map the metadata service, will be ignored") } @@ -56,7 +55,7 @@ func (d *DynamicConfigurationServiceNameMapping) Map(serviceInterface string, gr value := time.Now().UnixNano() err := d.dc.PublishConfig(appName, - d.buildGroup(serviceInterface, group, version, protocol), + d.buildGroup(serviceInterface), strconv.FormatInt(value, 10)) if err != nil { return perrors.WithStack(err) @@ -67,17 +66,13 @@ 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, group, version, protocol)) + return d.dc.GetConfigKeysByGroup(d.buildGroup(serviceInterface)) } // buildGroup will return group, now it looks like defaultGroup/serviceInterface -func (d *DynamicConfigurationServiceNameMapping) buildGroup( - serviceInterface string, - group string, - version string, - protocol string) string { +func (d *DynamicConfigurationServiceNameMapping) buildGroup(serviceInterface string) string { // the issue : https://github.com/apache/dubbo/issues/4671 - // so other params are ignored + // so other params are ignored and remove, including group string, version string, protocol string return defaultGroup + slash + serviceInterface } diff --git a/metadata/namemapping/dynamic/service_name_mapping_test.go b/metadata/namemapping/dynamic/service_name_mapping_test.go index 81fe350bcf..e3d620cd73 100644 --- a/metadata/namemapping/dynamic/service_name_mapping_test.go +++ b/metadata/namemapping/dynamic/service_name_mapping_test.go @@ -27,6 +27,7 @@ import ( ) import ( + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/config_center" ) @@ -41,7 +42,7 @@ func TestDynamicConfigurationServiceNameMapping(t *testing.T) { config.GetApplicationConfig().Name = appName mapping := NewServiceNameMapping(dc) - intf := metadataService + intf := constant.METADATA_SERVICE_NAME group := "myGroup" version := "myVersion" protocol := "myProtocol" From e7999f519e330a316a267631aaa2971dcada2c89 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 23:38:08 +0800 Subject: [PATCH 030/167] modify some comments and when parsing parameters occurred error, return error immediately --- .../rest/client/client_impl/resty_client.go | 4 +- protocol/rest/client/rest_client.go | 6 +- protocol/rest/server/rest_server.go | 114 ++++++++++-------- 3 files changed, 71 insertions(+), 53 deletions(-) diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go index bfd74455bc..b60f50a5a7 100644 --- a/protocol/rest/client/client_impl/resty_client.go +++ b/protocol/rest/client/client_impl/resty_client.go @@ -40,11 +40,12 @@ func init() { extension.SetRestClient(constant.DEFAULT_REST_CLIENT, NewRestyClient) } -// A rest client implement by Resty +// RestyClient a rest client implement by Resty type RestyClient struct { client *resty.Client } +// NewRestyClient a constructor of RestyClient func NewRestyClient(restOption *client.RestOptions) client.RestClient { client := resty.New() client.SetTransport( @@ -66,6 +67,7 @@ func NewRestyClient(restOption *client.RestOptions) client.RestClient { } } +// Do send request by RestyClient func (rc *RestyClient) Do(restRequest *client.RestClientRequest, res interface{}) error { req := rc.client.R() req.Header = restRequest.Header diff --git a/protocol/rest/client/rest_client.go b/protocol/rest/client/rest_client.go index 47d17c6943..d63c5e0bd0 100644 --- a/protocol/rest/client/rest_client.go +++ b/protocol/rest/client/rest_client.go @@ -22,13 +22,13 @@ import ( "time" ) -// Some rest options +// RestOptions type RestOptions struct { RequestTimeout time.Duration ConnectTimeout time.Duration } -// Client request +// RestClientRequest type RestClientRequest struct { Header http.Header Location string @@ -39,7 +39,7 @@ type RestClientRequest struct { Body interface{} } -// User can implement this client interface to send request +// RestClient user can implement this client interface to send request type RestClient interface { Do(request *RestClientRequest, res interface{}) error } diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 60f0dab942..60cac9afbb 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -19,6 +19,7 @@ package server import ( "context" + "errors" "net/http" "reflect" "strconv" @@ -37,6 +38,8 @@ import ( rest_config "github.com/apache/dubbo-go/protocol/rest/config" ) +const parseParameterErrorStr = "An error occurred while parsing parameters on the server" + type RestServer interface { // start rest server Start(url common.URL) @@ -50,19 +53,19 @@ type RestServer interface { // RestServerRequest interface type RestServerRequest interface { - // Get the Ptr of http.Request + // RawRequest get the Ptr of http.Request RawRequest() *http.Request - // Get the path parameter by name + // PathParameter get the path parameter by name PathParameter(name string) string - // Get the map of the path parameters + // PathParameters get the map of the path parameters PathParameters() map[string]string - // Get the query parameter by name + // QueryParameter get the query parameter by name QueryParameter(name string) string - // Get the map of query parameters + // QueryParameters get the map of query parameters QueryParameters(name string) []string - // Get the body parameter of name + // BodyParameter get the body parameter of name BodyParameter(name string) (string, error) - // Get the header parameter of name + // HeaderParameter get the header parameter of name HeaderParameter(name string) string // ReadEntity checks the Accept header and reads the content into the entityPointer. ReadEntity(entityPointer interface{}) error @@ -72,12 +75,13 @@ type RestServerRequest interface { type RestServerResponse interface { http.ResponseWriter // WriteError writes the http status and the error string on the response. err can be nil. - // Return an error if writing was not succesful. + // Return an error if writing was not successful. WriteError(httpStatus int, err error) (writeErr error) // WriteEntity marshals the value using the representation denoted by the Accept Header. WriteEntity(value interface{}) error } +// GetRouteFunc // A route function will be invoked by http server func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethodConfig) func(req RestServerRequest, resp RestServerResponse) { return func(req RestServerRequest, resp RestServerResponse) { @@ -92,9 +96,16 @@ func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethod replyType := method.ReplyType() if (len(argsTypes) == 1 || len(argsTypes) == 2 && replyType == nil) && argsTypes[0].String() == "[]interface {}" { - args = getArgsInterfaceFromRequest(req, methodConfig) + args, err = getArgsInterfaceFromRequest(req, methodConfig) } else { - args = getArgsFromRequest(req, argsTypes, methodConfig) + args, err = getArgsFromRequest(req, argsTypes, methodConfig) + } + if err != nil { + logger.Errorf("[Go Restful] parsing parameters error:%v", err) + err = resp.WriteError(http.StatusInternalServerError, errors.New(parseParameterErrorStr)) + if err != nil { + logger.Errorf("[Go Restful] WriteErrorString error:%v", err) + } } result := invoker.Invoke(context.Background(), invocation.NewRPCInvocation(methodConfig.MethodName, args, make(map[string]string))) if result.Error() != nil { @@ -111,9 +122,9 @@ func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethod } } -// when service function like GetUser(req []interface{}, rsp *User) error +// getArgsInterfaceFromRequest when service function like GetUser(req []interface{}, rsp *User) error // use this method to get arguments -func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_config.RestMethodConfig) []interface{} { +func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_config.RestMethodConfig) ([]interface{}, error) { argsMap := make(map[int]interface{}, 8) maxKey := 0 for k, v := range methodConfig.PathParamsMap { @@ -145,10 +156,10 @@ func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_confi } m := make(map[string]interface{}) // TODO read as a slice - if err := req.ReadEntity(&m); err != nil { - logger.Warnf("[Go restful] Read body entity as map[string]interface{} error:%v", perrors.WithStack(err)) - } else { + if err := req.ReadEntity(&m); err == nil { argsMap[methodConfig.Body] = m + } else { + return nil, perrors.Errorf("[Go restful] Read body entity as map[string]interface{} error:%v", err) } } args := make([]interface{}, maxKey+1) @@ -157,30 +168,37 @@ func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_confi args[k] = v } } - return args + return args, nil } -// get arguments from server.RestServerRequest -func getArgsFromRequest(req RestServerRequest, argsTypes []reflect.Type, methodConfig *rest_config.RestMethodConfig) []interface{} { +// getArgsFromRequest get arguments from server.RestServerRequest +func getArgsFromRequest(req RestServerRequest, argsTypes []reflect.Type, methodConfig *rest_config.RestMethodConfig) ([]interface{}, error) { argsLength := len(argsTypes) args := make([]interface{}, argsLength) for i, t := range argsTypes { args[i] = reflect.Zero(t).Interface() } - assembleArgsFromPathParams(methodConfig, argsLength, argsTypes, req, args) - assembleArgsFromQueryParams(methodConfig, argsLength, argsTypes, req, args) - assembleArgsFromBody(methodConfig, argsTypes, req, args) - assembleArgsFromHeaders(methodConfig, req, argsLength, argsTypes, args) - return args + if err := assembleArgsFromPathParams(methodConfig, argsLength, argsTypes, req, args); err != nil { + return nil, err + } + if err := assembleArgsFromQueryParams(methodConfig, argsLength, argsTypes, req, args); err != nil { + return nil, err + } + if err := assembleArgsFromBody(methodConfig, argsTypes, req, args); err != nil { + return nil, err + } + if err := assembleArgsFromHeaders(methodConfig, req, argsLength, argsTypes, args); err != nil { + return nil, err + } + return args, nil } -// assemble arguments from headers -func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req RestServerRequest, argsLength int, argsTypes []reflect.Type, args []interface{}) { +// assembleArgsFromHeaders assemble arguments from headers +func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req RestServerRequest, argsLength int, argsTypes []reflect.Type, args []interface{}) error { for k, v := range methodConfig.HeadersMap { param := req.HeaderParameter(v) if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Header param parse error, the args:%v doesn't exist", k) - continue + return perrors.Errorf("[Go restful] Header param parse error, the args:%v doesn't exist", k) } t := argsTypes[k] if t.Kind() == reflect.Ptr { @@ -189,13 +207,14 @@ func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req Res if t.Kind() == reflect.String { args[k] = param } else { - logger.Errorf("[Go restful] Header param parse error, the args:%v of type isn't string", k) + return perrors.Errorf("[Go restful] Header param parse error, the args:%v of type isn't string", k) } } + return nil } -// assemble arguments from body -func assembleArgsFromBody(methodConfig *rest_config.RestMethodConfig, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { +// assembleArgsFromBody assemble arguments from body +func assembleArgsFromBody(methodConfig *rest_config.RestMethodConfig, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) error { if methodConfig.Body >= 0 && methodConfig.Body < len(argsTypes) { t := argsTypes[methodConfig.Body] kind := t.Kind() @@ -213,16 +232,17 @@ func assembleArgsFromBody(methodConfig *rest_config.RestMethodConfig, argsTypes ni = n.Interface() } } - if err := req.ReadEntity(&ni); err != nil { - logger.Errorf("[Go restful] Read body entity error:%v", err) - } else { + if err := req.ReadEntity(&ni); err == nil { args[methodConfig.Body] = ni + } else { + return perrors.Errorf("[Go restful] Read body entity error, error is %v", perrors.WithStack(err)) } } + return nil } -// assemble arguments from query params -func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { +// assembleArgsFromQueryParams assemble arguments from query params +func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) error { var ( err error param interface{} @@ -230,8 +250,7 @@ func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, arg ) for k, v := range methodConfig.QueryParamsMap { if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Query param parse error, the args:%v doesn't exist", k) - continue + return perrors.Errorf("[Go restful] Query param parse error, the args:%v doesn't exist", k) } t := argsTypes[k] kind := t.Kind() @@ -252,19 +271,18 @@ func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, arg } else if kind == reflect.Int64 { param, err = strconv.ParseInt(req.QueryParameter(v), 10, 64) } else { - logger.Errorf("[Go restful] Query param parse error, the args:%v of type isn't int or string or slice", k) - continue + return perrors.Errorf("[Go restful] Query param parse error, the args:%v of type isn't int or string or slice", k) } if err != nil { - logger.Errorf("[Go restful] Query param parse error, error is %v", err) - continue + return perrors.Errorf("[Go restful] Query param parse error, error:%v", perrors.WithStack(err)) } args[k] = param } + return nil } -// assemble arguments from path params -func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) { +// assembleArgsFromPathParams assemble arguments from path params +func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, argsLength int, argsTypes []reflect.Type, req RestServerRequest, args []interface{}) error { var ( err error param interface{} @@ -272,8 +290,7 @@ func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, args ) for k, v := range methodConfig.PathParamsMap { if k < 0 || k >= argsLength { - logger.Errorf("[Go restful] Path param parse error, the args:%v doesn't exist", k) - continue + return perrors.Errorf("[Go restful] Path param parse error, the args:%v doesn't exist", k) } t := argsTypes[k] kind := t.Kind() @@ -292,13 +309,12 @@ func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, args } else if kind == reflect.String { param = req.PathParameter(v) } else { - logger.Warnf("[Go restful] Path param parse error, the args:%v of type isn't int or string", k) - continue + return perrors.Errorf("[Go restful] Path param parse error, the args:%v of type isn't int or string", k) } if err != nil { - logger.Errorf("[Go restful] Path param parse error, error is %v", err) - continue + return perrors.Errorf("[Go restful] Path param parse error, error is %v", perrors.WithStack(err)) } args[k] = param } + return nil } From a606b64eecc22e62dba816a4637eacbb030f9781 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 23:40:10 +0800 Subject: [PATCH 031/167] modify comments --- protocol/rest/server/rest_server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 60cac9afbb..8bc32e87b0 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -40,14 +40,15 @@ import ( const parseParameterErrorStr = "An error occurred while parsing parameters on the server" +// RestServer user can implement this server interface type RestServer interface { - // start rest server + // Start rest server Start(url common.URL) - // deploy a http api + // Deploy a http api Deploy(restMethodConfig *rest_config.RestMethodConfig, routeFunc func(request RestServerRequest, response RestServerResponse)) - // unDeploy a http api + // UnDeploy a http api UnDeploy(restMethodConfig *rest_config.RestMethodConfig) - // destroy rest server + // Destroy rest server Destroy() } From 6bd3ac6205abec8149055ff974c821b8be1d05a2 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 23:43:15 +0800 Subject: [PATCH 032/167] remove new function --- protocol/rest/server/server_impl/go_restful_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 00b644f208..667d58c16d 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -83,7 +83,7 @@ func (grs *GoRestfulServer) Start(url common.URL) { // Publish a http api in go-restful server // The routeFunc should be invoked when the server receive a request func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) { - ws := new(restful.WebService) + ws := &restful.WebService{} rf := func(req *restful.Request, resp *restful.Response) { routeFunc(NewGoRestfulRequestAdapter(req), resp) } From dcc2d26384adc5f125586b5d68fbd0b63828c362 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 1 Apr 2020 23:45:21 +0800 Subject: [PATCH 033/167] modify some comments --- .../server/server_impl/go_restful_server.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 667d58c16d..7f5e3538c8 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -115,59 +115,59 @@ func (grs *GoRestfulServer) Destroy() { logger.Infof("[Go Restful] Server exiting") } -// Let user add the http server of go-restful +// AddGoRestfulServerFilter let user add the http server of go-restful // addFilter should before config.Load() func AddGoRestfulServerFilter(filterFuc restful.FilterFunction) { filterSlice = append(filterSlice, filterFuc) } -// Adapter about RestServerRequest +// GoRestfulRequestAdapter a adapter struct about RestServerRequest type GoRestfulRequestAdapter struct { server.RestServerRequest request *restful.Request } -// A constructor of GoRestfulRequestAdapter +// NewGoRestfulRequestAdapter a constructor of GoRestfulRequestAdapter func NewGoRestfulRequestAdapter(request *restful.Request) *GoRestfulRequestAdapter { return &GoRestfulRequestAdapter{request: request} } -// A adapter function of server.RestServerRequest's RawRequest +// RawRequest a adapter function of server.RestServerRequest's RawRequest func (grra *GoRestfulRequestAdapter) RawRequest() *http.Request { return grra.request.Request } -// A adapter function of server.RestServerRequest's PathParameter +// PathParameter a adapter function of server.RestServerRequest's PathParameter func (grra *GoRestfulRequestAdapter) PathParameter(name string) string { return grra.request.PathParameter(name) } -// A adapter function of server.RestServerRequest's QueryParameter +// PathParameters a adapter function of server.RestServerRequest's QueryParameter func (grra *GoRestfulRequestAdapter) PathParameters() map[string]string { return grra.request.PathParameters() } -// A adapter function of server.RestServerRequest's QueryParameters +// QueryParameter a adapter function of server.RestServerRequest's QueryParameters func (grra *GoRestfulRequestAdapter) QueryParameter(name string) string { return grra.request.QueryParameter(name) } -// A adapter function of server.RestServerRequest's QueryParameters +// QueryParameters a adapter function of server.RestServerRequest's QueryParameters func (grra *GoRestfulRequestAdapter) QueryParameters(name string) []string { return grra.request.QueryParameters(name) } -// A adapter function of server.RestServerRequest's BodyParameter +// BodyParameter a adapter function of server.RestServerRequest's BodyParameter func (grra *GoRestfulRequestAdapter) BodyParameter(name string) (string, error) { return grra.request.BodyParameter(name) } -// A adapter function of server.RestServerRequest's HeaderParameter +// HeaderParameter a adapter function of server.RestServerRequest's HeaderParameter func (grra *GoRestfulRequestAdapter) HeaderParameter(name string) string { return grra.request.HeaderParameter(name) } -// A adapter func of server.RestServerRequest's ReadEntity +// ReadEntity a adapter func of server.RestServerRequest's ReadEntity func (grra *GoRestfulRequestAdapter) ReadEntity(entityPointer interface{}) error { return grra.request.ReadEntity(entityPointer) } From c6e1507ddad4f46a78c6f7341d3508f4d9874253 Mon Sep 17 00:00:00 2001 From: flycash Date: Wed, 1 Apr 2020 23:46:30 +0800 Subject: [PATCH 034/167] Tested nacos discovery --- registry/nacos/base_registry.go | 4 +++ registry/nacos/service_discovery.go | 6 +++-- registry/nacos/service_discovery_test.go | 32 +++++++++++++----------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/registry/nacos/base_registry.go b/registry/nacos/base_registry.go index b6ce09bc71..a92df4cdc2 100644 --- a/registry/nacos/base_registry.go +++ b/registry/nacos/base_registry.go @@ -22,12 +22,16 @@ import ( "strconv" "strings" "time" +) +import ( "github.com/nacos-group/nacos-sdk-go/clients" "github.com/nacos-group/nacos-sdk-go/clients/naming_client" nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant" perrors "github.com/pkg/errors" +) +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" ) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 746ab7088b..5a730e935d 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -23,7 +23,9 @@ import ( "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" perrors "github.com/pkg/errors" +) +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" @@ -105,7 +107,7 @@ func (n *nacosServiceDiscovery) GetServices() *gxset.HashSet { } for _, e := range services { - res.Add(e) + res.Add(e.Name) } return res } @@ -249,7 +251,7 @@ func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInst Enable: instance.IsEnable(), Healthy: instance.IsHealthy(), GroupName: n.group, - Ephemeral: true, + Ephemeral: true, } } diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index 6d59b4ad89..a756e86693 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -20,9 +20,13 @@ package nacos import ( "strconv" "testing" +) +import ( "github.com/stretchr/testify/assert" +) +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" @@ -65,20 +69,6 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { Port: port, }) - // serviceDiscovry.Unregister(®istry.DefaultServiceInstance{ - // Id: id, - // ServiceName: serviceName, - // Host: host, - // Port: 321, - // }) - // - // serviceDiscovry.Unregister(®istry.DefaultServiceInstance{ - // Id: id, - // ServiceName: serviceName, - // Host: "my.c", - // Port: 321, - // }) - err := serviceDiscovry.Register(instance) assert.Nil(t, err) @@ -97,7 +87,6 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { assert.Equal(t, serviceName, instance.GetServiceName()) assert.Equal(t, 0, len(instance.GetMetadata())) - instance.Metadata["a"] = "b" err = serviceDiscovry.Update(instance) @@ -112,6 +101,19 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { instance = page.GetData()[0].(*registry.DefaultServiceInstance) v, _ := instance.Metadata["a"] assert.Equal(t, "b", v) + + // test dispatcher event + err = serviceDiscovry.DispatchEventByServiceName(serviceName) + assert.Nil(t, err) + + // test AddListener + err = serviceDiscovry.AddListener(®istry.ServiceInstancesChangedListener{}) + assert.Nil(t, err) +} + +func TestNacosServiceDiscovery_GetDefaultPageSize(t *testing.T) { + serviceDiscovry, _ := extension.GetServiceDiscovery(constant.NACOS_KEY, mockUrl()) + assert.Equal(t, registry.DefaultPageSize, serviceDiscovry.GetDefaultPageSize()) } func mockUrl() *common.URL { From ad958fa47d335a47b4dfc785e68d083f0033a5df Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 2 Apr 2020 00:17:07 +0800 Subject: [PATCH 035/167] modify some comments and modify some logger's message --- protocol/rest/server/rest_server.go | 17 ++++++++++------- .../server/server_impl/go_restful_server.go | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 8bc32e87b0..60a75bc279 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -95,6 +95,9 @@ func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethod method := svc.Method()[methodConfig.MethodName] argsTypes := method.ArgsType() replyType := method.ReplyType() + // two ways to prepare arguments + // if method like this 'func1(req []interface{}, rsp *User) error' + // we don't have arguments type if (len(argsTypes) == 1 || len(argsTypes) == 2 && replyType == nil) && argsTypes[0].String() == "[]interface {}" { args, err = getArgsInterfaceFromRequest(req, methodConfig) @@ -102,7 +105,7 @@ func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethod args, err = getArgsFromRequest(req, argsTypes, methodConfig) } if err != nil { - logger.Errorf("[Go Restful] parsing parameters error:%v", err) + logger.Errorf("[Go Restful] parsing http parameters error:%v", err) err = resp.WriteError(http.StatusInternalServerError, errors.New(parseParameterErrorStr)) if err != nil { logger.Errorf("[Go Restful] WriteErrorString error:%v", err) @@ -199,7 +202,7 @@ func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req Res for k, v := range methodConfig.HeadersMap { param := req.HeaderParameter(v) if k < 0 || k >= argsLength { - return perrors.Errorf("[Go restful] Header param parse error, the args:%v doesn't exist", k) + return perrors.Errorf("[Go restful] Header param parse error, the index %v args of method:%v doesn't exist", k, methodConfig.MethodName) } t := argsTypes[k] if t.Kind() == reflect.Ptr { @@ -208,7 +211,7 @@ func assembleArgsFromHeaders(methodConfig *rest_config.RestMethodConfig, req Res if t.Kind() == reflect.String { args[k] = param } else { - return perrors.Errorf("[Go restful] Header param parse error, the args:%v of type isn't string", k) + return perrors.Errorf("[Go restful] Header param parse error, the index %v args's type isn't string", k) } } return nil @@ -251,7 +254,7 @@ func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, arg ) for k, v := range methodConfig.QueryParamsMap { if k < 0 || k >= argsLength { - return perrors.Errorf("[Go restful] Query param parse error, the args:%v doesn't exist", k) + return perrors.Errorf("[Go restful] Query param parse error, the index %v args of method:%v doesn't exist", k, methodConfig.MethodName) } t := argsTypes[k] kind := t.Kind() @@ -272,7 +275,7 @@ func assembleArgsFromQueryParams(methodConfig *rest_config.RestMethodConfig, arg } else if kind == reflect.Int64 { param, err = strconv.ParseInt(req.QueryParameter(v), 10, 64) } else { - return perrors.Errorf("[Go restful] Query param parse error, the args:%v of type isn't int or string or slice", k) + return perrors.Errorf("[Go restful] Query param parse error, the index %v args's type isn't int or string or slice", k) } if err != nil { return perrors.Errorf("[Go restful] Query param parse error, error:%v", perrors.WithStack(err)) @@ -291,7 +294,7 @@ func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, args ) for k, v := range methodConfig.PathParamsMap { if k < 0 || k >= argsLength { - return perrors.Errorf("[Go restful] Path param parse error, the args:%v doesn't exist", k) + return perrors.Errorf("[Go restful] Path param parse error, the index %v args of method:%v doesn't exist", k, methodConfig.MethodName) } t := argsTypes[k] kind := t.Kind() @@ -310,7 +313,7 @@ func assembleArgsFromPathParams(methodConfig *rest_config.RestMethodConfig, args } else if kind == reflect.String { param = req.PathParameter(v) } else { - return perrors.Errorf("[Go restful] Path param parse error, the args:%v of type isn't int or string", k) + return perrors.Errorf("[Go restful] Path param parse error, the index %v args's type isn't int or string", k) } if err != nil { return perrors.Errorf("[Go restful] Path param parse error, error is %v", perrors.WithStack(err)) diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index 7f5e3538c8..c7d971fcaa 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -46,13 +46,13 @@ func init() { var filterSlice []restful.FilterFunction -// A rest server implement by go-restful +// GoRestfulServer a rest server implement by go-restful type GoRestfulServer struct { srv *http.Server container *restful.Container } -// A constructor of GoRestfulServer +// NewGoRestfulServer a constructor of GoRestfulServer func NewGoRestfulServer() server.RestServer { return &GoRestfulServer{} } From e151ab289f72115d502030303639012167c18d21 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Thu, 2 Apr 2020 17:33:21 +0800 Subject: [PATCH 036/167] Fix: bug of subscribe --- registry/etcdv3/registry.go | 4 +--- registry/kubernetes/registry.go | 5 +---- registry/zookeeper/registry.go | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index e1c2576811..ed310bddfe 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -164,9 +164,7 @@ func (r *etcdV3Registry) DoSubscribe(svc *common.URL) (registry.Listener, error) //register the svc to dataListener r.dataListener.AddInterestedURL(svc) - for _, v := range strings.Split(svc.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), ",") { - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+v, svc.Service()), r.dataListener) - } + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, svc.Service()), r.dataListener) return configListener, nil } diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go index 7212a83d63..ddb2ce8379 100644 --- a/registry/kubernetes/registry.go +++ b/registry/kubernetes/registry.go @@ -21,7 +21,6 @@ import ( "fmt" "os" "path" - "strings" "sync" "time" ) @@ -135,9 +134,7 @@ func (r *kubernetesRegistry) DoSubscribe(svc *common.URL) (registry.Listener, er //register the svc to dataListener r.dataListener.AddInterestedURL(svc) - for _, v := range strings.Split(svc.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), ",") { - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+v, svc.Service()), r.dataListener) - } + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, svc.Service()), r.dataListener) return configListener, nil } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index e13443d57d..21d0f49a2d 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -20,7 +20,6 @@ package zookeeper import ( "fmt" "net/url" - "strings" "sync" "time" ) @@ -217,9 +216,7 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen //Interested register to dataconfig. r.dataListener.AddInterestedURL(conf) - for _, v := range strings.Split(conf.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), ",") { - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+v, url.QueryEscape(conf.Service())), r.dataListener) - } + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, url.QueryEscape(conf.Service())), r.dataListener) return zkListener, nil } From 2bdbce5b4a9b5b73bef87c3b03c2a49960904c17 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Thu, 2 Apr 2020 20:37:52 +0800 Subject: [PATCH 037/167] Fix: bug of subscribe --- registry/etcdv3/registry.go | 2 +- registry/kubernetes/registry.go | 2 +- registry/zookeeper/registry.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index ed310bddfe..5d389c3637 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -164,7 +164,7 @@ func (r *etcdV3Registry) DoSubscribe(svc *common.URL) (registry.Listener, error) //register the svc to dataListener r.dataListener.AddInterestedURL(svc) - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, svc.Service()), r.dataListener) + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener) return configListener, nil } diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go index ddb2ce8379..8a02d0e3e6 100644 --- a/registry/kubernetes/registry.go +++ b/registry/kubernetes/registry.go @@ -134,7 +134,7 @@ func (r *kubernetesRegistry) DoSubscribe(svc *common.URL) (registry.Listener, er //register the svc to dataListener r.dataListener.AddInterestedURL(svc) - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, svc.Service()), r.dataListener) + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener) return configListener, nil } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 21d0f49a2d..4fd58e9e4d 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -216,7 +216,7 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen //Interested register to dataconfig. r.dataListener.AddInterestedURL(conf) - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.PROVIDER_PROTOCOL, url.QueryEscape(conf.Service())), r.dataListener) + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) return zkListener, nil } From 093026b62e1f71417fe68cd78c1e6fc5eed12708 Mon Sep 17 00:00:00 2001 From: flycash Date: Thu, 2 Apr 2020 22:40:34 +0800 Subject: [PATCH 038/167] Add comment --- common/extension/service_discovery.go | 8 +++++++- go.sum | 1 + registry/event.go | 3 +++ registry/nacos/base_registry.go | 2 ++ registry/nacos/registry.go | 1 + registry/nacos/service_discovery.go | 9 +++++++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go index 4398dec39a..25b80cf335 100644 --- a/common/extension/service_discovery.go +++ b/common/extension/service_discovery.go @@ -17,6 +17,9 @@ package extension +import ( + perrors "github.com/pkg/errors" +) import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/registry" @@ -26,14 +29,17 @@ var ( discoveryCreatorMap = make(map[string]func(url *common.URL) (registry.ServiceDiscovery, error), 4) ) +// SetServiceDiscovery will store the creator and name func SetServiceDiscovery(name string, creator func(url *common.URL) (registry.ServiceDiscovery, error)) { discoveryCreatorMap[name] = creator } +// GetServiceDiscovery will return the registry.ServiceDiscovery +// if not found, or initialize instance failed, it will return error. func GetServiceDiscovery(name string, url *common.URL) (registry.ServiceDiscovery, error) { creator, ok := discoveryCreatorMap[name] if !ok { - panic("Could not find the service discovery with name: " + name) + return nil, perrors.New("Could not find the service discovery with name: " + name) } return creator(url) } diff --git a/go.sum b/go.sum index ed0bb84d82..e499992eb0 100644 --- a/go.sum +++ b/go.sum @@ -387,6 +387,7 @@ 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/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb h1:lbmvw8r9W55w+aQgWn35W1nuleRIECMoqUrmwAOAvoI= github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= +github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c h1:WoCa3AvgQMVKNs+RIFlWPRgY9QVJwUxJDrGxHs0fcRo= github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= diff --git a/registry/event.go b/registry/event.go index da66ccb33d..be9f11d00b 100644 --- a/registry/event.go +++ b/registry/event.go @@ -42,6 +42,7 @@ type ServiceEvent struct { Service common.URL } +// String return the description of event func (e ServiceEvent) String() string { return fmt.Sprintf("ServiceEvent{Action{%s}, Path{%s}}", e.Action, e.Service) } @@ -91,10 +92,12 @@ type ServiceInstancesChangedEvent struct { Instances []ServiceInstance } +// String return the description of the event func (s *ServiceInstancesChangedEvent) String() string { return fmt.Sprintf("ServiceInstancesChangedEvent[source=%s]", s.ServiceName) } +// NewServiceInstancesChangedEvent will create the ServiceInstanceChangedEvent instance func NewServiceInstancesChangedEvent(serviceName string, instances []ServiceInstance) *ServiceInstancesChangedEvent { return &ServiceInstancesChangedEvent{ baseEvent: baseEvent{ diff --git a/registry/nacos/base_registry.go b/registry/nacos/base_registry.go index a92df4cdc2..bd5dc86b43 100644 --- a/registry/nacos/base_registry.go +++ b/registry/nacos/base_registry.go @@ -43,6 +43,7 @@ type baseRegistry struct { namingClient naming_client.INamingClient } +// newBaseRegistry will create new instance func newBaseRegistry(url *common.URL) (baseRegistry, error) { nacosConfig, err := getNacosConfig(url) if err != nil { @@ -59,6 +60,7 @@ func newBaseRegistry(url *common.URL) (baseRegistry, error) { return registry, nil } +// getNacosConfig will return the nacos config func getNacosConfig(url *common.URL) (map[string]interface{}, error) { if url == nil { return nil, perrors.New("url is empty!") diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 697cbbeb83..b0f399862a 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -56,6 +56,7 @@ type nacosRegistry struct { baseRegistry } +// newNacosRegistry will create an instance func newNacosRegistry(url *common.URL) (registry.Registry, error) { base, err := newBaseRegistry(url) if err != nil { diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 5a730e935d..b89d4f611b 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -38,6 +38,7 @@ const ( idKey = "id" ) +// init will put the service discovery into extension func init() { extension.SetServiceDiscovery(constant.NACOS_KEY, newNacosServiceDiscovery) } @@ -224,19 +225,24 @@ func (n *nacosServiceDiscovery) AddListener(listener *registry.ServiceInstancesC }) } +// 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 { // TODO(waiting for event dispatcher, another task) return nil } +// toRegisterInstance convert the ServiceInstance to RegisterInstanceParam +// the Ephemeral will be true func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInstance) vo.RegisterInstanceParam { metadata := instance.GetMetadata() if metadata == nil { @@ -255,6 +261,7 @@ func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInst } } +// toDeregisterInstance will convert the ServiceInstance to DeregisterInstanceParam func (n *nacosServiceDiscovery) toDeregisterInstance(instance registry.ServiceInstance) vo.DeregisterInstanceParam { return vo.DeregisterInstanceParam{ ServiceName: instance.GetServiceName(), @@ -264,7 +271,9 @@ func (n *nacosServiceDiscovery) toDeregisterInstance(instance registry.ServiceIn } } +// toDeregisterInstance will create new service discovery instance func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) { + base, err := newBaseRegistry(url) if err != nil { return nil, perrors.WithStack(err) From 487c8b789f24aaa6c033aac1e0b3b830900ad8ad Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Thu, 2 Apr 2020 23:20:02 +0800 Subject: [PATCH 039/167] Mod: README.md --- README.md | 2 ++ README_CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 75f5406857..5c4de0559d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Apache License, Version 2.0 ## Release note ## +[v1.4.0-rc1 - Mar 12, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1) + [v1.3.0 - Mar 1, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.3.0) [v1.2.0 - Nov 15, 2019](https://github.com/apache/dubbo-go/releases/tag/v1.2.0) diff --git a/README_CN.md b/README_CN.md index bcb3883593..5dec68fd61 100644 --- a/README_CN.md +++ b/README_CN.md @@ -15,6 +15,8 @@ Apache License, Version 2.0 ## 发布日志 ## +[v1.4.0-rc1 - 2020年3月12日](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1) + [v1.3.0 - 2020年3月1日](https://github.com/apache/dubbo-go/releases/tag/v1.3.0) [v1.2.0 - 2019年11月15日](https://github.com/apache/dubbo-go/releases/tag/v1.2.0) From 7a5b916b259953c6feda791a37b5aa6761952bd2 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sat, 4 Apr 2020 18:33:01 +0800 Subject: [PATCH 040/167] optimized code --- protocol/rest/server/rest_server.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index 60a75bc279..fbd6fb7ad9 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -160,11 +160,10 @@ func getArgsInterfaceFromRequest(req RestServerRequest, methodConfig *rest_confi } m := make(map[string]interface{}) // TODO read as a slice - if err := req.ReadEntity(&m); err == nil { - argsMap[methodConfig.Body] = m - } else { + if err := req.ReadEntity(&m); err != nil { return nil, perrors.Errorf("[Go restful] Read body entity as map[string]interface{} error:%v", err) } + argsMap[methodConfig.Body] = m } args := make([]interface{}, maxKey+1) for k, v := range argsMap { @@ -236,11 +235,10 @@ func assembleArgsFromBody(methodConfig *rest_config.RestMethodConfig, argsTypes ni = n.Interface() } } - if err := req.ReadEntity(&ni); err == nil { - args[methodConfig.Body] = ni - } else { + if err := req.ReadEntity(&ni); err != nil { return perrors.Errorf("[Go restful] Read body entity error, error is %v", perrors.WithStack(err)) } + args[methodConfig.Body] = ni } return nil } From 183b70afa7bc53ad5d2e417cc209b69c1cfcb08e Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 6 Apr 2020 22:04:12 +0800 Subject: [PATCH 041/167] remove the category --- config/service_config.go | 1 - 1 file changed, 1 deletion(-) diff --git a/config/service_config.go b/config/service_config.go index d8b155102c..50bf5e12c3 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -196,7 +196,6 @@ func (c *ServiceConfig) getUrlMap() url.Values { 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.CATEGORY_KEY, (common.RoleType(common.PROVIDER)).String()) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) From 57c58d81838242eedc60d509c7601b3f0bf4ac9e Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 6 Apr 2020 22:17:26 +0800 Subject: [PATCH 042/167] remove the reference url category --- config/reference_config.go | 1 - config/service_config.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/config/reference_config.go b/config/reference_config.go index b9f3da1352..dcdba95805 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -188,7 +188,6 @@ func (c *ReferenceConfig) getUrlMap() url.Values { 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.CATEGORY_KEY, (common.RoleType(common.CONSUMER)).String()) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) diff --git a/config/service_config.go b/config/service_config.go index 50bf5e12c3..d8b155102c 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -196,6 +196,7 @@ func (c *ServiceConfig) getUrlMap() url.Values { 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.CATEGORY_KEY, (common.RoleType(common.PROVIDER)).String()) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) From 64d87515eb7a3d2e6dcb0c6f9f938012a7807afa Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Tue, 7 Apr 2020 14:45:19 +0800 Subject: [PATCH 043/167] Fix: remove category key --- config/reference_config.go | 1 - config/service_config.go | 1 - 2 files changed, 2 deletions(-) diff --git a/config/reference_config.go b/config/reference_config.go index b9f3da1352..dcdba95805 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -188,7 +188,6 @@ func (c *ReferenceConfig) getUrlMap() url.Values { 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.CATEGORY_KEY, (common.RoleType(common.CONSUMER)).String()) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) diff --git a/config/service_config.go b/config/service_config.go index d8b155102c..50bf5e12c3 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -196,7 +196,6 @@ func (c *ServiceConfig) getUrlMap() url.Values { 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.CATEGORY_KEY, (common.RoleType(common.PROVIDER)).String()) urlMap.Set(constant.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.PROVIDER)).Role()) From e10ef06a80bc19c24f0213caad0d38996220c2d0 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 17 Mar 2020 22:18:15 +0800 Subject: [PATCH 044/167] Modify registryProtocol as a singleton to fix graceful shutdown --- registry/protocol/protocol.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index a7678ba4e2..4976d34ecc 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -44,7 +44,7 @@ import ( ) var ( - regProtocol *registryProtocol + regProtocol = newRegistryProtocol() ) type registryProtocol struct { @@ -348,10 +348,7 @@ func setProviderUrl(regURL *common.URL, providerURL *common.URL) { // GetProtocol ... func GetProtocol() protocol.Protocol { - if regProtocol != nil { - return regProtocol - } - return newRegistryProtocol() + return regProtocol } type wrappedInvoker struct { From d3f3af065c69a79b702e60b2b696fb913794a9b0 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Fri, 20 Mar 2020 15:03:50 +0800 Subject: [PATCH 045/167] fix notification confusion caused by multiple references sharing the same zk listener --- registry/zookeeper/listener.go | 28 +++++++++++++-------- registry/zookeeper/listener_test.go | 8 +++--- registry/zookeeper/registry.go | 39 +++++++++++------------------ 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index bef1760e04..d2adc44d39 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -37,18 +37,19 @@ import ( // RegistryDataListener ... type RegistryDataListener struct { - interestedURL []*common.URL - listener config_center.ConfigurationListener + subscribed map[*common.URL]config_center.ConfigurationListener + listener config_center.ConfigurationListener } // NewRegistryDataListener ... -func NewRegistryDataListener(listener config_center.ConfigurationListener) *RegistryDataListener { - return &RegistryDataListener{listener: listener} +func NewRegistryDataListener() *RegistryDataListener { + return &RegistryDataListener{ + subscribed: make(map[*common.URL]config_center.ConfigurationListener)} } -// AddInterestedURL ... -func (l *RegistryDataListener) AddInterestedURL(url *common.URL) { - l.interestedURL = append(l.interestedURL, url) +// SubscribeURL is used to set a watch listener for url +func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_center.ConfigurationListener) { + l.subscribed[url] = listener } // DataChange ... @@ -65,10 +66,9 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { logger.Errorf("Listen NewURL(r{%s}) = error{%v} eventType.Path={%v}", url, err, eventType.Path) return false } - - for _, v := range l.interestedURL { - if serviceURL.URLEqual(*v) { - l.listener.Process( + for url, listener := range l.subscribed { + if serviceURL.URLEqual(*url) { + listener.Process( &config_center.ConfigChangeEvent{ Key: eventType.Path, Value: serviceURL, @@ -81,6 +81,12 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { return false } +func (l *RegistryDataListener) Close(){ + for _, listener := range l.subscribed { + listener.(*RegistryConfigurationListener).Close() + } +} + // RegistryConfigurationListener ... type RegistryConfigurationListener struct { client *zk.ZookeeperClient diff --git a/registry/zookeeper/listener_test.go b/registry/zookeeper/listener_test.go index 1a76b29a6f..a0e9147a9e 100644 --- a/registry/zookeeper/listener_test.go +++ b/registry/zookeeper/listener_test.go @@ -32,15 +32,15 @@ import ( ) func Test_DataChange(t *testing.T) { - listener := NewRegistryDataListener(&MockDataListener{}) + 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.AddInterestedURL(&url) + 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 MockDataListener struct { +type MockConfigurationListener struct { } -func (*MockDataListener) Process(configType *config_center.ConfigChangeEvent) { +func (*MockConfigurationListener) Process(configType *config_center.ConfigChangeEvent) { } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 4fd58e9e4d..7c776aeedd 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -20,6 +20,7 @@ package zookeeper import ( "fmt" "net/url" + "strings" "sync" "time" ) @@ -53,12 +54,11 @@ func init() { type zkRegistry struct { registry.BaseRegistry - client *zookeeper.ZookeeperClient - listenerLock sync.Mutex - listener *zookeeper.ZkEventListener - dataListener *RegistryDataListener - configListener *RegistryConfigurationListener - cltLock sync.Mutex + client *zookeeper.ZookeeperClient + listenerLock sync.Mutex + listener *zookeeper.ZkEventListener + dataListener *RegistryDataListener + cltLock sync.Mutex //for provider zkPath map[string]int // key = protocol://ip:port/interface } @@ -82,8 +82,8 @@ func newZkRegistry(url *common.URL) (registry.Registry, error) { go zookeeper.HandleClientRestart(r) r.listener = zookeeper.NewZkEventListener(r.client) - r.configListener = NewRegistryConfigurationListener(r.client, r) - r.dataListener = NewRegistryDataListener(r.configListener) + + r.dataListener = NewRegistryDataListener() return r, nil } @@ -120,8 +120,7 @@ func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestClust func (r *zkRegistry) InitListeners() { r.listener = zookeeper.NewZkEventListener(r.client) - r.configListener = NewRegistryConfigurationListener(r.client, r) - r.dataListener = NewRegistryDataListener(r.configListener) + r.dataListener = NewRegistryDataListener() } func (r *zkRegistry) CreatePath(path string) error { @@ -154,8 +153,8 @@ func (r *zkRegistry) ZkClientLock() *sync.Mutex { } func (r *zkRegistry) CloseListener() { - if r.configListener != nil { - r.configListener.Close() + if r.dataListener != nil { + r.dataListener.Close() } } @@ -187,17 +186,7 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { } func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListener, error) { - var ( - zkListener *RegistryConfigurationListener - ) - - r.listenerLock.Lock() - if r.configListener.isClosed { - r.listenerLock.Unlock() - return nil, perrors.New("configListener already been closed") - } - zkListener = r.configListener - r.listenerLock.Unlock() + zkListener := NewRegistryConfigurationListener(r.client, r) if r.listener == nil { r.cltLock.Lock() client := r.client @@ -215,8 +204,10 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen } //Interested register to dataconfig. - r.dataListener.AddInterestedURL(conf) + r.dataListener.SubscribeURL(conf, zkListener) + go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) + return zkListener, nil } From db27238e2b1a0dc0a66d7b3162c02a6d2b86c927 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Fri, 20 Mar 2020 16:32:59 +0800 Subject: [PATCH 046/167] fix fmt failure --- registry/zookeeper/listener.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index d2adc44d39..6bb8a932db 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -81,7 +81,7 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { return false } -func (l *RegistryDataListener) Close(){ +func (l *RegistryDataListener) Close() { for _, listener := range l.subscribed { listener.(*RegistryConfigurationListener).Close() } From 5e99201f6c01b2fde524b200de91f526372c7d4c Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Sun, 22 Mar 2020 20:14:39 +0800 Subject: [PATCH 047/167] use the once.do to init the registryprotocol --- registry/protocol/protocol.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 4976d34ecc..0ffeb3ef7e 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -44,7 +44,8 @@ import ( ) var ( - regProtocol = newRegistryProtocol() + regProtocol *registryProtocol + once sync.Once ) type registryProtocol struct { @@ -348,6 +349,9 @@ func setProviderUrl(regURL *common.URL, providerURL *common.URL) { // GetProtocol ... func GetProtocol() protocol.Protocol { + once.Do(func() { + regProtocol = newRegistryProtocol() + }) return regProtocol } From 8588bdab8a7812d4d26656810cc60ee779fd43f3 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Sun, 22 Mar 2020 20:15:05 +0800 Subject: [PATCH 048/167] use the once.do to init the registryprotocol --- registry/protocol/protocol.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 0ffeb3ef7e..c8b019bd4c 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -45,7 +45,7 @@ import ( var ( regProtocol *registryProtocol - once sync.Once + once sync.Once ) type registryProtocol struct { From 7a17cab2ac0ca6458bb1368600a4611e9e233f9d Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Mon, 23 Mar 2020 15:54:05 +0800 Subject: [PATCH 049/167] add mutex when use subscribed map --- registry/zookeeper/listener.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 6bb8a932db..5f398047a6 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -39,6 +39,8 @@ import ( type RegistryDataListener struct { subscribed map[*common.URL]config_center.ConfigurationListener listener config_center.ConfigurationListener + mutex sync.Mutex + closed bool } // NewRegistryDataListener ... @@ -49,6 +51,11 @@ func NewRegistryDataListener() *RegistryDataListener { // SubscribeURL is used to set a watch listener for url func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_center.ConfigurationListener) { + l.mutex.Lock() + defer l.mutex.Unlock() + if l.closed { + return + } l.subscribed[url] = listener } @@ -66,6 +73,11 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { logger.Errorf("Listen NewURL(r{%s}) = error{%v} eventType.Path={%v}", url, err, eventType.Path) return false } + l.mutex.Lock() + defer l.mutex.Unlock() + if l.closed { + return false + } for url, listener := range l.subscribed { if serviceURL.URLEqual(*url) { listener.Process( @@ -82,6 +94,8 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { } func (l *RegistryDataListener) Close() { + l.mutex.Lock() + defer l.mutex.Unlock() for _, listener := range l.subscribed { listener.(*RegistryConfigurationListener).Close() } From 43972d9381353f345515546e70f6838b6c3e9396 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 13:04:14 +0800 Subject: [PATCH 050/167] fix comments --- registry/zookeeper/registry.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 7c776aeedd..bfbb71d53c 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -186,7 +186,17 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { } func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListener, error) { - zkListener := NewRegistryConfigurationListener(r.client, r) + + var zkListener *RegistryConfigurationListener + if r.dataListener.subscribed[conf] != nil { + + zkListener, err := r.dataListener.subscribed[conf].(*RegistryConfigurationListener) + if err != nil && zkListener.isClosed { + return nil, perrors.New("zk connection broken") + } + } + + zkListener = NewRegistryConfigurationListener(r.client, r) if r.listener == nil { r.cltLock.Lock() client := r.client From 2d14439ed5d499580c042439fa1a8e9a93446161 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 13:12:23 +0800 Subject: [PATCH 051/167] fix comments --- registry/zookeeper/registry.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index bfbb71d53c..895242afc5 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -190,9 +190,11 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen var zkListener *RegistryConfigurationListener if r.dataListener.subscribed[conf] != nil { - zkListener, err := r.dataListener.subscribed[conf].(*RegistryConfigurationListener) - if err != nil && zkListener.isClosed { - return nil, perrors.New("zk connection broken") + zkListener, _ := r.dataListener.subscribed[conf].(*RegistryConfigurationListener) + r.listenerLock.Lock() + if zkListener.isClosed { + r.listenerLock.Unlock() + return nil, perrors.New("configListener already been closed") } } @@ -219,5 +221,6 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) + return zkListener, nil } From 319ca56270465de1e632fc9e45aee802c3415ac0 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 13:18:42 +0800 Subject: [PATCH 052/167] fix comments --- registry/zookeeper/registry.go | 1 + 1 file changed, 1 insertion(+) diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 895242afc5..9a59d81162 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -120,6 +120,7 @@ func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestClust func (r *zkRegistry) InitListeners() { r.listener = zookeeper.NewZkEventListener(r.client) + r.dataListener = NewRegistryDataListener() } From 52354fba2517c5ee4f6244c39c6e0ba0ac5d0e49 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 14:51:32 +0800 Subject: [PATCH 053/167] fix the zk HandleClientRestart issues --- registry/base_registry.go | 5 ++++- registry/zookeeper/listener.go | 1 - registry/zookeeper/registry.go | 14 +++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/registry/base_registry.go b/registry/base_registry.go index 04694da25a..cfc8f39bbc 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -178,7 +178,10 @@ func (r *BaseRegistry) RestartCallBack() bool { } logger.Infof("success to re-register service :%v", confIf.Key()) } - r.facadeBasedRegistry.InitListeners() + + if flag { + r.facadeBasedRegistry.InitListeners() + } return flag } diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 5f398047a6..45ffa31722 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -38,7 +38,6 @@ import ( // RegistryDataListener ... type RegistryDataListener struct { subscribed map[*common.URL]config_center.ConfigurationListener - listener config_center.ConfigurationListener mutex sync.Mutex closed bool } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 9a59d81162..37cf20149d 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -120,8 +120,12 @@ func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestClust func (r *zkRegistry) InitListeners() { r.listener = zookeeper.NewZkEventListener(r.client) - - r.dataListener = NewRegistryDataListener() + recoverd := r.dataListener.subscribed + newDataListener := NewRegistryDataListener() + for url, _ := range recoverd { + newDataListener.SubscribeURL(url, NewRegistryConfigurationListener(r.client, r)) + } + r.dataListener = newDataListener } func (r *zkRegistry) CreatePath(path string) error { @@ -174,8 +178,9 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { } zkPath, err = r.client.RegisterTemp(root, node) if err != nil { - if err == zk.ErrNodeExists { - logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + if perrors.Cause(err) == zk.ErrNodeExists { + logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}, ignore!", root, node, perrors.WithStack(err)) + return nil } else { logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) } @@ -222,6 +227,5 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) - return zkListener, nil } From 9657b397091c588e5ced3b66f30db4ccb8f07e44 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 16:37:23 +0800 Subject: [PATCH 054/167] change some comments --- registry/protocol/protocol.go | 2 +- registry/zookeeper/listener.go | 17 +++++++++-------- registry/zookeeper/registry.go | 12 +++++++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index c8b019bd4c..b47b9f372d 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -347,7 +347,7 @@ func setProviderUrl(regURL *common.URL, providerURL *common.URL) { regURL.SubURL = providerURL } -// GetProtocol ... +// GetProtocol return the singleton RegistryProtocol func GetProtocol() protocol.Protocol { once.Do(func() { regProtocol = newRegistryProtocol() diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 45ffa31722..355e7c18f5 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -35,14 +35,14 @@ import ( zk "github.com/apache/dubbo-go/remoting/zookeeper" ) -// RegistryDataListener ... +// RegistryDataListener contains all URL information subscribed by zookeeper registry type RegistryDataListener struct { subscribed map[*common.URL]config_center.ConfigurationListener mutex sync.Mutex closed bool } -// NewRegistryDataListener ... +// NewRegistryDataListener constructs a new RegistryDataListener func NewRegistryDataListener() *RegistryDataListener { return &RegistryDataListener{ subscribed: make(map[*common.URL]config_center.ConfigurationListener)} @@ -58,7 +58,7 @@ func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_cen l.subscribed[url] = listener } -// DataChange ... +// DataChange accepts all events sent from the zookeeper server and trigger the corresponding listener for processing func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { // Intercept the last bit index := strings.Index(eventType.Path, "/providers/") @@ -92,6 +92,7 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { return false } +// Close all RegistryConfigurationListener in subscribed func (l *RegistryDataListener) Close() { l.mutex.Lock() defer l.mutex.Unlock() @@ -100,7 +101,7 @@ func (l *RegistryDataListener) Close() { } } -// RegistryConfigurationListener ... +// RegistryConfigurationListener represent the processor of zookeeper watcher type RegistryConfigurationListener struct { client *zk.ZookeeperClient registry *zkRegistry @@ -115,12 +116,12 @@ func NewRegistryConfigurationListener(client *zk.ZookeeperClient, reg *zkRegistr return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32), isClosed: false} } -// Process ... +// Process submit the ConfigChangeEvent to the event chan to notify all observer func (l *RegistryConfigurationListener) Process(configType *config_center.ConfigChangeEvent) { l.events <- configType } -// Next ... +// Next will observe the registry state and events chan func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) { for { select { @@ -146,7 +147,7 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) { } } -// Close ... +// Close RegistryConfigurationListener only once func (l *RegistryConfigurationListener) Close() { // ensure that the listener will be closed at most once. l.closeOnce.Do(func() { @@ -154,7 +155,7 @@ func (l *RegistryConfigurationListener) Close() { l.registry.WaitGroup().Done() }) } - +// valid return the true if the client conn isn't nil func (l *RegistryConfigurationListener) valid() bool { return l.client.ZkConnValid() } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 37cf20149d..9d74aa9d6e 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -120,10 +120,16 @@ func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestClust func (r *zkRegistry) InitListeners() { r.listener = zookeeper.NewZkEventListener(r.client) - recoverd := r.dataListener.subscribed newDataListener := NewRegistryDataListener() - for url, _ := range recoverd { - newDataListener.SubscribeURL(url, NewRegistryConfigurationListener(r.client, r)) + // should recover if dataListener isn't nil before + if r.dataListener != nil { + recoverd := r.dataListener.subscribed + if recoverd != nil && len(recoverd) > 0 { + // recover all subscribed url + for url, _ := range recoverd { + newDataListener.SubscribeURL(url, NewRegistryConfigurationListener(r.client, r)) + } + } } r.dataListener = newDataListener } From c808d5ce2f3f6927e9f0944e692c79607c33d53e Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Tue, 31 Mar 2020 16:37:32 +0800 Subject: [PATCH 055/167] change some comments --- registry/zookeeper/listener.go | 1 + registry/zookeeper/registry.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 355e7c18f5..54edd9cc12 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -155,6 +155,7 @@ func (l *RegistryConfigurationListener) Close() { l.registry.WaitGroup().Done() }) } + // valid return the true if the client conn isn't nil func (l *RegistryConfigurationListener) valid() bool { return l.client.ZkConnValid() diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 9d74aa9d6e..8682806d0a 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -232,6 +232,5 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) - return zkListener, nil } From 774bd0116b57e7baffcddafa14b8c6b832bfa7b7 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Fri, 3 Apr 2020 11:30:33 +0800 Subject: [PATCH 056/167] remove unused import --- registry/zookeeper/registry.go | 1 - 1 file changed, 1 deletion(-) diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 8682806d0a..1e4a6d43b3 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -20,7 +20,6 @@ package zookeeper import ( "fmt" "net/url" - "strings" "sync" "time" ) From 68cc420d47e278830c5ec8fc97d0022652559375 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Fri, 3 Apr 2020 19:57:19 +0800 Subject: [PATCH 057/167] remove consumer category in referenceConfig --- config/reference_config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/reference_config.go b/config/reference_config.go index dcdba95805..3710cbc4bc 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -188,6 +188,7 @@ func (c *ReferenceConfig) getUrlMap() url.Values { 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.RELEASE_KEY, "dubbo-golang-"+constant.Version) urlMap.Set(constant.SIDE_KEY, (common.RoleType(common.CONSUMER)).Role()) From ff0f37633f8aef062b195c600feaae52526bb3d2 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Sun, 5 Apr 2020 22:55:34 +0800 Subject: [PATCH 058/167] fix not delete the node when shutdown gracefully and compare the path when subscribe the providers --- common/rpc_service.go | 4 ++- registry/base_registry.go | 5 +++ registry/zookeeper/listener.go | 10 +++--- registry/zookeeper/registry.go | 49 +++++++++++++++++++++-------- remoting/zookeeper/client.go | 12 +++++-- remoting/zookeeper/facade.go | 4 ++- remoting/zookeeper/listener.go | 22 +++++++++---- remoting/zookeeper/listener_test.go | 2 +- 8 files changed, 80 insertions(+), 28 deletions(-) diff --git a/common/rpc_service.go b/common/rpc_service.go index b138b4f300..ebd1d02f84 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -274,7 +274,9 @@ func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) erro } } delete(svcs, serviceId) - delete(sm.serviceMap, protocol) + if len(sm.serviceMap) == 0 { + delete(sm.serviceMap, protocol) + } return nil } diff --git a/registry/base_registry.go b/registry/base_registry.go index cfc8f39bbc..8e13a522c4 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -117,10 +117,15 @@ func (r *BaseRegistry) GetUrl() common.URL { func (r *BaseRegistry) Destroy() { //first step close registry's all listeners r.facadeBasedRegistry.CloseListener() + logger.Info("1---") // then close r.done to notify other program who listen to it close(r.done) + logger.Info("2---") + // wait waitgroup done (wait listeners outside close over) r.wg.Wait() + logger.Info("3---") + //close registry client r.closeRegisters() } diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 54edd9cc12..63c8d37a43 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -50,8 +50,6 @@ func NewRegistryDataListener() *RegistryDataListener { // SubscribeURL is used to set a watch listener for url func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_center.ConfigurationListener) { - l.mutex.Lock() - defer l.mutex.Unlock() if l.closed { return } @@ -95,6 +93,7 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { // Close all RegistryConfigurationListener in subscribed func (l *RegistryDataListener) Close() { l.mutex.Lock() + logger.Info("Close all reg") defer l.mutex.Unlock() for _, listener := range l.subscribed { listener.(*RegistryConfigurationListener).Close() @@ -107,13 +106,14 @@ type RegistryConfigurationListener struct { registry *zkRegistry events chan *config_center.ConfigChangeEvent isClosed bool + close chan struct{} closeOnce sync.Once } // NewRegistryConfigurationListener for listening the event of zk. func NewRegistryConfigurationListener(client *zk.ZookeeperClient, reg *zkRegistry) *RegistryConfigurationListener { reg.WaitGroup().Add(1) - return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32), isClosed: false} + return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32), isClosed: false, close: make(chan struct{}, 1)} } // Process submit the ConfigChangeEvent to the event chan to notify all observer @@ -129,10 +129,11 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) { logger.Warnf("listener's zk client connection is broken, so zk event listener exit now.") return nil, perrors.New("listener stopped") + case <-l.close: + return nil, perrors.New("listener closed") case <-l.registry.Done(): logger.Warnf("zk consumer register has quit, so zk event listener exit now.") return nil, perrors.New("listener stopped") - case e := <-l.events: logger.Debugf("got zk event %s", e) if e.ConfigType == remoting.EventTypeDel && !l.valid() { @@ -152,6 +153,7 @@ func (l *RegistryConfigurationListener) Close() { // ensure that the listener will be closed at most once. l.closeOnce.Do(func() { l.isClosed = true + l.close <- struct{}{} l.registry.WaitGroup().Done() }) } diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 1e4a6d43b3..3ab841b899 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -76,7 +76,6 @@ func newZkRegistry(url *common.URL) (registry.Registry, error) { if err != nil { return nil, err } - r.WaitGroup().Add(1) //zk client start successful, then wg +1 go zookeeper.HandleClientRestart(r) @@ -122,11 +121,20 @@ func (r *zkRegistry) InitListeners() { newDataListener := NewRegistryDataListener() // should recover if dataListener isn't nil before if r.dataListener != nil { + // close all old listener + oldDataListener := r.dataListener + oldDataListener.mutex.Lock() + defer oldDataListener.mutex.Unlock() recoverd := r.dataListener.subscribed if recoverd != nil && len(recoverd) > 0 { // recover all subscribed url - for url, _ := range recoverd { - newDataListener.SubscribeURL(url, NewRegistryConfigurationListener(r.client, r)) + for conf, oldListener := range recoverd { + if regConfigListener, ok := oldListener.(*RegistryConfigurationListener); ok { + regConfigListener.Close() + } + newDataListener.SubscribeURL(conf, NewRegistryConfigurationListener(r.client, r)) + go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), newDataListener) + } } } @@ -146,6 +154,7 @@ func (r *zkRegistry) DoSubscribe(conf *common.URL) (registry.Listener, error) { } func (r *zkRegistry) CloseAndNilClient() { + logger.Info("c") r.client.Close() r.client = nil } @@ -181,17 +190,24 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { logger.Errorf("zk.Create(root{%s}) = err{%v}", root, perrors.WithStack(err)) return perrors.WithStack(err) } + + // try to register the node zkPath, err = r.client.RegisterTemp(root, node) if err != nil { + logger.Errorf("Register temp node(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) if perrors.Cause(err) == zk.ErrNodeExists { - logger.Warnf("RegisterTempNode(root{%s}, node{%s}) = error{%v}, ignore!", root, node, perrors.WithStack(err)) - return nil - } else { - logger.Errorf("RegisterTempNode(root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + // should delete the old node + logger.Info("Register temp node failed, try to delete the old and recreate (root{%s}, node{%s}) , ignore!", root, node) + if err = r.client.Delete(zkPath); err == nil { + _, err = r.client.RegisterTemp(root, node) + } + if err != nil { + logger.Errorf("Recreate the temp node failed, (root{%s}, node{%s}) = error{%v}", root, node, perrors.WithStack(err)) + } } return perrors.WithMessagef(err, "RegisterTempNode(root{%s}, node{%s})", root, node) } - logger.Debugf("create a zookeeper node:%s", zkPath) + logger.Debugf("Create a zookeeper node:%s", zkPath) return nil } @@ -199,13 +215,20 @@ func (r *zkRegistry) registerTempZookeeperNode(root string, node string) error { func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListener, error) { var zkListener *RegistryConfigurationListener + dataListener := r.dataListener + dataListener.mutex.Lock() + defer dataListener.mutex.Unlock() if r.dataListener.subscribed[conf] != nil { zkListener, _ := r.dataListener.subscribed[conf].(*RegistryConfigurationListener) - r.listenerLock.Lock() - if zkListener.isClosed { - r.listenerLock.Unlock() - return nil, perrors.New("configListener already been closed") + if zkListener != nil { + r.listenerLock.Lock() + defer r.listenerLock.Unlock() + if zkListener.isClosed { + return nil, perrors.New("configListener already been closed") + } else { + return zkListener, nil + } } } @@ -229,7 +252,7 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen //Interested register to dataconfig. r.dataListener.SubscribeURL(conf, zkListener) - go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) + go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener) return zkListener, nil } diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 21486aab59..39812841d7 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -118,7 +118,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { for _, opt := range opts { opt(opions) } - + connected := false err = nil lock := container.ZkClientLock() @@ -143,6 +143,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.Location) } container.SetZkClient(newClient) + connected = true } if container.ZkClient().Conn == nil { @@ -150,10 +151,16 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { container.ZkClient().Conn, event, err = zk.Connect(container.ZkClient().ZkAddrs, container.ZkClient().Timeout) if err == nil { container.ZkClient().Wait.Add(1) + connected = true go container.ZkClient().HandleZkEvent(event) } } + if connected { + logger.Info("sdsds") + container.WaitGroup().Add(1) //zk client start successful, then registry wg +1 + } + return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.PrimitiveURL) } @@ -386,6 +393,7 @@ func (z *ZookeeperClient) Close() { z.Conn = nil z.Unlock() if conn != nil { + logger.Warnf("zkClient Conn{name:%s, zk addr:%s} exit now.", z.name, conn.SessionID()) conn.Close() } @@ -462,7 +470,7 @@ func (z *ZookeeperClient) RegisterTemp(basePath string, node string) (string, er //if err != nil && err != zk.ErrNodeExists { if err != nil { logger.Warnf("conn.Create(\"%s\", zk.FlagEphemeral) = error(%v)\n", zkPath, perrors.WithStack(err)) - return "", perrors.WithStack(err) + return zkPath, perrors.WithStack(err) } logger.Debugf("zkClient{%s} create a temp zookeeper node:%s\n", z.name, tmpPath) diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go index 055db4f716..4e3945388f 100644 --- a/remoting/zookeeper/facade.go +++ b/remoting/zookeeper/facade.go @@ -48,11 +48,11 @@ func HandleClientRestart(r zkClientFacade) { failTimes int ) - defer r.WaitGroup().Done() LOOP: for { select { case <-r.Done(): + r.WaitGroup().Done() // dec the wg when registry is closed logger.Warnf("(ZkProviderRegistry)reconnectZkRegistry goroutine exit now...") break LOOP // re-register all services @@ -63,12 +63,14 @@ LOOP: zkAddress := r.ZkClient().ZkAddrs r.SetZkClient(nil) r.ZkClientLock().Unlock() + r.WaitGroup().Done() // dec the wg when zk client is closed // Connect zk until success. failTimes = 0 for { select { case <-r.Done(): + r.WaitGroup().Done() // dec the wg when registry is closed logger.Warnf("(ZkProviderRegistry)reconnectZkRegistry goroutine exit now...") break LOOP case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // Prevent crazy reconnection zk. diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index eaf259f441..8487766776 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -18,6 +18,7 @@ package zookeeper import ( + "github.com/apache/dubbo-go/common" "path" "strings" "sync" @@ -173,7 +174,7 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li } } -func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataListener) { +func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listener remoting.DataListener) { defer l.wg.Done() var ( @@ -224,7 +225,16 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi } failTimes = 0 for _, c := range children { - // listen l service node + + // Only need to compare Path when subscribing to provider + if strings.LastIndex(zkPath, constant.PROVIDER_CATEGORY) != -1 { + provider, _ := common.NewURL(c) + if provider.Path != conf.Path { + continue + } + } + + //listen l service node dubboPath := path.Join(zkPath, c) //Save the path to avoid listen repeatedly @@ -232,7 +242,7 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi _, ok := l.pathMap[dubboPath] l.pathMapLock.Unlock() if ok { - logger.Warnf("@zkPath %s has already been listened.", zkPath) + logger.Warnf("@zkPath %s has already been listened.", dubboPath) continue } @@ -263,7 +273,7 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi strings.LastIndex(zkPath, constant.CONSUMER_CATEGORY) == -1 { l.wg.Add(1) go func(zkPath string, listener remoting.DataListener) { - l.listenDirEvent(zkPath, listener) + l.listenDirEvent(conf, zkPath, listener) logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath) }(dubboPath, listener) } @@ -291,11 +301,11 @@ func timeSecondDuration(sec int) time.Duration { // registry.go:Listen -> listenServiceEvent -> listenDirEvent -> ListenServiceNodeEvent // | // --------> ListenServiceNodeEvent -func (l *ZkEventListener) ListenServiceEvent(zkPath string, listener remoting.DataListener) { +func (l *ZkEventListener) ListenServiceEvent(conf *common.URL, zkPath string, listener remoting.DataListener) { logger.Infof("listen dubbo path{%s}", zkPath) l.wg.Add(1) go func(zkPath string, listener remoting.DataListener) { - l.listenDirEvent(zkPath, listener) + l.listenDirEvent(conf, zkPath, listener) logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath) }(zkPath, listener) } diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go index 7301cd52c3..ba7d6ba81b 100644 --- a/remoting/zookeeper/listener_test.go +++ b/remoting/zookeeper/listener_test.go @@ -97,7 +97,7 @@ func TestListener(t *testing.T) { go client.HandleZkEvent(event) listener := NewZkEventListener(client) dataListener := &mockDataListener{client: client, changedData: changedData, wait: &wait} - listener.ListenServiceEvent("/dubbo", dataListener) + listener.ListenServiceEvent(nil, "/dubbo", dataListener) time.Sleep(1 * time.Second) _, err := client.Conn.Set("/dubbo/dubbo.properties", []byte(changedData), 1) assert.NoError(t, err) From a530ed5c64a4f43169a80cef587c0e18143adb90 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Mon, 6 Apr 2020 11:54:07 +0800 Subject: [PATCH 059/167] rm debug logs and fix ut --- registry/base_registry.go | 4 ---- registry/zookeeper/listener.go | 12 +++++------- registry/zookeeper/registry.go | 1 - remoting/zookeeper/client.go | 2 +- remoting/zookeeper/facade_test.go | 12 +++++++++++- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/registry/base_registry.go b/registry/base_registry.go index 8e13a522c4..3e1bddf233 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -117,14 +117,10 @@ func (r *BaseRegistry) GetUrl() common.URL { func (r *BaseRegistry) Destroy() { //first step close registry's all listeners r.facadeBasedRegistry.CloseListener() - logger.Info("1---") // then close r.done to notify other program who listen to it close(r.done) - logger.Info("2---") - // wait waitgroup done (wait listeners outside close over) r.wg.Wait() - logger.Info("3---") //close registry client r.closeRegisters() diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index 63c8d37a43..c5b2f33c61 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -93,7 +93,6 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool { // Close all RegistryConfigurationListener in subscribed func (l *RegistryDataListener) Close() { l.mutex.Lock() - logger.Info("Close all reg") defer l.mutex.Unlock() for _, listener := range l.subscribed { listener.(*RegistryConfigurationListener).Close() @@ -126,14 +125,13 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) { for { select { case <-l.client.Done(): - logger.Warnf("listener's zk client connection is broken, so zk event listener exit now.") - return nil, perrors.New("listener stopped") - + logger.Warnf("listener's zk client connection (address {%s}) is broken, so zk event listener exit now.", l.client.ZkAddrs) + return nil, perrors.New("zookeeper client stopped") case <-l.close: - return nil, perrors.New("listener closed") + return nil, perrors.New("listener have been closed") case <-l.registry.Done(): - logger.Warnf("zk consumer register has quit, so zk event listener exit now.") - return nil, perrors.New("listener stopped") + 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: logger.Debugf("got zk event %s", e) if e.ConfigType == remoting.EventTypeDel && !l.valid() { diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 3ab841b899..88d5d6221b 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -154,7 +154,6 @@ func (r *zkRegistry) DoSubscribe(conf *common.URL) (registry.Listener, error) { } func (r *zkRegistry) CloseAndNilClient() { - logger.Info("c") r.client.Close() r.client = nil } diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 39812841d7..c788bc4c11 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -157,7 +157,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { } if connected { - logger.Info("sdsds") + logger.Info("Connect to zookeeper successfully, name{%s}, zk address{%v}", opions.zkName, url.Location) container.WaitGroup().Add(1) //zk client start successful, then registry wg +1 } diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go index a41f6cd323..01d46da6cc 100644 --- a/remoting/zookeeper/facade_test.go +++ b/remoting/zookeeper/facade_test.go @@ -38,6 +38,16 @@ type mockFacade struct { done chan struct{} } +func newMockFacade(client *ZookeeperClient, url *common.URL) zkClientFacade { + mock := &mockFacade{ + client: client, + URL: url, + } + + mock.wg.Add(1) + return mock +} + func (r *mockFacade) ZkClient() *ZookeeperClient { return r.client } @@ -80,7 +90,7 @@ func Test_Facade(t *testing.T) { assert.NoError(t, err) defer ts.Stop() url, _ := common.NewURL("mock://127.0.0.1") - mock := &mockFacade{client: z, URL: &url} + mock := newMockFacade(z, &url) go HandleClientRestart(mock) states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession} verifyEventStateOrder(t, event, states, "event channel") From 08e9d84ac0aae4b7adf36bfb04ddb0be86282d42 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Mon, 6 Apr 2020 12:19:46 +0800 Subject: [PATCH 060/167] fix ut --- config_center/zookeeper/impl.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 404243d475..5ffbb5f95d 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -74,7 +74,7 @@ func newZookeeperDynamicConfiguration(url *common.URL) (*zookeeperDynamicConfigu c.cacheListener = NewCacheListener(c.rootPath) err = c.client.Create(c.rootPath) - c.listener.ListenServiceEvent(c.rootPath, c.cacheListener) + c.listener.ListenServiceEvent(url, c.rootPath, c.cacheListener) return c, err } @@ -100,7 +100,7 @@ func newMockZookeeperDynamicConfiguration(url *common.URL, opts ...zookeeper.Opt c.cacheListener = NewCacheListener(c.rootPath) err = c.client.Create(c.rootPath) - go c.listener.ListenServiceEvent(c.rootPath, c.cacheListener) + go c.listener.ListenServiceEvent(url, c.rootPath, c.cacheListener) return tc, c, err } From ed2fa0c9c71ff9e87312dc6269e137b944c3b36c Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Tue, 7 Apr 2020 20:28:56 +0800 Subject: [PATCH 061/167] Add:registry directory extension --- common/extension/registry_directory.go | 39 ++++++++++++++++++++++++++ registry/directory/directory.go | 39 +++++++++----------------- registry/directory/directory_test.go | 15 +++++----- registry/protocol/protocol.go | 5 ++-- 4 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 common/extension/registry_directory.go diff --git a/common/extension/registry_directory.go b/common/extension/registry_directory.go new file mode 100644 index 0000000000..1d34add5a6 --- /dev/null +++ b/common/extension/registry_directory.go @@ -0,0 +1,39 @@ +/* + * 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 ( + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/registry" +) + +var defaultRegistry func(url *common.URL, registry registry.Registry) (cluster.Directory, error) + +// SetDefaultRegistryDirectory ... +func SetDefaultRegistryDirectory(v func(url *common.URL, registry registry.Registry) (cluster.Directory, error)) { + defaultRegistry = v +} + +// GetDefaultRegistryDirectory ... +func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (cluster.Directory, error) { + if defaultRegistry == nil { + panic("registry directory is not existing, make sure you have import the package.") + } + return defaultRegistry(config, registry) +} diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 20be268d74..20724c3737 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -19,7 +19,6 @@ package directory import ( "sync" - "time" ) import ( @@ -28,6 +27,7 @@ import ( ) import ( + "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/cluster/directory" "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" @@ -42,14 +42,10 @@ import ( "github.com/apache/dubbo-go/remoting" ) -// Options ... -type Options struct { - serviceTTL time.Duration +func init() { + extension.SetDefaultRegistryDirectory(newRegistryDirectory) } -// Option ... -type Option func(*Options) - type registryDirectory struct { directory.BaseDirectory cacheInvokers []protocol.Invoker @@ -61,20 +57,12 @@ type registryDirectory struct { configurators []config_center.Configurator consumerConfigurationListener *consumerConfigurationListener referenceConfigurationListener *referenceConfigurationListener - Options - serviceKey string - forbidden atomic.Bool + serviceKey string + forbidden atomic.Bool } -// NewRegistryDirectory ... -func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...Option) (*registryDirectory, error) { - options := Options{ - //default 300s - serviceTTL: time.Duration(300e9), - } - for _, opt := range opts { - opt(&options) - } +// newRegistryDirectory ... +func newRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.Directory, error) { if url.SubURL == nil { return nil, perrors.Errorf("url is invalid, suburl can not be nil") } @@ -84,14 +72,15 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...O cacheInvokersMap: &sync.Map{}, serviceType: url.SubURL.Service(), registry: registry, - Options: options, } dir.consumerConfigurationListener = newConsumerConfigurationListener(dir) + + 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) { dir.consumerConfigurationListener.addNotifyListener(dir) dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) dir.registry.Subscribe(url, dir) @@ -101,7 +90,7 @@ func (dir *registryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } -//subscribe service from registry, and update the cacheServices +// update: subscribe service from registry, and update the cacheServices func (dir *registryDirectory) update(res *registry.ServiceEvent) { if res == nil { return @@ -198,7 +187,7 @@ func (dir *registryDirectory) toGroupInvokers() []protocol.Invoker { return groupInvokersList } -// uncacheInvoker return abandoned Invoker,if no Invoker to be abandoned,return nil +// uncacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil func (dir *registryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { logger.Debugf("service will be deleted in cache invokers: invokers key is %s!", url.Key()) if cacheInvoker, ok := dir.cacheInvokersMap.Load(url.Key()); ok { @@ -208,7 +197,7 @@ func (dir *registryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { return nil } -// cacheInvoker return abandoned Invoker,if no Invoker to be abandoned,return nil +// cacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { dir.overrideUrl(dir.GetDirectoryUrl()) referenceUrl := dir.GetDirectoryUrl().SubURL @@ -244,7 +233,7 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { return nil } -//select the protocol invokers from the directory +// list :select the protocol invokers from the directory func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { invokers := dir.cacheInvokers routerChain := dir.RouterChain() diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 0dde44e73c..9a6efa4557 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -66,7 +66,7 @@ func TestSubscribe(t *testing.T) { func TestSubscribe_InvalidUrl(t *testing.T) { url, _ := common.NewURL("mock://127.0.0.1:1111") mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - _, err := NewRegistryDirectory(&url, mockRegistry) + _, err := newRegistryDirectory(&url, mockRegistry) assert.Error(t, err) } @@ -79,10 +79,9 @@ func TestSubscribe_Group(t *testing.T) { suburl.SetParam(constant.CLUSTER_KEY, "mock") regurl.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - registryDirectory, _ := NewRegistryDirectory(®url, mockRegistry) - - go registryDirectory.Subscribe(common.NewURLWithOptions(common.WithPath("testservice"))) + dir, _ := newRegistryDirectory(®url, mockRegistry) + go dir.(*registryDirectory).subscribe(common.NewURLWithOptions(common.WithPath("testservice"))) //for group1 urlmap := url.Values{} urlmap.Set(constant.GROUP_KEY, "group1") @@ -101,7 +100,7 @@ func TestSubscribe_Group(t *testing.T) { } time.Sleep(1e9) - assert.Len(t, registryDirectory.cacheInvokers, 2) + assert.Len(t, dir.(*registryDirectory).cacheInvokers, 2) } func Test_Destroy(t *testing.T) { @@ -185,9 +184,9 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR ) url.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - registryDirectory, _ := NewRegistryDirectory(&url, mockRegistry) + dir, _ := newRegistryDirectory(&url, mockRegistry) - go registryDirectory.Subscribe(&suburl) + go dir.(*registryDirectory).subscribe(&suburl) if len(noMockEvent) == 0 { for i := 0; i < 3; i++ { mockRegistry.(*registry.MockRegistry).MockEvent( @@ -201,5 +200,5 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR ) } } - return registryDirectory, mockRegistry.(*registry.MockRegistry) + return dir.(*registryDirectory), mockRegistry.(*registry.MockRegistry) } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index a7678ba4e2..591d4986cf 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -39,7 +39,7 @@ import ( "github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol/protocolwrapper" "github.com/apache/dubbo-go/registry" - directory2 "github.com/apache/dubbo-go/registry/directory" + _ "github.com/apache/dubbo-go/registry/directory" "github.com/apache/dubbo-go/remoting" ) @@ -111,7 +111,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { } //new registry directory for store service url from registry - directory, err := directory2.NewRegistryDirectory(®istryUrl, reg) + directory, err := extension.GetDefaultRegistryDirectory(®istryUrl, reg) if err != nil { logger.Errorf("consumer service %v create registry directory error, error message is %s, and will return nil invoker!", serviceUrl.String(), err.Error()) @@ -123,7 +123,6 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { logger.Errorf("consumer service %v register registry %v error, error message is %s", serviceUrl.String(), registryUrl.String(), err.Error()) } - go directory.Subscribe(serviceUrl) //new cluster invoker cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) From 54dc74a540fdbac62f11469c7e6bcc002738e26e Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Tue, 7 Apr 2020 23:32:25 +0800 Subject: [PATCH 062/167] Mod: upper RegistryDirectory for inherit --- registry/directory/directory.go | 40 ++++++++++++++-------------- registry/directory/directory_test.go | 16 +++++------ 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 20724c3737..b852c947db 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -43,10 +43,10 @@ import ( ) func init() { - extension.SetDefaultRegistryDirectory(newRegistryDirectory) + extension.SetDefaultRegistryDirectory(NewRegistryDirectory) } -type registryDirectory struct { +type RegistryDirectory struct { directory.BaseDirectory cacheInvokers []protocol.Invoker listenerLock sync.Mutex @@ -61,12 +61,12 @@ type registryDirectory struct { forbidden atomic.Bool } -// newRegistryDirectory ... -func newRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.Directory, error) { +// NewRegistryDirectory ... +func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.Directory, error) { if url.SubURL == nil { return nil, perrors.Errorf("url is invalid, suburl can not be nil") } - dir := ®istryDirectory{ + dir := &RegistryDirectory{ BaseDirectory: directory.NewBaseDirectory(url), cacheInvokers: []protocol.Invoker{}, cacheInvokersMap: &sync.Map{}, @@ -80,18 +80,18 @@ func newRegistryDirectory(url *common.URL, registry registry.Registry) (cluster. } //subscribe from registry -func (dir *registryDirectory) subscribe(url *common.URL) { +func (dir *RegistryDirectory) subscribe(url *common.URL) { dir.consumerConfigurationListener.addNotifyListener(dir) dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) dir.registry.Subscribe(url, dir) } -func (dir *registryDirectory) Notify(event *registry.ServiceEvent) { +func (dir *RegistryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } // update: subscribe service from registry, and update the cacheServices -func (dir *registryDirectory) update(res *registry.ServiceEvent) { +func (dir *RegistryDirectory) update(res *registry.ServiceEvent) { if res == nil { return } @@ -100,7 +100,7 @@ func (dir *registryDirectory) update(res *registry.ServiceEvent) { dir.refreshInvokers(res) } -func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) { +func (dir *RegistryDirectory) refreshInvokers(res *registry.ServiceEvent) { var ( url *common.URL oldInvoker protocol.Invoker = nil @@ -151,7 +151,7 @@ func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) { } -func (dir *registryDirectory) toGroupInvokers() []protocol.Invoker { +func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { newInvokersList := []protocol.Invoker{} groupInvokersMap := make(map[string][]protocol.Invoker) groupInvokersList := []protocol.Invoker{} @@ -188,7 +188,7 @@ func (dir *registryDirectory) toGroupInvokers() []protocol.Invoker { } // uncacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil -func (dir *registryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { +func (dir *RegistryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { logger.Debugf("service will be deleted in cache invokers: invokers key is %s!", url.Key()) if cacheInvoker, ok := dir.cacheInvokersMap.Load(url.Key()); ok { dir.cacheInvokersMap.Delete(url.Key()) @@ -198,7 +198,7 @@ func (dir *registryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { } // cacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil -func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { +func (dir *RegistryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { dir.overrideUrl(dir.GetDirectoryUrl()) referenceUrl := dir.GetDirectoryUrl().SubURL @@ -234,7 +234,7 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { } // list :select the protocol invokers from the directory -func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { +func (dir *RegistryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { invokers := dir.cacheInvokers routerChain := dir.RouterChain() @@ -244,7 +244,7 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.In return routerChain.Route(invokers, dir.cacheOriginUrl, invocation) } -func (dir *registryDirectory) IsAvailable() bool { +func (dir *RegistryDirectory) IsAvailable() bool { if !dir.BaseDirectory.IsAvailable() { return dir.BaseDirectory.IsAvailable() } @@ -258,7 +258,7 @@ func (dir *registryDirectory) IsAvailable() bool { return false } -func (dir *registryDirectory) Destroy() { +func (dir *RegistryDirectory) Destroy() { //TODO:unregister & unsubscribe dir.BaseDirectory.Destroy(func() { invokers := dir.cacheInvokers @@ -269,7 +269,7 @@ func (dir *registryDirectory) Destroy() { }) } -func (dir *registryDirectory) overrideUrl(targetUrl *common.URL) { +func (dir *RegistryDirectory) overrideUrl(targetUrl *common.URL) { doOverrideUrl(dir.configurators, targetUrl) doOverrideUrl(dir.consumerConfigurationListener.Configurators(), targetUrl) doOverrideUrl(dir.referenceConfigurationListener.Configurators(), targetUrl) @@ -283,11 +283,11 @@ func doOverrideUrl(configurators []config_center.Configurator, targetUrl *common type referenceConfigurationListener struct { registry.BaseConfigurationListener - directory *registryDirectory + directory *RegistryDirectory url *common.URL } -func newReferenceConfigurationListener(dir *registryDirectory, url *common.URL) *referenceConfigurationListener { +func newReferenceConfigurationListener(dir *RegistryDirectory, url *common.URL) *referenceConfigurationListener { listener := &referenceConfigurationListener{directory: dir, url: url} listener.InitWith( url.EncodedServiceKey()+constant.CONFIGURATORS_SUFFIX, @@ -305,10 +305,10 @@ func (l *referenceConfigurationListener) Process(event *config_center.ConfigChan type consumerConfigurationListener struct { registry.BaseConfigurationListener listeners []registry.NotifyListener - directory *registryDirectory + directory *RegistryDirectory } -func newConsumerConfigurationListener(dir *registryDirectory) *consumerConfigurationListener { +func newConsumerConfigurationListener(dir *RegistryDirectory) *consumerConfigurationListener { listener := &consumerConfigurationListener{directory: dir} listener.InitWith( config.GetConsumerConfig().ApplicationConfig.Name+constant.CONFIGURATORS_SUFFIX, diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 9a6efa4557..f1d5ce434a 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -66,7 +66,7 @@ func TestSubscribe(t *testing.T) { func TestSubscribe_InvalidUrl(t *testing.T) { url, _ := common.NewURL("mock://127.0.0.1:1111") mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - _, err := newRegistryDirectory(&url, mockRegistry) + _, err := NewRegistryDirectory(&url, mockRegistry) assert.Error(t, err) } @@ -79,9 +79,9 @@ func TestSubscribe_Group(t *testing.T) { suburl.SetParam(constant.CLUSTER_KEY, "mock") regurl.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - dir, _ := newRegistryDirectory(®url, mockRegistry) + dir, _ := NewRegistryDirectory(®url, mockRegistry) - go dir.(*registryDirectory).subscribe(common.NewURLWithOptions(common.WithPath("testservice"))) + go dir.(*RegistryDirectory).subscribe(common.NewURLWithOptions(common.WithPath("testservice"))) //for group1 urlmap := url.Values{} urlmap.Set(constant.GROUP_KEY, "group1") @@ -100,7 +100,7 @@ func TestSubscribe_Group(t *testing.T) { } time.Sleep(1e9) - assert.Len(t, dir.(*registryDirectory).cacheInvokers, 2) + assert.Len(t, dir.(*RegistryDirectory).cacheInvokers, 2) } func Test_Destroy(t *testing.T) { @@ -172,7 +172,7 @@ Loop1: } -func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockRegistry) { +func normalRegistryDir(noMockEvent ...bool) (*RegistryDirectory, *registry.MockRegistry) { extension.SetProtocol(protocolwrapper.FILTER, protocolwrapper.NewMockProtocolFilter) url, _ := common.NewURL("mock://127.0.0.1:1111") @@ -184,9 +184,9 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR ) url.SubURL = &suburl mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) - dir, _ := newRegistryDirectory(&url, mockRegistry) + dir, _ := NewRegistryDirectory(&url, mockRegistry) - go dir.(*registryDirectory).subscribe(&suburl) + go dir.(*RegistryDirectory).subscribe(&suburl) if len(noMockEvent) == 0 { for i := 0; i < 3; i++ { mockRegistry.(*registry.MockRegistry).MockEvent( @@ -200,5 +200,5 @@ func normalRegistryDir(noMockEvent ...bool) (*registryDirectory, *registry.MockR ) } } - return dir.(*registryDirectory), mockRegistry.(*registry.MockRegistry) + return dir.(*RegistryDirectory), mockRegistry.(*registry.MockRegistry) } From 6b58f6c77e5f4f35568a88ababf01b059a983c22 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Wed, 8 Apr 2020 11:34:15 +0800 Subject: [PATCH 063/167] Update registry/directory/directory.go Co-Authored-By: Joe Zou --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index b852c947db..fe922cb980 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -233,7 +233,7 @@ func (dir *RegistryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { return nil } -// list :select the protocol invokers from the directory +// List selected protocol invokers from the directory func (dir *RegistryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { invokers := dir.cacheInvokers routerChain := dir.RouterChain() From 5d630cafe6f46a77c27342e4064a630437331299 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Wed, 8 Apr 2020 11:34:30 +0800 Subject: [PATCH 064/167] Update registry/directory/directory.go Co-Authored-By: Joe Zou --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index fe922cb980..fe77f3c657 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -90,7 +90,7 @@ func (dir *RegistryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } -// update: subscribe service from registry, and update the cacheServices +// update the cacheServices and subscribe service from registry func (dir *RegistryDirectory) update(res *registry.ServiceEvent) { if res == nil { return From 57fa801f6de75bd9d7ae8a389d9a4dc8f86915f0 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Wed, 8 Apr 2020 11:34:39 +0800 Subject: [PATCH 065/167] Update registry/directory/directory.go Co-Authored-By: Joe Zou --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index fe77f3c657..ab131ad617 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -187,7 +187,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { return groupInvokersList } -// uncacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil +// uncacheInvoker will return abandoned Invoker,if no Invoker to be abandoned,return nil func (dir *RegistryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { logger.Debugf("service will be deleted in cache invokers: invokers key is %s!", url.Key()) if cacheInvoker, ok := dir.cacheInvokersMap.Load(url.Key()); ok { From 34c52a16a0e5e6493ea3cc32d23b21fff0de57d5 Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Wed, 8 Apr 2020 11:34:49 +0800 Subject: [PATCH 066/167] Update registry/directory/directory.go Co-Authored-By: Joe Zou --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index ab131ad617..552aa57061 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -197,7 +197,7 @@ func (dir *RegistryDirectory) uncacheInvoker(url *common.URL) protocol.Invoker { return nil } -// cacheInvoker: return abandoned Invoker,if no Invoker to be abandoned,return nil +// cacheInvoker will return abandoned Invoker,if no Invoker to be abandoned,return nil func (dir *RegistryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { dir.overrideUrl(dir.GetDirectoryUrl()) referenceUrl := dir.GetDirectoryUrl().SubURL From eac6b6311122776d66d05c257d6a5afd75bde18a Mon Sep 17 00:00:00 2001 From: "vito.he" Date: Wed, 8 Apr 2020 11:37:53 +0800 Subject: [PATCH 067/167] Add:new func type --- common/extension/registry_directory.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/extension/registry_directory.go b/common/extension/registry_directory.go index 1d34add5a6..6b92189c4e 100644 --- a/common/extension/registry_directory.go +++ b/common/extension/registry_directory.go @@ -23,10 +23,12 @@ import ( "github.com/apache/dubbo-go/registry" ) -var defaultRegistry func(url *common.URL, registry registry.Registry) (cluster.Directory, error) +type registryDirectory func(url *common.URL, registry registry.Registry) (cluster.Directory, error) + +var defaultRegistry registryDirectory // SetDefaultRegistryDirectory ... -func SetDefaultRegistryDirectory(v func(url *common.URL, registry registry.Registry) (cluster.Directory, error)) { +func SetDefaultRegistryDirectory(v registryDirectory) { defaultRegistry = v } From 6aedd1af8dc1442220b4549f87c26ab831f67850 Mon Sep 17 00:00:00 2001 From: flycash Date: Wed, 8 Apr 2020 21:30:04 +0800 Subject: [PATCH 068/167] rename baseRegistry to nacosBaseRegistry --- registry/nacos/base_registry.go | 10 +++++----- registry/nacos/registry.go | 2 +- registry/nacos/service_discovery.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/registry/nacos/base_registry.go b/registry/nacos/base_registry.go index bd5dc86b43..63f4999675 100644 --- a/registry/nacos/base_registry.go +++ b/registry/nacos/base_registry.go @@ -38,22 +38,22 @@ import ( // baseRegistry is the parent of both interface-level registry // and service discovery(related to application-level registry) -type baseRegistry struct { +type nacosBaseRegistry struct { *common.URL namingClient naming_client.INamingClient } // newBaseRegistry will create new instance -func newBaseRegistry(url *common.URL) (baseRegistry, error) { +func newBaseRegistry(url *common.URL) (nacosBaseRegistry, error) { nacosConfig, err := getNacosConfig(url) if err != nil { - return baseRegistry{}, err + return nacosBaseRegistry{}, err } client, err := clients.CreateNamingClient(nacosConfig) if err != nil { - return baseRegistry{}, err + return nacosBaseRegistry{}, err } - registry := baseRegistry{ + registry := nacosBaseRegistry{ URL: url, namingClient: client, } diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index b0f399862a..a436b85064 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -53,7 +53,7 @@ func init() { } type nacosRegistry struct { - baseRegistry + nacosBaseRegistry } // newNacosRegistry will create an instance diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index b89d4f611b..8ef72c1b11 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -47,7 +47,7 @@ func init() { // There is a problem, the go client for nacos does not support the id field. // we will use the metadata to store the id of ServiceInstance type nacosServiceDiscovery struct { - baseRegistry + nacosBaseRegistry group string } @@ -279,7 +279,7 @@ func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error return nil, perrors.WithStack(err) } return &nacosServiceDiscovery{ - baseRegistry: base, + nacosBaseRegistry: base, group: url.GetParam(constant.NACOS_GROUP, defaultGroup), }, nil } From cf80d06453632799bd97521d5b8cd8a5de2bf978 Mon Sep 17 00:00:00 2001 From: AlexStocks Date: Fri, 10 Apr 2020 12:19:50 +0800 Subject: [PATCH 069/167] Update: hessian2 & getty version --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 54d532eac0..b77fd3edae 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/Workiva/go-datastructures v1.0.50 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e // indirect - github.com/apache/dubbo-go-hessian2 v1.4.0 + github.com/apache/dubbo-go-hessian2 v1.5.0 github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23 // indirect github.com/coreos/bbolt v1.3.3 // indirect github.com/coreos/etcd v3.3.13+incompatible @@ -12,7 +12,7 @@ require ( github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/creasty/defaults v1.3.0 - github.com/dubbogo/getty v1.3.3 + github.com/dubbogo/getty v1.3.4 github.com/dubbogo/go-zookeeper v1.0.0 github.com/dubbogo/gost v1.8.0 github.com/emicklei/go-restful/v3 v3.0.0 From 9e06cc21f91a8df4a016b660768ac95cad5d57fe Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sat, 11 Apr 2020 11:46:27 +0800 Subject: [PATCH 070/167] add simplified attribute in registry config --- common/constant/default.go | 1 + common/url.go | 55 ++++++++++++++++++++++------------- config/registry_config.go | 35 ++++++++++------------ registry/protocol/protocol.go | 22 ++++++++++---- 4 files changed, 69 insertions(+), 44 deletions(-) diff --git a/common/constant/default.go b/common/constant/default.go index 3c889158e4..9b229844f0 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -73,4 +73,5 @@ const ( const ( COMMA_SPLIT_PATTERN = "\\s*[,]+\\s*" + PATH_SEPARATOR = "," ) diff --git a/common/url.go b/common/url.go index ebb648db27..5c3ba91a22 100644 --- a/common/url.go +++ b/common/url.go @@ -313,7 +313,6 @@ func (c URL) Key() string { "%s://%s:%s@%s:%s/?interface=%s&group=%s&version=%s", c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Service(), c.GetParam(constant.GROUP_KEY, ""), c.GetParam(constant.VERSION_KEY, "")) return buildString - //return c.ServiceKey() } // ServiceKey ... @@ -409,17 +408,19 @@ func (c *URL) RangeParams(f func(key, value string) bool) { // GetParam ... func (c URL) GetParam(s string, d string) string { - var r string c.paramsLock.RLock() - if r = c.params.Get(s); len(r) == 0 { + defer c.paramsLock.RUnlock() + r := c.params.Get(s) + if len(r) == 0 { r = d } - c.paramsLock.RUnlock() return r } // GetParams ... func (c URL) GetParams() url.Values { + c.paramsLock.RLock() + defer c.paramsLock.RUnlock() return c.params } @@ -454,10 +455,8 @@ func (c URL) GetRawParam(key string) string { // GetParamBool ... func (c URL) GetParamBool(s string, d bool) bool { - - var r bool - var err error - if r, err = strconv.ParseBool(c.GetParam(s, "")); err != nil { + r, err := strconv.ParseBool(c.GetParam(s, "")) + if err != nil { return d } return r @@ -465,10 +464,8 @@ func (c URL) GetParamBool(s string, d bool) bool { // GetParamInt ... func (c URL) GetParamInt(s string, d int64) int64 { - var r int - var err error - - if r, err = strconv.Atoi(c.GetParam(s, "")); r == 0 || err != nil { + r, err := strconv.Atoi(c.GetParam(s, "")) + if r == 0 || err != nil { return d } return int64(r) @@ -476,11 +473,10 @@ func (c URL) GetParamInt(s string, d int64) int64 { // GetMethodParamInt ... func (c URL) GetMethodParamInt(method string, key string, d int64) int64 { - var r int - var err error c.paramsLock.RLock() defer c.paramsLock.RUnlock() - if r, err = strconv.Atoi(c.GetParam("methods."+method+"."+key, "")); r == 0 || err != nil { + r, err := strconv.Atoi(c.GetParam("methods."+method+"."+key, "")) + if r == 0 || err != nil { return d } return int64(r) @@ -492,14 +488,13 @@ func (c URL) GetMethodParamInt64(method string, key string, d int64) int64 { if r == math.MinInt64 { return c.GetParamInt(key, d) } - return r } // GetMethodParam ... func (c URL) GetMethodParam(method string, key string, d string) string { - var r string - if r = c.GetParam("methods."+method+"."+key, ""); r == "" { + r := c.GetParam("methods."+method+"."+key, "") + if r == "" { r = d } return r @@ -530,7 +525,6 @@ func (c *URL) SetParams(m url.Values) { // ToMap transfer URL to Map func (c URL) ToMap() map[string]string { - paramsMap := make(map[string]string) c.RangeParams(func(key, value string) bool { @@ -615,8 +609,29 @@ func (c *URL) Clone() *URL { return newUrl } +func (c *URL) CloneWithParams(reserveParams []string, methods []string) *URL { + params := url.Values{} + for _, reserveParam := range reserveParams { + v := c.GetParam(reserveParam, "") + if v != "" { + params.Set(reserveParam, v) + } + } + + return NewURLWithOptions( + WithProtocol(c.Protocol), + WithUsername(c.Username), + WithPassword(c.Password), + WithIp(c.Ip), + WithPort(c.Port), + WithPath(c.Path), + WithMethods(methods), + WithParams(params), + ) +} + func mergeNormalParam(mergedUrl *URL, referenceUrl *URL, paramKeys []string) []func(method string) { - var methodConfigMergeFcn = []func(method string){} + methodConfigMergeFcn := make([]func(method string), 0, len(paramKeys)) for _, paramKey := range paramKeys { if v := referenceUrl.GetParam(paramKey, ""); len(v) > 0 { mergedUrl.SetParam(paramKey, v) diff --git a/config/registry_config.go b/config/registry_config.go index f3d22311b8..e877a2c19d 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -36,14 +36,15 @@ import ( // RegistryConfig ... type RegistryConfig struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` - //I changed "type" to "protocol" ,the same as "protocol" field in java class RegistryConfig + // I changed "type" to "protocol" ,the same as "protocol" field in java class RegistryConfig TimeoutStr string `yaml:"timeout" default:"5s" json:"timeout,omitempty" property:"timeout"` // unit: second Group string `yaml:"group" json:"group,omitempty" property:"group"` - //for registry - Address string `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"` - Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` + // for registry + Address string `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"` + Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } // UnmarshalYAML ... @@ -70,9 +71,11 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf 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 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 { @@ -86,29 +89,24 @@ func loadRegistries(targetRegistries string, registries map[string]*RegistryConf } if target { - var ( - url common.URL - err error - ) - addresses := strings.Split(registryConf.Address, ",") address := addresses[0] address = translateRegistryConf(address, registryConf) - url, err = common.NewURL(constant.REGISTRY_PROTOCOL+"://"+address, + 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) + logger.Errorf("The registry id: %s url is invalid, error: %#v", k, err) panic(err) } else { urls = append(urls, &url) } } - } return urls @@ -123,7 +121,6 @@ func (c *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values { for k, v := range c.Params { urlMap.Set(k, v) } - return urlMap } @@ -131,7 +128,7 @@ func translateRegistryConf(address string, registryConf *RegistryConfig) string if strings.Contains(address, "://") { translatedUrl, err := url.Parse(address) if err != nil { - logger.Errorf("The registry url is invalid , error: %#v", err) + logger.Errorf("The registry url is invalid, error: %#v", err) panic(err) } address = translatedUrl.Host diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index b47b9f372d..3aefc7bdfd 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -24,7 +24,7 @@ import ( ) import ( - gxset "github.com/dubbogo/gost/container/set" + "github.com/dubbogo/gost/container/set" ) import ( @@ -44,8 +44,13 @@ import ( ) var ( - regProtocol *registryProtocol - once sync.Once + regProtocol *registryProtocol + once sync.Once + reserveParams = []string{ + "application", "codec", "exchanger", "serialization", "cluster", "connections", "deprecated", "group", + "loadbalance", "mock", "path", "timeout", "token", "version", "warmup", "weight", "timestamp", "dubbo", + "release", "interface", + } ) type registryProtocol struct { @@ -88,6 +93,13 @@ func getRegistry(regUrl *common.URL) registry.Registry { return reg } +func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common.URL { + if registryUrl.GetParamBool("simplified", false) { + return providerUrl.CloneWithParams(reserveParams, providerUrl.Methods) + } + return providerUrl +} + func (proto *registryProtocol) initConfigurationListeners() { proto.overrideListeners = &sync.Map{} proto.serviceConfigurationListeners = &sync.Map{} @@ -151,7 +163,6 @@ 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) @@ -159,7 +170,8 @@ func (proto *registryProtocol) Export(invoker protocol.Invoker) protocol.Exporte reg = regI.(registry.Registry) } - err := reg.Register(*providerUrl) + 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()) From ef33eb10f146021f07e485cc9db37c407bae7eff Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sat, 11 Apr 2020 14:41:52 +0800 Subject: [PATCH 071/167] go fmt --- registry/nacos/service_discovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 8ef72c1b11..7d3406cac2 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -280,6 +280,6 @@ func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error } return &nacosServiceDiscovery{ nacosBaseRegistry: base, - group: url.GetParam(constant.NACOS_GROUP, defaultGroup), + group: url.GetParam(constant.NACOS_GROUP, defaultGroup), }, nil } From 4ea624b5c76f951a8cf29fbceace8a37f1131f1c Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sat, 11 Apr 2020 16:58:14 +0800 Subject: [PATCH 072/167] add license --- config/metadata_report_config_test.go | 17 +++++++++++++++++ .../identifier/subscribe_metadata_identifier.go | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go index d6b08d5fb0..635feecc2d 100644 --- a/config/metadata_report_config_test.go +++ b/config/metadata_report_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 "testing" diff --git a/metadata/identifier/subscribe_metadata_identifier.go b/metadata/identifier/subscribe_metadata_identifier.go index fd3a290b41..321a216a3e 100644 --- a/metadata/identifier/subscribe_metadata_identifier.go +++ b/metadata/identifier/subscribe_metadata_identifier.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 identifier type SubscriberMetadataIdentifier struct { From 01bbba55aef4df61dcc7f1befd41881d6efee176 Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sat, 11 Apr 2020 17:03:10 +0800 Subject: [PATCH 073/167] improve code --- common/url.go | 7 +++---- registry/protocol/protocol.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/url.go b/common/url.go index 5c3ba91a22..dfc231efcd 100644 --- a/common/url.go +++ b/common/url.go @@ -419,8 +419,6 @@ func (c URL) GetParam(s string, d string) string { // GetParams ... func (c URL) GetParams() url.Values { - c.paramsLock.RLock() - defer c.paramsLock.RUnlock() return c.params } @@ -609,7 +607,8 @@ func (c *URL) Clone() *URL { return newUrl } -func (c *URL) CloneWithParams(reserveParams []string, methods []string) *URL { +// Copy url based on the reserved parameters' keys. +func (c *URL) CloneWithParams(reserveParams []string) *URL { params := url.Values{} for _, reserveParam := range reserveParams { v := c.GetParam(reserveParam, "") @@ -625,7 +624,7 @@ func (c *URL) CloneWithParams(reserveParams []string, methods []string) *URL { WithIp(c.Ip), WithPort(c.Port), WithPath(c.Path), - WithMethods(methods), + WithMethods(c.Methods), WithParams(params), ) } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 3aefc7bdfd..f9e9cd6b9e 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -95,7 +95,7 @@ func getRegistry(regUrl *common.URL) registry.Registry { func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common.URL { if registryUrl.GetParamBool("simplified", false) { - return providerUrl.CloneWithParams(reserveParams, providerUrl.Methods) + return providerUrl.CloneWithParams(reserveParams) } return providerUrl } From b25b628c1ecb70e390336102751d51260a0b065d Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sat, 11 Apr 2020 17:10:02 +0800 Subject: [PATCH 074/167] fix --- common/url.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/url.go b/common/url.go index dfc231efcd..3916ff105e 100644 --- a/common/url.go +++ b/common/url.go @@ -195,7 +195,6 @@ func NewURLWithOptions(opts ...option) *URL { // NewURL will create a new url // the urlString should not be empty func NewURL(urlString string, opts ...option) (URL, error) { - var ( err error rawUrlString string @@ -471,8 +470,6 @@ func (c URL) GetParamInt(s string, d int64) int64 { // GetMethodParamInt ... func (c URL) GetMethodParamInt(method string, key string, d int64) int64 { - c.paramsLock.RLock() - defer c.paramsLock.RUnlock() r, err := strconv.Atoi(c.GetParam("methods."+method+"."+key, "")) if r == 0 || err != nil { return d From 2532b495f61bb6c25f9c668b7eaffde51ae42316 Mon Sep 17 00:00:00 2001 From: AlexStocks Date: Sat, 11 Apr 2020 23:24:35 +0800 Subject: [PATCH 075/167] Mod: gofmt all go files --- registry/nacos/service_discovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 8ef72c1b11..7d3406cac2 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -280,6 +280,6 @@ func newNacosServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error } return &nacosServiceDiscovery{ nacosBaseRegistry: base, - group: url.GetParam(constant.NACOS_GROUP, defaultGroup), + group: url.GetParam(constant.NACOS_GROUP, defaultGroup), }, nil } From d6ab9d12cb7823f1e6a344a4a6ae8717e3f0809b Mon Sep 17 00:00:00 2001 From: AlexStocks Date: Sun, 12 Apr 2020 12:17:10 +0800 Subject: [PATCH 076/167] Add: license header --- config/metadata_report_config_test.go | 17 +++++++++++++++++ go.sum | 6 ++++++ .../identifier/subscribe_metadata_identifier.go | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/config/metadata_report_config_test.go b/config/metadata_report_config_test.go index d6b08d5fb0..635feecc2d 100644 --- a/config/metadata_report_config_test.go +++ b/config/metadata_report_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 "testing" diff --git a/go.sum b/go.sum index e499992eb0..e0e1c7a9ff 100644 --- a/go.sum +++ b/go.sum @@ -40,6 +40,8 @@ github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/apache/dubbo-go-hessian2 v1.4.0 h1:Cb9FQVTy3G93dnDr7P93U8DeKFYpDTJjQp44JG5TafA= github.com/apache/dubbo-go-hessian2 v1.4.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= +github.com/apache/dubbo-go-hessian2 v1.5.0 h1:fzulDG5G7nX0ccgKdiN9XipJ7tZ4WXKgmk4stdlDS6s= +github.com/apache/dubbo-go-hessian2 v1.5.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= 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= @@ -102,12 +104,15 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/digitalocean/godo v1.10.0 h1:uW1/FcvZE/hoixnJcnlmIUvTVNdZCLjRLzmDtRi1xXY= github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= +github.com/divebomb/dubbo-go v1.0.0 h1:QsQxD6UU2WbcaA8YCxU9stiuPUsVCPabFg8hhKGJR8A= github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dubbogo/getty v1.3.3 h1:8m4zZBqFHO+NmhH7rMPlFuuYRVjcPD7cUhumevqMZZs= github.com/dubbogo/getty v1.3.3/go.mod h1:U92BDyJ6sW9Jpohr2Vlz8w2uUbIbNZ3d+6rJvFTSPp0= +github.com/dubbogo/getty v1.3.4 h1:5TvH213pnSIKYzY7IK8TT/r6yr5uPTB/U6YNLT+GsU0= +github.com/dubbogo/getty v1.3.4/go.mod h1:36f+gH/ekaqcDWKbxNBQk9b9HXcGtaI6YHxp4YTntX8= github.com/dubbogo/go-zookeeper v1.0.0 h1:RsYdlGwhDW+iKXM3eIIcvt34P2swLdmQfuIJxsHlGoM= github.com/dubbogo/go-zookeeper v1.0.0/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= @@ -326,6 +331,7 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 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/juju/errors v0.0.0-20190930114154-d42613fe1ab9/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b h1:VE6r2OwP5gj+Z9aCkSKl3MlmnZbfMAjhvR5T7abKHEo= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= diff --git a/metadata/identifier/subscribe_metadata_identifier.go b/metadata/identifier/subscribe_metadata_identifier.go index fd3a290b41..321a216a3e 100644 --- a/metadata/identifier/subscribe_metadata_identifier.go +++ b/metadata/identifier/subscribe_metadata_identifier.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 identifier type SubscriberMetadataIdentifier struct { From b330db7697a2ef26944c2985da197e741a507dc2 Mon Sep 17 00:00:00 2001 From: AlexStocks Date: Sun, 12 Apr 2020 12:34:04 +0800 Subject: [PATCH 077/167] Fix: add PATH_SEPARATOR --- common/constant/key.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/constant/key.go b/common/constant/key.go index 1479af2305..d9413fcc9e 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -223,6 +223,7 @@ const ( KEY_SEPARATOR = ":" DEFAULT_PATH_TAG = "metadata" KEY_REVISON_PREFIX = "revision" + PATH_SEPARATOR = "/" // metadata service METADATA_SERVICE_NAME = "org.apache.dubbo.metadata.MetadataService" From 0098b2bffa28456a85ee2a2d79f4be3bf5372c0b Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sun, 12 Apr 2020 18:07:13 +0800 Subject: [PATCH 078/167] fix --- common/url.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/url.go b/common/url.go index 3916ff105e..3f1761e703 100644 --- a/common/url.go +++ b/common/url.go @@ -609,7 +609,7 @@ func (c *URL) CloneWithParams(reserveParams []string) *URL { params := url.Values{} for _, reserveParam := range reserveParams { v := c.GetParam(reserveParam, "") - if v != "" { + if len(v) != 0 { params.Set(reserveParam, v) } } From b57ba606d15ee863e757036da1c123b1d2f05bf7 Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sun, 12 Apr 2020 18:09:08 +0800 Subject: [PATCH 079/167] fix --- common/constant/default.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/constant/default.go b/common/constant/default.go index 9b229844f0..4e2afa5cb2 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -73,5 +73,5 @@ const ( const ( COMMA_SPLIT_PATTERN = "\\s*[,]+\\s*" - PATH_SEPARATOR = "," + PATH_SEPARATOR = "/" ) From 258a6e925646ff63fcd1a314a16e9cdfb853a083 Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sun, 12 Apr 2020 18:55:40 +0800 Subject: [PATCH 080/167] fix --- common/constant/default.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/constant/default.go b/common/constant/default.go index 4e2afa5cb2..3c889158e4 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -73,5 +73,4 @@ const ( const ( COMMA_SPLIT_PATTERN = "\\s*[,]+\\s*" - PATH_SEPARATOR = "/" ) From 8d92fcb8735d48c45d74309019fef14eadcc0e3e Mon Sep 17 00:00:00 2001 From: "xg.gao" Date: Sun, 12 Apr 2020 19:35:48 +0800 Subject: [PATCH 081/167] go mod --- go.mod | 2 ++ go.sum | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b77fd3edae..1f8edc647c 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,8 @@ require ( github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 github.com/jonboulle/clockwork v0.1.0 // indirect + github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect + github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect diff --git a/go.sum b/go.sum index e0e1c7a9ff..83a96618e7 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e h1:MSuLXx/mveDbpDNhVrcWTMeV4lbYWKcyO4rH+jAxmX0= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= -github.com/apache/dubbo-go-hessian2 v1.4.0 h1:Cb9FQVTy3G93dnDr7P93U8DeKFYpDTJjQp44JG5TafA= -github.com/apache/dubbo-go-hessian2 v1.4.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= github.com/apache/dubbo-go-hessian2 v1.5.0 h1:fzulDG5G7nX0ccgKdiN9XipJ7tZ4WXKgmk4stdlDS6s= github.com/apache/dubbo-go-hessian2 v1.5.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= @@ -104,13 +102,10 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/digitalocean/godo v1.10.0 h1:uW1/FcvZE/hoixnJcnlmIUvTVNdZCLjRLzmDtRi1xXY= github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/divebomb/dubbo-go v1.0.0 h1:QsQxD6UU2WbcaA8YCxU9stiuPUsVCPabFg8hhKGJR8A= github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dubbogo/getty v1.3.3 h1:8m4zZBqFHO+NmhH7rMPlFuuYRVjcPD7cUhumevqMZZs= -github.com/dubbogo/getty v1.3.3/go.mod h1:U92BDyJ6sW9Jpohr2Vlz8w2uUbIbNZ3d+6rJvFTSPp0= github.com/dubbogo/getty v1.3.4 h1:5TvH213pnSIKYzY7IK8TT/r6yr5uPTB/U6YNLT+GsU0= github.com/dubbogo/getty v1.3.4/go.mod h1:36f+gH/ekaqcDWKbxNBQk9b9HXcGtaI6YHxp4YTntX8= github.com/dubbogo/go-zookeeper v1.0.0 h1:RsYdlGwhDW+iKXM3eIIcvt34P2swLdmQfuIJxsHlGoM= @@ -118,8 +113,6 @@ github.com/dubbogo/go-zookeeper v1.0.0/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4D github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.7.0 h1:lWNBIE2hk1Aj2be2uXkyRTpZG0RQZj0/xbXnkIq6EHE= -github.com/dubbogo/gost v1.7.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.8.0 h1:9ACbQe5OwMjqtinQcNJC5xp16kky27OsfSGw5L9A6vw= github.com/dubbogo/gost v1.8.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= @@ -331,7 +324,12 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 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/juju/errors v0.0.0-20190930114154-d42613fe1ab9 h1:hJix6idebFclqlfZCHE7EUX7uqLCyb70nHNHH1XKGBg= github.com/juju/errors v0.0.0-20190930114154-d42613fe1ab9/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI= +github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b h1:Rrp0ByJXEjhREMPGTt3aWYjoIsUGCbt21ekbeJcTWv0= +github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b h1:VE6r2OwP5gj+Z9aCkSKl3MlmnZbfMAjhvR5T7abKHEo= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= @@ -391,8 +389,6 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 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/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb h1:lbmvw8r9W55w+aQgWn35W1nuleRIECMoqUrmwAOAvoI= -github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c h1:WoCa3AvgQMVKNs+RIFlWPRgY9QVJwUxJDrGxHs0fcRo= github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= From 68602ee094bca78a3be12790aaad56b81fe6ce79 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 13 Apr 2020 00:12:37 +0800 Subject: [PATCH 082/167] add start provider with random port --- config/service_config.go | 28 +++++++++++++++++++++++++--- config/service_config_test.go | 9 +++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 50bf5e12c3..3f120aaff2 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -20,6 +20,7 @@ package config import ( "context" "fmt" + "math/rand" "net/url" "strconv" "strings" @@ -105,6 +106,20 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } +// Get Random Ports with size +func getRandomPorts(size int) []int { + ports := make([]int, 0, size) + if size <= 0 { + return ports + } + startPort := int(rand.Int31n(6000) + 10000) + + for i := 0; i < size; i++ { + ports = append(ports, startPort+i*3) + } + return ports +} + // Export ... func (c *ServiceConfig) Export() error { // TODO: config center start here @@ -123,11 +138,14 @@ func (c *ServiceConfig) Export() error { regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols) - if len(protocolConfigs) == 0 { + protocolSize := len(protocolConfigs) + if protocolSize == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs ", c.InterfaceName, c.Protocol) return nil } - for _, proto := range protocolConfigs { + + ports := getRandomPorts(protocolSize) + for i, proto := range protocolConfigs { // registry the service reflect methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.rpcService) if err != nil { @@ -135,11 +153,15 @@ func (c *ServiceConfig) Export() error { logger.Errorf(err.Error()) return err } + port := proto.Port + if len(proto.Port) == 0 { + port = strconv.Itoa(ports[i]) + } ivkURL := common.NewURLWithOptions( common.WithPath(c.id), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), - common.WithPort(proto.Port), + common.WithPort(port), common.WithParams(urlMap), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), common.WithMethods(strings.Split(methods, ",")), diff --git a/config/service_config_test.go b/config/service_config_test.go index 6f32308903..8d9e224a12 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -189,3 +189,12 @@ func Test_Export(t *testing.T) { } providerConfig = nil } + +func Test_getRandomPorts(t *testing.T) { + ports := getRandomPorts(3) + t.Logf("len:%v", len(ports)) + + for _, port := range ports { + t.Logf("port:%v", port) + } +} From a2a3adcd40e281cbc97f0c8cc921dd69873e6577 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 13 Apr 2020 23:50:57 +0800 Subject: [PATCH 083/167] modify test --- config/service_config_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/service_config_test.go b/config/service_config_test.go index 8d9e224a12..c87eb32e61 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -18,6 +18,7 @@ package config import ( + "github.com/stretchr/testify/assert" "testing" ) @@ -191,10 +192,13 @@ func Test_Export(t *testing.T) { } func Test_getRandomPorts(t *testing.T) { - ports := getRandomPorts(3) + size := 3 + ports := getRandomPorts(size) t.Logf("len:%v", len(ports)) for _, port := range ports { t.Logf("port:%v", port) } + + assert.Equal(t, size, len(ports)) } From 3c19887b99ba6f8c143211a2d7bdc7b3ecd08e41 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Tue, 14 Apr 2020 22:02:46 +0800 Subject: [PATCH 084/167] modify start provider with random port --- config/service_config.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 3f120aaff2..c996604617 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -20,7 +20,7 @@ package config import ( "context" "fmt" - "math/rand" + "net" "net/url" "strconv" "strings" @@ -112,10 +112,30 @@ func getRandomPorts(size int) []int { if size <= 0 { return ports } - startPort := int(rand.Int31n(6000) + 10000) - for i := 0; i < size; i++ { - ports = append(ports, startPort+i*3) + var ( + flag bool + addr *net.TCPAddr + ) + i := 0 + for i < size { + flag = false + addr = nil + go func() { + listener, err := net.Listen("tcp", ":0") + if err != nil { + return + } + + flag = true + addr = listener.Addr().(*net.TCPAddr) + }() + time.Sleep(50 * time.Millisecond) + if !flag { + continue + } + ports = append(ports, addr.Port) + i++ } return ports } From cc1f480aa994efc52a9eb090700e13f659e73a6d Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Tue, 14 Apr 2020 22:06:41 +0800 Subject: [PATCH 085/167] modify start provider with random port --- config/service_config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index c996604617..f1ea65889c 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -106,6 +106,11 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } +// Get Random Ports with no size +func getRandomPort() int { + return getRandomPorts(1)[0] +} + // Get Random Ports with size func getRandomPorts(size int) []int { ports := make([]int, 0, size) @@ -164,8 +169,7 @@ func (c *ServiceConfig) Export() error { return nil } - ports := getRandomPorts(protocolSize) - for i, proto := range protocolConfigs { + for _, proto := range protocolConfigs { // registry the service reflect methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.rpcService) if err != nil { @@ -175,7 +179,7 @@ func (c *ServiceConfig) Export() error { } port := proto.Port if len(proto.Port) == 0 { - port = strconv.Itoa(ports[i]) + port = strconv.Itoa(getRandomPort()) } ivkURL := common.NewURLWithOptions( common.WithPath(c.id), From 2810c63560b15e544170670de3d157eb6a243ad5 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Tue, 14 Apr 2020 22:08:49 +0800 Subject: [PATCH 086/167] modify test --- config/service_config_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/service_config_test.go b/config/service_config_test.go index c87eb32e61..bf27e6d6de 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -202,3 +202,10 @@ func Test_getRandomPorts(t *testing.T) { assert.Equal(t, size, len(ports)) } + +func Test_getRandomPort(t *testing.T) { + port := getRandomPort() + t.Logf("port:%v", port) + + assert.Greater(t, port, 0) +} From ceb0292482c271c6ba9719afbc1f2f6c0456f89e Mon Sep 17 00:00:00 2001 From: Xargin Date: Fri, 17 Apr 2020 16:02:50 +0800 Subject: [PATCH 087/167] a little refactor --- common/url.go | 10 +- config/config_loader.go | 204 +++++++++++++++++++++------------------- 2 files changed, 113 insertions(+), 101 deletions(-) diff --git a/common/url.go b/common/url.go index 3f1761e703..768b62d4bf 100644 --- a/common/url.go +++ b/common/url.go @@ -264,17 +264,19 @@ func (c URL) URLEqual(url URL) bool { } else if urlGroup == constant.ANY_VALUE { urlKey = strings.Replace(urlKey, "group=*", "group="+cGroup, 1) } + + // 1. protocol, username, password, ip, port, service name, group, version should be equal if cKey != urlKey { return false } + + // 2. if url contains enabled key, should be true, or * if url.GetParam(constant.ENABLED_KEY, "true") != "true" && url.GetParam(constant.ENABLED_KEY, "") != constant.ANY_VALUE { return false } + //TODO :may need add interface key any value condition - if !isMatchCategory(url.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), c.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY)) { - return false - } - return true + return isMatchCategory(url.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), c.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY)) } func isMatchCategory(category1 string, category2 string) bool { diff --git a/config/config_loader.go b/config/config_loader.go index 61cb49457b..74039b0b6b 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -81,128 +81,138 @@ func checkApplicationName(config *ApplicationConfig) { } } -// Load Dubbo Init -func Load() { - - // init router - if confRouterFile != "" { - if errPro := RouterInit(confRouterFile); errPro != nil { - log.Printf("[routerConfig init] %#v", errPro) - } - } - - // reference config +func loadConsumerConfig() { if consumerConfig == nil { logger.Warnf("consumerConfig is nil!") - } else { - // 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) + 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) + } + } - metricConfig = consumerConfig.MetricConfig - applicationConfig = consumerConfig.ApplicationConfig + metricConfig = consumerConfig.MetricConfig + applicationConfig = consumerConfig.ApplicationConfig - checkApplicationName(consumerConfig.ApplicationConfig) - if err := configCenterRefreshConsumer(); err != nil { - logger.Errorf("[consumer config center refresh] %#v", err) + checkApplicationName(consumerConfig.ApplicationConfig) + if err := configCenterRefreshConsumer(); err != nil { + logger.Errorf("[consumer config center refresh] %#v", err) + } + checkRegistries(consumerConfig.Registries, consumerConfig.Registry) + for key, ref := range consumerConfig.References { + if ref.Generic { + genericService := NewGenericService(key) + SetConsumerService(genericService) } - 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) + rpcService := GetConsumerService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue } + ref.id = key + ref.Refer(rpcService) + ref.Implement(rpcService) + } - //wait for invoker is available, if wait over default 3s, then panic - var count int - checkok := true - for { - 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 + //wait for invoker is available, if wait over default 3s, then panic + var count int + checkok := true + for { + 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 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 - } - checkok = true } + if checkok { + break + } + checkok = true } +} - // service config +func loadProviderConfig() { if providerConfig == nil { logger.Warnf("providerConfig is nil!") - } else { - // 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) + 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) + } + } - // so, you should know that the consumer's config will be override - metricConfig = providerConfig.MetricConfig - applicationConfig = providerConfig.ApplicationConfig + // so, you should know that the consumer's config will be override + metricConfig = providerConfig.MetricConfig + applicationConfig = providerConfig.ApplicationConfig - checkApplicationName(providerConfig.ApplicationConfig) - if err := configCenterRefreshProvider(); err != nil { - logger.Errorf("[provider config center refresh] %#v", err) + checkApplicationName(providerConfig.ApplicationConfig) + if err := configCenterRefreshProvider(); err != nil { + logger.Errorf("[provider config center refresh] %#v", err) + } + checkRegistries(providerConfig.Registries, providerConfig.Registry) + for key, svs := range providerConfig.Services { + rpcService := GetProviderService(key) + if rpcService == nil { + logger.Warnf("%s does not exist!", key) + continue } - checkRegistries(providerConfig.Registries, providerConfig.Registry) - 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) - if err := svs.Export(); err != nil { - panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) - } + svs.id = key + svs.Implement(rpcService) + if err := svs.Export(); err != nil { + panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) } } +} + +// Load Dubbo Init +func Load() { + + // init router + if confRouterFile != "" { + if errPro := RouterInit(confRouterFile); errPro != nil { + log.Printf("[routerConfig init] %#v", errPro) + } + } + + // reference config + loadConsumerConfig() + + // service config + loadProviderConfig() + // init the shutdown callback GracefulShutdownInit() } From b4df1256772a2ef05db84ba1a20637e107308ecb Mon Sep 17 00:00:00 2001 From: Xargin Date: Sat, 18 Apr 2020 23:06:35 +0800 Subject: [PATCH 088/167] extract router init to func --- config/config_loader.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/config/config_loader.go b/config/config_loader.go index 74039b0b6b..c84817eaea 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -197,15 +197,19 @@ func loadProviderConfig() { } } +func initRouter() { + if confRouterFile != "" { + if err := RouterInit(confRouterFile); err != nil { + log.Printf("[routerConfig init] %#v", err) + } + } +} + // Load Dubbo Init func Load() { // init router - if confRouterFile != "" { - if errPro := RouterInit(confRouterFile); errPro != nil { - log.Printf("[routerConfig init] %#v", errPro) - } - } + initRouter() // reference config loadConsumerConfig() From f9eeb8b8fc21ee25100971db73aa562b58d56a8e Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Sat, 18 Apr 2020 23:28:08 +0800 Subject: [PATCH 089/167] modify random port implement --- config/service_config.go | 47 ++++++++-------------------------------- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index f1ea65889c..a05c7a0388 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -20,7 +20,7 @@ package config import ( "context" "fmt" - "net" + gxnet "github.com/dubbogo/gost/net" "net/url" "strconv" "strings" @@ -106,43 +106,14 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } -// Get Random Ports with no size -func getRandomPort() int { - return getRandomPorts(1)[0] -} - -// Get Random Ports with size -func getRandomPorts(size int) []int { - ports := make([]int, 0, size) - if size <= 0 { - return ports - } - - var ( - flag bool - addr *net.TCPAddr - ) - i := 0 - for i < size { - flag = false - addr = nil - go func() { - listener, err := net.Listen("tcp", ":0") - if err != nil { - return - } - - flag = true - addr = listener.Addr().(*net.TCPAddr) - }() - time.Sleep(50 * time.Millisecond) - if !flag { - continue - } - ports = append(ports, addr.Port) - i++ +// Get Random Port +func getRandomPort(ip string) string { + tcp, err := gxnet.ListenOnTCPRandomPort(ip) + if err != nil { + panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) } - return ports + defer tcp.Close() + return strings.Split(tcp.Addr().String(), ":")[1] } // Export ... @@ -179,7 +150,7 @@ func (c *ServiceConfig) Export() error { } port := proto.Port if len(proto.Port) == 0 { - port = strconv.Itoa(getRandomPort()) + port = getRandomPort(proto.Ip) } ivkURL := common.NewURLWithOptions( common.WithPath(c.id), diff --git a/go.mod b/go.mod index b77fd3edae..649f9b781a 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/creasty/defaults v1.3.0 github.com/dubbogo/getty v1.3.4 github.com/dubbogo/go-zookeeper v1.0.0 - github.com/dubbogo/gost v1.8.0 + github.com/dubbogo/gost v1.9.0 github.com/emicklei/go-restful/v3 v3.0.0 github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect github.com/go-errors/errors v1.0.1 // indirect diff --git a/go.sum b/go.sum index e0e1c7a9ff..95deb6611b 100644 --- a/go.sum +++ b/go.sum @@ -122,6 +122,8 @@ github.com/dubbogo/gost v1.7.0 h1:lWNBIE2hk1Aj2be2uXkyRTpZG0RQZj0/xbXnkIq6EHE= github.com/dubbogo/gost v1.7.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.8.0 h1:9ACbQe5OwMjqtinQcNJC5xp16kky27OsfSGw5L9A6vw= github.com/dubbogo/gost v1.8.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +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/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0 h1:ZoRgc53qJCfSLimXqJDrmBhnt5GChDsExMCK7t48o0Y= From 5076a4f8450d5151bd3fbe954bc2475c9a8c28d2 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Sat, 18 Apr 2020 23:51:56 +0800 Subject: [PATCH 090/167] fix test case error --- config/service_config_test.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/config/service_config_test.go b/config/service_config_test.go index bf27e6d6de..f0d69e6c65 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -18,9 +18,12 @@ package config import ( - "github.com/stretchr/testify/assert" "testing" ) +import ( + gxnet "github.com/dubbogo/gost/net" + "github.com/stretchr/testify/assert" +) import ( "github.com/apache/dubbo-go/common/extension" @@ -191,21 +194,11 @@ func Test_Export(t *testing.T) { providerConfig = nil } -func Test_getRandomPorts(t *testing.T) { - size := 3 - ports := getRandomPorts(size) - t.Logf("len:%v", len(ports)) - - for _, port := range ports { - t.Logf("port:%v", port) - } - - assert.Equal(t, size, len(ports)) -} - func Test_getRandomPort(t *testing.T) { - port := getRandomPort() + ip, err := gxnet.GetLocalIP() + assert.NoError(t, err) + port := getRandomPort(ip) t.Logf("port:%v", port) - assert.Greater(t, port, 0) + assert.Greater(t, len(port), 0) } From 86dfd94b60b2f349cd3f77e494780a78313abc38 Mon Sep 17 00:00:00 2001 From: wongoo Date: Mon, 20 Apr 2020 10:43:19 +0800 Subject: [PATCH 091/167] update v1.4.0 tag link in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd4b936d4d..b3e7173c43 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Apache License, Version 2.0 ## Release note ## -[v1.4.0-rc1 - Mar 17, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1) +[v1.4.0 - Mar 17, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0) [v1.3.0 - Mar 1, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.3.0) From c50325bbbe03914eabb59cd5cd0634a44b1faa98 Mon Sep 17 00:00:00 2001 From: wongoo Date: Mon, 20 Apr 2020 10:46:45 +0800 Subject: [PATCH 092/167] add v1.4.0 link in readme --- README_CN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_CN.md b/README_CN.md index 9fe34074f3..5c40249ed2 100644 --- a/README_CN.md +++ b/README_CN.md @@ -15,6 +15,8 @@ Apache License, Version 2.0 ## 发布日志 ## +[v1.4.0 - 2020年3月17日](https://github.com/apache/dubbo-go/releases/tag/v1.4.0) + [v1.3.0 - 2020年3月1日](https://github.com/apache/dubbo-go/releases/tag/v1.3.0) [v1.2.0 - 2019年11月15日](https://github.com/apache/dubbo-go/releases/tag/v1.2.0) From 58dd5bdc4ee99bf1b1191562f0e4a6133ed87603 Mon Sep 17 00:00:00 2001 From: flycash Date: Thu, 23 Apr 2020 21:53:15 +0800 Subject: [PATCH 093/167] Add comments for ServiceMethodLimiter --- .../tps/tps_limiter_method_service.go | 25 +++++++++++++++++-- filter/tps_limiter.go | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/filter/filter_impl/tps/tps_limiter_method_service.go b/filter/filter_impl/tps/tps_limiter_method_service.go index 7fe8de9237..2d44c688eb 100644 --- a/filter/filter_impl/tps/tps_limiter_method_service.go +++ b/filter/filter_impl/tps/tps_limiter_method_service.go @@ -115,7 +115,12 @@ type MethodServiceTpsLimiterImpl struct { tpsState *concurrent.Map } -// IsAllowable ... +// IsAllowable based on method-level and service-level. +// The method-level has high priority which means that if there is any rate limit configuration for the method, +// the service-level rate limit strategy will be ignored. +// The key point is how to keep thread-safe +// This implementation use concurrent map + loadOrStore to make implementation thread-safe +// You can image that even multiple threads create limiter, but only one could store the limiter into tpsState func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocation protocol.Invocation) bool { methodConfigPrefix := "methods." + invocation.MethodName() + "." @@ -123,23 +128,30 @@ func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocatio methodLimitRateConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_RATE_KEY, "") methodIntervalConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_INTERVAL_KEY, "") + // service-level tps limit limitTarget := url.ServiceKey() // method-level tps limit if len(methodIntervalConfig) > 0 || len(methodLimitRateConfig) > 0 { + // it means that if the method-level rate limit exist, we will use method-level rate limit strategy limitTarget = limitTarget + "#" + invocation.MethodName() } + // looking up the limiter from 'cache' limitState, found := limiter.tpsState.Load(limitTarget) if found { + // the limiter has been cached, we return its result return limitState.(filter.TpsLimitStrategy).IsAllowable() } + // we could not find the limiter, and try to create one. + limitRate := getLimitConfig(methodLimitRateConfig, url, invocation, constant.TPS_LIMIT_RATE_KEY, constant.DEFAULT_TPS_LIMIT_RATE) if limitRate < 0 { + // the limitTarget is not necessary to be limited. return true } @@ -150,13 +162,20 @@ func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url common.URL, invocatio panic(fmt.Sprintf("The interval must be positive, please check your configuration! url: %s", url.String())) } + // find the strategy config and then create one limitStrategyConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_STRATEGY_KEY, url.GetParam(constant.TPS_LIMIT_STRATEGY_KEY, constant.DEFAULT_KEY)) limitStateCreator := extension.GetTpsLimitStrategyCreator(limitStrategyConfig) + + // we using loadOrStore to ensure thread-safe limitState, _ = limiter.tpsState.LoadOrStore(limitTarget, limitStateCreator.Create(int(limitRate), int(limitInterval))) + return limitState.(filter.TpsLimitStrategy).IsAllowable() } +// getLimitConfig will try to fetch the configuration from url. +// If we can convert the methodLevelConfig to int64, return; +// Or, we will try to look up server-level configuration and then convert it to int64 func getLimitConfig(methodLevelConfig string, url common.URL, invocation protocol.Invocation, @@ -172,6 +191,8 @@ func getLimitConfig(methodLevelConfig string, return result } + // actually there is no method-level configuration, so we use the service-level configuration + result, err := strconv.ParseInt(url.GetParam(configKey, defaultVal), 0, 0) if err != nil { @@ -183,7 +204,7 @@ func getLimitConfig(methodLevelConfig string, var methodServiceTpsLimiterInstance *MethodServiceTpsLimiterImpl var methodServiceTpsLimiterOnce sync.Once -// GetMethodServiceTpsLimiter ... +// GetMethodServiceTpsLimiter will return an MethodServiceTpsLimiterImpl instance. func GetMethodServiceTpsLimiter() filter.TpsLimiter { methodServiceTpsLimiterOnce.Do(func() { methodServiceTpsLimiterInstance = &MethodServiceTpsLimiterImpl{ diff --git a/filter/tps_limiter.go b/filter/tps_limiter.go index dbc9f76838..531eb09823 100644 --- a/filter/tps_limiter.go +++ b/filter/tps_limiter.go @@ -34,5 +34,6 @@ import ( * tps.limiter: "the name of limiter", */ type TpsLimiter interface { + // IsAllowable will check whether this invocation should be enabled for further process IsAllowable(common.URL, protocol.Invocation) bool } From f04c1702f3d24894dc99e4c23bae04aa07b12fb7 Mon Sep 17 00:00:00 2001 From: fangyincheng Date: Sat, 25 Apr 2020 19:27:43 +0800 Subject: [PATCH 094/167] Mod: add comment and modify log level --- common/proxy/proxy.go | 7 +++---- common/proxy/proxy_factory.go | 2 +- common/rpc_service.go | 23 +++++++++++------------ common/url.go | 4 ++-- protocol/dubbo/client.go | 27 ++++++++++++--------------- protocol/dubbo/codec.go | 10 +++++----- protocol/dubbo/config.go | 6 +++--- protocol/dubbo/dubbo_exporter.go | 6 +++--- protocol/dubbo/dubbo_invoker.go | 13 +++++++------ protocol/dubbo/dubbo_protocol.go | 12 ++++++------ protocol/dubbo/listener.go | 4 ++-- protocol/dubbo/readwriter.go | 10 +++++++--- protocol/dubbo/server.go | 19 +++++++++---------- 13 files changed, 71 insertions(+), 72 deletions(-) diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 68ba3ff788..f98a44873a 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -44,7 +44,7 @@ var ( typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type() ) -// NewProxy ... +// NewProxy create service proxy. func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[string]string) *Proxy { return &Proxy{ invoke: invoke, @@ -59,7 +59,6 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str // type XxxProvider struct { // Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error // } - func (p *Proxy) Implement(v common.RPCService) { // check parameters, incoming interface must be a elem's pointer. @@ -202,12 +201,12 @@ func (p *Proxy) Implement(v common.RPCService) { } -// Get ... +// Get get rpc service instance. func (p *Proxy) Get() common.RPCService { return p.rpc } -// GetCallback ... +// GetCallback get callback. func (p *Proxy) GetCallback() interface{} { return p.callBack } diff --git a/common/proxy/proxy_factory.go b/common/proxy/proxy_factory.go index 7b249a3e97..34fa3fd07e 100644 --- a/common/proxy/proxy_factory.go +++ b/common/proxy/proxy_factory.go @@ -22,7 +22,7 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// ProxyFactory ... +// ProxyFactory interface. type ProxyFactory interface { GetProxy(invoker protocol.Invoker, url *common.URL) *Proxy GetAsyncProxy(invoker protocol.Invoker, callBack interface{}, url *common.URL) *Proxy diff --git a/common/rpc_service.go b/common/rpc_service.go index ebd1d02f84..d7d900718e 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -59,7 +59,6 @@ type AsyncCallback func(response CallbackResponse) // return map[string][string]{} // } const ( - // METHOD_MAPPER ... METHOD_MAPPER = "MethodMapper" ) @@ -68,7 +67,7 @@ var ( // because Typeof takes an empty interface value. This is annoying. typeOfError = reflect.TypeOf((*error)(nil)).Elem() - // ServiceMap ... + // ServiceMap store description of service. // todo: lowerecas? ServiceMap = &serviceMap{ serviceMap: make(map[string]map[string]*Service), @@ -80,7 +79,7 @@ var ( // info of method ////////////////////////// -// MethodType ... +// MethodType is description of service method. type MethodType struct { method reflect.Method ctxType reflect.Type // request context @@ -88,27 +87,27 @@ type MethodType struct { replyType reflect.Type // return value, otherwise it is nil } -// Method ... +// Method get @m.method. func (m *MethodType) Method() reflect.Method { return m.method } -// CtxType ... +// CtxType get @m.ctxType. func (m *MethodType) CtxType() reflect.Type { return m.ctxType } -// ArgsType ... +// ArgsType get @m.argsType. func (m *MethodType) ArgsType() []reflect.Type { return m.argsType } -// ReplyType ... +// ReplyType get @m.replyType. func (m *MethodType) ReplyType() reflect.Type { return m.replyType } -// SuiteContext ... +// SuiteContext tranfer @ctx to reflect.Value type or get it from @m.ctxType. func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value { if contextv := reflect.ValueOf(ctx); contextv.IsValid() { return contextv @@ -120,7 +119,7 @@ func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value { // info of service interface ////////////////////////// -// Service ... +// Service is description of service type Service struct { name string rcvr reflect.Value @@ -128,17 +127,17 @@ type Service struct { methods map[string]*MethodType } -// Method ... +// Method get @s.methods. func (s *Service) Method() map[string]*MethodType { return s.methods } -// RcvrType ... +// RcvrType get @s.rcvrType. func (s *Service) RcvrType() reflect.Type { return s.rcvrType } -// Rcvr ... +// Rcvr get @s.rcvr. func (s *Service) Rcvr() reflect.Value { return s.rcvr } diff --git a/common/url.go b/common/url.go index 768b62d4bf..a70ac7dc9d 100644 --- a/common/url.go +++ b/common/url.go @@ -248,7 +248,7 @@ func NewURL(urlString string, opts ...option) (URL, error) { return s, nil } -// URLEqual ... +// URLEqual judge @url and @c is equal or not. func (c URL) URLEqual(url URL) bool { c.Ip = "" c.Port = "" @@ -316,7 +316,7 @@ func (c URL) Key() string { return buildString } -// ServiceKey ... +// ServiceKey get a unique key of a service. func (c URL) ServiceKey() string { intf := c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/")) if intf == "" { diff --git a/protocol/dubbo/client.go b/protocol/dubbo/client.go index 5ec7db51af..e6ffa64d80 100644 --- a/protocol/dubbo/client.go +++ b/protocol/dubbo/client.go @@ -88,7 +88,7 @@ func init() { rand.Seed(time.Now().UnixNano()) } -// SetClientConf ... +// SetClientConf set dubbo client config. func SetClientConf(c ClientConfig) { clientConf = &c err := clientConf.CheckValidity() @@ -99,7 +99,7 @@ func SetClientConf(c ClientConfig) { setClientGrpool() } -// GetClientConf ... +// GetClientConf get dubbo client config. func GetClientConf() ClientConfig { return *clientConf } @@ -129,7 +129,7 @@ type AsyncCallbackResponse struct { Reply interface{} } -// Client ... +// Client is dubbo protocol client. type Client struct { opts Options conf ClientConfig @@ -139,7 +139,7 @@ type Client struct { pendingResponses *sync.Map } -// NewClient ... +// NewClient create a new Client. func NewClient(opt Options) *Client { switch { @@ -167,7 +167,7 @@ func NewClient(opt Options) *Client { return c } -// Request ... +// Request is dubbo protocol request. type Request struct { addr string svcUrl common.URL @@ -176,7 +176,7 @@ type Request struct { atta map[string]string } -// NewRequest ... +// NewRequest create a new Request. func NewRequest(addr string, svcUrl common.URL, method string, args interface{}, atta map[string]string) *Request { return &Request{ addr: addr, @@ -187,13 +187,13 @@ func NewRequest(addr string, svcUrl common.URL, method string, args interface{}, } } -// Response ... +// Response is dubbo protocol response. type Response struct { reply interface{} atta map[string]string } -// NewResponse ... +// NewResponse create a new Response. func NewResponse(reply interface{}, atta map[string]string) *Response { return &Response{ reply: reply, @@ -201,15 +201,14 @@ func NewResponse(reply interface{}, atta map[string]string) *Response { } } -// CallOneway call one way +// CallOneway call by one way func (c *Client) CallOneway(request *Request) error { return perrors.WithStack(c.call(CT_OneWay, request, NewResponse(nil, nil), nil)) } -// Call if @response is nil, the transport layer will get the response without notify the invoker. +// Call call remoting by two way or one way, if @response.reply is nil, the way of call is one way. func (c *Client) Call(request *Request, response *Response) error { - ct := CT_TwoWay if response.reply == nil { ct = CT_OneWay @@ -218,14 +217,12 @@ func (c *Client) Call(request *Request, response *Response) error { return perrors.WithStack(c.call(ct, request, response, nil)) } -// AsyncCall ... +// AsyncCall call remoting by async with callback. func (c *Client) AsyncCall(request *Request, callback common.AsyncCallback, response *Response) error { - return perrors.WithStack(c.call(CT_TwoWay, request, response, callback)) } func (c *Client) call(ct CallType, request *Request, response *Response, callback common.AsyncCallback) error { - p := &DubboPackage{} p.Service.Path = strings.TrimPrefix(request.svcUrl.Path, "/") p.Service.Interface = request.svcUrl.GetParam(constant.INTERFACE_KEY, "") @@ -293,7 +290,7 @@ func (c *Client) call(ct CallType, request *Request, response *Response, callbac return perrors.WithStack(err) } -// Close ... +// Close close the client pool. func (c *Client) Close() { if c.pool != nil { c.pool.close() diff --git a/protocol/dubbo/codec.go b/protocol/dubbo/codec.go index 76416b2baf..620a57d4a7 100644 --- a/protocol/dubbo/codec.go +++ b/protocol/dubbo/codec.go @@ -69,7 +69,7 @@ func (p DubboPackage) String() string { return fmt.Sprintf("DubboPackage: Header-%v, Path-%v, Body-%v", p.Header, p.Service, p.Body) } -// Marshal ... +// Marshal encode hessian package. func (p *DubboPackage) Marshal() (*bytes.Buffer, error) { codec := hessian.NewHessianCodec(nil) @@ -81,7 +81,7 @@ func (p *DubboPackage) Marshal() (*bytes.Buffer, error) { return bytes.NewBuffer(pkg), nil } -// Unmarshal ... +// Unmarshal dncode hessian package. func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error { // fix issue https://github.com/apache/dubbo-go/issues/380 bufLen := buf.Len() @@ -125,7 +125,7 @@ func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error { // PendingResponse //////////////////////////////////////////// -// PendingResponse ... +// PendingResponse is a pending response. type PendingResponse struct { seq uint64 err error @@ -136,7 +136,7 @@ type PendingResponse struct { done chan struct{} } -// NewPendingResponse ... +// NewPendingResponse create a PendingResponses. func NewPendingResponse() *PendingResponse { return &PendingResponse{ start: time.Now(), @@ -145,7 +145,7 @@ func NewPendingResponse() *PendingResponse { } } -// GetCallResponse ... +// GetCallResponse get AsyncCallbackResponse. func (r PendingResponse) GetCallResponse() common.CallbackResponse { return AsyncCallbackResponse{ Cause: r.err, diff --git a/protocol/dubbo/config.go b/protocol/dubbo/config.go index dbc6989c54..6a1daf857a 100644 --- a/protocol/dubbo/config.go +++ b/protocol/dubbo/config.go @@ -147,7 +147,7 @@ func GetDefaultServerConfig() ServerConfig { } } -// CheckValidity ... +// CheckValidity confirm getty sessian params. func (c *GettySessionParam) CheckValidity() error { var err error @@ -170,7 +170,7 @@ func (c *GettySessionParam) CheckValidity() error { return nil } -// CheckValidity ... +// CheckValidity confirm client params. func (c *ClientConfig) CheckValidity() error { var err error @@ -192,7 +192,7 @@ func (c *ClientConfig) CheckValidity() error { return perrors.WithStack(c.GettySessionParam.CheckValidity()) } -// CheckValidity ... +// CheckValidity confirm server params. func (c *ServerConfig) CheckValidity() error { var err error diff --git a/protocol/dubbo/dubbo_exporter.go b/protocol/dubbo/dubbo_exporter.go index 1c45c40056..dd80937c5b 100644 --- a/protocol/dubbo/dubbo_exporter.go +++ b/protocol/dubbo/dubbo_exporter.go @@ -28,19 +28,19 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// DubboExporter ... +// DubboExporter is dubbo service exporter. type DubboExporter struct { protocol.BaseExporter } -// NewDubboExporter ... +// NewDubboExporter get a DubboExporter. func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map) *DubboExporter { return &DubboExporter{ BaseExporter: *protocol.NewBaseExporter(key, invoker, exporterMap), } } -// Unexport ... +// Unexport unexport dubbo service exporter. func (de *DubboExporter) Unexport() { serviceId := de.GetInvoker().GetUrl().GetParam(constant.BEAN_NAME_KEY, "") interfaceName := de.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 09c3725710..59202d5f49 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -39,8 +39,9 @@ import ( ) var ( - // ErrNoReply ... - ErrNoReply = perrors.New("request need @response") + // ErrNoReply + ErrNoReply = perrors.New("request need @response") + // ErrDestroyedInvoker ErrDestroyedInvoker = perrors.New("request Destroyed invoker") ) @@ -48,7 +49,7 @@ var ( attachmentKey = []string{constant.INTERFACE_KEY, constant.GROUP_KEY, constant.TOKEN_KEY, constant.TIMEOUT_KEY} ) -// DubboInvoker ... +// DubboInvoker is dubbo client invoker. type DubboInvoker struct { protocol.BaseInvoker client *Client @@ -57,7 +58,7 @@ type DubboInvoker struct { reqNum int64 } -// NewDubboInvoker ... +// NewDubboInvoker create dubbo client invoker. func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker { return &DubboInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), @@ -66,7 +67,7 @@ func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker { } } -// Invoke ... +// Invoke call remoting. func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { var ( err error @@ -122,7 +123,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati return &result } -// Destroy ... +// Destroy destroy dubbo client invoker. func (di *DubboInvoker) Destroy() { di.quitOnce.Do(func() { for { diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 355dbc8024..b7d0a8a268 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -45,14 +45,14 @@ var ( dubboProtocol *DubboProtocol ) -// DubboProtocol ... +// DubboProtocol is a dubbo protocol implement. type DubboProtocol struct { protocol.BaseProtocol serverMap map[string]*Server serverLock sync.Mutex } -// NewDubboProtocol ... +// NewDubboProtocol create a dubbo protocol. func NewDubboProtocol() *DubboProtocol { return &DubboProtocol{ BaseProtocol: protocol.NewBaseProtocol(), @@ -60,7 +60,7 @@ func NewDubboProtocol() *DubboProtocol { } } -// Export ... +// Export export dubbo service. func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { url := invoker.GetUrl() serviceKey := url.ServiceKey() @@ -73,7 +73,7 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { return exporter } -// Refer ... +// Refer create dubbo service reference. func (dp *DubboProtocol) Refer(url common.URL) protocol.Invoker { //default requestTimeout var requestTimeout = config.GetConsumerConfig().RequestTimeout @@ -92,7 +92,7 @@ func (dp *DubboProtocol) Refer(url common.URL) protocol.Invoker { return invoker } -// Destroy ... +// Destroy destroy dubbo service. func (dp *DubboProtocol) Destroy() { logger.Infof("DubboProtocol destroy.") @@ -124,7 +124,7 @@ func (dp *DubboProtocol) openServer(url common.URL) { } } -// GetProtocol ... +// GetProtocol get a single dubbo protocol. func GetProtocol() protocol.Protocol { if dubboProtocol == nil { dubboProtocol = NewDubboProtocol() diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index 0251b78a2b..1f4cc0068e 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -86,7 +86,7 @@ func (h *RpcClientHandler) OnOpen(session getty.Session) error { // OnError ... func (h *RpcClientHandler) OnError(session getty.Session, err error) { - logger.Infof("session{%s} got error{%v}, will be closed.", session.Stat(), err) + logger.Warnf("session{%s} got error{%v}, will be closed.", session.Stat(), err) h.conn.removeSession(session) } @@ -201,7 +201,7 @@ func (h *RpcServerHandler) OnOpen(session getty.Session) error { // OnError ... func (h *RpcServerHandler) OnError(session getty.Session, err error) { - logger.Infof("session{%s} got error{%v}, will be closed.", session.Stat(), err) + logger.Warnf("session{%s} got error{%v}, will be closed.", session.Stat(), err) h.rwlock.Lock() delete(h.sessionMap, session) h.rwlock.Unlock() diff --git a/protocol/dubbo/readwriter.go b/protocol/dubbo/readwriter.go index b5c4f50919..9cc7ea25cd 100644 --- a/protocol/dubbo/readwriter.go +++ b/protocol/dubbo/readwriter.go @@ -38,16 +38,17 @@ import ( // RpcClientPackageHandler //////////////////////////////////////////// -// RpcClientPackageHandler ... +// RpcClientPackageHandler handle package for client in getty. type RpcClientPackageHandler struct { client *Client } -// NewRpcClientPackageHandler ... +// NewRpcClientPackageHandler create a RpcClientPackageHandler. func NewRpcClientPackageHandler(client *Client) *RpcClientPackageHandler { return &RpcClientPackageHandler{client: client} } +// Read decode @data to DubboPackage. func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) { pkg := &DubboPackage{} @@ -72,6 +73,7 @@ func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface return pkg, hessian.HEADER_LENGTH + pkg.Header.BodyLen, nil } +// Write encode @pkg. func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error) { req, ok := pkg.(*DubboPackage) if !ok { @@ -96,9 +98,10 @@ var ( rpcServerPkgHandler = &RpcServerPackageHandler{} ) -// RpcServerPackageHandler ... +// RpcServerPackageHandler handle package for server in getty. type RpcServerPackageHandler struct{} +// Read decode @data to DubboPackage. func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) { pkg := &DubboPackage{ Body: make([]interface{}, 7), @@ -169,6 +172,7 @@ func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface return pkg, hessian.HEADER_LENGTH + pkg.Header.BodyLen, nil } +// Write encode @pkg. func (p *RpcServerPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error) { res, ok := pkg.(*DubboPackage) if !ok { diff --git a/protocol/dubbo/server.go b/protocol/dubbo/server.go index bd2b37b7a9..8de353a0b3 100644 --- a/protocol/dubbo/server.go +++ b/protocol/dubbo/server.go @@ -71,10 +71,10 @@ func init() { if err := srvConf.CheckValidity(); err != nil { panic(err) } - SetServerGrpool() + setServerGrpool() } -// SetServerConfig ... +// SetServerConfig set dubbo server config. func SetServerConfig(s ServerConfig) { srvConf = &s err := srvConf.CheckValidity() @@ -82,30 +82,29 @@ func SetServerConfig(s ServerConfig) { logger.Warnf("[ServerConfig CheckValidity] error: %v", err) return } - SetServerGrpool() + setServerGrpool() } -// GetServerConfig ... +// GetServerConfig get dubbo server config. func GetServerConfig() ServerConfig { return *srvConf } -// SetServerGrpool ... -func SetServerGrpool() { +func setServerGrpool() { if srvConf.GrPoolSize > 1 { srvGrpool = gxsync.NewTaskPool(gxsync.WithTaskPoolTaskPoolSize(srvConf.GrPoolSize), gxsync.WithTaskPoolTaskQueueLength(srvConf.QueueLen), gxsync.WithTaskPoolTaskQueueNumber(srvConf.QueueNumber)) } } -// Server ... +// Server is dubbo protocol server. type Server struct { conf ServerConfig tcpServer getty.Server rpcHandler *RpcServerHandler } -// NewServer ... +// NewServer create a new Server. func NewServer() *Server { s := &Server{ @@ -156,7 +155,7 @@ func (s *Server) newSession(session getty.Session) error { return nil } -// Start ... +// Start start dubbo server. func (s *Server) Start(url common.URL) { var ( addr string @@ -173,7 +172,7 @@ func (s *Server) Start(url common.URL) { } -// Stop ... +// Stop stop dubbo server. func (s *Server) Stop() { s.tcpServer.Close() } From 74212fdeeae9efe48a87bf5d0d1b8643045d7c7b Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Sat, 25 Apr 2020 23:25:00 +0800 Subject: [PATCH 095/167] modify implement --- config/service_config.go | 17 +---------------- config/service_config_test.go | 13 ------------- go.mod | 4 +++- go.sum | 22 +++++++--------------- 4 files changed, 11 insertions(+), 45 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index a05c7a0388..4cd7ae2739 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -20,7 +20,6 @@ package config import ( "context" "fmt" - gxnet "github.com/dubbogo/gost/net" "net/url" "strconv" "strings" @@ -106,16 +105,6 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } -// Get Random Port -func getRandomPort(ip string) string { - tcp, err := gxnet.ListenOnTCPRandomPort(ip) - if err != nil { - panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) - } - defer tcp.Close() - return strings.Split(tcp.Addr().String(), ":")[1] -} - // Export ... func (c *ServiceConfig) Export() error { // TODO: config center start here @@ -148,15 +137,11 @@ func (c *ServiceConfig) Export() error { logger.Errorf(err.Error()) return err } - port := proto.Port - if len(proto.Port) == 0 { - port = getRandomPort(proto.Ip) - } ivkURL := common.NewURLWithOptions( common.WithPath(c.id), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), - common.WithPort(port), + common.WithPort(proto.Port), common.WithParams(urlMap), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), common.WithMethods(strings.Split(methods, ",")), diff --git a/config/service_config_test.go b/config/service_config_test.go index f0d69e6c65..6f32308903 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -20,10 +20,6 @@ package config import ( "testing" ) -import ( - gxnet "github.com/dubbogo/gost/net" - "github.com/stretchr/testify/assert" -) import ( "github.com/apache/dubbo-go/common/extension" @@ -193,12 +189,3 @@ func Test_Export(t *testing.T) { } providerConfig = nil } - -func Test_getRandomPort(t *testing.T) { - ip, err := gxnet.GetLocalIP() - assert.NoError(t, err) - port := getRandomPort(ip) - t.Logf("port:%v", port) - - assert.Greater(t, len(port), 0) -} diff --git a/go.mod b/go.mod index 649f9b781a..b238173cb9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/creasty/defaults v1.3.0 - github.com/dubbogo/getty v1.3.4 + github.com/dubbogo/getty v1.3.5 github.com/dubbogo/go-zookeeper v1.0.0 github.com/dubbogo/gost v1.9.0 github.com/emicklei/go-restful/v3 v3.0.0 @@ -32,6 +32,8 @@ require ( github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 github.com/jonboulle/clockwork v0.1.0 // indirect + github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect + github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 // indirect github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect diff --git a/go.sum b/go.sum index 95deb6611b..62e51170c7 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e h1:MSuLXx/mveDbpDNhVrcWTMeV4lbYWKcyO4rH+jAxmX0= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= -github.com/apache/dubbo-go-hessian2 v1.4.0 h1:Cb9FQVTy3G93dnDr7P93U8DeKFYpDTJjQp44JG5TafA= -github.com/apache/dubbo-go-hessian2 v1.4.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= github.com/apache/dubbo-go-hessian2 v1.5.0 h1:fzulDG5G7nX0ccgKdiN9XipJ7tZ4WXKgmk4stdlDS6s= github.com/apache/dubbo-go-hessian2 v1.5.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= @@ -104,24 +102,15 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/digitalocean/godo v1.10.0 h1:uW1/FcvZE/hoixnJcnlmIUvTVNdZCLjRLzmDtRi1xXY= github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= -github.com/divebomb/dubbo-go v1.0.0 h1:QsQxD6UU2WbcaA8YCxU9stiuPUsVCPabFg8hhKGJR8A= github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dubbogo/getty v1.3.3 h1:8m4zZBqFHO+NmhH7rMPlFuuYRVjcPD7cUhumevqMZZs= -github.com/dubbogo/getty v1.3.3/go.mod h1:U92BDyJ6sW9Jpohr2Vlz8w2uUbIbNZ3d+6rJvFTSPp0= -github.com/dubbogo/getty v1.3.4 h1:5TvH213pnSIKYzY7IK8TT/r6yr5uPTB/U6YNLT+GsU0= -github.com/dubbogo/getty v1.3.4/go.mod h1:36f+gH/ekaqcDWKbxNBQk9b9HXcGtaI6YHxp4YTntX8= +github.com/dubbogo/getty v1.3.5 h1:xJxdDj9jm7wlrRSsVZSk2TDNxJbbac5GpxV0QpjO+Tw= +github.com/dubbogo/getty v1.3.5/go.mod h1:T55vN8Q6tZjf2AQZiGmkujneD3LfqYbv2b3QjacwYOY= github.com/dubbogo/go-zookeeper v1.0.0 h1:RsYdlGwhDW+iKXM3eIIcvt34P2swLdmQfuIJxsHlGoM= github.com/dubbogo/go-zookeeper v1.0.0/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= -github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.7.0 h1:lWNBIE2hk1Aj2be2uXkyRTpZG0RQZj0/xbXnkIq6EHE= -github.com/dubbogo/gost v1.7.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.8.0 h1:9ACbQe5OwMjqtinQcNJC5xp16kky27OsfSGw5L9A6vw= -github.com/dubbogo/gost v1.8.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= 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/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIhn2R6oXQbgW5yHfS+d6YqyMfXiu2L55rFZC4UD/M= @@ -333,7 +322,12 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 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/juju/errors v0.0.0-20190930114154-d42613fe1ab9 h1:hJix6idebFclqlfZCHE7EUX7uqLCyb70nHNHH1XKGBg= github.com/juju/errors v0.0.0-20190930114154-d42613fe1ab9/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 h1:UUHMLvzt/31azWTN/ifGWef4WUqvXk0iRqdhdy/2uzI= +github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b h1:Rrp0ByJXEjhREMPGTt3aWYjoIsUGCbt21ekbeJcTWv0= +github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b h1:VE6r2OwP5gj+Z9aCkSKl3MlmnZbfMAjhvR5T7abKHEo= github.com/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= @@ -393,8 +387,6 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 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/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb h1:lbmvw8r9W55w+aQgWn35W1nuleRIECMoqUrmwAOAvoI= -github.com/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c h1:WoCa3AvgQMVKNs+RIFlWPRgY9QVJwUxJDrGxHs0fcRo= github.com/nacos-group/nacos-sdk-go v0.0.0-20191128082542-fe1b325b125c/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= From 5582a70b0aef386ca2a83f32833e8211490259a6 Mon Sep 17 00:00:00 2001 From: flycash Date: Mon, 27 Apr 2020 22:13:08 +0800 Subject: [PATCH 096/167] Add comments --- filter/filter_impl/access_log_filter.go | 30 +++++++++++++++---- .../rejected_execution_handler_only_log.go | 6 ++-- filter/rejected_execution_handler.go | 2 ++ filter/tps_limit_strategy.go | 10 +++++-- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/filter/filter_impl/access_log_filter.go b/filter/filter_impl/access_log_filter.go index fbfe756517..49cdc2287c 100644 --- a/filter/filter_impl/access_log_filter.go +++ b/filter/filter_impl/access_log_filter.go @@ -71,14 +71,18 @@ func init() { * * the value of "accesslog" can be "true" or "default" too. * If the value is one of them, the access log will be record in log file which defined in log.yml + * AccessLogFilter is designed to be singleton */ type AccessLogFilter struct { logChan chan AccessLogData } -// Invoke ... +// Invoke will check whether user wants to use this filter. +// If we find the value of key constant.ACCESS_LOG_KEY, we will log the invocation info func (ef *AccessLogFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { accessLog := invoker.GetUrl().GetParam(constant.ACCESS_LOG_KEY, "") + + // the user do not if len(accessLog) > 0 { accessLogData := AccessLogData{data: ef.buildAccessLogData(invoker, invocation), accessLog: accessLog} ef.logIntoChannel(accessLogData) @@ -86,7 +90,7 @@ func (ef *AccessLogFilter) Invoke(ctx context.Context, invoker protocol.Invoker, return invoker.Invoke(ctx, invocation) } -// it won't block the invocation +// logIntoChannel won't block the invocation func (ef *AccessLogFilter) logIntoChannel(accessLogData AccessLogData) { select { case ef.logChan <- accessLogData: @@ -97,6 +101,7 @@ func (ef *AccessLogFilter) logIntoChannel(accessLogData AccessLogData) { } } +// buildAccessLogData builds the access log data func (ef *AccessLogFilter) buildAccessLogData(_ protocol.Invoker, invocation protocol.Invocation) map[string]string { dataMap := make(map[string]string, 16) attachments := invocation.Attachments() @@ -130,11 +135,12 @@ func (ef *AccessLogFilter) buildAccessLogData(_ protocol.Invoker, invocation pro return dataMap } -// OnResponse ... +// OnResponse do nothing func (ef *AccessLogFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result { return result } +// writeLogToFile actually write the logs into file func (ef *AccessLogFilter) writeLogToFile(data AccessLogData) { accessLog := data.accessLog if isDefault(accessLog) { @@ -156,6 +162,12 @@ func (ef *AccessLogFilter) writeLogToFile(data AccessLogData) { } } +// openLogFile will open the log file with append mode. +// If the file is not found, it will create the file. +// Actually, the accessLog is the filename +// You may find out that, once we want to write access log into log file, +// we open the file again and again. +// It needs to be optimized. func (ef *AccessLogFilter) openLogFile(accessLog string) (*os.File, error) { logFile, err := os.OpenFile(accessLog, os.O_CREATE|os.O_APPEND|os.O_RDWR, LogFileMode) if err != nil { @@ -169,6 +181,12 @@ func (ef *AccessLogFilter) openLogFile(accessLog string) (*os.File, error) { return nil, err } last := fileInfo.ModTime().Format(FileDateFormat) + + // this is confused. + // for example, if the last = '2020-03-04' + // and today is '2020-03-05' + // we will create one new file to log access data + // By this way, we can split the access log based on days. if now != last { err = os.Rename(fileInfo.Name(), fileInfo.Name()+"."+now) if err != nil { @@ -180,11 +198,12 @@ func (ef *AccessLogFilter) openLogFile(accessLog string) (*os.File, error) { return logFile, err } +// isDefault check whether accessLog == true or accessLog == default func isDefault(accessLog string) bool { return strings.EqualFold("true", accessLog) || strings.EqualFold("default", accessLog) } -// GetAccessLogFilter ... +// GetAccessLogFilter return the instance of AccessLogFilter func GetAccessLogFilter() filter.Filter { accessLogFilter := &AccessLogFilter{logChan: make(chan AccessLogData, LogMaxBuffer)} go func() { @@ -195,12 +214,13 @@ func GetAccessLogFilter() filter.Filter { return accessLogFilter } -// AccessLogData ... +// AccessLogData defines the data that will be log into file type AccessLogData struct { accessLog string data map[string]string } +// toLogMessage convert the AccessLogData to String func (ef *AccessLogData) toLogMessage() string { builder := strings.Builder{} builder.WriteString("[") diff --git a/filter/handler/rejected_execution_handler_only_log.go b/filter/handler/rejected_execution_handler_only_log.go index 0f9003c7df..fe9cf4869f 100644 --- a/filter/handler/rejected_execution_handler_only_log.go +++ b/filter/handler/rejected_execution_handler_only_log.go @@ -36,6 +36,7 @@ const ( ) func init() { + // this implementation is the the default implementation of RejectedExecutionHandler extension.SetRejectedExecutionHandler(HandlerName, GetOnlyLogRejectedExecutionHandler) extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, GetOnlyLogRejectedExecutionHandler) } @@ -56,11 +57,12 @@ var onlyLogHandlerOnce sync.Once * tps.limit.rejected.handler: "default" or "log" * methods: * - name: "GetUser" + * OnlyLogRejectedExecutionHandler is designed to be singleton */ type OnlyLogRejectedExecutionHandler struct { } -// RejectedExecution ... +// RejectedExecution will do nothing, it only log the invocation. func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL, _ protocol.Invocation) protocol.Result { @@ -68,7 +70,7 @@ func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL return &protocol.RPCResult{} } -// GetOnlyLogRejectedExecutionHandler ... +// GetOnlyLogRejectedExecutionHandler will return the instance of OnlyLogRejectedExecutionHandler func GetOnlyLogRejectedExecutionHandler() filter.RejectedExecutionHandler { onlyLogHandlerOnce.Do(func() { onlyLogHandlerInstance = &OnlyLogRejectedExecutionHandler{} diff --git a/filter/rejected_execution_handler.go b/filter/rejected_execution_handler.go index caeea1db66..d02481b98d 100644 --- a/filter/rejected_execution_handler.go +++ b/filter/rejected_execution_handler.go @@ -31,5 +31,7 @@ import ( * In such situation, implement this interface and register it by invoking extension.SetRejectedExecutionHandler. */ type RejectedExecutionHandler interface { + + // RejectedExecution will be called if the invocation was rejected by some component. RejectedExecution(url common.URL, invocation protocol.Invocation) protocol.Result } diff --git a/filter/tps_limit_strategy.go b/filter/tps_limit_strategy.go index 5edf32ce19..e194f1da06 100644 --- a/filter/tps_limit_strategy.go +++ b/filter/tps_limit_strategy.go @@ -33,10 +33,16 @@ package filter * tps.limit.strategy: "name of implementation" # method-level */ type TpsLimitStrategy interface { + // IsAllowable will return true if this invocation is not over limitation IsAllowable() bool } -// TpsLimitStrategyCreator ... +// TpsLimitStrategyCreator, the creator abstraction for TpsLimitStrategy type TpsLimitStrategyCreator interface { - Create(rate int, interval int) TpsLimitStrategy + // Create will create an instance of TpsLimitStrategy + // It will be a little hard to understand this method. + // The unit of interval is ms + // for example, if the limit = 100, interval = 1000 + // which means that the tps limitation is 100 times per 1000ms (100/1000ms) + Create(limit int, interval int) TpsLimitStrategy } From c05e5c178cde8d7089425c5e8f8a82f99319ec8b Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 27 Apr 2020 23:12:12 +0800 Subject: [PATCH 097/167] modify implement --- config/service_config.go | 30 +++++++++++++++++++++++++++++- config/service_config_test.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/config/service_config.go b/config/service_config.go index 4cd7ae2739..45d37961b2 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -18,6 +18,7 @@ package config import ( + "container/list" "context" "fmt" "net/url" @@ -29,6 +30,7 @@ import ( import ( "github.com/creasty/defaults" + gxnet "github.com/dubbogo/gost/net" perrors "github.com/pkg/errors" "go.uber.org/atomic" ) @@ -105,6 +107,24 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } +// Get Random Port +func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { + l := list.New() + for _, proto := range protocolConfigs { + if proto.Port != "" { + continue + } + + tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) + if err != nil { + panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) + } + l.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) + defer tcp.Close() + } + return l +} + // Export ... func (c *ServiceConfig) Export() error { // TODO: config center start here @@ -129,6 +149,8 @@ func (c *ServiceConfig) Export() error { return nil } + ports := getRandomPort(protocolConfigs) + nextPort := ports.Front() for _, proto := range protocolConfigs { // registry the service reflect methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.rpcService) @@ -137,11 +159,17 @@ func (c *ServiceConfig) Export() error { logger.Errorf(err.Error()) return err } + + port := proto.Port + if proto.Port == "" { + port = nextPort.Value.(string) + nextPort = nextPort.Next() + } ivkURL := common.NewURLWithOptions( common.WithPath(c.id), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), - common.WithPort(proto.Port), + common.WithPort(port), common.WithParams(urlMap), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), common.WithMethods(strings.Split(methods, ",")), diff --git a/config/service_config_test.go b/config/service_config_test.go index 6f32308903..c84a381e28 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -23,6 +23,8 @@ import ( import ( "github.com/apache/dubbo-go/common/extension" + gxnet "github.com/dubbogo/gost/net" + "github.com/stretchr/testify/assert" ) func doInitProvider() { @@ -189,3 +191,35 @@ func Test_Export(t *testing.T) { } providerConfig = nil } + +func Test_getRandomPort(t *testing.T) { + protocolConfigs := make([]*ProtocolConfig, 0, 3) + + ip, err := gxnet.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)) +} From af29f5bd5da97c7e97ac5b2b5850899c55746011 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 27 Apr 2020 23:28:04 +0800 Subject: [PATCH 098/167] travis trigger --- config/service_config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/service_config.go b/config/service_config.go index 45d37961b2..832430a9c0 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -161,6 +161,7 @@ func (c *ServiceConfig) Export() error { } port := proto.Port + if proto.Port == "" { port = nextPort.Value.(string) nextPort = nextPort.Next() From e4fc89d592957a2a1aacfdcfdcc681affee67b99 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 27 Apr 2020 23:29:48 +0800 Subject: [PATCH 099/167] travis trigger --- config/service_config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 832430a9c0..f45e78cd63 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -111,7 +111,7 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { l := list.New() for _, proto := range protocolConfigs { - if proto.Port != "" { + if len(proto.Port) > 0 { continue } @@ -162,7 +162,7 @@ func (c *ServiceConfig) Export() error { port := proto.Port - if proto.Port == "" { + if len(proto.Port) == 0 { port = nextPort.Value.(string) nextPort = nextPort.Next() } From 7711df8678d0ba682299250d107414701bb196c1 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Mon, 27 Apr 2020 23:30:47 +0800 Subject: [PATCH 100/167] change variable name --- config/service_config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index f45e78cd63..4dbd584398 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -109,7 +109,7 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { // Get Random Port func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { - l := list.New() + ports := list.New() for _, proto := range protocolConfigs { if len(proto.Port) > 0 { continue @@ -119,10 +119,10 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { if err != nil { panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) } - l.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) + ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) defer tcp.Close() } - return l + return ports } // Export ... From fcaa44add6822c5a6347d6aa12a63e9375c00158 Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Tue, 28 Apr 2020 11:42:33 +0800 Subject: [PATCH 101/167] fix review comments --- config/service_config.go | 7 ++++--- config/service_config_test.go | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index 4dbd584398..ffacd2017c 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -116,11 +116,13 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { } tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) + if tcp != nil { + defer tcp.Close() + } if err != nil { panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) } ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) - defer tcp.Close() } return ports } @@ -143,8 +145,7 @@ func (c *ServiceConfig) Export() error { regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols) - protocolSize := len(protocolConfigs) - if protocolSize == 0 { + if len(protocolConfigs) == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs ", c.InterfaceName, c.Protocol) return nil } diff --git a/config/service_config_test.go b/config/service_config_test.go index c84a381e28..e39d32b7f7 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -22,11 +22,14 @@ import ( ) import ( - "github.com/apache/dubbo-go/common/extension" gxnet "github.com/dubbogo/gost/net" "github.com/stretchr/testify/assert" ) +import ( + "github.com/apache/dubbo-go/common/extension" +) + func doInitProvider() { providerConfig = &ProviderConfig{ ApplicationConfig: &ApplicationConfig{ From 94414e4bde392a22f4f7ed0983df4cc992aa643a Mon Sep 17 00:00:00 2001 From: Joe Zou Date: Tue, 28 Apr 2020 18:04:00 +0800 Subject: [PATCH 102/167] fix review comments --- config/service_config.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/service_config.go b/config/service_config.go index ffacd2017c..45e7df6306 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -116,12 +116,10 @@ func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { } tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) - if tcp != nil { - defer tcp.Close() - } 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 From 9cbee5866c41e31c595c23cf074b4e3d6489ea95 Mon Sep 17 00:00:00 2001 From: Huang YunKun Date: Wed, 29 Apr 2020 10:25:45 +0800 Subject: [PATCH 103/167] add .asf.yaml to change gitbox behaviour align with https://gitbox.apache.org/schemes.cgi?dubbo --- .asf.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .asf.yaml diff --git a/.asf.yaml b/.asf.yaml new file mode 100644 index 0000000000..745d2fc7a5 --- /dev/null +++ b/.asf.yaml @@ -0,0 +1,5 @@ +notifications: + commits: commits@dubbo.apache.org + issues: dev@null + pullrequests: dev@null + jira_options: link label link label From 8a3c02c9b7737a12712451b16a3cdc8ce46a5c7d Mon Sep 17 00:00:00 2001 From: Huang YunKun Date: Wed, 29 Apr 2020 10:30:55 +0800 Subject: [PATCH 104/167] Update .asf.yaml --- .asf.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.asf.yaml b/.asf.yaml index 745d2fc7a5..8d84e695a5 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -1,5 +1,5 @@ notifications: commits: commits@dubbo.apache.org - issues: dev@null - pullrequests: dev@null + issues: notifications@dubbo.apache.org + pullrequests: notifications@dubbo.apache.org jira_options: link label link label From 731020ded36b349140accb006deb2d6fde1f75b4 Mon Sep 17 00:00:00 2001 From: renzhiyuan Date: Tue, 5 May 2020 11:39:07 +0800 Subject: [PATCH 105/167] add comments for directory --- registry/directory/directory.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index a6d2cdf49b..4f0daad2e5 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -42,12 +42,12 @@ import ( "github.com/apache/dubbo-go/remoting" ) -// Options ... +// Options Option is configuration related struct of serviceTTL type Options struct { serviceTTL time.Duration } -// Option ... +// Option function of handling Options type Option func(*Options) type registryDirectory struct { @@ -66,7 +66,7 @@ type registryDirectory struct { forbidden atomic.Bool } -// NewRegistryDirectory ... +// NewRegistryDirectory Create a new RegistryDirectory func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...Option) (*registryDirectory, error) { options := Options{ //default 300s @@ -90,18 +90,19 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...O return dir, nil } -//subscribe from registry +//Subscribe subscribe from registry func (dir *registryDirectory) Subscribe(url *common.URL) { dir.consumerConfigurationListener.addNotifyListener(dir) dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) dir.registry.Subscribe(url, dir) } +//Subscribe monitor changes from registry,and update the cacheServices func (dir *registryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } -//subscribe service from registry, and update the cacheServices +//update subscribe service from registry, and update the cacheServices func (dir *registryDirectory) update(res *registry.ServiceEvent) { if res == nil { return @@ -245,7 +246,7 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { return nil } -//select the protocol invokers from the directory +//List select the protocol invokers from the directory func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { invokers := dir.cacheInvokers routerChain := dir.RouterChain() @@ -256,7 +257,8 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.In return routerChain.Route(invokers, dir.cacheOriginUrl, invocation) } -func (dir *registryDirectory) IsAvailable() bool { +//IsAvailable whether the directory is available +func (dir *registryDirectory) IsAvailableAvailable() bool { if !dir.BaseDirectory.IsAvailable() { return dir.BaseDirectory.IsAvailable() } @@ -270,6 +272,7 @@ func (dir *registryDirectory) IsAvailable() bool { return false } +//Destroy destroy method func (dir *registryDirectory) Destroy() { //TODO:unregister & unsubscribe dir.BaseDirectory.Destroy(func() { @@ -309,6 +312,7 @@ func newReferenceConfigurationListener(dir *registryDirectory, url *common.URL) return listener } +//Process handle events and update Invokers func (l *referenceConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) @@ -334,6 +338,7 @@ func (l *consumerConfigurationListener) addNotifyListener(listener registry.Noti l.listeners = append(l.listeners, listener) } +//Process handle events and update Invokers func (l *consumerConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) From 2264cda6f7652ea20474df89effeab0daa9bd7bd Mon Sep 17 00:00:00 2001 From: renzhiyuan Date: Tue, 5 May 2020 11:39:52 +0800 Subject: [PATCH 106/167] add comments for directory --- registry/directory/directory.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 4f0daad2e5..bdfc3d6e6e 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -90,19 +90,19 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...O return dir, nil } -//Subscribe subscribe from registry +// Subscribe subscribe from registry func (dir *registryDirectory) Subscribe(url *common.URL) { dir.consumerConfigurationListener.addNotifyListener(dir) dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) dir.registry.Subscribe(url, dir) } -//Subscribe monitor changes from registry,and update the cacheServices +// Subscribe monitor changes from registry,and update the cacheServices func (dir *registryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } -//update subscribe service from registry, and update the cacheServices +// update subscribe service from registry, and update the cacheServices func (dir *registryDirectory) update(res *registry.ServiceEvent) { if res == nil { return @@ -246,7 +246,7 @@ func (dir *registryDirectory) cacheInvoker(url *common.URL) protocol.Invoker { return nil } -//List select the protocol invokers from the directory +// List select the protocol invokers from the directory func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.Invoker { invokers := dir.cacheInvokers routerChain := dir.RouterChain() @@ -257,7 +257,7 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.In return routerChain.Route(invokers, dir.cacheOriginUrl, invocation) } -//IsAvailable whether the directory is available +// IsAvailable whether the directory is available func (dir *registryDirectory) IsAvailableAvailable() bool { if !dir.BaseDirectory.IsAvailable() { return dir.BaseDirectory.IsAvailable() @@ -272,7 +272,7 @@ func (dir *registryDirectory) IsAvailableAvailable() bool { return false } -//Destroy destroy method +// Destroy destroy method func (dir *registryDirectory) Destroy() { //TODO:unregister & unsubscribe dir.BaseDirectory.Destroy(func() { @@ -312,7 +312,7 @@ func newReferenceConfigurationListener(dir *registryDirectory, url *common.URL) return listener } -//Process handle events and update Invokers +// Process handle events and update Invokers func (l *referenceConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) @@ -338,7 +338,7 @@ func (l *consumerConfigurationListener) addNotifyListener(listener registry.Noti l.listeners = append(l.listeners, listener) } -//Process handle events and update Invokers +// Process handle events and update Invokers func (l *consumerConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) From fc6bdfaa7e550721988bb72ec4b37ccfc4c94c5a Mon Sep 17 00:00:00 2001 From: aliiohs Date: Wed, 6 May 2020 22:39:22 +0800 Subject: [PATCH 107/167] Modify the comment of Process method --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index bdfc3d6e6e..8a11f1b36e 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -338,7 +338,7 @@ func (l *consumerConfigurationListener) addNotifyListener(listener registry.Noti l.listeners = append(l.listeners, listener) } -// Process handle events and update Invokers +// Process Process handles events from Configuration Center and update Invokers func (l *consumerConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) From ea89aece854ffdd826e812a8a5c5d84c85620105 Mon Sep 17 00:00:00 2001 From: aliiohs Date: Thu, 7 May 2020 22:02:08 +0800 Subject: [PATCH 108/167] add the comment of ConsistentHash --- cluster/loadbalance/consistent_hash.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index 957c110663..81962503b9 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -53,16 +53,16 @@ func init() { extension.SetLoadbalance(ConsistentHash, NewConsistentHashLoadBalance) } -// ConsistentHashLoadBalance ... +// ConsistentHashLoadBalance Implementation of load balancing: using consistent hashing type ConsistentHashLoadBalance struct { } -// NewConsistentHashLoadBalance ... +// NewConsistentHashLoadBalance create NewConsistentHashLoadBalance func NewConsistentHashLoadBalance() cluster.LoadBalance { return &ConsistentHashLoadBalance{} } -// Select ... +// Select Get 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 @@ -85,22 +85,25 @@ func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocat return selector.Select(invocation) } -// Uint32Slice ... +// Uint32Slice Slice of uint32 type Uint32Slice []uint32 +// Len Get slice length func (s Uint32Slice) Len() int { return len(s) } +// Less reports whether the element with index i should sort before the element with index j. func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] } +// Swap swaps the elements with indexes i and j. func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -// ConsistentHashSelector ... +// ConsistentHashSelector Implementation of Selector:get invoker based on load balancing strategy type ConsistentHashSelector struct { hashCode uint32 replicaNum int @@ -141,7 +144,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, return selector } -// Select ... +// Select Get invoker based on load balancing strategy func (c *ConsistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker { key := c.toKey(invocation.Arguments()) digest := md5.Sum([]byte(key)) From 861a9cdd5282fdbde5e161c5f42754d868a2437e Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Fri, 8 May 2020 21:36:30 +0800 Subject: [PATCH 109/167] provider can get attachment in ctx --- common/constant/key.go | 3 +++ common/proxy/proxy.go | 7 ++++++- common/proxy/proxy_factory/default.go | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/constant/key.go b/common/constant/key.go index d9413fcc9e..54ca9d614b 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -180,6 +180,9 @@ const ( // ForceUseTag is the tag in attachment ForceUseTag = "dubbo.force.tag" Tagkey = "dubbo.tag" + + // Attachment key in context in invoker + AttachmentKey = "attachment" ) const ( diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index f98a44873a..6b68080800 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -25,6 +25,7 @@ import ( import ( "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/protocol" invocation_impl "github.com/apache/dubbo-go/protocol/invocation" @@ -140,7 +141,7 @@ func (p *Proxy) Implement(v common.RPCService) { } // add user setAttachment - atm := invCtx.Value("attachment") + atm := invCtx.Value(constant.AttachmentKey) if m, ok := atm.(map[string]string); ok { for k, value := range m { inv.SetAttachments(k, value) @@ -148,6 +149,10 @@ func (p *Proxy) Implement(v common.RPCService) { } result := p.invoke.Invoke(invCtx, inv) + logger.Error(result.Attachments()) + if len(result.Attachments()) > 0 { + invCtx = context.WithValue(invCtx, constant.AttachmentKey, result.Attachments()) + } err = result.Error() logger.Debugf("[makeDubboCallProxy] result: %v, err: %v", result.Result(), err) diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 114cfee236..013b399110 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -113,6 +113,7 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati in := []reflect.Value{svc.Rcvr()} if method.CtxType() != nil { + ctx = context.WithValue(ctx, constant.AttachmentKey, invocation.Attachments()) in = append(in, method.SuiteContext(ctx)) } From c6be5541c6329de6bd731c56f93c69ed5ef383c0 Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Fri, 8 May 2020 21:40:50 +0800 Subject: [PATCH 110/167] fix --- common/proxy/proxy.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 6b68080800..a77d26d110 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -149,7 +149,6 @@ func (p *Proxy) Implement(v common.RPCService) { } result := p.invoke.Invoke(invCtx, inv) - logger.Error(result.Attachments()) if len(result.Attachments()) > 0 { invCtx = context.WithValue(invCtx, constant.AttachmentKey, result.Attachments()) } From d1e6d85c6472750a7f65de3fb0c03b2385422a36 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Sat, 9 May 2020 17:04:32 +0800 Subject: [PATCH 111/167] filter registry url params starting with dot --- common/constant/key.go | 4 ++-- registry/protocol/protocol.go | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/common/constant/key.go b/common/constant/key.go index d9413fcc9e..a076152647 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -210,9 +210,9 @@ const ( // consumer CONSUMER = "consumer" // key of access key id - ACCESS_KEY_ID_KEY = "accessKeyId" + ACCESS_KEY_ID_KEY = ".accessKeyId" // key of secret access key - SECRET_ACCESS_KEY_KEY = "secretAccessKey" + SECRET_ACCESS_KEY_KEY = ".secretAccessKey" ) // metadata report diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 52a7dcbfc7..aa8fbcbe7d 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -22,9 +22,8 @@ import ( "strings" "sync" ) - import ( - "github.com/dubbogo/gost/container/set" + gxset "github.com/dubbogo/gost/container/set" ) import ( @@ -96,8 +95,24 @@ func getRegistry(regUrl *common.URL) registry.Registry { func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common.URL { if registryUrl.GetParamBool("simplified", false) { return providerUrl.CloneWithParams(reserveParams) + } else { + return filterHideKey(providerUrl) + } +} + +// filterHideKey filter the parameters that do not need to be output in url(Starting with .) +func filterHideKey(url *common.URL) *common.URL { + + //be careful params maps in url is map type + cloneURL := url.Clone() + removeSet := gxset.NewSet() + for k, _ := range cloneURL.GetParams() { + if strings.HasPrefix(k, ".") { + removeSet.Add(k) + } } - return providerUrl + cloneURL.RemoveParams(removeSet) + return cloneURL } func (proto *registryProtocol) initConfigurationListeners() { From be8dd32df184cf7c0824b69cbb141201bc839312 Mon Sep 17 00:00:00 2001 From: CodingSinger Date: Sat, 9 May 2020 17:08:13 +0800 Subject: [PATCH 112/167] add unit test --- registry/protocol/protocol_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index cee2a6a625..15fd3cacfa 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -284,3 +284,12 @@ func TestExportWithApplicationConfig(t *testing.T) { v2, _ := regProtocol.bounds.Load(getCacheKey(newUrl)) assert.NotNil(t, v2) } + +func TestGetProviderUrlWithHideKey(t *testing.T) { + url, _ := common.NewURL("dubbo://127.0.0.1:1111?a=a1&b=b1&.c=c1&.d=d1&e=e1&protocol=registry") + providerUrl := getUrlToRegistry(&url, &url) + assert.NotContains(t, providerUrl.GetParams(), ".c") + assert.NotContains(t, providerUrl.GetParams(), ".d") + assert.Contains(t, providerUrl.GetParams(), "a") + +} From 9fb89edfaa37fae6e86a0d8819468a3ceb168c73 Mon Sep 17 00:00:00 2001 From: aliiohs Date: Sun, 10 May 2020 18:32:31 +0800 Subject: [PATCH 113/167] add the comment of ConsistentHash --- cluster/loadbalance/consistent_hash.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index 81962503b9..0215dd025f 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -40,7 +40,7 @@ const ( ConsistentHash = "consistenthash" // HashNodes ... HashNodes = "hash.nodes" - // HashArguments ... + // HashArguments key of hash arguments in url HashArguments = "hash.arguments" ) @@ -53,16 +53,16 @@ func init() { extension.SetLoadbalance(ConsistentHash, NewConsistentHashLoadBalance) } -// ConsistentHashLoadBalance Implementation of load balancing: using consistent hashing +// ConsistentHashLoadBalance implementation of load balancing: using consistent hashing type ConsistentHashLoadBalance struct { } -// NewConsistentHashLoadBalance create NewConsistentHashLoadBalance +// NewConsistentHashLoadBalance creates NewConsistentHashLoadBalance func NewConsistentHashLoadBalance() cluster.LoadBalance { return &ConsistentHashLoadBalance{} } -// Select Get invoker based on load balancing strategy +// 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 @@ -88,7 +88,7 @@ func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocat // Uint32Slice Slice of uint32 type Uint32Slice []uint32 -// Len Get slice length +// Len gets slice length func (s Uint32Slice) Len() int { return len(s) } @@ -144,7 +144,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, return selector } -// Select Get invoker based on load balancing strategy +// Select Gets invoker based on load balancing strategy func (c *ConsistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker { key := c.toKey(invocation.Arguments()) digest := md5.Sum([]byte(key)) From 7df8822f8ff20a60747acdc691cae2c4c5af3ca4 Mon Sep 17 00:00:00 2001 From: aliiohs Date: Sun, 10 May 2020 18:33:22 +0800 Subject: [PATCH 114/167] fix --- registry/directory/directory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 8a11f1b36e..bab510d95e 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -258,7 +258,7 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) []protocol.In } // IsAvailable whether the directory is available -func (dir *registryDirectory) IsAvailableAvailable() bool { +func (dir *registryDirectory) IsAvailable() bool { if !dir.BaseDirectory.IsAvailable() { return dir.BaseDirectory.IsAvailable() } From 2e0e8024708652b611ec9f987d9620fb4a7eb916 Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Tue, 12 May 2020 18:08:16 +0800 Subject: [PATCH 115/167] delete meaningless code --- common/proxy/proxy_factory/default.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 013b399110..3e21a21ca3 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -86,7 +86,6 @@ type ProxyInvoker struct { // Invoke ... func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { result := &protocol.RPCResult{} - result.SetAttachments(invocation.Attachments()) url := pi.GetUrl() From d82e10f891526a2155456901331d82356a71d0d1 Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Thu, 14 May 2020 11:00:07 +0800 Subject: [PATCH 116/167] fix ut --- common/proxy/proxy_factory/default.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 3e21a21ca3..013b399110 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -86,6 +86,7 @@ type ProxyInvoker struct { // Invoke ... func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { result := &protocol.RPCResult{} + result.SetAttachments(invocation.Attachments()) url := pi.GetUrl() From ebb1b0ce66cbaaad34937e745bb7edd61d76918d Mon Sep 17 00:00:00 2001 From: zhengxianle Date: Sat, 16 May 2020 23:25:43 +0800 Subject: [PATCH 117/167] =?UTF-8?q?Fix=20=E2=80=9Ccompile=20errors=20cause?= =?UTF-8?q?d=20by=20unsupported=20import=20packages=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 -- go.sum | 4 ---- registry/etcdv3/listener_test.go | 2 +- remoting/etcdv3/client_test.go | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index b238173cb9..24357c3c72 100644 --- a/go.mod +++ b/go.mod @@ -53,8 +53,6 @@ require ( github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8 - go.etcd.io/bbolt v1.3.3 // indirect - go.etcd.io/etcd v3.3.13+incompatible go.uber.org/atomic v1.4.0 go.uber.org/zap v1.10.0 google.golang.org/grpc v1.22.1 diff --git a/go.sum b/go.sum index 62e51170c7..5bf460fc48 100644 --- a/go.sum +++ b/go.sum @@ -502,10 +502,6 @@ 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/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8 h1:k8TV7Gz7cpWpOw/dz71fx8cCZdWoPuckHJ/wkJl+meg= github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8/go.mod h1:S1cAa98KMFv4Sa8SbJ6ZtvOmf0VlgH0QJ1gXI0lBfBY= -go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/etcd v3.3.13+incompatible h1:jCejD5EMnlGxFvcGRyEV4VGlENZc7oPQX6o0t7n3xbw= -go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index e691ae3cf1..333d7378fa 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -26,7 +26,7 @@ import ( import ( "github.com/dubbogo/getty" "github.com/stretchr/testify/suite" - "go.etcd.io/etcd/embed" + "github.com/coreos/etcd/embed" ) import ( diff --git a/remoting/etcdv3/client_test.go b/remoting/etcdv3/client_test.go index 895cc2954a..329aed6c0b 100644 --- a/remoting/etcdv3/client_test.go +++ b/remoting/etcdv3/client_test.go @@ -33,7 +33,7 @@ import ( perrors "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "go.etcd.io/etcd/embed" + "github.com/coreos/etcd/embed" "google.golang.org/grpc/connectivity" ) From f87a292806032d89a6385dbbfa7d8f3b043df093 Mon Sep 17 00:00:00 2001 From: aliiohs Date: Sun, 17 May 2020 13:25:10 +0800 Subject: [PATCH 118/167] fix --- registry/directory/directory.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index bab510d95e..54c3d853f8 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -42,12 +42,12 @@ import ( "github.com/apache/dubbo-go/remoting" ) -// Options Option is configuration related struct of serviceTTL +// Options Options is configuration related struct of serviceTTL type Options struct { serviceTTL time.Duration } -// Option function of handling Options +// Option Option will define a function of handling Options type Option func(*Options) type registryDirectory struct { @@ -66,7 +66,7 @@ type registryDirectory struct { forbidden atomic.Bool } -// NewRegistryDirectory Create a new RegistryDirectory +// NewRegistryDirectory NewRegistryDirectory will create a new RegistryDirectory func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...Option) (*registryDirectory, error) { options := Options{ //default 300s From cb9045cdba38d363f00a1e906ab0c076cb40dc74 Mon Sep 17 00:00:00 2001 From: zhengxianle Date: Sun, 17 May 2020 13:33:02 +0800 Subject: [PATCH 119/167] =?UTF-8?q?Fix=20=E2=80=9Cuncheck=20travis=20rules?= =?UTF-8?q?=20of=20go=20fmt=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registry/etcdv3/listener_test.go | 2 +- remoting/etcdv3/client_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go index 333d7378fa..f27e7ce8ba 100644 --- a/registry/etcdv3/listener_test.go +++ b/registry/etcdv3/listener_test.go @@ -24,9 +24,9 @@ import ( ) import ( + "github.com/coreos/etcd/embed" "github.com/dubbogo/getty" "github.com/stretchr/testify/suite" - "github.com/coreos/etcd/embed" ) import ( diff --git a/remoting/etcdv3/client_test.go b/remoting/etcdv3/client_test.go index 329aed6c0b..e37b6383df 100644 --- a/remoting/etcdv3/client_test.go +++ b/remoting/etcdv3/client_test.go @@ -29,11 +29,11 @@ import ( ) import ( + "github.com/coreos/etcd/embed" "github.com/coreos/etcd/mvcc/mvccpb" perrors "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" - "github.com/coreos/etcd/embed" "google.golang.org/grpc/connectivity" ) From 14333475e18ad889ff99c745f593019674ae665d Mon Sep 17 00:00:00 2001 From: aliiohs Date: Sun, 17 May 2020 13:43:40 +0800 Subject: [PATCH 120/167] replace Uint32Slice --- cluster/loadbalance/consistent_hash.go | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index 0215dd025f..a3c4066be4 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -27,7 +27,9 @@ import ( "strconv" "strings" ) - +import ( + gxsort "github.com/dubbogo/gost/sort" +) import ( "github.com/apache/dubbo-go/cluster" "github.com/apache/dubbo-go/common/constant" @@ -85,30 +87,12 @@ func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocat return selector.Select(invocation) } -// Uint32Slice Slice of uint32 -type Uint32Slice []uint32 - -// Len gets slice length -func (s Uint32Slice) Len() int { - return len(s) -} - -// Less reports whether the element with index i should sort before the element with index j. -func (s Uint32Slice) Less(i, j int) bool { - return s[i] < s[j] -} - -// Swap swaps the elements with indexes i and j. -func (s Uint32Slice) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -// ConsistentHashSelector Implementation of Selector:get invoker based on load balancing strategy +// ConsistentHashSelector implementation of Selector:get invoker based on load balancing strategy type ConsistentHashSelector struct { hashCode uint32 replicaNum int virtualInvokers map[uint32]protocol.Invoker - keys Uint32Slice + keys gxsort.Uint32Slice argumentIndex []int } From b22fc9f93936ed26a41ff37cd3cb8909cd2ae6dc Mon Sep 17 00:00:00 2001 From: aliiohs Date: Sun, 17 May 2020 13:44:35 +0800 Subject: [PATCH 121/167] replace Uint32Slice --- cluster/loadbalance/consistent_hash.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index a3c4066be4..492434431f 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -128,7 +128,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, return selector } -// Select Gets invoker based on load balancing strategy +// Select gets invoker based on load balancing strategy func (c *ConsistentHashSelector) Select(invocation protocol.Invocation) protocol.Invoker { key := c.toKey(invocation.Arguments()) digest := md5.Sum([]byte(key)) From dd2ff3eac8bec38b8757a395a575dec22f4c05c1 Mon Sep 17 00:00:00 2001 From: flycash Date: Mon, 18 May 2020 23:59:13 +0800 Subject: [PATCH 122/167] remove lock from url --- common/url.go | 99 ++++++++++++++------------ config_center/configurator/override.go | 11 ++- registry/protocol/protocol.go | 30 ++++---- 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/common/url.go b/common/url.go index a70ac7dc9d..b8a3d48016 100644 --- a/common/url.go +++ b/common/url.go @@ -26,7 +26,6 @@ import ( "net/url" "strconv" "strings" - "sync" ) import ( @@ -40,9 +39,9 @@ import ( "github.com/apache/dubbo-go/common/constant" ) -///////////////////////////////// +// /////////////////////////////// // dubbo role type -///////////////////////////////// +// /////////////////////////////// // role constant const ( @@ -80,20 +79,22 @@ type baseUrl struct { Location string // ip+port Ip string Port string - //url.Values is not safe map, add to avoid concurrent map read and map write error - paramsLock sync.RWMutex params url.Values PrimitiveURL string } -// URL ... +// URL is not thread-safe. +// we fail to define this struct to be immutable object. +// but, those method which will update the URL, including SetParam, SetParams +// are only allowed to be invoked in creating URL instance +// Please keep in mind that this struct is immutable after it has been created and initialized. type URL struct { baseUrl Path string // like /com.ikurento.dubbo.UserProvider3 Username string Password string Methods []string - //special for registry + // special for registry SubURL *URL } @@ -212,7 +213,7 @@ func NewURL(urlString string, opts ...option) (URL, error) { return s, perrors.Errorf("url.QueryUnescape(%s), error{%v}", urlString, err) } - //rawUrlString = "//" + rawUrlString + // rawUrlString = "//" + rawUrlString if strings.Index(rawUrlString, "//") < 0 { t := URL{baseUrl: baseUrl{}} for _, opt := range opts { @@ -275,7 +276,7 @@ func (c URL) URLEqual(url URL) bool { return false } - //TODO :may need add interface key any value condition + // TODO :may need add interface key any value condition return isMatchCategory(url.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), c.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY)) } @@ -302,9 +303,7 @@ func (c URL) String() string { "%s://%s:%s@%s:%s%s?", c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Path) } - c.paramsLock.RLock() buildString += c.params.Encode() - c.paramsLock.RUnlock() return buildString } @@ -375,31 +374,31 @@ func (c URL) Service() string { return service } else if c.SubURL != nil { service = c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/")) - if service != "" { //if url.path is "" then return suburl's path, special for registry url + if service != "" { // if url.path is "" then return suburl's path, special for registry url return service } } return "" } -// AddParam ... +// AddParam will add the key-value pair +// Not thread-safe +// think twice before using it. func (c *URL) AddParam(key string, value string) { - c.paramsLock.Lock() c.params.Add(key, value) - c.paramsLock.Unlock() } -// SetParam ... +// SetParam will put the key-value pair into url +// it's not thread safe. +// think twice before you want to use this method +// usually it should only be invoked when you want to initialized an url func (c *URL) SetParam(key string, value string) { - c.paramsLock.Lock() c.params.Set(key, value) - c.paramsLock.Unlock() } -// RangeParams ... +// RangeParams will iterate the params +// it's not thread-safe func (c *URL) RangeParams(f func(key, value string) bool) { - c.paramsLock.RLock() - defer c.paramsLock.RUnlock() for k, v := range c.params { if !f(k, v[0]) { break @@ -409,8 +408,8 @@ func (c *URL) RangeParams(f func(key, value string) bool) { // GetParam ... func (c URL) GetParam(s string, d string) string { - c.paramsLock.RLock() - defer c.paramsLock.RUnlock() + // c.paramsLock.RLock() + // defer c.paramsLock.RUnlock() r := c.params.Get(s) if len(r) == 0 { r = d @@ -425,8 +424,8 @@ func (c URL) GetParams() url.Values { // GetParamAndDecoded ... func (c URL) GetParamAndDecoded(key string) (string, error) { - c.paramsLock.RLock() - defer c.paramsLock.RUnlock() + // c.paramsLock.RLock() + // defer c.paramsLock.RUnlock() ruleDec, err := base64.URLEncoding.DecodeString(c.GetParam(key, "")) value := string(ruleDec) return value, err @@ -503,17 +502,10 @@ func (c URL) GetMethodParamBool(method string, key string, d bool) bool { return r } -// RemoveParams ... -func (c *URL) RemoveParams(set *gxset.HashSet) { - c.paramsLock.Lock() - defer c.paramsLock.Unlock() - for k := range set.Items { - s := k.(string) - delete(c.params, s) - } -} - -// SetParams ... +// SetParams will put all key-value pair into url. +// 1. if there already has same key, the value will be override +// 2. it's not thread safe +// 3. think twice when you want to invoke this method func (c *URL) SetParams(m url.Values) { for k := range m { c.SetParam(k, m.Get(k)) @@ -562,29 +554,35 @@ func (c URL) ToMap() map[string]string { // configuration > reference config >service config // in this function we should merge the reference local url config into the service url from registry. -//TODO configuration merge, in the future , the configuration center's config should merge too. - -// MergeUrl ... +// TODO configuration merge, in the future , the configuration center's config should merge too. + +// MergeUrl will merge those two url +// the result is based on serviceUrl, and the key which si only contained in referenceUrl +// will be added into result. +// for example, if serviceUrl contains params (a1->v1, b1->v2) and referenceUrl contains params(a2->v3, b1 -> v4) +// the params of result will be (a1->v1, b1->v2, a2->v3). +// You should notice that the value of b1 is v2, not v4. +// due to URL is not thread-safe, so this method is not thread-safe func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL { mergedUrl := serviceUrl.Clone() - //iterator the referenceUrl if serviceUrl not have the key ,merge in + // iterator the referenceUrl if serviceUrl not have the key ,merge in referenceUrl.RangeParams(func(key, value string) bool { if v := mergedUrl.GetParam(key, ""); len(v) == 0 { mergedUrl.SetParam(key, value) } return true }) - //loadBalance,cluster,retries strategy config + // loadBalance,cluster,retries strategy config methodConfigMergeFcn := mergeNormalParam(mergedUrl, referenceUrl, []string{constant.LOADBALANCE_KEY, constant.CLUSTER_KEY, constant.RETRIES_KEY, constant.TIMEOUT_KEY}) - //remote timestamp + // remote timestamp if v := serviceUrl.GetParam(constant.TIMESTAMP_KEY, ""); len(v) > 0 { mergedUrl.SetParam(constant.REMOTE_TIMESTAMP_KEY, v) mergedUrl.SetParam(constant.TIMESTAMP_KEY, referenceUrl.GetParam(constant.TIMESTAMP_KEY, "")) } - //finally execute methodConfigMergeFcn + // finally execute methodConfigMergeFcn for _, method := range referenceUrl.Methods { for _, fcn := range methodConfigMergeFcn { fcn("methods." + method) @@ -594,7 +592,7 @@ func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL { return mergedUrl } -// Clone ... +// Clone will copy the url func (c *URL) Clone() *URL { newUrl := &URL{} copier.Copy(newUrl, c) @@ -606,6 +604,19 @@ func (c *URL) Clone() *URL { return newUrl } +func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL { + newUrl := &URL{} + copier.Copy(newUrl, c) + newUrl.params = url.Values{} + c.RangeParams(func(key, value string) bool { + if !excludeParams.Contains(key) { + newUrl.SetParam(key, value) + } + return true + }) + return newUrl +} + // Copy url based on the reserved parameters' keys. func (c *URL) CloneWithParams(reserveParams []string) *URL { params := url.Values{} diff --git a/config_center/configurator/override.go b/config_center/configurator/override.go index 18415bee3a..ebd3dc601b 100644 --- a/config_center/configurator/override.go +++ b/config_center/configurator/override.go @@ -50,12 +50,12 @@ func (c *overrideConfigurator) GetUrl() *common.URL { } func (c *overrideConfigurator) Configure(url *common.URL) { - //remove configuratorUrl some param that can not be configured + // remove configuratorUrl some param that can not be configured if c.configuratorUrl.GetParam(constant.ENABLED_KEY, "true") == "false" || len(c.configuratorUrl.Location) == 0 { return } - //branch for version 2.7.x + // branch for version 2.7.x apiVersion := c.configuratorUrl.GetParam(constant.CONFIG_VERSION_KEY, "") if len(apiVersion) != 0 { currentSide := url.GetParam(constant.SIDE_KEY, "") @@ -67,12 +67,12 @@ func (c *overrideConfigurator) Configure(url *common.URL) { c.configureIfMatch(url.Ip, url) } } else { - //branch for version 2.6.x and less + // branch for version 2.6.x and less c.configureDeprecated(url) } } -//translate from java, compatible rules in java +// configureIfMatch translate from java, compatible rules in java func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) { if constant.ANYHOST_VALUE == c.configuratorUrl.Ip || host == c.configuratorUrl.Ip { providers := c.configuratorUrl.GetParam(constant.OVERRIDE_PROVIDERS_KEY, "") @@ -105,8 +105,7 @@ func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) { if returnUrl { return } - configUrl := c.configuratorUrl.Clone() - configUrl.RemoveParams(conditionKeys) + configUrl := c.configuratorUrl.CloneExceptParams(conditionKeys) url.SetParams(configUrl.GetParams()) } } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index aa8fbcbe7d..a936db80bf 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -56,8 +56,8 @@ type registryProtocol struct { invokers []protocol.Invoker // Registry Map registries *sync.Map - //To solve the problem of RMI repeated exposure port conflicts, the services that have been exposed are no longer exposed. - //providerurl <--> exporter + // To solve the problem of RMI repeated exposure port conflicts, the services that have been exposed are no longer exposed. + // providerurl <--> exporter bounds *sync.Map overrideListeners *sync.Map serviceConfigurationListeners *sync.Map @@ -70,10 +70,8 @@ func init() { } func getCacheKey(url *common.URL) string { - newUrl := url.Clone() delKeys := gxset.NewSet("dynamic", "enabled") - newUrl.RemoveParams(delKeys) - return newUrl.String() + return url.CloneExceptParams(delKeys).String() } func newRegistryProtocol() *registryProtocol { @@ -103,16 +101,14 @@ func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common. // filterHideKey filter the parameters that do not need to be output in url(Starting with .) func filterHideKey(url *common.URL) *common.URL { - //be careful params maps in url is map type - cloneURL := url.Clone() + // be careful params maps in url is map type removeSet := gxset.NewSet() - for k, _ := range cloneURL.GetParams() { + for k, _ := range url.GetParams() { if strings.HasPrefix(k, ".") { removeSet.Add(k) } } - cloneURL.RemoveParams(removeSet) - return cloneURL + return url.CloneExceptParams(removeSet) } func (proto *registryProtocol) initConfigurationListeners() { @@ -138,7 +134,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { reg = regI.(registry.Registry) } - //new registry directory for store service url from registry + // new registry directory for store service url from registry directory, err := extension.GetDefaultRegistryDirectory(®istryUrl, reg) if err != nil { logger.Errorf("consumer service %v create registry directory error, error message is %s, and will return nil invoker!", @@ -152,7 +148,7 @@ func (proto *registryProtocol) Refer(url common.URL) protocol.Invoker { serviceUrl.String(), registryUrl.String(), err.Error()) } - //new cluster invoker + // new cluster invoker cluster := extension.GetCluster(serviceUrl.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) invoker := cluster.Join(directory) @@ -217,7 +213,7 @@ func (proto *registryProtocol) reExport(invoker protocol.Invoker, newUrl *common oldExporter.(protocol.Exporter).Unexport() proto.bounds.Delete(key) proto.Export(wrappedNewInvoker) - //TODO: unregister & unsubscribe + // TODO: unregister & unsubscribe } } @@ -300,7 +296,7 @@ func isMatched(providerUrl *common.URL, consumerUrl *common.URL) bool { providerGroup := providerUrl.GetParam(constant.GROUP_KEY, "") providerVersion := providerUrl.GetParam(constant.VERSION_KEY, "") providerClassifier := providerUrl.GetParam(constant.CLASSIFIER_KEY, "") - //todo: public static boolean isContains(String values, String value) { + // todo: public static boolean isContains(String values, String value) { // return isNotEmpty(values) && isContains(COMMA_SPLIT_PATTERN.split(values), value); // } return (consumerGroup == constant.ANY_VALUE || consumerGroup == providerGroup || @@ -353,9 +349,9 @@ func (proto *registryProtocol) Destroy() { } func getRegistryUrl(invoker protocol.Invoker) *common.URL { - //here add * for return a new url + // here add * for return a new url url := invoker.GetUrl() - //if the protocol == registry ,set protocol the registry value in url.params + // 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 @@ -365,7 +361,7 @@ func getRegistryUrl(invoker protocol.Invoker) *common.URL { func getProviderUrl(invoker protocol.Invoker) *common.URL { url := invoker.GetUrl() - //be careful params maps in url is map type + // be careful params maps in url is map type return url.SubURL.Clone() } From 0f64e2cda44eb8656e53f27b2842dc8a766a23e7 Mon Sep 17 00:00:00 2001 From: flycash Date: Tue, 19 May 2020 10:23:42 +0800 Subject: [PATCH 123/167] format code --- common/url.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/url.go b/common/url.go index b8a3d48016..40b6071481 100644 --- a/common/url.go +++ b/common/url.go @@ -75,10 +75,10 @@ func (t RoleType) Role() string { } type baseUrl struct { - Protocol string - Location string // ip+port - Ip string - Port string + Protocol string + Location string // ip+port + Ip string + Port string params url.Values PrimitiveURL string } From ceba6d720b1fc56877ff07d6d56d2c5719c57b0c Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 11:47:33 +0800 Subject: [PATCH 124/167] Wait for test --- .travis.yml | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b46f5d872..b337eb0f4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,40 @@ -language: go - -os: - - linux +dist: trusty +sudo: required +# depend env +language: go go: - "1.13" - +os: + - linux +services: + - docker env: - GO111MODULE=on -install: true +# ci stage define +stages: + - name: licensecheck + - name: format + - name: uinttest + - name: integratetest -script: - - go fmt ./... && [[ -z `git status -s` ]] - - sh before_validate_license.sh - - chmod u+x /tmp/tools/license/license-header-checker - - /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] - - chmod u+x before_ut.sh && ./before_ut.sh - - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic +jobs: + include: + - stage: licensecheck + script: + - sh before_validate_license.sh + - chmod u+x /tmp/tools/license/license-header-checker + - /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] + - stage: format + script: + - go fmt ./... && [[ -z `git status -s` ]] + - go mod vendor + - stage: uinttest + script: go test ./... -coverprofile=coverage.txt -covermode=atomic + - stage: integratetest + script: + - echo "intergrate test" after_success: - bash <(curl -s https://codecov.io/bash) From 6b53a984302620d349f4147ff4c20da9545d99ff Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 13:40:16 +0800 Subject: [PATCH 125/167] delete lot of stage, direct used one-stage --- .travis.yml | 47 ++-- test/integrate/dubbo/go-client/app/client.go | 92 ++++++++ test/integrate/dubbo/go-client/app/user.go | 54 +++++ test/integrate/dubbo/go-client/app/version.go | 22 ++ .../dubbo/go-client/assembly/bin/load.sh | 203 ++++++++++++++++++ .../go-client/assembly/common/app.properties | 23 ++ .../dubbo/go-client/assembly/common/build.sh | 83 +++++++ .../dubbo/go-client/assembly/linux/dev.sh | 36 ++++ .../dubbo/go-client/assembly/linux/release.sh | 35 +++ .../dubbo/go-client/assembly/linux/test.sh | 35 +++ .../dubbo/go-client/assembly/mac/dev.sh | 36 ++++ .../dubbo/go-client/assembly/mac/release.sh | 34 +++ .../dubbo/go-client/assembly/mac/test.sh | 34 +++ .../dubbo/go-client/assembly/windows/dev.sh | 34 +++ .../go-client/assembly/windows/release.sh | 34 +++ .../dubbo/go-client/assembly/windows/test.sh | 34 +++ .../dubbo/go-client/profiles/dev/client.yml | 61 ++++++ .../dubbo/go-client/profiles/dev/log.yml | 28 +++ .../go-client/profiles/release/client.yml | 60 ++++++ .../dubbo/go-client/profiles/release/log.yml | 28 +++ .../dubbo/go-client/profiles/test/client.yml | 59 +++++ .../dubbo/go-client/profiles/test/log.yml | 28 +++ test/integrate/dubbo/go-server/app/server.go | 79 +++++++ test/integrate/dubbo/go-server/app/user.go | 64 ++++++ test/integrate/dubbo/go-server/app/version.go | 22 ++ .../dubbo/go-server/assembly/bin/load.sh | 151 +++++++++++++ .../go-server/assembly/common/app.properties | 23 ++ .../dubbo/go-server/assembly/common/build.sh | 80 +++++++ .../dubbo/go-server/assembly/linux/dev.sh | 36 ++++ .../dubbo/go-server/assembly/linux/release.sh | 36 ++++ .../dubbo/go-server/assembly/linux/test.sh | 36 ++++ .../dubbo/go-server/assembly/mac/dev.sh | 36 ++++ .../dubbo/go-server/assembly/mac/release.sh | 36 ++++ .../dubbo/go-server/assembly/mac/test.sh | 36 ++++ .../dubbo/go-server/assembly/windows/dev.sh | 36 ++++ .../go-server/assembly/windows/release.sh | 36 ++++ .../dubbo/go-server/assembly/windows/test.sh | 36 ++++ .../dubbo/go-server/profiles/dev/log.yml | 28 +++ .../dubbo/go-server/profiles/dev/server.yml | 57 +++++ .../dubbo/go-server/profiles/release/log.yml | 28 +++ .../go-server/profiles/release/server.yml | 62 ++++++ .../dubbo/go-server/profiles/test/log.yml | 28 +++ .../dubbo/go-server/profiles/test/server.yml | 62 ++++++ 43 files changed, 2078 insertions(+), 30 deletions(-) create mode 100755 test/integrate/dubbo/go-client/app/client.go create mode 100755 test/integrate/dubbo/go-client/app/user.go create mode 100755 test/integrate/dubbo/go-client/app/version.go create mode 100755 test/integrate/dubbo/go-client/assembly/bin/load.sh create mode 100755 test/integrate/dubbo/go-client/assembly/common/app.properties create mode 100755 test/integrate/dubbo/go-client/assembly/common/build.sh create mode 100755 test/integrate/dubbo/go-client/assembly/linux/dev.sh create mode 100755 test/integrate/dubbo/go-client/assembly/linux/release.sh create mode 100755 test/integrate/dubbo/go-client/assembly/linux/test.sh create mode 100755 test/integrate/dubbo/go-client/assembly/mac/dev.sh create mode 100755 test/integrate/dubbo/go-client/assembly/mac/release.sh create mode 100755 test/integrate/dubbo/go-client/assembly/mac/test.sh create mode 100755 test/integrate/dubbo/go-client/assembly/windows/dev.sh create mode 100755 test/integrate/dubbo/go-client/assembly/windows/release.sh create mode 100755 test/integrate/dubbo/go-client/assembly/windows/test.sh create mode 100755 test/integrate/dubbo/go-client/profiles/dev/client.yml create mode 100755 test/integrate/dubbo/go-client/profiles/dev/log.yml create mode 100755 test/integrate/dubbo/go-client/profiles/release/client.yml create mode 100755 test/integrate/dubbo/go-client/profiles/release/log.yml create mode 100755 test/integrate/dubbo/go-client/profiles/test/client.yml create mode 100755 test/integrate/dubbo/go-client/profiles/test/log.yml create mode 100755 test/integrate/dubbo/go-server/app/server.go create mode 100755 test/integrate/dubbo/go-server/app/user.go create mode 100755 test/integrate/dubbo/go-server/app/version.go create mode 100755 test/integrate/dubbo/go-server/assembly/bin/load.sh create mode 100755 test/integrate/dubbo/go-server/assembly/common/app.properties create mode 100755 test/integrate/dubbo/go-server/assembly/common/build.sh create mode 100755 test/integrate/dubbo/go-server/assembly/linux/dev.sh create mode 100755 test/integrate/dubbo/go-server/assembly/linux/release.sh create mode 100755 test/integrate/dubbo/go-server/assembly/linux/test.sh create mode 100755 test/integrate/dubbo/go-server/assembly/mac/dev.sh create mode 100755 test/integrate/dubbo/go-server/assembly/mac/release.sh create mode 100755 test/integrate/dubbo/go-server/assembly/mac/test.sh create mode 100755 test/integrate/dubbo/go-server/assembly/windows/dev.sh create mode 100755 test/integrate/dubbo/go-server/assembly/windows/release.sh create mode 100755 test/integrate/dubbo/go-server/assembly/windows/test.sh create mode 100755 test/integrate/dubbo/go-server/profiles/dev/log.yml create mode 100755 test/integrate/dubbo/go-server/profiles/dev/server.yml create mode 100755 test/integrate/dubbo/go-server/profiles/release/log.yml create mode 100755 test/integrate/dubbo/go-server/profiles/release/server.yml create mode 100755 test/integrate/dubbo/go-server/profiles/test/log.yml create mode 100755 test/integrate/dubbo/go-server/profiles/test/server.yml diff --git a/.travis.yml b/.travis.yml index b337eb0f4d..fb3e40e6a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,27 @@ -dist: trusty -sudo: required - -# depend env language: go -go: - - "1.13" + os: - linux -services: - - docker + +go: + - "1.13" + env: - GO111MODULE=on -# ci stage define -stages: - - name: licensecheck - - name: format - - name: uinttest - - name: integratetest +install: true -jobs: - include: - - stage: licensecheck - script: - - sh before_validate_license.sh - - chmod u+x /tmp/tools/license/license-header-checker - - /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] - - stage: format - script: - - go fmt ./... && [[ -z `git status -s` ]] - - go mod vendor - - stage: uinttest - script: go test ./... -coverprofile=coverage.txt -covermode=atomic - - stage: integratetest - script: - - echo "intergrate test" +script: + - echo 'start license check' + - go fmt ./... && [[ -z `git status -s` ]] + - sh before_validate_license.sh + - chmod u+x /tmp/tools/license/license-header-checker + - /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] + - echo 'start unit-test' + - chmod u+x before_ut.sh && ./before_ut.sh + - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic + - echo 'start integrate-test' + - echo 'hello-world' after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/test/integrate/dubbo/go-client/app/client.go b/test/integrate/dubbo/go-client/app/client.go new file mode 100755 index 0000000000..28fe7eb899 --- /dev/null +++ b/test/integrate/dubbo/go-client/app/client.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 main + +import ( + "context" + "fmt" + "os" + "os/signal" + "syscall" + "time" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" + + _ "github.com/apache/dubbo-go/filter/filter_impl" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" +) + +var ( + survivalTimeout int = 10e9 +) + +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") + user := &User{} + err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) + if err != nil { + panic(err) + } + println("response result: %v\n", user) + initSignal() +} + +func initSignal() { + signals := make(chan os.Signal, 1) + // It is not possible to block SIGKILL or syscall.SIGSTOP + signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, + syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) + for { + sig := <-signals + logger.Infof("get signal %s", sig.String()) + switch sig { + case syscall.SIGHUP: + // reload() + default: + time.AfterFunc(time.Duration(survivalTimeout), func() { + logger.Warnf("app exit now by force...") + os.Exit(1) + }) + + // The program exits normally or timeout forcibly exits. + fmt.Println("app exit now...") + return + } + } +} diff --git a/test/integrate/dubbo/go-client/app/user.go b/test/integrate/dubbo/go-client/app/user.go new file mode 100755 index 0000000000..ff4486f079 --- /dev/null +++ b/test/integrate/dubbo/go-client/app/user.go @@ -0,0 +1,54 @@ +/* + * 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" + "github.com/apache/dubbo-go/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/app/version.go b/test/integrate/dubbo/go-client/app/version.go new file mode 100755 index 0000000000..c6138584f1 --- /dev/null +++ b/test/integrate/dubbo/go-client/app/version.go @@ -0,0 +1,22 @@ +/* + * 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-client/assembly/bin/load.sh b/test/integrate/dubbo/go-client/assembly/bin/load.sh new file mode 100755 index 0000000000..ffa240b29d --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/bin/load.sh @@ -0,0 +1,203 @@ +#!/usr/bin/env bash +# +# 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. + + +APP_NAME="APPLICATION_NAME" +APP_ARGS="" +SLEEP_INTERVAL=5 +MAX_LIFETIME=4000 + +PROJECT_HOME="" +OS_NAME=`uname` +if [[ ${OS_NAME} != "Windows" ]]; then + PROJECT_HOME=`pwd` + PROJECT_HOME=${PROJECT_HOME}"/" +else + APP_NAME="APPLICATION_NAME.exe" +fi + +export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" +export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" +# export GOTRACEBACK=system +# export GODEBUG=gctrace=1 + +usage() { + echo "Usage: $0 start [conf suffix]" + echo " $0 stop" + echo " $0 term" + echo " $0 restart" + echo " $0 list" + echo " $0 monitor" + echo " $0 crontab" + exit +} + +start() { + arg=$1 + if [ "$arg" = "" ];then + echo "No registry type! Default client.yml!" + else + export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml} + fi + if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then + echo $CONF_CONSUMER_FILE_PATH" is not existing!" + return + fi + APP_LOG_PATH=${PROJECT_HOME}"logs/" + mkdir -p ${APP_LOG_PATH} + APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} + chmod u+x ${APP_BIN} + # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" + CMD="${APP_BIN}" + eval ${CMD} + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + CUR=`date +%FT%T` + if [ "${PID}" != "" ]; then + for p in ${PID} + do + echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} + done + fi +} + +stop() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" + kill -2 ${ps} + done + fi +} + + +term() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" + kill -9 ${ps} + done + fi +} + +list() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` + fi + + if [ "${PID}" != "" ]; then + echo "list ${APP_NAME}" + + if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then + echo "index: user, pid, start, duration" + else + echo "index: PID, WINPID, UID, STIME, COMMAND" + fi + idx=0 + for ps in ${PID} + do + echo "${idx}: ${ps}" + ((idx ++)) + done + fi +} + +monitor() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + done +} + +crontab() { + idx=0 + while true; do + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [[ "${PID}" == "" ]]; then + start + idx=0 + fi + + ((LIFE=idx*${SLEEP_INTERVAL})) + echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." + ((idx ++)) + sleep ${SLEEP_INTERVAL} + if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then + kill -9 ${PID} + fi + done +} + +opt=$1 +case C"$opt" in + Cstart) + start $2 + ;; + Cstop) + stop + ;; + Cterm) + term + ;; + Crestart) + term + start $2 + ;; + Clist) + list + ;; + Cmonitor) + monitor + ;; + Ccrontab) + crontab + ;; + C*) + usage + ;; +esac + diff --git a/test/integrate/dubbo/go-client/assembly/common/app.properties b/test/integrate/dubbo/go-client/assembly/common/app.properties new file mode 100755 index 0000000000..e10868f4d2 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/common/app.properties @@ -0,0 +1,23 @@ +# +# 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. + + +export TARGET_EXEC_NAME="user_info_client" +# BUILD_PACKAGE="dubbogo-examples/user-info/client/app" +export BUILD_PACKAGE="app" + +export TARGET_CONF_FILE="conf/client.yml" +export TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/test/integrate/dubbo/go-client/assembly/common/build.sh b/test/integrate/dubbo/go-client/assembly/common/build.sh new file mode 100755 index 0000000000..d38f889ed9 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/common/build.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# +# 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. + +rm -rf target/ + +PROJECT_HOME=`pwd` +TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} + +TARGET_SBIN_NAME=${TARGET_EXEC_NAME} +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +if [[ ${GOOS} == "windows" ]]; then + TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe +fi +TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} +if [[ $PROFILE == "dev" || $PROFILE == "test" ]]; then + # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 + # GFLAGS=-gcflags "-N -l" -race -v + # GFLAGS="-gcflags \"-N -l\" -v" + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - +else + # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), + # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, + # -w基本没啥损失。-s的损失就有点大了。 + cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - +fi + +TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} + +mkdir -p ${TARGET_FOLDER}/${TAR_NAME} + +SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin +BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} +CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf + +mkdir -p ${SBIN_DIR} +mkdir -p ${CONF_DIR} + +mv ${TARGET_NAME} ${SBIN_DIR} +cp -r assembly/bin ${BIN_DIR} +cd ${BIN_DIR}/bin/ && mv load.sh load_${TARGET_EXEC_NAME}.sh && cd - + +platform=$(uname) +# modify APPLICATION_NAME +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +else + sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +# modify TARGET_LOG_CONF_FILE +if [ ${platform} == "Darwin" ]; then + sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +cp -r profiles/${PROFILE}/* ${CONF_DIR} + +cd ${TARGET_FOLDER} + +tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* + diff --git a/test/integrate/dubbo/go-client/assembly/linux/dev.sh b/test/integrate/dubbo/go-client/assembly/linux/dev.sh new file mode 100755 index 0000000000..eada737c8d --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/linux/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/linux/release.sh b/test/integrate/dubbo/go-client/assembly/linux/release.sh new file mode 100755 index 0000000000..10eb3d73f8 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/linux/release.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/linux/test.sh b/test/integrate/dubbo/go-client/assembly/linux/test.sh new file mode 100755 index 0000000000..78b650c0d4 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/linux/test.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/dev.sh b/test/integrate/dubbo/go-client/assembly/mac/dev.sh new file mode 100755 index 0000000000..c828476990 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/mac/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="dev" + +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/release.sh b/test/integrate/dubbo/go-client/assembly/mac/release.sh new file mode 100755 index 0000000000..91c2dfee79 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/mac/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/test.sh b/test/integrate/dubbo/go-client/assembly/mac/test.sh new file mode 100755 index 0000000000..a7853f5e2d --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/mac/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/dev.sh b/test/integrate/dubbo/go-client/assembly/windows/dev.sh new file mode 100755 index 0000000000..10a3866c0f --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/windows/dev.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +export PROFILE="dev" +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/release.sh b/test/integrate/dubbo/go-client/assembly/windows/release.sh new file mode 100755 index 0000000000..21af573fa3 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/windows/release.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="release" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/test.sh b/test/integrate/dubbo/go-client/assembly/windows/test.sh new file mode 100755 index 0000000000..2104da8b59 --- /dev/null +++ b/test/integrate/dubbo/go-client/assembly/windows/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +export PROFILE="test" +export PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then + . ${PROJECT_HOME}/assembly/common/app.properties +fi + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then + sh ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-client/profiles/dev/client.yml b/test/integrate/dubbo/go-client/profiles/dev/client.yml new file mode 100755 index 0000000000..55bc9246cb --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/dev/client.yml @@ -0,0 +1,61 @@ +# 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: 1 + heartbeat_period: "5s" + session_timeout: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + 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/profiles/dev/log.yml b/test/integrate/dubbo/go-client/profiles/dev/log.yml new file mode 100755 index 0000000000..59fa4279ad --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/dev/log.yml @@ -0,0 +1,28 @@ + +level: "debug" +development: true +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/profiles/release/client.yml b/test/integrate/dubbo/go-client/profiles/release/client.yml new file mode 100755 index 0000000000..baa4382293 --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/release/client.yml @@ -0,0 +1,60 @@ +# 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 : "release" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + + +references: + "UserProvider": + # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 + registry: "hangzhouzk" + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 1 + heartbeat_period: "5s" + session_timeout: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + 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/profiles/release/log.yml b/test/integrate/dubbo/go-client/profiles/release/log.yml new file mode 100755 index 0000000000..e0514be020 --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/release/log.yml @@ -0,0 +1,28 @@ + +level: "warn" +development: true +disableCaller: true +disableStacktrace: true +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/profiles/test/client.yml b/test/integrate/dubbo/go-client/profiles/test/client.yml new file mode 100755 index 0000000000..90d72a24a4 --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/test/client.yml @@ -0,0 +1,59 @@ +# 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 : "test" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + +references: + "UserProvider": + # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 + registry: "hangzhouzk" + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 1 + heartbeat_period: "5s" + session_timeout: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + 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/profiles/test/log.yml b/test/integrate/dubbo/go-client/profiles/test/log.yml new file mode 100755 index 0000000000..baee0b7248 --- /dev/null +++ b/test/integrate/dubbo/go-client/profiles/test/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +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/app/server.go b/test/integrate/dubbo/go-server/app/server.go new file mode 100755 index 0000000000..fd81aab037 --- /dev/null +++ b/test/integrate/dubbo/go-server/app/server.go @@ -0,0 +1,79 @@ +/* + * 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 ( + "fmt" + "os" + "os/signal" + "syscall" + "time" +) + +import ( + hessian "github.com/apache/dubbo-go-hessian2" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" + + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + _ "github.com/apache/dubbo-go/filter/filter_impl" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" +) + +var ( + survivalTimeout = int(3e9) +) + +// they are necessary: +// export CONF_PROVIDER_FILE_PATH="xxx" +// export APP_LOG_CONF_FILE="xxx" +func main() { + + hessian.RegisterPOJO(&User{}) + config.Load() + + initSignal() +} + +func initSignal() { + signals := make(chan os.Signal, 1) + // It is not possible to block SIGKILL or syscall.SIGSTOP + signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) + for { + sig := <-signals + logger.Infof("get signal %s", sig.String()) + switch sig { + case syscall.SIGHUP: + // reload() + default: + time.AfterFunc(time.Duration(survivalTimeout), func() { + logger.Warnf("app exit now by force...") + os.Exit(1) + }) + + // The program exits normally or timeout forcibly exits. + fmt.Println("provider app exit now...") + return + } + } +} diff --git a/test/integrate/dubbo/go-server/app/user.go b/test/integrate/dubbo/go-server/app/user.go new file mode 100755 index 0000000000..6410074fc0 --- /dev/null +++ b/test/integrate/dubbo/go-server/app/user.go @@ -0,0 +1,64 @@ +/* + * 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" + "github.com/apache/dubbo-go/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) + 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/app/version.go b/test/integrate/dubbo/go-server/app/version.go new file mode 100755 index 0000000000..c6138584f1 --- /dev/null +++ b/test/integrate/dubbo/go-server/app/version.go @@ -0,0 +1,22 @@ +/* + * 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/assembly/bin/load.sh b/test/integrate/dubbo/go-server/assembly/bin/load.sh new file mode 100755 index 0000000000..90077c2471 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/bin/load.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash +# +# 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. + + +APP_NAME="APPLICATION_NAME" +APP_ARGS="" + + +PROJECT_HOME="" +OS_NAME=`uname` +if [[ ${OS_NAME} != "Windows" ]]; then + PROJECT_HOME=`pwd` + PROJECT_HOME=${PROJECT_HOME}"/" +fi + +export CONF_PROVIDER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" +export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" + +usage() { + echo "Usage: $0 start [conf suffix]" + echo " $0 stop" + echo " $0 term" + echo " $0 restart" + echo " $0 list" + echo " $0 monitor" + echo " $0 crontab" + exit +} + +start() { + arg=$1 + if [ "$arg" = "" ];then + echo "No registry type! Default server.yml!" + else + export CONF_PROVIDER_FILE_PATH=${CONF_PROVIDER_FILE_PATH//\.yml/\_$arg\.yml} + fi + if [ ! -f "${CONF_PROVIDER_FILE_PATH}" ];then + echo $CONF_PROVIDER_FILE_PATH" is not existing!" + return + fi + APP_LOG_PATH="${PROJECT_HOME}logs/" + mkdir -p ${APP_LOG_PATH} + APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} + chmod u+x ${APP_BIN} + # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" + CMD="${APP_BIN}" + eval ${CMD} + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + CUR=`date +%FT%T` + if [ "${PID}" != "" ]; then + for p in ${PID} + do + echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} + done + fi +} + +stop() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" + kill -2 ${ps} + done + fi +} + + +term() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` + fi + if [ "${PID}" != "" ]; + then + for ps in ${PID} + do + echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" + kill -9 ${ps} + done + fi +} + +list() { + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` + if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then + PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` + fi + + if [ "${PID}" != "" ]; then + echo "list ${APP_NAME}" + + if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then + echo "index: user, pid, start, duration" + else + echo "index: PID, WINPID, UID, STIME, COMMAND" + fi + idx=0 + for ps in ${PID} + do + echo "${idx}: ${ps}" + ((idx ++)) + done + fi +} + +opt=$1 +case C"$opt" in + Cstart) + start $2 + ;; + Cstop) + stop + ;; + Cterm) + term + ;; + Crestart) + term + start $2 + ;; + Clist) + list + ;; + C*) + usage + ;; +esac + diff --git a/test/integrate/dubbo/go-server/assembly/common/app.properties b/test/integrate/dubbo/go-server/assembly/common/app.properties new file mode 100755 index 0000000000..1f0827eb51 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/common/app.properties @@ -0,0 +1,23 @@ +# +# 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. + + +TARGET_EXEC_NAME="user_info_server" +# BUILD_PACKAGE="dubbogo-examples/user-info/server/app" +BUILD_PACKAGE="app" + +TARGET_CONF_FILE="conf/server.yml" +TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/test/integrate/dubbo/go-server/assembly/common/build.sh b/test/integrate/dubbo/go-server/assembly/common/build.sh new file mode 100755 index 0000000000..d90d0263b2 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/common/build.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# +# 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. + +rm -rf target/ + +PROJECT_HOME=`pwd` +TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} + +TARGET_SBIN_NAME=${TARGET_EXEC_NAME} +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +if [[ ${GOOS} == "windows" ]]; then + TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe +fi +TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} +if [[ $PROFILE = "test" ]]; then + # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 + # GFLAGS=-gcflags "-N -l" -race -v + # GFLAGS="-gcflags \"-N -l\" -v" + cd ${BUILD_PACKAGE} && GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - +else + # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), + # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, + # -w基本没啥损失。-s的损失就有点大了。 + cd ${BUILD_PACKAGE} && GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - +fi + +TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} + +mkdir -p ${TARGET_FOLDER}/${TAR_NAME} + +SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin +BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} +CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf + +mkdir -p ${SBIN_DIR} +mkdir -p ${CONF_DIR} + +mv ${TARGET_NAME} ${SBIN_DIR} +cp -r assembly/bin ${BIN_DIR} +# modify APPLICATION_NAME +# OS=`uname` +# if [[ $OS=="Darwin" ]]; then +if [ "$(uname)" == "Darwin" ]; then + sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +else + sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* +fi +# modify TARGET_CONF_FILE +if [ "$(uname)" == "Darwin" ]; then + sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi +# modify TARGET_LOG_CONF_FILE +if [ "$(uname)" == "Darwin" ]; then + sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +else + sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* +fi + +cp -r profiles/${PROFILE}/* ${CONF_DIR} + +cd ${TARGET_FOLDER} + +tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* + diff --git a/test/integrate/dubbo/go-server/assembly/linux/dev.sh b/test/integrate/dubbo/go-server/assembly/linux/dev.sh new file mode 100755 index 0000000000..d830ac98c2 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/linux/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +PROFILE=dev + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/linux/release.sh b/test/integrate/dubbo/go-server/assembly/linux/release.sh new file mode 100755 index 0000000000..99303800b0 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/linux/release.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +PROFILE=release + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/linux/test.sh b/test/integrate/dubbo/go-server/assembly/linux/test.sh new file mode 100755 index 0000000000..87144bb973 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/linux/test.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=linux +export GOARCH=amd64 + +PROFILE=test + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/dev.sh b/test/integrate/dubbo/go-server/assembly/mac/dev.sh new file mode 100755 index 0000000000..3a7659b2d5 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/mac/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +PROFILE=dev + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/release.sh b/test/integrate/dubbo/go-server/assembly/mac/release.sh new file mode 100755 index 0000000000..1c4bce4bf8 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/mac/release.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +PROFILE=release + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/test.sh b/test/integrate/dubbo/go-server/assembly/mac/test.sh new file mode 100755 index 0000000000..69206e32fe --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/mac/test.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + +set -e + +export GOOS=darwin +export GOARCH=amd64 + +PROFILE=test + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi + diff --git a/test/integrate/dubbo/go-server/assembly/windows/dev.sh b/test/integrate/dubbo/go-server/assembly/windows/dev.sh new file mode 100755 index 0000000000..011fb41148 --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/windows/dev.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +PROFILE=dev + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/windows/release.sh b/test/integrate/dubbo/go-server/assembly/windows/release.sh new file mode 100755 index 0000000000..679a26a7dc --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/windows/release.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +PROFILE=release + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/assembly/windows/test.sh b/test/integrate/dubbo/go-server/assembly/windows/test.sh new file mode 100755 index 0000000000..4a36de0f3a --- /dev/null +++ b/test/integrate/dubbo/go-server/assembly/windows/test.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# 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. + + + +set -e + +export GOOS=windows +export GOARCH=amd64 + +PROFILE=test + +PROJECT_HOME=`pwd` + +if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then +. ${PROJECT_HOME}/assembly/common/app.properties +fi + + +if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then +. ${PROJECT_HOME}/assembly/common/build.sh +fi diff --git a/test/integrate/dubbo/go-server/profiles/dev/log.yml b/test/integrate/dubbo/go-server/profiles/dev/log.yml new file mode 100755 index 0000000000..59fa4279ad --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/dev/log.yml @@ -0,0 +1,28 @@ + +level: "debug" +development: true +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/profiles/dev/server.yml b/test/integrate/dubbo/go-server/profiles/dev/server.yml new file mode 100755 index 0000000000..b9f1da696b --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/dev/server.yml @@ -0,0 +1,57 @@ +# 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: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + 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/profiles/release/log.yml b/test/integrate/dubbo/go-server/profiles/release/log.yml new file mode 100755 index 0000000000..e0514be020 --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/release/log.yml @@ -0,0 +1,28 @@ + +level: "warn" +development: true +disableCaller: true +disableStacktrace: true +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/profiles/release/server.yml b/test/integrate/dubbo/go-server/profiles/release/server.yml new file mode 100755 index 0000000000..2e2e88b772 --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/release/server.yml @@ -0,0 +1,62 @@ +# 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 : "release" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + + +services: + "UserProvider": + # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 + registry: "hangzhouzk" + 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" + # ip : "127.0.0.1" + port: 20000 + + +protocol_conf: + dubbo: + session_number: 700 + session_timeout: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + 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/profiles/test/log.yml b/test/integrate/dubbo/go-server/profiles/test/log.yml new file mode 100755 index 0000000000..baee0b7248 --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/test/log.yml @@ -0,0 +1,28 @@ + +level: "info" +development: false +disableCaller: false +disableStacktrace: true +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/profiles/test/server.yml b/test/integrate/dubbo/go-server/profiles/test/server.yml new file mode 100755 index 0000000000..2d84f872c5 --- /dev/null +++ b/test/integrate/dubbo/go-server/profiles/test/server.yml @@ -0,0 +1,62 @@ +# 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 : "test" + +registries : + "hangzhouzk": + protocol: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + + + +services: + "UserProvider": + # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 + registry: "hangzhouzk" + 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" + # ip : "127.0.0.1" + port: 20000 + + +protocol_conf: + dubbo: + session_number: 700 + session_timeout: "180s" + 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 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 1024000 + session_name: "server" From 6bce31094eab9b29024c8d6a9e258c4ac59630e6 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 13:42:01 +0800 Subject: [PATCH 126/167] push to test --- .travis.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb3e40e6a8..d6dc352d6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,30 @@ -language: go +dist: trusty +sudo: required +# define the dependence env +language: go os: - linux - go: - "1.13" - +services: + - docker env: - GO111MODULE=on -install: true - +# define ci-stage script: + # license-check - echo 'start license check' - go fmt ./... && [[ -z `git status -s` ]] - sh before_validate_license.sh - chmod u+x /tmp/tools/license/license-header-checker - /tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]] + # unit-test - echo 'start unit-test' - chmod u+x before_ut.sh && ./before_ut.sh - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic + # integrate-test - echo 'start integrate-test' - echo 'hello-world' From 5835e3c447077f7463da974f0040faf1d284c7a8 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 13:46:33 +0800 Subject: [PATCH 127/167] reinit integrate test case --- test/integrate/dubbo/go-client/app/client.go | 0 test/integrate/dubbo/go-client/app/go.mod | 3 +++ test/integrate/dubbo/go-client/app/user.go | 0 test/integrate/dubbo/go-client/app/version.go | 0 test/integrate/dubbo/go-server/app/go.mod | 3 +++ test/integrate/dubbo/go-server/app/server.go | 0 test/integrate/dubbo/go-server/app/user.go | 0 test/integrate/dubbo/go-server/app/version.go | 0 8 files changed, 6 insertions(+) mode change 100755 => 100644 test/integrate/dubbo/go-client/app/client.go create mode 100644 test/integrate/dubbo/go-client/app/go.mod mode change 100755 => 100644 test/integrate/dubbo/go-client/app/user.go mode change 100755 => 100644 test/integrate/dubbo/go-client/app/version.go create mode 100644 test/integrate/dubbo/go-server/app/go.mod mode change 100755 => 100644 test/integrate/dubbo/go-server/app/server.go mode change 100755 => 100644 test/integrate/dubbo/go-server/app/user.go mode change 100755 => 100644 test/integrate/dubbo/go-server/app/version.go diff --git a/test/integrate/dubbo/go-client/app/client.go b/test/integrate/dubbo/go-client/app/client.go old mode 100755 new mode 100644 diff --git a/test/integrate/dubbo/go-client/app/go.mod b/test/integrate/dubbo/go-client/app/go.mod new file mode 100644 index 0000000000..2376ddee36 --- /dev/null +++ b/test/integrate/dubbo/go-client/app/go.mod @@ -0,0 +1,3 @@ +module github.com/apache/dubbo-go/test/integrate/dubbo/go-client/app + +go 1.14 diff --git a/test/integrate/dubbo/go-client/app/user.go b/test/integrate/dubbo/go-client/app/user.go old mode 100755 new mode 100644 diff --git a/test/integrate/dubbo/go-client/app/version.go b/test/integrate/dubbo/go-client/app/version.go old mode 100755 new mode 100644 diff --git a/test/integrate/dubbo/go-server/app/go.mod b/test/integrate/dubbo/go-server/app/go.mod new file mode 100644 index 0000000000..868d0a1470 --- /dev/null +++ b/test/integrate/dubbo/go-server/app/go.mod @@ -0,0 +1,3 @@ +module github.com/apache/dubbo-go/test/integrate/dubbo/go-server/app + +go 1.14 diff --git a/test/integrate/dubbo/go-server/app/server.go b/test/integrate/dubbo/go-server/app/server.go old mode 100755 new mode 100644 diff --git a/test/integrate/dubbo/go-server/app/user.go b/test/integrate/dubbo/go-server/app/user.go old mode 100755 new mode 100644 diff --git a/test/integrate/dubbo/go-server/app/version.go b/test/integrate/dubbo/go-server/app/version.go old mode 100755 new mode 100644 From 1c20fead0cf2fa20cd24022cbdac22dbede38633 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 13:51:56 +0800 Subject: [PATCH 128/167] add main func for protocol/grpc/protoc-gen-dubbo/examples --- .../grpc/protoc-gen-dubbo/examples/main.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 protocol/grpc/protoc-gen-dubbo/examples/main.go diff --git a/protocol/grpc/protoc-gen-dubbo/examples/main.go b/protocol/grpc/protoc-gen-dubbo/examples/main.go new file mode 100644 index 0000000000..321cf2b5df --- /dev/null +++ b/protocol/grpc/protoc-gen-dubbo/examples/main.go @@ -0,0 +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 main + +func main() { +} From 496610a30f6d40550b6c0d04a7fe3e5c715f6e8e Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 14:35:20 +0800 Subject: [PATCH 129/167] Add integrate-test --- .travis.yml | 17 +- .../grpc/protoc-gen-dubbo/examples/main.go | 20 - test/integrate/dubbo/go-client/Dockerfile | 14 + test/integrate/dubbo/go-client/app/go.mod | 3 - .../dubbo/go-client/assembly/bin/load.sh | 203 --------- .../go-client/assembly/common/app.properties | 23 - .../dubbo/go-client/assembly/common/build.sh | 83 ---- .../dubbo/go-client/assembly/linux/dev.sh | 36 -- .../dubbo/go-client/assembly/linux/release.sh | 35 -- .../dubbo/go-client/assembly/linux/test.sh | 35 -- .../dubbo/go-client/assembly/mac/dev.sh | 36 -- .../dubbo/go-client/assembly/mac/release.sh | 34 -- .../dubbo/go-client/assembly/mac/test.sh | 34 -- .../dubbo/go-client/assembly/windows/dev.sh | 34 -- .../go-client/assembly/windows/release.sh | 34 -- .../dubbo/go-client/assembly/windows/test.sh | 34 -- .../dubbo/go-client/{app => }/client.go | 35 +- .../go-client/{profiles/dev => }/client.yml | 6 +- test/integrate/dubbo/go-client/go.mod | 8 + test/integrate/dubbo/go-client/go.sum | 411 ++++++++++++++++++ .../go-client/{profiles/dev => }/log.yml | 0 .../go-client/profiles/release/client.yml | 60 --- .../dubbo/go-client/profiles/release/log.yml | 28 -- .../dubbo/go-client/profiles/test/client.yml | 59 --- .../dubbo/go-client/profiles/test/log.yml | 28 -- .../dubbo/go-client/{app => }/user.go | 0 .../dubbo/go-client/{app => }/version.go | 0 test/integrate/dubbo/go-server/Dockerfile | 14 + .../dubbo/go-server/assembly/bin/load.sh | 151 ------- .../go-server/assembly/common/app.properties | 23 - .../dubbo/go-server/assembly/common/build.sh | 80 ---- .../dubbo/go-server/assembly/linux/dev.sh | 36 -- .../dubbo/go-server/assembly/linux/release.sh | 36 -- .../dubbo/go-server/assembly/linux/test.sh | 36 -- .../dubbo/go-server/assembly/mac/dev.sh | 36 -- .../dubbo/go-server/assembly/mac/release.sh | 36 -- .../dubbo/go-server/assembly/mac/test.sh | 36 -- .../dubbo/go-server/assembly/windows/dev.sh | 36 -- .../go-server/assembly/windows/release.sh | 36 -- .../dubbo/go-server/assembly/windows/test.sh | 36 -- .../dubbo/go-server/{app => }/go.mod | 2 +- .../go-server/{profiles/dev => }/log.yml | 0 .../dubbo/go-server/profiles/release/log.yml | 28 -- .../go-server/profiles/release/server.yml | 62 --- .../dubbo/go-server/profiles/test/log.yml | 28 -- .../dubbo/go-server/profiles/test/server.yml | 62 --- .../dubbo/go-server/{app => }/server.go | 47 +- .../go-server/{profiles/dev => }/server.yml | 4 +- .../dubbo/go-server/{app => }/user.go | 1 + .../dubbo/go-server/{app => }/version.go | 0 50 files changed, 489 insertions(+), 1647 deletions(-) delete mode 100644 protocol/grpc/protoc-gen-dubbo/examples/main.go create mode 100644 test/integrate/dubbo/go-client/Dockerfile delete mode 100644 test/integrate/dubbo/go-client/app/go.mod delete mode 100755 test/integrate/dubbo/go-client/assembly/bin/load.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/common/app.properties delete mode 100755 test/integrate/dubbo/go-client/assembly/common/build.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/linux/dev.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/linux/release.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/linux/test.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/mac/dev.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/mac/release.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/mac/test.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/windows/dev.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/windows/release.sh delete mode 100755 test/integrate/dubbo/go-client/assembly/windows/test.sh rename test/integrate/dubbo/go-client/{app => }/client.go (74%) rename test/integrate/dubbo/go-client/{profiles/dev => }/client.yml (93%) mode change 100755 => 100644 create mode 100644 test/integrate/dubbo/go-client/go.mod create mode 100644 test/integrate/dubbo/go-client/go.sum rename test/integrate/dubbo/go-client/{profiles/dev => }/log.yml (100%) mode change 100755 => 100644 delete mode 100755 test/integrate/dubbo/go-client/profiles/release/client.yml delete mode 100755 test/integrate/dubbo/go-client/profiles/release/log.yml delete mode 100755 test/integrate/dubbo/go-client/profiles/test/client.yml delete mode 100755 test/integrate/dubbo/go-client/profiles/test/log.yml rename test/integrate/dubbo/go-client/{app => }/user.go (100%) rename test/integrate/dubbo/go-client/{app => }/version.go (100%) create mode 100644 test/integrate/dubbo/go-server/Dockerfile delete mode 100755 test/integrate/dubbo/go-server/assembly/bin/load.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/common/app.properties delete mode 100755 test/integrate/dubbo/go-server/assembly/common/build.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/linux/dev.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/linux/release.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/linux/test.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/mac/dev.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/mac/release.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/mac/test.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/windows/dev.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/windows/release.sh delete mode 100755 test/integrate/dubbo/go-server/assembly/windows/test.sh rename test/integrate/dubbo/go-server/{app => }/go.mod (93%) rename test/integrate/dubbo/go-server/{profiles/dev => }/log.yml (100%) mode change 100755 => 100644 delete mode 100755 test/integrate/dubbo/go-server/profiles/release/log.yml delete mode 100755 test/integrate/dubbo/go-server/profiles/release/server.yml delete mode 100755 test/integrate/dubbo/go-server/profiles/test/log.yml delete mode 100755 test/integrate/dubbo/go-server/profiles/test/server.yml rename test/integrate/dubbo/go-server/{app => }/server.go (66%) rename test/integrate/dubbo/go-server/{profiles/dev => }/server.yml (95%) mode change 100755 => 100644 rename test/integrate/dubbo/go-server/{app => }/user.go (99%) rename test/integrate/dubbo/go-server/{app => }/version.go (100%) diff --git a/.travis.yml b/.travis.yml index d6dc352d6c..ed2d48639c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ services: - docker env: - GO111MODULE=on +install: true # define ci-stage script: @@ -26,7 +27,21 @@ script: - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic # integrate-test - echo 'start integrate-test' - - echo 'hello-world' + # start zookeeper registry insecure listen in [:]:2181 + - docker run -d --network host zookeeper + - ROOTDIR=$(pwd) + - cd ./test/integrate/dubbo-/go-client && docker build . -t ci-consumer && cd $ROOTDIR + - cd ./test/integrate/dubbo-/go-server && docker build . -t ci-provider && cd $ROOTDIR + - docker run -d --network host ci-provider + - docker run -it --network host ci-consumer + + # another registry instance, start it by dep + # start etcd registry insecure listen in [:]:2379 + #- docker run -d --network host k8s.gcr.io/etcd:3.3.10 etcd + # start consul registry insecure listen in [:]:8500 + #- docker run -d --network host consul + # start nacos registry insecure listen in [:]:8848 + #- docker run -d --network host nacos/nacos-server:latest after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/protocol/grpc/protoc-gen-dubbo/examples/main.go b/protocol/grpc/protoc-gen-dubbo/examples/main.go deleted file mode 100644 index 321cf2b5df..0000000000 --- a/protocol/grpc/protoc-gen-dubbo/examples/main.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 - -func main() { -} diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile new file mode 100644 index 0000000000..89d0549803 --- /dev/null +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -0,0 +1,14 @@ +FROM golang + +MAINTAINER scottwangsxll@gmail.com + +WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client + +ENV CONF_CONSUMER_FILE_PATH "client.yml" +ENV APP_LOG_CONF_FILE "log.yml" + +ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client + +RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client + +CMD go-client \ No newline at end of file diff --git a/test/integrate/dubbo/go-client/app/go.mod b/test/integrate/dubbo/go-client/app/go.mod deleted file mode 100644 index 2376ddee36..0000000000 --- a/test/integrate/dubbo/go-client/app/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/apache/dubbo-go/test/integrate/dubbo/go-client/app - -go 1.14 diff --git a/test/integrate/dubbo/go-client/assembly/bin/load.sh b/test/integrate/dubbo/go-client/assembly/bin/load.sh deleted file mode 100755 index ffa240b29d..0000000000 --- a/test/integrate/dubbo/go-client/assembly/bin/load.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -APP_NAME="APPLICATION_NAME" -APP_ARGS="" -SLEEP_INTERVAL=5 -MAX_LIFETIME=4000 - -PROJECT_HOME="" -OS_NAME=`uname` -if [[ ${OS_NAME} != "Windows" ]]; then - PROJECT_HOME=`pwd` - PROJECT_HOME=${PROJECT_HOME}"/" -else - APP_NAME="APPLICATION_NAME.exe" -fi - -export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" -export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" -# export GOTRACEBACK=system -# export GODEBUG=gctrace=1 - -usage() { - echo "Usage: $0 start [conf suffix]" - echo " $0 stop" - echo " $0 term" - echo " $0 restart" - echo " $0 list" - echo " $0 monitor" - echo " $0 crontab" - exit -} - -start() { - arg=$1 - if [ "$arg" = "" ];then - echo "No registry type! Default client.yml!" - else - export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml} - fi - if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then - echo $CONF_CONSUMER_FILE_PATH" is not existing!" - return - fi - APP_LOG_PATH=${PROJECT_HOME}"logs/" - mkdir -p ${APP_LOG_PATH} - APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} - chmod u+x ${APP_BIN} - # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" - CMD="${APP_BIN}" - eval ${CMD} - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - CUR=`date +%FT%T` - if [ "${PID}" != "" ]; then - for p in ${PID} - do - echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} - done - fi -} - -stop() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" - kill -2 ${ps} - done - fi -} - - -term() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" - kill -9 ${ps} - done - fi -} - -list() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` - fi - - if [ "${PID}" != "" ]; then - echo "list ${APP_NAME}" - - if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then - echo "index: user, pid, start, duration" - else - echo "index: PID, WINPID, UID, STIME, COMMAND" - fi - idx=0 - for ps in ${PID} - do - echo "${idx}: ${ps}" - ((idx ++)) - done - fi -} - -monitor() { - idx=0 - while true; do - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [[ "${PID}" == "" ]]; then - start - idx=0 - fi - - ((LIFE=idx*${SLEEP_INTERVAL})) - echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." - ((idx ++)) - sleep ${SLEEP_INTERVAL} - done -} - -crontab() { - idx=0 - while true; do - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [[ "${PID}" == "" ]]; then - start - idx=0 - fi - - ((LIFE=idx*${SLEEP_INTERVAL})) - echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." - ((idx ++)) - sleep ${SLEEP_INTERVAL} - if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then - kill -9 ${PID} - fi - done -} - -opt=$1 -case C"$opt" in - Cstart) - start $2 - ;; - Cstop) - stop - ;; - Cterm) - term - ;; - Crestart) - term - start $2 - ;; - Clist) - list - ;; - Cmonitor) - monitor - ;; - Ccrontab) - crontab - ;; - C*) - usage - ;; -esac - diff --git a/test/integrate/dubbo/go-client/assembly/common/app.properties b/test/integrate/dubbo/go-client/assembly/common/app.properties deleted file mode 100755 index e10868f4d2..0000000000 --- a/test/integrate/dubbo/go-client/assembly/common/app.properties +++ /dev/null @@ -1,23 +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. - - -export TARGET_EXEC_NAME="user_info_client" -# BUILD_PACKAGE="dubbogo-examples/user-info/client/app" -export BUILD_PACKAGE="app" - -export TARGET_CONF_FILE="conf/client.yml" -export TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/test/integrate/dubbo/go-client/assembly/common/build.sh b/test/integrate/dubbo/go-client/assembly/common/build.sh deleted file mode 100755 index d38f889ed9..0000000000 --- a/test/integrate/dubbo/go-client/assembly/common/build.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - -rm -rf target/ - -PROJECT_HOME=`pwd` -TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} - -TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` -if [[ ${GOOS} == "windows" ]]; then - TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe -fi -TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} -if [[ $PROFILE == "dev" || $PROFILE == "test" ]]; then - # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 - # GFLAGS=-gcflags "-N -l" -race -v - # GFLAGS="-gcflags \"-N -l\" -v" - cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - -else - # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), - # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, - # -w基本没啥损失。-s的损失就有点大了。 - cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - -fi - -TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} - -mkdir -p ${TARGET_FOLDER}/${TAR_NAME} - -SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin -BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} -CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf - -mkdir -p ${SBIN_DIR} -mkdir -p ${CONF_DIR} - -mv ${TARGET_NAME} ${SBIN_DIR} -cp -r assembly/bin ${BIN_DIR} -cd ${BIN_DIR}/bin/ && mv load.sh load_${TARGET_EXEC_NAME}.sh && cd - - -platform=$(uname) -# modify APPLICATION_NAME -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -else - sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -fi - -# modify TARGET_CONF_FILE -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -# modify TARGET_LOG_CONF_FILE -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -cp -r profiles/${PROFILE}/* ${CONF_DIR} - -cd ${TARGET_FOLDER} - -tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* - diff --git a/test/integrate/dubbo/go-client/assembly/linux/dev.sh b/test/integrate/dubbo/go-client/assembly/linux/dev.sh deleted file mode 100755 index eada737c8d..0000000000 --- a/test/integrate/dubbo/go-client/assembly/linux/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="dev" - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/linux/release.sh b/test/integrate/dubbo/go-client/assembly/linux/release.sh deleted file mode 100755 index 10eb3d73f8..0000000000 --- a/test/integrate/dubbo/go-client/assembly/linux/release.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/linux/test.sh b/test/integrate/dubbo/go-client/assembly/linux/test.sh deleted file mode 100755 index 78b650c0d4..0000000000 --- a/test/integrate/dubbo/go-client/assembly/linux/test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/dev.sh b/test/integrate/dubbo/go-client/assembly/mac/dev.sh deleted file mode 100755 index c828476990..0000000000 --- a/test/integrate/dubbo/go-client/assembly/mac/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="dev" - -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/release.sh b/test/integrate/dubbo/go-client/assembly/mac/release.sh deleted file mode 100755 index 91c2dfee79..0000000000 --- a/test/integrate/dubbo/go-client/assembly/mac/release.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/mac/test.sh b/test/integrate/dubbo/go-client/assembly/mac/test.sh deleted file mode 100755 index a7853f5e2d..0000000000 --- a/test/integrate/dubbo/go-client/assembly/mac/test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/dev.sh b/test/integrate/dubbo/go-client/assembly/windows/dev.sh deleted file mode 100755 index 10a3866c0f..0000000000 --- a/test/integrate/dubbo/go-client/assembly/windows/dev.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="dev" -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/release.sh b/test/integrate/dubbo/go-client/assembly/windows/release.sh deleted file mode 100755 index 21af573fa3..0000000000 --- a/test/integrate/dubbo/go-client/assembly/windows/release.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/assembly/windows/test.sh b/test/integrate/dubbo/go-client/assembly/windows/test.sh deleted file mode 100755 index 2104da8b59..0000000000 --- a/test/integrate/dubbo/go-client/assembly/windows/test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-client/app/client.go b/test/integrate/dubbo/go-client/client.go similarity index 74% rename from test/integrate/dubbo/go-client/app/client.go rename to test/integrate/dubbo/go-client/client.go index 28fe7eb899..37a5e7bfbc 100644 --- a/test/integrate/dubbo/go-client/app/client.go +++ b/test/integrate/dubbo/go-client/client.go @@ -20,9 +20,6 @@ package main import ( "context" "fmt" - "os" - "os/signal" - "syscall" "time" ) @@ -58,35 +55,17 @@ func main() { 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) - initSignal() -} - -func initSignal() { - signals := make(chan os.Signal, 1) - // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, - syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) - for { - sig := <-signals - logger.Infof("get signal %s", sig.String()) - switch sig { - case syscall.SIGHUP: - // reload() - default: - time.AfterFunc(time.Duration(survivalTimeout), func() { - logger.Warnf("app exit now by force...") - os.Exit(1) - }) - - // The program exits normally or timeout forcibly exits. - fmt.Println("app exit now...") - return - } - } } diff --git a/test/integrate/dubbo/go-client/profiles/dev/client.yml b/test/integrate/dubbo/go-client/client.yml old mode 100755 new mode 100644 similarity index 93% rename from test/integrate/dubbo/go-client/profiles/dev/client.yml rename to test/integrate/dubbo/go-client/client.yml index 55bc9246cb..8a318fd040 --- a/test/integrate/dubbo/go-client/profiles/dev/client.yml +++ b/test/integrate/dubbo/go-client/client.yml @@ -40,9 +40,9 @@ references: protocol_conf: dubbo: reconnect_interval: 0 - connection_number: 1 + connection_number: 2 heartbeat_period: "5s" - session_timeout: "180s" + session_timeout: "20s" pool_size: 64 pool_ttl: 600 getty_session_param: @@ -57,5 +57,5 @@ protocol_conf: tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" - max_msg_len: 1024000 + max_msg_len: 10240 session_name: "client" diff --git a/test/integrate/dubbo/go-client/go.mod b/test/integrate/dubbo/go-client/go.mod new file mode 100644 index 0000000000..6104a46e39 --- /dev/null +++ b/test/integrate/dubbo/go-client/go.mod @@ -0,0 +1,8 @@ +module github.com/apache/dubbo-go/test/integrate/dubbo/go-client + +go 1.14 + +require ( + github.com/apache/dubbo-go v1.4.1 // indirect + github.com/apache/dubbo-go-hessian2 v1.5.0 // indirect +) diff --git a/test/integrate/dubbo/go-client/go.sum b/test/integrate/dubbo/go-client/go.sum new file mode 100644 index 0000000000..05ff347d5f --- /dev/null +++ b/test/integrate/dubbo/go-client/go.sum @@ -0,0 +1,411 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/azure-sdk-for-go v16.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +github.com/Azure/go-autorest v10.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Azure/go-autorest v10.15.3+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/Jeffail/gabs v1.1.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= +github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= +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/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +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/SAP/go-hdb v0.12.0/go.mod h1:etBT+FAi1t5k3K3tf5vQTnosgYmhDkRi8jEnQqCnxF0= +github.com/SermoDigital/jose v0.0.0-20180104203859-803625baeddc/go.mod h1:ARgCUhI1MHQH+ONky/PAtmVHQrP5JlGY0F3poXOp/fA= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= +github.com/Workiva/go-datastructures v1.0.50/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/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= +github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= +github.com/apache/dubbo-go v1.4.1 h1:YjPPpoaM1hMnRtB45CCyd4PxGtP5DsGHQPYOytiaICA= +github.com/apache/dubbo-go v1.4.1/go.mod h1:hzP9PQkcYFcBUgedttDeimugDNqbmGzh18QQy/vBjnw= +github.com/apache/dubbo-go-hessian2 v1.4.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= +github.com/apache/dubbo-go-hessian2 v1.5.0 h1:fzulDG5G7nX0ccgKdiN9XipJ7tZ4WXKgmk4stdlDS6s= +github.com/apache/dubbo-go-hessian2 v1.5.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= +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.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aws/aws-sdk-go v1.15.24/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +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/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +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/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +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/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/containerd/continuity v0.0.0-20181203112020-004b46473808/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/coredns/coredns v1.1.2/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0= +github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/creasty/defaults v1.3.0 h1:uG+RAxYbJgOPCOdKEcec9ZJXeva7Y6mj/8egdzwmLtw= +github.com/creasty/defaults v1.3.0/go.mod h1:CIEEvs7oIVZm30R8VxtFJs+4k201gReYyuYHJxZc68I= +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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20180620032804-94c9c97e8c9f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= +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/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/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/dubbogo/getty v1.3.3 h1:8m4zZBqFHO+NmhH7rMPlFuuYRVjcPD7cUhumevqMZZs= +github.com/dubbogo/getty v1.3.3/go.mod h1:U92BDyJ6sW9Jpohr2Vlz8w2uUbIbNZ3d+6rJvFTSPp0= +github.com/dubbogo/go-zookeeper v1.0.0 h1:RsYdlGwhDW+iKXM3eIIcvt34P2swLdmQfuIJxsHlGoM= +github.com/dubbogo/go-zookeeper v1.0.0/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= +github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= +github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= +github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= +github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emicklei/go-restful/v3 v3.0.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +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 v0.0.0-20180123065059-ebf56d35bba7/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= +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-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +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-resty/resty/v2 v2.1.0/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8= +github.com/go-sql-driver/mysql v0.0.0-20180618115901-749ddf1598b4/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/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gocql/gocql v0.0.0-20180617115710-e06f8c1bcd78/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= +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.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +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-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +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/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +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-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +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.0.0-20180828235145-f29afc2cceca/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= +github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +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-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= +github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/hashicorp/consul v1.5.3/go.mod h1:61E2GJCPEP3oq8La7sfDdWGQ66+Zbxzw5ecOdFD7xIE= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.0/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-discover v0.0.0-20190403160810-22221edb15cd/go.mod h1:ueUgD9BeIocT7QNuvxSyJyPAM9dfifBcaWmeybb67OY= +github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71/go.mod h1:kbfItVoBJwCfKXDXN4YoAXjxcFVZ7MRrJzyTX6H4giE= +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-plugin v0.0.0-20180331002553-e8d22c780116/go.mod h1:JSqWYsict+jzcj0+xElxyrBQRPNoiWQuddnxArJ7XHQ= +github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +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-version v0.0.0-20170202080759-03c5bf6be031/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/hcl v0.0.0-20180906183839-65a6292f0157/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.1.4/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +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-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/vault v0.10.3/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= +github.com/hashicorp/vault-plugin-secrets-kv v0.0.0-20190318174639-195e0e9d07f1/go.mod h1:VJHHT2SC1tAPrfENQeBhLlb5FbZoKZM+oC/ROmEftz0= +github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443/go.mod h1:bEpDU35nTu0ey1EXjwNwPjI9xErAsoOCmcMb9GKvyxo= +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/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= +github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee/go.mod h1:N0t2vlmpe8nyZB5ouIbJQPDSR+mH6oe7xHB9VZHSUzM= +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-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +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/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA= +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/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +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/keybase/go-crypto v0.0.0-20180614160407-5114a9a81e1b/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +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/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/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/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 v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +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-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +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/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +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/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 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +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/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +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/nacos-group/nacos-sdk-go v0.0.0-20190723125407-0242d42e3dbb/go.mod h1:CEkSvEpoveoYjA81m4HNeYQ0sge0LFGKSEqO3JKHllo= +github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk= +github.com/oklog/run v0.0.0-20180308005104-6934b124db28/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +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/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= +github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= +github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= +github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= +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 v0.0.0-20180527043350-9f6ff22cfff8/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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 v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +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.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +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/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +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 v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= +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/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v0.0.0-20190710185942-9d28bd7c0945/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/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +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/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/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= +github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= +github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/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/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8/go.mod h1:S1cAa98KMFv4Sa8SbJ6ZtvOmf0VlgH0QJ1gXI0lBfBY= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20170114055629-f2499483f923/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-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/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/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +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-20190423024810-112230192c58/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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/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-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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/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-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +google.golang.org/api v0.0.0-20180829000535-087779f1d2c9/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +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.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +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/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +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/mgo.v2 v2.0.0-20160818020120-3f83fa500528/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/ory-am/dockertest.v3 v3.3.4/go.mod h1:s9mmoLkaGeAh97qygnNj4xWkiN7e1SKekYC6CovU+ek= +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/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= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= +k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/api v0.0.0-20190325185214-7544f9db76f6/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= +k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/apimachinery v0.0.0-20190223001710-c182ff3b9841/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= +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/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= +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-client/profiles/dev/log.yml b/test/integrate/dubbo/go-client/log.yml old mode 100755 new mode 100644 similarity index 100% rename from test/integrate/dubbo/go-client/profiles/dev/log.yml rename to test/integrate/dubbo/go-client/log.yml diff --git a/test/integrate/dubbo/go-client/profiles/release/client.yml b/test/integrate/dubbo/go-client/profiles/release/client.yml deleted file mode 100755 index baa4382293..0000000000 --- a/test/integrate/dubbo/go-client/profiles/release/client.yml +++ /dev/null @@ -1,60 +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 : "release" - -registries : - "hangzhouzk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - - -references: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "hangzhouzk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 - -protocol_conf: - dubbo: - reconnect_interval: 0 - connection_number: 1 - heartbeat_period: "5s" - session_timeout: "180s" - 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 - pkg_rq_size: 1024 - pkg_wq_size: 512 - 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/profiles/release/log.yml b/test/integrate/dubbo/go-client/profiles/release/log.yml deleted file mode 100755 index e0514be020..0000000000 --- a/test/integrate/dubbo/go-client/profiles/release/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "warn" -development: true -disableCaller: true -disableStacktrace: true -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/profiles/test/client.yml b/test/integrate/dubbo/go-client/profiles/test/client.yml deleted file mode 100755 index 90d72a24a4..0000000000 --- a/test/integrate/dubbo/go-client/profiles/test/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 : "test" - -registries : - "hangzhouzk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - -references: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "hangzhouzk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 - -protocol_conf: - dubbo: - reconnect_interval: 0 - connection_number: 1 - heartbeat_period: "5s" - session_timeout: "180s" - 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 - pkg_rq_size: 1024 - pkg_wq_size: 512 - 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/profiles/test/log.yml b/test/integrate/dubbo/go-client/profiles/test/log.yml deleted file mode 100755 index baee0b7248..0000000000 --- a/test/integrate/dubbo/go-client/profiles/test/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "info" -development: false -disableCaller: false -disableStacktrace: true -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/app/user.go b/test/integrate/dubbo/go-client/user.go similarity index 100% rename from test/integrate/dubbo/go-client/app/user.go rename to test/integrate/dubbo/go-client/user.go diff --git a/test/integrate/dubbo/go-client/app/version.go b/test/integrate/dubbo/go-client/version.go similarity index 100% rename from test/integrate/dubbo/go-client/app/version.go rename to test/integrate/dubbo/go-client/version.go diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile new file mode 100644 index 0000000000..004f550699 --- /dev/null +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -0,0 +1,14 @@ +FROM golang + +MAINTAINER scottwangsxll@gmail.com + +WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server + +ENV CONF_PROVIDER_FILE_PATH "server.yml" +ENV APP_LOG_CONF_FILE "log.yml" + +ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server + +RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server + +CMD go-server diff --git a/test/integrate/dubbo/go-server/assembly/bin/load.sh b/test/integrate/dubbo/go-server/assembly/bin/load.sh deleted file mode 100755 index 90077c2471..0000000000 --- a/test/integrate/dubbo/go-server/assembly/bin/load.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -APP_NAME="APPLICATION_NAME" -APP_ARGS="" - - -PROJECT_HOME="" -OS_NAME=`uname` -if [[ ${OS_NAME} != "Windows" ]]; then - PROJECT_HOME=`pwd` - PROJECT_HOME=${PROJECT_HOME}"/" -fi - -export CONF_PROVIDER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" -export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" - -usage() { - echo "Usage: $0 start [conf suffix]" - echo " $0 stop" - echo " $0 term" - echo " $0 restart" - echo " $0 list" - echo " $0 monitor" - echo " $0 crontab" - exit -} - -start() { - arg=$1 - if [ "$arg" = "" ];then - echo "No registry type! Default server.yml!" - else - export CONF_PROVIDER_FILE_PATH=${CONF_PROVIDER_FILE_PATH//\.yml/\_$arg\.yml} - fi - if [ ! -f "${CONF_PROVIDER_FILE_PATH}" ];then - echo $CONF_PROVIDER_FILE_PATH" is not existing!" - return - fi - APP_LOG_PATH="${PROJECT_HOME}logs/" - mkdir -p ${APP_LOG_PATH} - APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} - chmod u+x ${APP_BIN} - # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" - CMD="${APP_BIN}" - eval ${CMD} - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - CUR=`date +%FT%T` - if [ "${PID}" != "" ]; then - for p in ${PID} - do - echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} - done - fi -} - -stop() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" - kill -2 ${ps} - done - fi -} - - -term() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" - kill -9 ${ps} - done - fi -} - -list() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` - fi - - if [ "${PID}" != "" ]; then - echo "list ${APP_NAME}" - - if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then - echo "index: user, pid, start, duration" - else - echo "index: PID, WINPID, UID, STIME, COMMAND" - fi - idx=0 - for ps in ${PID} - do - echo "${idx}: ${ps}" - ((idx ++)) - done - fi -} - -opt=$1 -case C"$opt" in - Cstart) - start $2 - ;; - Cstop) - stop - ;; - Cterm) - term - ;; - Crestart) - term - start $2 - ;; - Clist) - list - ;; - C*) - usage - ;; -esac - diff --git a/test/integrate/dubbo/go-server/assembly/common/app.properties b/test/integrate/dubbo/go-server/assembly/common/app.properties deleted file mode 100755 index 1f0827eb51..0000000000 --- a/test/integrate/dubbo/go-server/assembly/common/app.properties +++ /dev/null @@ -1,23 +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. - - -TARGET_EXEC_NAME="user_info_server" -# BUILD_PACKAGE="dubbogo-examples/user-info/server/app" -BUILD_PACKAGE="app" - -TARGET_CONF_FILE="conf/server.yml" -TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/test/integrate/dubbo/go-server/assembly/common/build.sh b/test/integrate/dubbo/go-server/assembly/common/build.sh deleted file mode 100755 index d90d0263b2..0000000000 --- a/test/integrate/dubbo/go-server/assembly/common/build.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - -rm -rf target/ - -PROJECT_HOME=`pwd` -TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} - -TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` -if [[ ${GOOS} == "windows" ]]; then - TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe -fi -TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} -if [[ $PROFILE = "test" ]]; then - # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 - # GFLAGS=-gcflags "-N -l" -race -v - # GFLAGS="-gcflags \"-N -l\" -v" - cd ${BUILD_PACKAGE} && GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - -else - # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), - # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, - # -w基本没啥损失。-s的损失就有点大了。 - cd ${BUILD_PACKAGE} && GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - -fi - -TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} - -mkdir -p ${TARGET_FOLDER}/${TAR_NAME} - -SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin -BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} -CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf - -mkdir -p ${SBIN_DIR} -mkdir -p ${CONF_DIR} - -mv ${TARGET_NAME} ${SBIN_DIR} -cp -r assembly/bin ${BIN_DIR} -# modify APPLICATION_NAME -# OS=`uname` -# if [[ $OS=="Darwin" ]]; then -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -else - sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -fi -# modify TARGET_CONF_FILE -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi -# modify TARGET_LOG_CONF_FILE -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -cp -r profiles/${PROFILE}/* ${CONF_DIR} - -cd ${TARGET_FOLDER} - -tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* - diff --git a/test/integrate/dubbo/go-server/assembly/linux/dev.sh b/test/integrate/dubbo/go-server/assembly/linux/dev.sh deleted file mode 100755 index d830ac98c2..0000000000 --- a/test/integrate/dubbo/go-server/assembly/linux/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/linux/release.sh b/test/integrate/dubbo/go-server/assembly/linux/release.sh deleted file mode 100755 index 99303800b0..0000000000 --- a/test/integrate/dubbo/go-server/assembly/linux/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/linux/test.sh b/test/integrate/dubbo/go-server/assembly/linux/test.sh deleted file mode 100755 index 87144bb973..0000000000 --- a/test/integrate/dubbo/go-server/assembly/linux/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/dev.sh b/test/integrate/dubbo/go-server/assembly/mac/dev.sh deleted file mode 100755 index 3a7659b2d5..0000000000 --- a/test/integrate/dubbo/go-server/assembly/mac/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/release.sh b/test/integrate/dubbo/go-server/assembly/mac/release.sh deleted file mode 100755 index 1c4bce4bf8..0000000000 --- a/test/integrate/dubbo/go-server/assembly/mac/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/mac/test.sh b/test/integrate/dubbo/go-server/assembly/mac/test.sh deleted file mode 100755 index 69206e32fe..0000000000 --- a/test/integrate/dubbo/go-server/assembly/mac/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi - diff --git a/test/integrate/dubbo/go-server/assembly/windows/dev.sh b/test/integrate/dubbo/go-server/assembly/windows/dev.sh deleted file mode 100755 index 011fb41148..0000000000 --- a/test/integrate/dubbo/go-server/assembly/windows/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/windows/release.sh b/test/integrate/dubbo/go-server/assembly/windows/release.sh deleted file mode 100755 index 679a26a7dc..0000000000 --- a/test/integrate/dubbo/go-server/assembly/windows/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/assembly/windows/test.sh b/test/integrate/dubbo/go-server/assembly/windows/test.sh deleted file mode 100755 index 4a36de0f3a..0000000000 --- a/test/integrate/dubbo/go-server/assembly/windows/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/test/integrate/dubbo/go-server/app/go.mod b/test/integrate/dubbo/go-server/go.mod similarity index 93% rename from test/integrate/dubbo/go-server/app/go.mod rename to test/integrate/dubbo/go-server/go.mod index 868d0a1470..c738fe340d 100644 --- a/test/integrate/dubbo/go-server/app/go.mod +++ b/test/integrate/dubbo/go-server/go.mod @@ -1,3 +1,3 @@ -module github.com/apache/dubbo-go/test/integrate/dubbo/go-server/app +module github.com/apache/dubbo-go/test/integrate/dubbo/go-server go 1.14 diff --git a/test/integrate/dubbo/go-server/profiles/dev/log.yml b/test/integrate/dubbo/go-server/log.yml old mode 100755 new mode 100644 similarity index 100% rename from test/integrate/dubbo/go-server/profiles/dev/log.yml rename to test/integrate/dubbo/go-server/log.yml diff --git a/test/integrate/dubbo/go-server/profiles/release/log.yml b/test/integrate/dubbo/go-server/profiles/release/log.yml deleted file mode 100755 index e0514be020..0000000000 --- a/test/integrate/dubbo/go-server/profiles/release/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "warn" -development: true -disableCaller: true -disableStacktrace: true -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/profiles/release/server.yml b/test/integrate/dubbo/go-server/profiles/release/server.yml deleted file mode 100755 index 2e2e88b772..0000000000 --- a/test/integrate/dubbo/go-server/profiles/release/server.yml +++ /dev/null @@ -1,62 +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 : "release" - -registries : - "hangzhouzk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - - -services: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "hangzhouzk" - 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" - # ip : "127.0.0.1" - port: 20000 - - -protocol_conf: - dubbo: - session_number: 700 - session_timeout: "180s" - 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 - pkg_rq_size: 1024 - pkg_wq_size: 512 - 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/profiles/test/log.yml b/test/integrate/dubbo/go-server/profiles/test/log.yml deleted file mode 100755 index baee0b7248..0000000000 --- a/test/integrate/dubbo/go-server/profiles/test/log.yml +++ /dev/null @@ -1,28 +0,0 @@ - -level: "info" -development: false -disableCaller: false -disableStacktrace: true -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/profiles/test/server.yml b/test/integrate/dubbo/go-server/profiles/test/server.yml deleted file mode 100755 index 2d84f872c5..0000000000 --- a/test/integrate/dubbo/go-server/profiles/test/server.yml +++ /dev/null @@ -1,62 +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 : "test" - -registries : - "hangzhouzk": - protocol: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - - - -services: - "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 - registry: "hangzhouzk" - 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" - # ip : "127.0.0.1" - port: 20000 - - -protocol_conf: - dubbo: - session_number: 700 - session_timeout: "180s" - 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 - pkg_rq_size: 1024 - pkg_wq_size: 512 - 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/app/server.go b/test/integrate/dubbo/go-server/server.go similarity index 66% rename from test/integrate/dubbo/go-server/app/server.go rename to test/integrate/dubbo/go-server/server.go index fd81aab037..115bf0a4d7 100644 --- a/test/integrate/dubbo/go-server/app/server.go +++ b/test/integrate/dubbo/go-server/server.go @@ -18,30 +18,23 @@ package main import ( - "fmt" - "os" - "os/signal" - "syscall" "time" ) import ( hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/filter/filter_impl" _ "github.com/apache/dubbo-go/protocol/dubbo" _ "github.com/apache/dubbo-go/registry/protocol" - - _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" - _ "github.com/apache/dubbo-go/filter/filter_impl" - - _ "github.com/apache/dubbo-go/cluster/cluster_impl" - _ "github.com/apache/dubbo-go/cluster/loadbalance" _ "github.com/apache/dubbo-go/registry/zookeeper" ) var ( - survivalTimeout = int(3e9) + stopC = make(chan struct{}) ) // they are necessary: @@ -52,28 +45,12 @@ func main() { hessian.RegisterPOJO(&User{}) config.Load() - initSignal() -} - -func initSignal() { - signals := make(chan os.Signal, 1) - // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) - for { - sig := <-signals - logger.Infof("get signal %s", sig.String()) - switch sig { - case syscall.SIGHUP: - // reload() - default: - time.AfterFunc(time.Duration(survivalTimeout), func() { - logger.Warnf("app exit now by force...") - os.Exit(1) - }) - - // The program exits normally or timeout forcibly exits. - fmt.Println("provider app exit now...") - return - } + 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/profiles/dev/server.yml b/test/integrate/dubbo/go-server/server.yml old mode 100755 new mode 100644 similarity index 95% rename from test/integrate/dubbo/go-server/profiles/dev/server.yml rename to test/integrate/dubbo/go-server/server.yml index b9f1da696b..ab7f63d7e4 --- a/test/integrate/dubbo/go-server/profiles/dev/server.yml +++ b/test/integrate/dubbo/go-server/server.yml @@ -40,7 +40,7 @@ protocols: protocol_conf: dubbo: session_number: 700 - session_timeout: "180s" + session_timeout: "20s" getty_session_param: compress_encoding: false tcp_no_delay: true @@ -53,5 +53,5 @@ protocol_conf: tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" - max_msg_len: 1024000 + max_msg_len: 1024 session_name: "server" diff --git a/test/integrate/dubbo/go-server/app/user.go b/test/integrate/dubbo/go-server/user.go similarity index 99% rename from test/integrate/dubbo/go-server/app/user.go rename to test/integrate/dubbo/go-server/user.go index 6410074fc0..7bff415661 100644 --- a/test/integrate/dubbo/go-server/app/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -48,6 +48,7 @@ func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, e println("req:%#v", req) rsp := User{"A001", "Alex Stocks", 18, time.Now()} println("rsp:%#v", rsp) + close(stopC) return &rsp, nil } diff --git a/test/integrate/dubbo/go-server/app/version.go b/test/integrate/dubbo/go-server/version.go similarity index 100% rename from test/integrate/dubbo/go-server/app/version.go rename to test/integrate/dubbo/go-server/version.go From 47b9666e7076ea51fde5b282a54d30b7d44c1f23 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 14:44:55 +0800 Subject: [PATCH 130/167] Fix travis integrate test case filepath mistake --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed2d48639c..ba743167e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ install: true # define ci-stage script: # license-check + # start zookeeper registry insecure listen in [:]:2181 - echo 'start license check' - go fmt ./... && [[ -z `git status -s` ]] - sh before_validate_license.sh @@ -30,8 +31,8 @@ script: # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo-/go-client && docker build . -t ci-consumer && cd $ROOTDIR - - cd ./test/integrate/dubbo-/go-server && docker build . -t ci-provider && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer From b6a5888e6d0aa537baa1e3d7c26cb45be1852884 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 14:51:43 +0800 Subject: [PATCH 131/167] Drop ci-consumer unused package --- test/integrate/dubbo/go-client/client.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go index 37a5e7bfbc..4c62674d33 100644 --- a/test/integrate/dubbo/go-client/client.go +++ b/test/integrate/dubbo/go-client/client.go @@ -25,7 +25,6 @@ import ( import ( hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/common/logger" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" _ "github.com/apache/dubbo-go/protocol/dubbo" From c109d8fbfd54e2839d995dbe50a68cc427b7359a Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:13:33 +0800 Subject: [PATCH 132/167] Add ci used current commit id --- .travis.yml | 5 +++-- test/integrate/dubbo/go-client/Dockerfile | 4 ++++ test/integrate/dubbo/go-server/Dockerfile | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba743167e4..434279d04a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: true # define ci-stage script: + - COMMITID=$(git rev-parse HEAD) # license-check # start zookeeper registry insecure listen in [:]:2181 - echo 'start license check' @@ -31,8 +32,8 @@ script: # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${COMMITID} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${COMMITID} && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index 89d0549803..0f124a6e7b 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -7,8 +7,12 @@ WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client ENV CONF_CONSUMER_FILE_PATH "client.yml" ENV APP_LOG_CONF_FILE "log.yml" +ARG COMMITID + ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client +RUN go get -u github.com/apache/dubbo-go@ARG + RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client CMD go-client \ No newline at end of file diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index 004f550699..91839f7942 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -7,8 +7,12 @@ WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server ENV CONF_PROVIDER_FILE_PATH "server.yml" ENV APP_LOG_CONF_FILE "log.yml" +ARG COMMITID + ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server +RUN go get -u github.com/apache/dubbo-go@ARG + RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server CMD go-server From 9a68bb4c11a6a978312d5a26c3bba6ed35564dfe Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:21:39 +0800 Subject: [PATCH 133/167] Fix dockerfile mistake, and fast fail --- .travis.yml | 9 +++++++++ test/integrate/dubbo/go-client/Dockerfile | 5 ++--- test/integrate/dubbo/go-server/Dockerfile | 5 ++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 434279d04a..e2929067be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,15 @@ script: - COMMITID=$(git rev-parse HEAD) # license-check # start zookeeper registry insecure listen in [:]:2181 + - echo 'start integrate-test' + # start zookeeper registry insecure listen in [:]:2181 + - docker run -d --network host zookeeper + - ROOTDIR=$(pwd) + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${COMMITID} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${COMMITID} && cd $ROOTDIR + - docker run -d --network host ci-provider + - docker run -it --network host ci-consumer + - exit 0 - echo 'start license check' - go fmt ./... && [[ -z `git status -s` ]] - sh before_validate_license.sh diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index 0f124a6e7b..cf465b8db5 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -10,9 +10,8 @@ ENV APP_LOG_CONF_FILE "log.yml" ARG COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client - -RUN go get -u github.com/apache/dubbo-go@ARG - +# update dubbo-go to current commit id +RUN go get -u github.com/apache/dubbo-go@${COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client CMD go-client \ No newline at end of file diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index 91839f7942..80990a142c 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -10,9 +10,8 @@ ENV APP_LOG_CONF_FILE "log.yml" ARG COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server - -RUN go get -u github.com/apache/dubbo-go@ARG - +# update dubbo-go to current commit id +RUN go get -u github.com/apache/dubbo-go@${COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server CMD go-server From 385f2674c16f7c8e9f378cf024a3bd45f80f7755 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:25:44 +0800 Subject: [PATCH 134/167] Add more rich debug log --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e2929067be..e6edd4b683 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ script: # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) + - echo ${COMMITID} ${ROOTDIR} - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${COMMITID} && cd $ROOTDIR - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${COMMITID} && cd $ROOTDIR - docker run -d --network host ci-provider From a14978e9fcf1d84aad448e32edd80fe45037aecb Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:28:57 +0800 Subject: [PATCH 135/167] Fix to used travis env direct --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e6edd4b683..e2214ce2ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,16 +15,15 @@ install: true # define ci-stage script: - - COMMITID=$(git rev-parse HEAD) # license-check # start zookeeper registry insecure listen in [:]:2181 - echo 'start integrate-test' # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - echo ${COMMITID} ${ROOTDIR} - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${COMMITID} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${COMMITID} && cd $ROOTDIR + - echo ${TRAVIS_COMMIT} ${ROOTDIR} + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${TRAVIS_COMMIT} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${TRAVIS_COMMIT} && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer - exit 0 From 4866c0cea3ed9cff40071c20262a1552e03d8a1a Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:46:31 +0800 Subject: [PATCH 136/167] Add check travis env --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index e2214ce2ed..3658c7dc27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,14 @@ install: true # define ci-stage script: + + # travis env + - echo ${TRAVIS_PULL_REQUEST} + - echo ${TRAVIS_PULL_REQUEST_BRANCH} + - echo ${TRAVIS_PULL_REQUEST_SLUG} + - echo ${TRAVIS_PULL_REQUEST_SHA} + - echo ${TRAVIS_REPO_SLUG} + - exit 1 # license-check # start zookeeper registry insecure listen in [:]:2181 - echo 'start integrate-test' From eb46ba9767530a64104887a4a20d0811d223d307 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 15:54:38 +0800 Subject: [PATCH 137/167] Fix dockerfile and build the latest code --- .travis.yml | 6 ++---- test/integrate/dubbo/go-client/Dockerfile | 8 ++++++-- test/integrate/dubbo/go-server/Dockerfile | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3658c7dc27..37dea01a97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,16 +22,14 @@ script: - echo ${TRAVIS_PULL_REQUEST_SLUG} - echo ${TRAVIS_PULL_REQUEST_SHA} - echo ${TRAVIS_REPO_SLUG} - - exit 1 # license-check # start zookeeper registry insecure listen in [:]:2181 - echo 'start integrate-test' # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - echo ${TRAVIS_COMMIT} ${ROOTDIR} - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${TRAVIS_COMMIT} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${TRAVIS_COMMIT} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer - exit 0 diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index cf465b8db5..914d4a50bc 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -7,11 +7,15 @@ WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client ENV CONF_CONSUMER_FILE_PATH "client.yml" ENV APP_LOG_CONF_FILE "log.yml" -ARG COMMITID +ARG PR_ORIGIN_REPO +ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client + # update dubbo-go to current commit id -RUN go get -u github.com/apache/dubbo-go@${COMMITID} +RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} + RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client CMD go-client \ No newline at end of file diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index 80990a142c..c981d8a6d1 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -7,11 +7,14 @@ WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server ENV CONF_PROVIDER_FILE_PATH "server.yml" ENV APP_LOG_CONF_FILE "log.yml" -ARG COMMITID +ARG PR_ORIGIN_REPO +ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server # update dubbo-go to current commit id -RUN go get -u github.com/apache/dubbo-go@${COMMITID} +RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} + RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server CMD go-server From 7a225fc4538c8ed23df865b31faf121f0402430b Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 16:18:16 +0800 Subject: [PATCH 138/167] Sync latest travis config --- .travis.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37dea01a97..98ef1fd10f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ install: true # define ci-stage script: - # travis env - echo ${TRAVIS_PULL_REQUEST} - echo ${TRAVIS_PULL_REQUEST_BRANCH} @@ -23,16 +22,6 @@ script: - echo ${TRAVIS_PULL_REQUEST_SHA} - echo ${TRAVIS_REPO_SLUG} # license-check - # start zookeeper registry insecure listen in [:]:2181 - - echo 'start integrate-test' - # start zookeeper registry insecure listen in [:]:2181 - - docker run -d --network host zookeeper - - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - - docker run -d --network host ci-provider - - docker run -it --network host ci-consumer - - exit 0 - echo 'start license check' - go fmt ./... && [[ -z `git status -s` ]] - sh before_validate_license.sh @@ -47,8 +36,8 @@ script: # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg COMMITID=${COMMITID} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg COMMITID=${COMMITID} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer From 06a543b2891f476223b751bf68772252bd6008bc Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 16:41:31 +0800 Subject: [PATCH 139/167] Drop ci-consumer go.sum --- test/integrate/dubbo/go-client/go.mod | 5 ----- test/integrate/dubbo/go-client/go.sum | 22 ---------------------- 2 files changed, 27 deletions(-) diff --git a/test/integrate/dubbo/go-client/go.mod b/test/integrate/dubbo/go-client/go.mod index 6104a46e39..25c91bd7a1 100644 --- a/test/integrate/dubbo/go-client/go.mod +++ b/test/integrate/dubbo/go-client/go.mod @@ -1,8 +1,3 @@ module github.com/apache/dubbo-go/test/integrate/dubbo/go-client go 1.14 - -require ( - github.com/apache/dubbo-go v1.4.1 // indirect - github.com/apache/dubbo-go-hessian2 v1.5.0 // indirect -) diff --git a/test/integrate/dubbo/go-client/go.sum b/test/integrate/dubbo/go-client/go.sum index 05ff347d5f..687fd0f337 100644 --- a/test/integrate/dubbo/go-client/go.sum +++ b/test/integrate/dubbo/go-client/go.sum @@ -15,19 +15,15 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdko github.com/SAP/go-hdb v0.12.0/go.mod h1:etBT+FAi1t5k3K3tf5vQTnosgYmhDkRi8jEnQqCnxF0= github.com/SermoDigital/jose v0.0.0-20180104203859-803625baeddc/go.mod h1:ARgCUhI1MHQH+ONky/PAtmVHQrP5JlGY0F3poXOp/fA= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= github.com/Workiva/go-datastructures v1.0.50/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/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190802083043-4cd0c391755e/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ= github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= -github.com/apache/dubbo-go v1.4.1 h1:YjPPpoaM1hMnRtB45CCyd4PxGtP5DsGHQPYOytiaICA= github.com/apache/dubbo-go v1.4.1/go.mod h1:hzP9PQkcYFcBUgedttDeimugDNqbmGzh18QQy/vBjnw= github.com/apache/dubbo-go-hessian2 v1.4.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= -github.com/apache/dubbo-go-hessian2 v1.5.0 h1:fzulDG5G7nX0ccgKdiN9XipJ7tZ4WXKgmk4stdlDS6s= github.com/apache/dubbo-go-hessian2 v1.5.0/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= 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= @@ -55,7 +51,6 @@ github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/creasty/defaults v1.3.0 h1:uG+RAxYbJgOPCOdKEcec9ZJXeva7Y6mj/8egdzwmLtw= github.com/creasty/defaults v1.3.0/go.mod h1:CIEEvs7oIVZm30R8VxtFJs+4k201gReYyuYHJxZc68I= 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= @@ -67,12 +62,9 @@ github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nb github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dubbogo/getty v1.3.3 h1:8m4zZBqFHO+NmhH7rMPlFuuYRVjcPD7cUhumevqMZZs= github.com/dubbogo/getty v1.3.3/go.mod h1:U92BDyJ6sW9Jpohr2Vlz8w2uUbIbNZ3d+6rJvFTSPp0= -github.com/dubbogo/go-zookeeper v1.0.0 h1:RsYdlGwhDW+iKXM3eIIcvt34P2swLdmQfuIJxsHlGoM= github.com/dubbogo/go-zookeeper v1.0.0/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.5.1/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= -github.com/dubbogo/gost v1.5.2 h1:ri/03971hdpnn3QeCU+4UZgnRNGDXLDGDucR/iozZm8= github.com/dubbogo/gost v1.5.2/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= @@ -109,7 +101,6 @@ github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptG github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 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= @@ -117,7 +108,6 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 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= @@ -133,7 +123,6 @@ github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTV github.com/gophercloud/gophercloud v0.0.0-20180828235145-f29afc2cceca/go.mod h1:3WdhXV3rUYy9p6AUW8d94kr+HS62Y4VL9mBnFxsD8q4= github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -188,7 +177,6 @@ github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4= github.com/jefferai/jsonx v0.0.0-20160721235117-9cc31c3135ee/go.mod h1:N0t2vlmpe8nyZB5ouIbJQPDSR+mH6oe7xHB9VZHSUzM= 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-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -213,7 +201,6 @@ github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8 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 v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 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= @@ -228,12 +215,10 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452/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 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 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= @@ -251,7 +236,6 @@ github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/ory/dockertest v3.3.4+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/packethost/packngo v0.1.1-0.20180711074735-b9cb5096f54c/go.mod h1:otzZQXgoO96RTzDB/Hycg0qZcXZsWJGJRSXbmEIJ+4M= @@ -260,7 +244,6 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/patrickmn/go-cache v0.0.0-20180527043350-9f6ff22cfff8/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -282,7 +265,6 @@ github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5N github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -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 v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= @@ -317,11 +299,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8/go.mod h1:S1cAa98KMFv4Sa8SbJ6ZtvOmf0VlgH0QJ1gXI0lBfBY= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v3.3.13+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= -go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 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= @@ -393,7 +372,6 @@ gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 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= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From f83dade0936c4783cb4394ff1d1f27a6fdc832ff Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 18:00:09 +0800 Subject: [PATCH 140/167] Fix docker build multi args --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 98ef1fd10f..a1c13a31a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,8 @@ script: # start zookeeper registry insecure listen in [:]:2181 - docker run -d --network host zookeeper - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - docker run -d --network host ci-provider - docker run -it --network host ci-consumer From dc27a11ace4dc9ea48ed6fe695eaa52c023244f4 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Tue, 19 May 2020 20:56:36 +0800 Subject: [PATCH 141/167] Delete used debug info --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1c13a31a9..7fb7420d8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,12 +15,6 @@ install: true # define ci-stage script: - # travis env - - echo ${TRAVIS_PULL_REQUEST} - - echo ${TRAVIS_PULL_REQUEST_BRANCH} - - echo ${TRAVIS_PULL_REQUEST_SLUG} - - echo ${TRAVIS_PULL_REQUEST_SHA} - - echo ${TRAVIS_REPO_SLUG} # license-check - echo 'start license check' - go fmt ./... && [[ -z `git status -s` ]] From 8e9c2b2abb4c97643f9a6db6f285db571fd03bf8 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Wed, 20 May 2020 10:33:21 +0800 Subject: [PATCH 142/167] Fix mistake according comment --- test/integrate/dubbo/go-client/Dockerfile | 19 +++++++++++++++++-- test/integrate/dubbo/go-client/go.mod | 2 +- test/integrate/dubbo/go-server/Dockerfile | 19 +++++++++++++++++-- test/integrate/dubbo/go-server/go.mod | 2 +- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index 914d4a50bc..1c683613f5 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -1,6 +1,21 @@ -FROM golang +# +#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. +# -MAINTAINER scottwangsxll@gmail.com +FROM golang WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client diff --git a/test/integrate/dubbo/go-client/go.mod b/test/integrate/dubbo/go-client/go.mod index 25c91bd7a1..4708eb1f0f 100644 --- a/test/integrate/dubbo/go-client/go.mod +++ b/test/integrate/dubbo/go-client/go.mod @@ -1,3 +1,3 @@ module github.com/apache/dubbo-go/test/integrate/dubbo/go-client -go 1.14 +go 1.13 diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index c981d8a6d1..05596980c3 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -1,6 +1,21 @@ -FROM golang +# +#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. +# -MAINTAINER scottwangsxll@gmail.com +FROM golang WORKDIR /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server diff --git a/test/integrate/dubbo/go-server/go.mod b/test/integrate/dubbo/go-server/go.mod index c738fe340d..9e1162327d 100644 --- a/test/integrate/dubbo/go-server/go.mod +++ b/test/integrate/dubbo/go-server/go.mod @@ -1,3 +1,3 @@ module github.com/apache/dubbo-go/test/integrate/dubbo/go-server -go 1.14 +go 1.13 From a5192035156bde40e47fe3e74c662a82d21c8ce2 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Wed, 20 May 2020 17:15:59 +0800 Subject: [PATCH 143/167] Update go-client config --- test/integrate/dubbo/go-client/client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrate/dubbo/go-client/client.yml b/test/integrate/dubbo/go-client/client.yml index 8a318fd040..df44a13da3 100644 --- a/test/integrate/dubbo/go-client/client.yml +++ b/test/integrate/dubbo/go-client/client.yml @@ -57,5 +57,5 @@ protocol_conf: tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" - max_msg_len: 10240 + max_msg_len: 1024000 session_name: "client" From b39f87682b9cdb2ef82396bbebee90294f4843b2 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Wed, 20 May 2020 17:22:52 +0800 Subject: [PATCH 144/167] Update go-server config --- test/integrate/dubbo/go-server/server.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integrate/dubbo/go-server/server.yml b/test/integrate/dubbo/go-server/server.yml index ab7f63d7e4..8a17297b10 100644 --- a/test/integrate/dubbo/go-server/server.yml +++ b/test/integrate/dubbo/go-server/server.yml @@ -53,5 +53,5 @@ protocol_conf: tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" - max_msg_len: 1024 + max_msg_len: 1024000 session_name: "server" From 71517efe98109d4f74befec696cb7f090363ef60 Mon Sep 17 00:00:00 2001 From: aliiohs Date: Wed, 20 May 2020 23:22:28 +0800 Subject: [PATCH 145/167] change go.mod --- go.mod | 1 + go.sum | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/go.mod b/go.mod index 24357c3c72..887df01aa2 100644 --- a/go.mod +++ b/go.mod @@ -53,6 +53,7 @@ require ( github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8 + go.etcd.io/bbolt v1.3.4 // indirect go.uber.org/atomic v1.4.0 go.uber.org/zap v1.10.0 google.golang.org/grpc v1.22.1 diff --git a/go.sum b/go.sum index 5bf460fc48..92ab16c434 100644 --- a/go.sum +++ b/go.sum @@ -502,6 +502,8 @@ 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/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8 h1:k8TV7Gz7cpWpOw/dz71fx8cCZdWoPuckHJ/wkJl+meg= github.com/zouyx/agollo v0.0.0-20191114083447-dde9fc9f35b8/go.mod h1:S1cAa98KMFv4Sa8SbJ6ZtvOmf0VlgH0QJ1gXI0lBfBY= +go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg= +go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= @@ -548,6 +550,8 @@ golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0= golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= From d1e5463b2c1b81f79aa83663d8399b750fe5dc3e Mon Sep 17 00:00:00 2001 From: renzhiyuan02 Date: Thu, 21 May 2020 09:47:44 +0800 Subject: [PATCH 146/167] change comments --- registry/directory/directory.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 771f31d499..bf2d0e2dc2 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -61,7 +61,7 @@ type RegistryDirectory struct { forbidden atomic.Bool } -// NewRegistryDirectory NewRegistryDirectory will create a new RegistryDirectory +// NewRegistryDirectory will create a new RegistryDirectory func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.Directory, error) { if url.SubURL == nil { return nil, perrors.Errorf("url is invalid, suburl can not be nil") @@ -79,14 +79,14 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster. return dir, nil } -// Subscribe subscribe from registry +// subscribe from registry func (dir *RegistryDirectory) subscribe(url *common.URL) { dir.consumerConfigurationListener.addNotifyListener(dir) dir.referenceConfigurationListener = newReferenceConfigurationListener(dir, url) dir.registry.Subscribe(url, dir) } -// Notify monitors changes from registry,and update the cacheServices +// Notify monitor changes from registry,and update the cacheServices func (dir *RegistryDirectory) Notify(event *registry.ServiceEvent) { go dir.update(event) } @@ -260,7 +260,7 @@ func (dir *RegistryDirectory) IsAvailable() bool { return false } -// Destroy destroy method +// Destroy method func (dir *RegistryDirectory) Destroy() { //TODO:unregister & unsubscribe dir.BaseDirectory.Destroy(func() { @@ -326,7 +326,7 @@ func (l *consumerConfigurationListener) addNotifyListener(listener registry.Noti l.listeners = append(l.listeners, listener) } -// Process Process handles events from Configuration Center and update Invokers +// Process handles events from Configuration Center and update Invokers func (l *consumerConfigurationListener) Process(event *config_center.ConfigChangeEvent) { l.BaseConfigurationListener.Process(event) l.directory.refreshInvokers(nil) From 1df116504c0becabbe9b268437050f860adc3614 Mon Sep 17 00:00:00 2001 From: haohongfan Date: Thu, 21 May 2020 11:15:10 +0800 Subject: [PATCH 147/167] feat: fix gitee code analysis shadow err fix #514 --- .../available_cluster_invoker_test.go | 6 +++--- cluster/cluster_impl/base_cluster_invoker.go | 1 - cluster/cluster_impl/failover_cluster_test.go | 4 ++-- cluster/directory/base_directory.go | 2 +- cluster/directory/base_directory_test.go | 5 ++--- cluster/directory/static_directory.go | 2 +- config/base_config_test.go | 15 ++++++++------- config/consumer_config.go | 3 +-- config/service_config.go | 6 +++--- filter/filter_impl/hystrix_filter.go | 2 +- filter/filter_impl/token_filter_test.go | 12 ++++++------ protocol/dubbo/listener.go | 4 ++-- protocol/dubbo/pool.go | 13 +++++++------ protocol/jsonrpc/http.go | 4 ++-- protocol/jsonrpc/json.go | 8 ++++---- protocol/jsonrpc/jsonrpc_protocol.go | 4 ++-- protocol/jsonrpc/server.go | 6 +++--- registry/consul/listener.go | 3 +-- registry/kubernetes/listener_test.go | 3 +-- registry/kubernetes/registry_test.go | 2 +- registry/nacos/registry_test.go | 10 +++++----- remoting/zookeeper/client.go | 19 ++++++++----------- remoting/zookeeper/listener.go | 4 +--- 23 files changed, 65 insertions(+), 73 deletions(-) diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster_impl/available_cluster_invoker_test.go index c2cebd3843..61d1c93452 100644 --- a/cluster/cluster_impl/available_cluster_invoker_test.go +++ b/cluster/cluster_impl/available_cluster_invoker_test.go @@ -42,7 +42,7 @@ var ( availableUrl, _ = common.NewURL("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") ) -func registerAvailable(t *testing.T, invoker *mock.MockInvoker) protocol.Invoker { +func registerAvailable(invoker *mock.MockInvoker) protocol.Invoker { extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance) availableCluster := NewAvailableCluster() @@ -60,7 +60,7 @@ func TestAvailableClusterInvokerSuccess(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerAvailable(t, invoker) + clusterInvoker := registerAvailable(invoker) mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}} invoker.EXPECT().IsAvailable().Return(true) @@ -76,7 +76,7 @@ func TestAvailableClusterInvokerNoAvail(t *testing.T) { defer ctrl.Finish() invoker := mock.NewMockInvoker(ctrl) - clusterInvoker := registerAvailable(t, invoker) + clusterInvoker := registerAvailable(invoker) invoker.EXPECT().IsAvailable().Return(false) diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go index 1279999412..cabd6c5f17 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster_impl/base_cluster_invoker.go @@ -87,7 +87,6 @@ func (invoker *baseClusterInvoker) checkWhetherDestroyed() error { } func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation protocol.Invocation, invokers []protocol.Invoker, invoked []protocol.Invoker) protocol.Invoker { - var selectedInvoker protocol.Invoker url := invokers[0].GetUrl() sticky := url.GetParamBool(constant.STICKY_KEY, false) diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go index 1be21067a6..ee7d48f349 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster_impl/failover_cluster_test.go @@ -107,8 +107,8 @@ func normalInvoke(t *testing.T, successCount int, urlParam url.Values, invocatio 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), common.WithParams(urlParam)) - invokers = append(invokers, NewMockInvoker(url, successCount)) + 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)) } staticDir := directory.NewStaticDirectory(invokers) diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index 75d9ef2656..cff0a983a1 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -92,7 +92,7 @@ func (dir *BaseDirectory) SetRouters(urls []*common.URL) { factory := extension.GetRouterFactory(url.Protocol) r, err := factory.NewRouter(url) if err != nil { - logger.Errorf("Create router fail. router key: %s, error: %v", routerKey, url.Service(), err) + logger.Errorf("Create router fail. router key: %s, url:%s, error: %s", routerKey, url.Service(), err.Error()) return } routers = append(routers, r) diff --git a/cluster/directory/base_directory_test.go b/cluster/directory/base_directory_test.go index d5993959f1..6dc55b3940 100644 --- a/cluster/directory/base_directory_test.go +++ b/cluster/directory/base_directory_test.go @@ -19,7 +19,6 @@ package directory import ( "encoding/base64" - "fmt" "testing" ) @@ -35,7 +34,7 @@ import ( ) func TestNewBaseDirectory(t *testing.T) { - url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider")) + url, _ := common.NewURL("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") directory := NewBaseDirectory(&url) assert.NotNil(t, directory) @@ -46,7 +45,7 @@ func TestNewBaseDirectory(t *testing.T) { } func TestBuildRouterChain(t *testing.T) { - url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider")) + url, _ := common.NewURL("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") directory := NewBaseDirectory(&url) assert.NotNil(t, directory) diff --git a/cluster/directory/static_directory.go b/cluster/directory/static_directory.go index 9f600fedc4..87f5135649 100644 --- a/cluster/directory/static_directory.go +++ b/cluster/directory/static_directory.go @@ -61,7 +61,7 @@ func (dir *staticDirectory) IsAvailable() bool { // List List invokers func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invoker { l := len(dir.invokers) - invokers := make([]protocol.Invoker, l, l) + invokers := make([]protocol.Invoker, l) copy(invokers, dir.invokers) routerChain := dir.RouterChain() diff --git a/config/base_config_test.go b/config/base_config_test.go index d16b242092..bc422d0189 100644 --- a/config/base_config_test.go +++ b/config/base_config_test.go @@ -21,9 +21,11 @@ import ( "reflect" "testing" ) + import ( "github.com/stretchr/testify/assert" ) + import ( "github.com/apache/dubbo-go/common/config" "github.com/apache/dubbo-go/common/extension" @@ -481,7 +483,6 @@ func Test_refreshProvider(t *testing.T) { } func Test_startConfigCenter(t *testing.T) { - extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory { return &config_center.MockDynamicConfigurationFactory{} }) @@ -499,21 +500,21 @@ func Test_startConfigCenter(t *testing.T) { } func Test_initializeStruct(t *testing.T) { - consumerConfig := &ConsumerConfig{} + testConsumerConfig := &ConsumerConfig{} tp := reflect.TypeOf(ConsumerConfig{}) v := reflect.New(tp) initializeStruct(tp, v.Elem()) - fmt.Println(reflect.ValueOf(consumerConfig).Elem().Type().String()) + fmt.Println(reflect.ValueOf(testConsumerConfig).Elem().Type().String()) fmt.Println(v.Elem().Type().String()) - reflect.ValueOf(consumerConfig).Elem().Set(v.Elem()) + reflect.ValueOf(testConsumerConfig).Elem().Set(v.Elem()) assert.Condition(t, func() (success bool) { - return consumerConfig.ApplicationConfig != nil + return testConsumerConfig.ApplicationConfig != nil }) assert.Condition(t, func() (success bool) { - return consumerConfig.Registries != nil + return testConsumerConfig.Registries != nil }) assert.Condition(t, func() (success bool) { - return consumerConfig.References != nil + return testConsumerConfig.References != nil }) } diff --git a/config/consumer_config.go b/config/consumer_config.go index debcd79fa2..1b563054ec 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -129,7 +129,7 @@ func configCenterRefreshConsumer() error { var err error if consumerConfig.ConfigCenterConfig != nil { consumerConfig.SetFatherConfig(consumerConfig) - if err := consumerConfig.startConfigCenter(); err != nil { + if err = consumerConfig.startConfigCenter(); err != nil { return perrors.Errorf("start config center error , error message is {%v}", perrors.WithStack(err)) } consumerConfig.fresh() @@ -144,6 +144,5 @@ func configCenterRefreshConsumer() error { return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) } } - return nil } diff --git a/config/service_config.go b/config/service_config.go index 45e7df6306..09308d032e 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -154,9 +154,9 @@ func (c *ServiceConfig) Export() error { // registry the service reflect methods, err := common.ServiceMap.Register(c.InterfaceName, proto.Name, c.rpcService) if err != nil { - err := perrors.Errorf("The service %v export the protocol %v error! Error message is %v .", c.InterfaceName, proto.Name, err.Error()) - logger.Errorf(err.Error()) - return err + 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 diff --git a/filter/filter_impl/hystrix_filter.go b/filter/filter_impl/hystrix_filter.go index 9fd97b57b6..ff4b405f48 100644 --- a/filter/filter_impl/hystrix_filter.go +++ b/filter/filter_impl/hystrix_filter.go @@ -124,7 +124,7 @@ func (hf *HystrixFilter) Invoke(ctx context.Context, invoker protocol.Invoker, i _, _, err := hystrix.GetCircuit(cmdName) configLoadMutex.RUnlock() if err != nil { - logger.Errorf("[Hystrix Filter]Errors occurred getting circuit for %s , will invoke without hystrix, error is: ", cmdName, err) + logger.Errorf("[Hystrix Filter]Errors occurred getting circuit for %s , will invoke without hystrix, error is: %s", cmdName, err.Error()) return invoker.Invoke(ctx, invocation) } logger.Infof("[Hystrix Filter]Using hystrix filter: %s", cmdName) diff --git a/filter/filter_impl/token_filter_test.go b/filter/filter_impl/token_filter_test.go index d7a7f20a5d..b8b297e672 100644 --- a/filter/filter_impl/token_filter_test.go +++ b/filter/filter_impl/token_filter_test.go @@ -53,10 +53,10 @@ func TestTokenFilter_Invoke(t *testing.T) { func TestTokenFilter_InvokeEmptyToken(t *testing.T) { filter := GetTokenFilter() - url := common.URL{} + testUrl := common.URL{} attch := make(map[string]string, 0) attch[constant.TOKEN_KEY] = "ori_key" - result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(url), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) + result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) assert.Nil(t, result.Error()) assert.Nil(t, result.Result()) } @@ -64,23 +64,23 @@ func TestTokenFilter_InvokeEmptyToken(t *testing.T) { func TestTokenFilter_InvokeEmptyAttach(t *testing.T) { filter := GetTokenFilter() - url := common.NewURLWithOptions( + testUrl := common.NewURLWithOptions( common.WithParams(url.Values{}), common.WithParamsValue(constant.TOKEN_KEY, "ori_key")) attch := make(map[string]string, 0) - result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(*url), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) + result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(*testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) assert.NotNil(t, result.Error()) } func TestTokenFilter_InvokeNotEqual(t *testing.T) { filter := GetTokenFilter() - url := common.NewURLWithOptions( + testUrl := common.NewURLWithOptions( common.WithParams(url.Values{}), common.WithParamsValue(constant.TOKEN_KEY, "ori_key")) attch := make(map[string]string, 0) attch[constant.TOKEN_KEY] = "err_key" result := filter.Invoke(context.Background(), - protocol.NewBaseInvoker(*url), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) + protocol.NewBaseInvoker(*testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch)) assert.NotNil(t, result.Error()) } diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index 1f4cc0068e..f57d89d1a7 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -143,7 +143,7 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) { // OnCron ... func (h *RpcClientHandler) OnCron(session getty.Session) { - rpcSession, err := h.conn.getClientRpcSession(session) + clientRpcSession, err := h.conn.getClientRpcSession(session) if err != nil { logger.Errorf("client.getClientSession(session{%s}) = error{%v}", session.Stat(), perrors.WithStack(err)) @@ -151,7 +151,7 @@ func (h *RpcClientHandler) OnCron(session getty.Session) { } if h.conn.pool.rpcClient.conf.sessionTimeout.Nanoseconds() < time.Since(session.GetActive()).Nanoseconds() { logger.Warnf("session{%s} timeout{%s}, reqNum{%d}", - session.Stat(), time.Since(session.GetActive()).String(), rpcSession.reqNum) + session.Stat(), time.Since(session.GetActive()).String(), clientRpcSession.reqNum) h.conn.removeSession(session) // -> h.conn.close() -> h.conn.pool.remove(h.conn) return } diff --git a/protocol/dubbo/pool.go b/protocol/dubbo/pool.go index 918514c267..f0bd09ba7c 100644 --- a/protocol/dubbo/pool.go +++ b/protocol/dubbo/pool.go @@ -219,25 +219,25 @@ func (c *gettyRPCClient) updateSession(session getty.Session) { func (c *gettyRPCClient) getClientRpcSession(session getty.Session) (rpcSession, error) { var ( - err error - rpcSession rpcSession + err error + rpcClientSession rpcSession ) c.lock.RLock() defer c.lock.RUnlock() if c.sessions == nil { - return rpcSession, errClientClosed + return rpcClientSession, errClientClosed } err = errSessionNotExist for _, s := range c.sessions { if s.session == session { - rpcSession = *s + rpcClientSession = *s err = nil break } } - return rpcSession, perrors.WithStack(err) + return rpcClientSession, perrors.WithStack(err) } func (c *gettyRPCClient) isAvailable() bool { @@ -319,7 +319,8 @@ func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPC conn, err := p.get() if err == nil && conn == nil { // create new conn - rpcClientConn, err := newGettyRPCClientConn(p, protocol, addr) + var rpcClientConn *gettyRPCClient + rpcClientConn, err = newGettyRPCClientConn(p, protocol, addr) return rpcClientConn, perrors.WithStack(err) } return conn, perrors.WithStack(err) diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index ba7197dbc8..70b3abd24f 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -172,7 +172,7 @@ func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte) httpReq.Close = true reqBuf := bytes.NewBuffer(make([]byte, 0)) - if err := httpReq.Write(reqBuf); err != nil { + if err = httpReq.Write(reqBuf); err != nil { return nil, perrors.WithStack(err) } @@ -191,7 +191,7 @@ func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte) } setNetConnTimeout(tcpConn, c.options.HTTPTimeout) - if _, err := reqBuf.WriteTo(tcpConn); err != nil { + if _, err = reqBuf.WriteTo(tcpConn); err != nil { return nil, perrors.WithStack(err) } diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go index d1c2a858b4..3176e19381 100644 --- a/protocol/jsonrpc/json.go +++ b/protocol/jsonrpc/json.go @@ -67,8 +67,8 @@ type Error struct { func (e *Error) Error() string { buf, err := json.Marshal(e) if err != nil { - msg, err := json.Marshal(err.Error()) - if err != nil { + msg, retryErr := json.Marshal(err.Error()) + if retryErr != nil { msg = []byte("jsonrpc2.Error: json.Marshal failed") } return fmt.Sprintf(`{"code":%d,"message":%s}`, -32001, string(msg)) @@ -133,7 +133,7 @@ func (c *jsonClientCodec) Write(d *CodecData) ([]byte, error) { } case reflect.Array, reflect.Struct: case reflect.Ptr: - switch k := reflect.TypeOf(param).Elem().Kind(); k { + switch ptrK := reflect.TypeOf(param).Elem().Kind(); ptrK { case reflect.Map: if reflect.TypeOf(param).Elem().Key().Kind() == reflect.String { if reflect.ValueOf(param).Elem().IsNil() { @@ -146,7 +146,7 @@ func (c *jsonClientCodec) Write(d *CodecData) ([]byte, error) { } case reflect.Array, reflect.Struct: default: - return nil, perrors.New("unsupported param type: Ptr to " + k.String()) + return nil, perrors.New("unsupported param type: Ptr to " + ptrK.String()) } default: return nil, perrors.New("unsupported param type: " + k.String()) diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index bed7099ab6..64f708652d 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -109,8 +109,8 @@ func (jp *JsonrpcProtocol) Destroy() { func (jp *JsonrpcProtocol) openServer(url common.URL) { _, ok := jp.serverMap[url.Location] if !ok { - _, ok := jp.ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) - if !ok { + _, loadOk := jp.ExporterMap().Load(strings.TrimPrefix(url.Path, "/")) + if !loadOk { panic("[JsonrpcProtocol]" + url.Key() + "is not existing") } diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 8600f02dad..fcea66632e 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -349,9 +349,9 @@ func serveRequest(ctx context.Context, constant.PATH_KEY: path, constant.VERSION_KEY: codec.req.Version})) if err := result.Error(); err != nil { - rspStream, err := codec.Write(err.Error(), invalidRequest) - if err != nil { - return perrors.WithStack(err) + rspStream, codecErr := codec.Write(err.Error(), invalidRequest) + if codecErr != nil { + return perrors.WithStack(codecErr) } if errRsp := sendErrorResp(header, rspStream); errRsp != nil { logger.Warnf("Exporter: sendErrorResp(header:%#v, error:%v) = error:%s", diff --git a/registry/consul/listener.go b/registry/consul/listener.go index b047a4c08c..5fac9ec0f9 100644 --- a/registry/consul/listener.go +++ b/registry/consul/listener.go @@ -142,7 +142,6 @@ func (l *consulListener) run() { func (l *consulListener) handler(idx uint64, raw interface{}) { var ( service *consul.ServiceEntry - event *registry.ServiceEvent url common.URL ok bool err error @@ -183,7 +182,7 @@ func (l *consulListener) handler(idx uint64, raw interface{}) { } l.urls = newUrls - for _, event = range events { + for _, event := range events { l.eventCh <- event } } diff --git a/registry/kubernetes/listener_test.go b/registry/kubernetes/listener_test.go index c50b5b670a..1c9d8bdd5e 100644 --- a/registry/kubernetes/listener_test.go +++ b/registry/kubernetes/listener_test.go @@ -191,7 +191,6 @@ type KubernetesRegistryTestSuite struct { } func (s *KubernetesRegistryTestSuite) initRegistry() *kubernetesRegistry { - t := s.T() regurl, err := common.NewURL("registry://127.0.0.1:443", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER))) @@ -204,7 +203,7 @@ func (s *KubernetesRegistryTestSuite) initRegistry() *kubernetesRegistry { out := fake.NewSimpleClientset() // mock current pod - if _, err := out.CoreV1().Pods(s.currentPod.GetNamespace()).Create(&s.currentPod); err != nil { + if _, err = out.CoreV1().Pods(s.currentPod.GetNamespace()).Create(&s.currentPod); err != nil { t.Fatal(err) } return out, nil diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go index ea6d7663a9..3360532f1f 100644 --- a/registry/kubernetes/registry_test.go +++ b/registry/kubernetes/registry_test.go @@ -68,7 +68,7 @@ func (s *KubernetesRegistryTestSuite) TestSubscribe() { time.Sleep(1e9) go func() { - err := r.Register(url) + err = r.Register(url) if err != nil { t.Fatal(err) } diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go index 7475b455c0..d0311b200b 100644 --- a/registry/nacos/registry_test.go +++ b/registry/nacos/registry_test.go @@ -42,7 +42,7 @@ func TestNacosRegistry_Register(t *testing.T) { urlMap.Set(constant.INTERFACE_KEY, "com.ikurento.user.UserProvider") urlMap.Set(constant.VERSION_KEY, "1.0.0") urlMap.Set(constant.CLUSTER_KEY, "mock") - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + testUrl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) reg, err := newNacosRegistry(®url) assert.Nil(t, err) @@ -50,7 +50,7 @@ func TestNacosRegistry_Register(t *testing.T) { t.Errorf("new nacos registry error:%s \n", err.Error()) return } - err = reg.Register(url) + err = reg.Register(testUrl) assert.Nil(t, err) if err != nil { t.Errorf("register error:%s \n", err.Error()) @@ -72,10 +72,10 @@ func TestNacosRegistry_Subscribe(t *testing.T) { urlMap.Set(constant.VERSION_KEY, "1.0.0") urlMap.Set(constant.CLUSTER_KEY, "mock") urlMap.Set(constant.NACOS_PATH_KEY, "") - url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) + testUrl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"})) reg, _ := newNacosRegistry(®url) - err := reg.Register(url) + err := reg.Register(testUrl) assert.Nil(t, err) if err != nil { t.Errorf("new nacos registry error:%s \n", err.Error()) @@ -84,7 +84,7 @@ func TestNacosRegistry_Subscribe(t *testing.T) { regurl.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)) reg2, _ := newNacosRegistry(®url) - listener, err := reg2.(*nacosRegistry).subscribe(&url) + listener, err := reg2.(*nacosRegistry).subscribe(&testUrl) assert.Nil(t, err) if err != nil { t.Errorf("subscribe error:%s \n", err.Error()) diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index bd1da54776..92ea76046f 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -87,8 +87,6 @@ func StateToString(state zk.State) string { default: return state.String() } - - return "zookeeper unknown state" } // Options ... @@ -111,12 +109,10 @@ func WithZkName(name string) Option { // ValidateZookeeperClient ... func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { - var ( - err error - ) - opions := &Options{} + var err error + options := &Options{} for _, opt := range opts { - opt(opions) + opt(options) } connected := false err = nil @@ -129,17 +125,18 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { if container.ZkClient() == nil { //in dubbo ,every registry only connect one node ,so this is []string{r.Address} - timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + var timeout time.Duration + 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 perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.Location) } zkAddresses := strings.Split(url.Location, ",") - newClient, err := newZookeeperClient(opions.zkName, zkAddresses, timeout) + newClient, err := newZookeeperClient(options.zkName, zkAddresses, timeout) if err != nil { logger.Warnf("newZookeeperClient(name{%s}, zk address{%v}, timeout{%d}) = error{%v}", - opions.zkName, url.Location, timeout.String(), err) + options.zkName, url.Location, timeout.String(), err) return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.Location) } container.SetZkClient(newClient) @@ -157,7 +154,7 @@ func ValidateZookeeperClient(container zkClientFacade, opts ...Option) error { } if connected { - logger.Info("Connect to zookeeper successfully, name{%s}, zk address{%v}", opions.zkName, url.Location) + logger.Info("Connect to zookeeper successfully, name{%s}, zk address{%v}", options.zkName, url.Location) container.WaitGroup().Add(1) //zk client start successful, then registry wg +1 } diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go index 8487766776..b3f6e29bf8 100644 --- a/remoting/zookeeper/listener.go +++ b/remoting/zookeeper/listener.go @@ -18,7 +18,6 @@ package zookeeper import ( - "github.com/apache/dubbo-go/common" "path" "strings" "sync" @@ -32,6 +31,7 @@ import ( ) import ( + "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/remoting" @@ -96,8 +96,6 @@ func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remo return false } } - - return false } func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, listener remoting.DataListener) { From 6f326a50421dfb087af64092d6dbe80864dbe4bd Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Thu, 21 May 2020 12:46:38 +0800 Subject: [PATCH 148/167] Add comments for common directory --- common/config/environment.go | 21 +++--- common/extension/cluster.go | 5 +- common/extension/config_center.go | 4 +- common/extension/config_center_factory.go | 4 +- common/extension/configurator.go | 12 ++-- common/extension/filter.go | 9 +-- common/extension/graceful_shutdown.go | 2 +- common/extension/loadbalance.go | 5 +- common/extension/metadata_report_factory.go | 4 +- common/extension/protocol.go | 4 +- common/extension/proxy_factory.go | 4 +- common/extension/registry.go | 4 +- common/extension/registry_directory.go | 4 +- common/extension/rest_client.go | 2 + common/extension/rest_server.go | 2 + common/extension/tps_limit.go | 9 +-- common/logger/logger.go | 18 ++--- common/logger/logging.go | 16 ++--- common/node.go | 2 +- common/proxy/proxy_factory.go | 2 +- common/rpc_service.go | 8 +-- common/url.go | 80 +++++++++++---------- 22 files changed, 116 insertions(+), 105 deletions(-) diff --git a/common/config/environment.go b/common/config/environment.go index 071af31152..793512cfbb 100644 --- a/common/config/environment.go +++ b/common/config/environment.go @@ -46,7 +46,7 @@ var ( once sync.Once ) -// GetEnvInstance ... +// GetEnvInstance get env instance by singleton func GetEnvInstance() *Environment { once.Do(func() { instance = &Environment{configCenterFirst: true} @@ -54,7 +54,7 @@ func GetEnvInstance() *Environment { return instance } -// NewEnvInstance ... +// NewEnvInstance creates Environment instance func NewEnvInstance() { instance = &Environment{configCenterFirst: true} } @@ -67,21 +67,22 @@ func NewEnvInstance() { // return env.configCenterFirst //} -// UpdateExternalConfigMap ... +// UpdateExternalConfigMap update env externalConfigMap field func (env *Environment) UpdateExternalConfigMap(externalMap map[string]string) { for k, v := range externalMap { env.externalConfigMap.Store(k, v) } } -// UpdateAppExternalConfigMap ... +// UpdateAppExternalConfigMap update env appExternalConfigMap field func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string) { for k, v := range externalMap { env.appExternalConfigMap.Store(k, v) } } -// Configuration ... +// List represents a doubly linked list. +// Configuration put externalConfigMap and appExternalConfigMap into list func (env *Environment) Configuration() *list.List { cfgList := list.New() // The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration @@ -90,17 +91,17 @@ func (env *Environment) Configuration() *list.List { return cfgList } -// SetDynamicConfiguration ... +// SetDynamicConfiguration use to set value for dynamicConfiguration func (env *Environment) SetDynamicConfiguration(dc config_center.DynamicConfiguration) { env.dynamicConfiguration = dc } -// GetDynamicConfiguration ... +// GetDynamicConfiguration use to get dynamicConfiguration func (env *Environment) GetDynamicConfiguration() config_center.DynamicConfiguration { return env.dynamicConfiguration } -// InmemoryConfiguration ... +// InmemoryConfiguration use to store config in memory type InmemoryConfiguration struct { store *sync.Map } @@ -109,7 +110,7 @@ func newInmemoryConfiguration(p *sync.Map) *InmemoryConfiguration { return &InmemoryConfiguration{store: p} } -// GetProperty ... +// GetProperty use the key to get value from InmemoryConfiguration instance func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) { if conf.store == nil { return false, "" @@ -123,7 +124,7 @@ func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) { return false, "" } -// GetSubProperty ... +// GetSubProperty use the subkey to get sub property from InmemoryConfiguration instance func (conf *InmemoryConfiguration) GetSubProperty(subKey string) map[string]struct{} { if conf.store == nil { return nil diff --git a/common/extension/cluster.go b/common/extension/cluster.go index b2d81f6b1e..0e7c537cd3 100644 --- a/common/extension/cluster.go +++ b/common/extension/cluster.go @@ -25,12 +25,13 @@ var ( clusters = make(map[string]func() cluster.Cluster) ) -// SetCluster ... +// SetCluster set the cluster fault-tolerant mode with name +// For example: available/failfast/broadcast/failfast/failsafe/... func SetCluster(name string, fcn func() cluster.Cluster) { clusters[name] = fcn } -// GetCluster ... +// GetCluster find the cluster fault-tolerant mode with name func GetCluster(name string) cluster.Cluster { if clusters[name] == nil { panic("cluster for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/config_center.go b/common/extension/config_center.go index 03d27db46c..b18f0f9522 100644 --- a/common/extension/config_center.go +++ b/common/extension/config_center.go @@ -26,12 +26,12 @@ var ( configCenters = make(map[string]func(config *common.URL) (config_center.DynamicConfiguration, error)) ) -// SetConfigCenter ... +// SetConfigCenter set the DynamicConfiguration with name func SetConfigCenter(name string, v func(config *common.URL) (config_center.DynamicConfiguration, error)) { configCenters[name] = v } -// GetConfigCenter ... +// GetConfigCenter find the DynamicConfiguration with name func GetConfigCenter(name string, config *common.URL) (config_center.DynamicConfiguration, error) { if configCenters[name] == nil { panic("config center for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/config_center_factory.go b/common/extension/config_center_factory.go index 85913fdce1..67ecf0fe5c 100644 --- a/common/extension/config_center_factory.go +++ b/common/extension/config_center_factory.go @@ -25,12 +25,12 @@ var ( configCenterFactories = make(map[string]func() config_center.DynamicConfigurationFactory) ) -// SetConfigCenterFactory ... +// SetConfigCenterFactory set the DynamicConfigurationFactory with name func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigurationFactory) { configCenterFactories[name] = v } -// GetConfigCenterFactory ... +// GetConfigCenterFactory find 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.") diff --git a/common/extension/configurator.go b/common/extension/configurator.go index de98f8a260..d24863ae84 100644 --- a/common/extension/configurator.go +++ b/common/extension/configurator.go @@ -23,7 +23,7 @@ import ( ) const ( - // DefaultKey ... + // DefaultKey for default Configurator DefaultKey = "default" ) @@ -33,12 +33,12 @@ var ( configurator = make(map[string]getConfiguratorFunc) ) -// SetConfigurator ... +// SetConfigurator set the getConfiguratorFunc with name func SetConfigurator(name string, v getConfiguratorFunc) { configurator[name] = v } -// GetConfigurator ... +// GetConfigurator find the Configurator with name func GetConfigurator(name string, url *common.URL) config_center.Configurator { if configurator[name] == nil { panic("configurator for " + name + " is not existing, make sure you have import the package.") @@ -47,12 +47,12 @@ func GetConfigurator(name string, url *common.URL) config_center.Configurator { } -// SetDefaultConfigurator ... +// SetDefaultConfigurator set the default Configurator func SetDefaultConfigurator(v getConfiguratorFunc) { configurator[DefaultKey] = v } -// GetDefaultConfigurator ... +// GetDefaultConfigurator get default configurator func GetDefaultConfigurator(url *common.URL) config_center.Configurator { if configurator[DefaultKey] == nil { panic("configurator for default is not existing, make sure you have import the package.") @@ -61,7 +61,7 @@ func GetDefaultConfigurator(url *common.URL) config_center.Configurator { } -// GetDefaultConfiguratorFunc ... +// GetDefaultConfiguratorFunc default configurator function func GetDefaultConfiguratorFunc() getConfiguratorFunc { if configurator[DefaultKey] == nil { panic("configurator for default is not existing, make sure you have import the package.") diff --git a/common/extension/filter.go b/common/extension/filter.go index deea2d908b..849aa1ba7b 100644 --- a/common/extension/filter.go +++ b/common/extension/filter.go @@ -26,12 +26,13 @@ var ( rejectedExecutionHandler = make(map[string]func() filter.RejectedExecutionHandler) ) -// SetFilter ... +// SetFilter set the filter extension with name +// For example: hystrix/metrics/token/tracing/limit/... func SetFilter(name string, v func() filter.Filter) { filters[name] = v } -// GetFilter ... +// GetFilter find the filter extension with name func GetFilter(name string) filter.Filter { if filters[name] == nil { panic("filter for " + name + " is not existing, make sure you have imported the package.") @@ -39,12 +40,12 @@ func GetFilter(name string) filter.Filter { return filters[name]() } -// SetRejectedExecutionHandler ... +// SetRejectedExecutionHandler set the RejectedExecutionHandler with name func SetRejectedExecutionHandler(name string, creator func() filter.RejectedExecutionHandler) { rejectedExecutionHandler[name] = creator } -// GetRejectedExecutionHandler ... +// GetRejectedExecutionHandler find the RejectedExecutionHandler with name func GetRejectedExecutionHandler(name string) filter.RejectedExecutionHandler { creator, ok := rejectedExecutionHandler[name] if !ok { diff --git a/common/extension/graceful_shutdown.go b/common/extension/graceful_shutdown.go index 3abd75c0aa..04f0146595 100644 --- a/common/extension/graceful_shutdown.go +++ b/common/extension/graceful_shutdown.go @@ -49,7 +49,7 @@ func AddCustomShutdownCallback(callback func()) { customShutdownCallbacks.PushBack(callback) } -// GetAllCustomShutdownCallbacks ... +// GetAllCustomShutdownCallbacks get all custom shutdown callbacks func GetAllCustomShutdownCallbacks() *list.List { return customShutdownCallbacks } diff --git a/common/extension/loadbalance.go b/common/extension/loadbalance.go index 0d557a4640..2d6380750d 100644 --- a/common/extension/loadbalance.go +++ b/common/extension/loadbalance.go @@ -25,12 +25,13 @@ var ( loadbalances = make(map[string]func() cluster.LoadBalance) ) -// SetLoadbalance ... +// SetLoadbalance set the loadbalance extension with name +// For example: random/round_robin/consistent_hash/least_active/... func SetLoadbalance(name string, fcn func() cluster.LoadBalance) { loadbalances[name] = fcn } -// GetLoadbalance ... +// GetLoadbalance find the loadbalance extension with name func GetLoadbalance(name string) cluster.LoadBalance { if loadbalances[name] == nil { panic("loadbalance for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/metadata_report_factory.go b/common/extension/metadata_report_factory.go index 0ae0793bb4..715c2c701f 100644 --- a/common/extension/metadata_report_factory.go +++ b/common/extension/metadata_report_factory.go @@ -25,12 +25,12 @@ var ( metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory, 8) ) -// SetMetadataReportFactory ... +// SetMetadataReportFactory set the MetadataReportFactory with name func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFactory) { metaDataReportFactories[name] = v } -// GetMetadataReportFactory ... +// GetMetadataReportFactory find the MetadataReportFactory with name func GetMetadataReportFactory(name string) metadata.MetadataReportFactory { if metaDataReportFactories[name] == nil { panic("metadata report for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/protocol.go b/common/extension/protocol.go index 009687a17a..34e659aca3 100644 --- a/common/extension/protocol.go +++ b/common/extension/protocol.go @@ -25,12 +25,12 @@ var ( protocols = make(map[string]func() protocol.Protocol) ) -// SetProtocol ... +// SetProtocol set the protocol extension with name func SetProtocol(name string, v func() protocol.Protocol) { protocols[name] = v } -// GetProtocol ... +// GetProtocol find the protocol extension with name func GetProtocol(name string) protocol.Protocol { if protocols[name] == nil { panic("protocol for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go index 19826bb056..6006dd5d97 100644 --- a/common/extension/proxy_factory.go +++ b/common/extension/proxy_factory.go @@ -25,12 +25,12 @@ var ( proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory) ) -// SetProxyFactory ... +// SetProxyFactory set the ProxyFactory extension with name func SetProxyFactory(name string, f func(...proxy.Option) proxy.ProxyFactory) { proxyFactories[name] = f } -// GetProxyFactory ... +// GetProxyFactory find the ProxyFactory extension with name func GetProxyFactory(name string) proxy.ProxyFactory { if name == "" { name = "default" diff --git a/common/extension/registry.go b/common/extension/registry.go index 6ba746dc47..c94f913f25 100644 --- a/common/extension/registry.go +++ b/common/extension/registry.go @@ -26,12 +26,12 @@ var ( registrys = make(map[string]func(config *common.URL) (registry.Registry, error)) ) -// SetRegistry ... +// SetRegistry set the registry extension with name func SetRegistry(name string, v func(config *common.URL) (registry.Registry, error)) { registrys[name] = v } -// GetRegistry ... +// GetRegistry find the registry extension with name func GetRegistry(name string, config *common.URL) (registry.Registry, error) { if registrys[name] == nil { panic("registry 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 6b92189c4e..86155f9117 100644 --- a/common/extension/registry_directory.go +++ b/common/extension/registry_directory.go @@ -27,12 +27,12 @@ type registryDirectory func(url *common.URL, registry registry.Registry) (cluste var defaultRegistry registryDirectory -// SetDefaultRegistryDirectory ... +// SetDefaultRegistryDirectory set the default registryDirectory func SetDefaultRegistryDirectory(v registryDirectory) { defaultRegistry = v } -// GetDefaultRegistryDirectory ... +// GetDefaultRegistryDirectory find the registryDirectory with url and registry func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (cluster.Directory, error) { if defaultRegistry == nil { panic("registry directory is not existing, make sure you have import the package.") diff --git a/common/extension/rest_client.go b/common/extension/rest_client.go index 514d1fdfd2..e2b9918683 100644 --- a/common/extension/rest_client.go +++ b/common/extension/rest_client.go @@ -25,10 +25,12 @@ var ( restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8) ) +// SetRestClient set the RestClient with name func SetRestClient(name string, fun func(restOptions *client.RestOptions) client.RestClient) { restClients[name] = fun } +// GetNewRestClient find the RestClient with name func GetNewRestClient(name string, restOptions *client.RestOptions) client.RestClient { if restClients[name] == nil { panic("restClient for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/rest_server.go b/common/extension/rest_server.go index fa8d435a5c..2ad661a9fe 100644 --- a/common/extension/rest_server.go +++ b/common/extension/rest_server.go @@ -25,10 +25,12 @@ var ( restServers = make(map[string]func() server.RestServer, 8) ) +// SetRestServer set the RestServer with name func SetRestServer(name string, fun func() server.RestServer) { restServers[name] = fun } +// GetNewRestServer find the RestServer with name func GetNewRestServer(name string) server.RestServer { if restServers[name] == nil { panic("restServer for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/tps_limit.go b/common/extension/tps_limit.go index c72c2b030f..dd2ccf9775 100644 --- a/common/extension/tps_limit.go +++ b/common/extension/tps_limit.go @@ -26,12 +26,13 @@ var ( tpsLimiter = make(map[string]func() filter.TpsLimiter) ) -// SetTpsLimiter ... + +// SetTpsLimiter set the TpsLimiter with name func SetTpsLimiter(name string, creator func() filter.TpsLimiter) { tpsLimiter[name] = creator } -// GetTpsLimiter ... +// GetTpsLimiter find the TpsLimiter with name func GetTpsLimiter(name string) filter.TpsLimiter { creator, ok := tpsLimiter[name] if !ok { @@ -41,12 +42,12 @@ func GetTpsLimiter(name string) filter.TpsLimiter { return creator() } -// SetTpsLimitStrategy ... +// SetTpsLimitStrategy set the TpsLimitStrategyCreator with name func SetTpsLimitStrategy(name string, creator filter.TpsLimitStrategyCreator) { tpsLimitStrategy[name] = creator } -// GetTpsLimitStrategyCreator ... +// GetTpsLimitStrategyCreator find the TpsLimitStrategyCreator with name func GetTpsLimitStrategyCreator(name string) filter.TpsLimitStrategyCreator { creator, ok := tpsLimitStrategy[name] if !ok { diff --git a/common/logger/logger.go b/common/logger/logger.go index 016afe6980..7510b1eb8f 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -40,13 +40,13 @@ var ( logger Logger ) -// DubboLogger ... +// DubboLogger type DubboLogger struct { Logger dynamicLevel zap.AtomicLevel } -// Logger ... +// Logger is the interface for Logger types type Logger interface { Info(args ...interface{}) Warn(args ...interface{}) @@ -67,7 +67,7 @@ func init() { } } -// InitLog ... +// InitLog used to init logger by call InitLogger func InitLog(logConfFile string) error { if logConfFile == "" { InitLogger(nil) @@ -96,7 +96,7 @@ func InitLog(logConfFile string) error { return nil } -// InitLogger ... +// InitLogger used to init logger by conf func InitLogger(conf *zap.Config) { var zapLoggerConfig zap.Config if conf == nil { @@ -125,18 +125,18 @@ func InitLogger(conf *zap.Config) { getty.SetLogger(logger) } -// SetLogger ... +// SetLogger sets logger for dubbo and getty func SetLogger(log Logger) { logger = log getty.SetLogger(logger) } -// GetLogger ... +// GetLogger gets the logger func GetLogger() Logger { return logger } -// SetLoggerLevel ... +// SetLoggerLevel used to set logger level func SetLoggerLevel(level string) bool { if l, ok := logger.(OpsLogger); ok { l.SetLoggerLevel(level) @@ -145,13 +145,13 @@ func SetLoggerLevel(level string) bool { return false } -// OpsLogger ... +// OpsLogger used by the SetLoggerLevel type OpsLogger interface { Logger SetLoggerLevel(level string) } -// SetLoggerLevel ... +// SetLoggerLevel used to set logger level func (dl *DubboLogger) SetLoggerLevel(level string) { l := new(zapcore.Level) l.Set(level) diff --git a/common/logger/logging.go b/common/logger/logging.go index 36d48ee61e..7a31ece203 100644 --- a/common/logger/logging.go +++ b/common/logger/logging.go @@ -17,42 +17,42 @@ package logger -// Info ... +// Info is info level func Info(args ...interface{}) { logger.Info(args...) } -// Warn ... +// Warn is warning level func Warn(args ...interface{}) { logger.Warn(args...) } -// Error ... +// Error is error level func Error(args ...interface{}) { logger.Error(args...) } -// Debug ... +// Debug is debug level func Debug(args ...interface{}) { logger.Debug(args...) } -// Infof ... +// Infof is format info level func Infof(fmt string, args ...interface{}) { logger.Infof(fmt, args...) } -// Warnf ... +// Warnf is format warning level func Warnf(fmt string, args ...interface{}) { logger.Warnf(fmt, args...) } -// Errorf ... +// Errorf is format error level func Errorf(fmt string, args ...interface{}) { logger.Errorf(fmt, args...) } -// Debugf ... +// Debugf is format debug level func Debugf(fmt string, args ...interface{}) { logger.Debugf(fmt, args...) } diff --git a/common/node.go b/common/node.go index 979eee31ef..f812d1bcce 100644 --- a/common/node.go +++ b/common/node.go @@ -17,7 +17,7 @@ package common -// Node ... +// Node is used to process dubbo node type Node interface { GetUrl() URL IsAvailable() bool diff --git a/common/proxy/proxy_factory.go b/common/proxy/proxy_factory.go index 34fa3fd07e..117428cb25 100644 --- a/common/proxy/proxy_factory.go +++ b/common/proxy/proxy_factory.go @@ -29,5 +29,5 @@ type ProxyFactory interface { GetInvoker(url common.URL) protocol.Invoker } -// Option ... +// Option will define a function of handling ProxyFactory type Option func(ProxyFactory) diff --git a/common/rpc_service.go b/common/rpc_service.go index d7d900718e..232f2120a9 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -35,23 +35,23 @@ import ( ) // RPCService -//rpc service interface +// rpc service interface type RPCService interface { // Reference: // rpc service id or reference id Reference() string } -//AsyncCallbackService callback interface for async +// AsyncCallbackService callback interface for async type AsyncCallbackService interface { // Callback: callback CallBack(response CallbackResponse) } -//CallbackResponse for different protocol +// CallbackResponse for different protocol type CallbackResponse interface{} -//AsyncCallback async callback method +// AsyncCallback async callback method type AsyncCallback func(response CallbackResponse) // for lowercase func diff --git a/common/url.go b/common/url.go index a70ac7dc9d..ae8a63d995 100644 --- a/common/url.go +++ b/common/url.go @@ -46,31 +46,31 @@ import ( // role constant const ( - // CONSUMER ... + // CONSUMER is consumer role CONSUMER = iota - // CONFIGURATOR ... + // CONFIGURATOR is configurator role CONFIGURATOR - // ROUTER ... + // ROUTER is router role ROUTER - // PROVIDER ... + // PROVIDER is provider role PROVIDER ) var ( - // DubboNodes ... + // DubboNodes Dubbo service node DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"} // DubboRole Dubbo service role DubboRole = [...]string{"consumer", "", "routers", "provider"} ) -// RoleType ... +// RoleType type RoleType int func (t RoleType) String() string { return DubboNodes[t] } -// Role ... +// Role returns role func (t RoleType) Role() string { return DubboRole[t] } @@ -86,7 +86,7 @@ type baseUrl struct { PrimitiveURL string } -// URL ... +// URL is used to locate resourse to transfer data between nodes type URL struct { baseUrl Path string // like /com.ikurento.dubbo.UserProvider3 @@ -97,79 +97,81 @@ type URL struct { SubURL *URL } +// Option accepts url +// Option will define a function of handling URL type option func(*URL) -// WithUsername ... +// WithUsername set username for url func WithUsername(username string) option { return func(url *URL) { url.Username = username } } -// WithPassword ... +// WithPassword set password for url func WithPassword(pwd string) option { return func(url *URL) { url.Password = pwd } } -// WithMethods ... +// WithMethods set methods for url func WithMethods(methods []string) option { return func(url *URL) { url.Methods = methods } } -// WithParams ... +// WithParams set params for url func WithParams(params url.Values) option { return func(url *URL) { url.params = params } } -// WithParamsValue ... +// WithParamsValue set params field for url func WithParamsValue(key, val string) option { return func(url *URL) { url.SetParam(key, val) } } -// WithProtocol ... +// WithProtocol set protocol for url func WithProtocol(proto string) option { return func(url *URL) { url.Protocol = proto } } -// WithIp ... +// WithIp set ip for url func WithIp(ip string) option { return func(url *URL) { url.Ip = ip } } -// WithPort ... +// WithPort set port for url func WithPort(port string) option { return func(url *URL) { url.Port = port } } -// WithPath ... +// WithPath set path for url func WithPath(path string) option { return func(url *URL) { url.Path = "/" + strings.TrimPrefix(path, "/") } } -// WithLocation ... +// WithLocation set location for url func WithLocation(location string) option { return func(url *URL) { url.Location = location } } -// WithToken ... +// WithToken set token for url func WithToken(token string) option { return func(url *URL) { if len(token) > 0 { @@ -182,7 +184,7 @@ func WithToken(token string) option { } } -// NewURLWithOptions ... +// NewURLWithOptions will create a new url with options func NewURLWithOptions(opts ...option) *URL { url := &URL{} for _, opt := range opts { @@ -362,13 +364,13 @@ func (c *URL) ColonSeparatedKey() string { return buf.String() } -// EncodedServiceKey ... +// EncodedServiceKey is used to encode service key func (c *URL) EncodedServiceKey() string { serviceKey := c.ServiceKey() return strings.Replace(serviceKey, "/", "*", 1) } -// Service ... +// Service is used to get service func (c URL) Service() string { service := c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/")) if service != "" { @@ -382,21 +384,21 @@ func (c URL) Service() string { return "" } -// AddParam ... +// AddParam is used to add value for key func (c *URL) AddParam(key string, value string) { c.paramsLock.Lock() c.params.Add(key, value) c.paramsLock.Unlock() } -// SetParam ... +// SetParam is used to set key and value func (c *URL) SetParam(key string, value string) { c.paramsLock.Lock() c.params.Set(key, value) c.paramsLock.Unlock() } -// RangeParams ... +// RangeParams is used to range params func (c *URL) RangeParams(f func(key, value string) bool) { c.paramsLock.RLock() defer c.paramsLock.RUnlock() @@ -407,7 +409,7 @@ func (c *URL) RangeParams(f func(key, value string) bool) { } } -// GetParam ... +// GetParam is used to get value by key func (c URL) GetParam(s string, d string) string { c.paramsLock.RLock() defer c.paramsLock.RUnlock() @@ -418,12 +420,12 @@ func (c URL) GetParam(s string, d string) string { return r } -// GetParams ... +// GetParams is used to get values func (c URL) GetParams() url.Values { return c.params } -// GetParamAndDecoded ... +// GetParamAndDecoded is used to get values and decode func (c URL) GetParamAndDecoded(key string) (string, error) { c.paramsLock.RLock() defer c.paramsLock.RUnlock() @@ -432,7 +434,7 @@ func (c URL) GetParamAndDecoded(key string) (string, error) { return value, err } -// GetRawParam ... +// GetRawParam is used to get raw param func (c URL) GetRawParam(key string) string { switch key { case "protocol": @@ -452,7 +454,7 @@ func (c URL) GetRawParam(key string) string { } } -// GetParamBool ... +// GetParamBool is used to judge whether key exists or not func (c URL) GetParamBool(s string, d bool) bool { r, err := strconv.ParseBool(c.GetParam(s, "")) if err != nil { @@ -461,7 +463,7 @@ func (c URL) GetParamBool(s string, d bool) bool { return r } -// GetParamInt ... +// GetParamInt is used to get int value by key func (c URL) GetParamInt(s string, d int64) int64 { r, err := strconv.Atoi(c.GetParam(s, "")) if r == 0 || err != nil { @@ -470,7 +472,7 @@ func (c URL) GetParamInt(s string, d int64) int64 { return int64(r) } -// GetMethodParamInt ... +// GetMethodParamInt is used to get int method param func (c URL) GetMethodParamInt(method string, key string, d int64) int64 { r, err := strconv.Atoi(c.GetParam("methods."+method+"."+key, "")) if r == 0 || err != nil { @@ -479,7 +481,7 @@ func (c URL) GetMethodParamInt(method string, key string, d int64) int64 { return int64(r) } -// GetMethodParamInt64 ... +// GetMethodParamInt64 is used to get int64 method param func (c URL) GetMethodParamInt64(method string, key string, d int64) int64 { r := c.GetMethodParamInt(method, key, math.MinInt64) if r == math.MinInt64 { @@ -488,7 +490,7 @@ func (c URL) GetMethodParamInt64(method string, key string, d int64) int64 { return r } -// GetMethodParam ... +// GetMethodParam is used to get method param func (c URL) GetMethodParam(method string, key string, d string) string { r := c.GetParam("methods."+method+"."+key, "") if r == "" { @@ -497,13 +499,13 @@ func (c URL) GetMethodParam(method string, key string, d string) string { return r } -// GetMethodParamBool ... +// GetMethodParamBool is used to judge whether method param exists or not func (c URL) GetMethodParamBool(method string, key string, d bool) bool { r := c.GetParamBool("methods."+method+"."+key, d) return r } -// RemoveParams ... +// RemoveParams is used to remove params func (c *URL) RemoveParams(set *gxset.HashSet) { c.paramsLock.Lock() defer c.paramsLock.Unlock() @@ -513,7 +515,7 @@ func (c *URL) RemoveParams(set *gxset.HashSet) { } } -// SetParams ... +// SetParams is used to set params func (c *URL) SetParams(m url.Values) { for k := range m { c.SetParam(k, m.Get(k)) @@ -564,7 +566,7 @@ func (c URL) ToMap() map[string]string { // in this function we should merge the reference local url config into the service url from registry. //TODO configuration merge, in the future , the configuration center's config should merge too. -// MergeUrl ... +// MergeUrl is used to merge url func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL { mergedUrl := serviceUrl.Clone() @@ -594,7 +596,7 @@ func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL { return mergedUrl } -// Clone ... +// Clone is used to clone a url func (c *URL) Clone() *URL { newUrl := &URL{} copier.Copy(newUrl, c) From 8ffc312461c1131aa716d9dd7eda44e472217e46 Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Thu, 21 May 2020 13:33:57 +0800 Subject: [PATCH 149/167] Opt: optimize url to string --- common/url.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/common/url.go b/common/url.go index a70ac7dc9d..fd233244bb 100644 --- a/common/url.go +++ b/common/url.go @@ -18,7 +18,6 @@ package common import ( - "bytes" "encoding/base64" "fmt" "math" @@ -292,20 +291,20 @@ func isMatchCategory(category1 string, category2 string) bool { } func (c URL) String() string { - var buildString string + var buf strings.Builder if len(c.Username) == 0 && len(c.Password) == 0 { - buildString = fmt.Sprintf( + buf.WriteString(fmt.Sprintf( "%s://%s:%s%s?", - c.Protocol, c.Ip, c.Port, c.Path) + c.Protocol, c.Ip, c.Port, c.Path)) } else { - buildString = fmt.Sprintf( + buf.WriteString(fmt.Sprintf( "%s://%s:%s@%s:%s%s?", - c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Path) + c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Path)) } c.paramsLock.RLock() - buildString += c.params.Encode() + buf.WriteString(c.params.Encode()) c.paramsLock.RUnlock() - return buildString + return buf.String() } // Key ... @@ -322,7 +321,7 @@ func (c URL) ServiceKey() string { if intf == "" { return "" } - buf := &bytes.Buffer{} + var buf strings.Builder group := c.GetParam(constant.GROUP_KEY, "") if group != "" { buf.WriteString(group) @@ -347,7 +346,7 @@ func (c *URL) ColonSeparatedKey() string { if intf == "" { return "" } - buf := &bytes.Buffer{} + var buf strings.Builder buf.WriteString(intf) buf.WriteString(":") version := c.GetParam(constant.VERSION_KEY, "") From 8822f2cc2a6b096f6dad67c24170521ad60fcedb Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Thu, 21 May 2020 13:40:11 +0800 Subject: [PATCH 150/167] fmt the codes --- common/extension/tps_limit.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/extension/tps_limit.go b/common/extension/tps_limit.go index dd2ccf9775..036debc335 100644 --- a/common/extension/tps_limit.go +++ b/common/extension/tps_limit.go @@ -26,7 +26,6 @@ var ( tpsLimiter = make(map[string]func() filter.TpsLimiter) ) - // SetTpsLimiter set the TpsLimiter with name func SetTpsLimiter(name string, creator func() filter.TpsLimiter) { tpsLimiter[name] = creator From 8581202c9aded24b821a49878eabe76711262fde Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 14:32:35 +0800 Subject: [PATCH 151/167] Fix ci bug --- .travis.yml | 17 +------------ integrate_test.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 integrate_test.sh diff --git a/.travis.yml b/.travis.yml index 7fb7420d8d..ee5f6a50cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,22 +26,7 @@ script: - chmod u+x before_ut.sh && ./before_ut.sh - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic # integrate-test - - echo 'start integrate-test' - # start zookeeper registry insecure listen in [:]:2181 - - docker run -d --network host zookeeper - - ROOTDIR=$(pwd) - - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR - - docker run -d --network host ci-provider - - docker run -it --network host ci-consumer - - # another registry instance, start it by dep - # start etcd registry insecure listen in [:]:2379 - #- docker run -d --network host k8s.gcr.io/etcd:3.3.10 etcd - # start consul registry insecure listen in [:]:8500 - #- docker run -d --network host consul - # start nacos registry insecure listen in [:]:8848 - #- docker run -d --network host nacos/nacos-server:latest + - chmod +x integrate_test.sh && ./integtrate_test.sh after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/integrate_test.sh b/integrate_test.sh new file mode 100644 index 0000000000..eacd9a58c0 --- /dev/null +++ b/integrate_test.sh @@ -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. + +#!/bin/bash + +# stop integrate test when command return !0 +set -e + +echo 'start integrate-test' + +# set root workspace +ROOT_DIR=$(pwd) + + +echo "integrate-test root work-space -> ${ROOT_DIR}" +echo "travis current commit id -> ${TRAVIS_COMMIT}" +echo "travis pull request -> ${TRAVIS_PULL_REQUEST}" +echo "travis pull request branch -> ${TRAVIS_PULL_REQUEST_BRANCH}" +echo "travis pull request slug -> ${TRAVIS_PULL_REQUEST_SLUG}" +echo "travis pull request sha -> ${TRAVIS_PULL_REQUEST_SHA}" +echo "travis pull request repo slug -> ${TRAVIS_REPO_SLUG}" + + +# #start etcd registry insecure listen in [:]:2379 +# docker run -d --network host k8s.gcr.io/etcd:3.3.10 etcd +# echo "etcdv3 listen in [:]2379" + +# #start consul registry insecure listen in [:]:8500 +# docker run -d --network host consul +# echo "consul listen in [:]8500" + +# #start nacos registry insecure listen in [:]:8848 +# docker run -d --network host nacos/nacos-server:latest +# echo "ncacos listen in [:]8848" + +# default use zk as registry +#start zookeeper registry insecure listen in [:]:2181 +docker run -d --network host zookeeper +echo "zookeeper listen in [:]2181" + +# fast fail +exit 1 + + +cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd ${ROOT_DIR} +cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd ${ROOT_DIR} +docker run -d --network host ci-provider +docker run -it --network host ci-consumer From f9368d501bf5d828549c3506ce3a5af34987b456 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 14:53:51 +0800 Subject: [PATCH 152/167] Add extra logic for Dockerfile --- integrate_test.sh | 27 ++++++++++++++++------- test/integrate/dubbo/go-client/Dockerfile | 4 ++-- test/integrate/dubbo/go-server/Dockerfile | 4 ++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/integrate_test.sh b/integrate_test.sh index eacd9a58c0..6480ffeeb2 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -51,11 +51,22 @@ echo "travis pull request repo slug -> ${TRAVIS_REPO_SLUG}" docker run -d --network host zookeeper echo "zookeeper listen in [:]2181" -# fast fail -exit 1 - - -cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd ${ROOT_DIR} -cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd ${ROOT_DIR} -docker run -d --network host ci-provider -docker run -it --network host ci-consumer +if [ ${TRAVIS_PULL_REQUEST_SLUG} ] +then + # this is a pull-request commit + # build go-client image + cd ./test/integrate/dubbo/go-client + docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} + cd ${ROOT_DIR} + # build go-server image + cd ./test/integrate/dubbo/go-server + docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} + cd ${ROOT_DIR} + # run provider + docker run -d --network host ci-provider + # check consumer status + docker run -it --network host ci-consumer +else + # this is merge pull-request to local-repo + echo '' +fi diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index 1c683613f5..dbe7608cc8 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -28,8 +28,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client # update dubbo-go to current commit id -RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" -RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} +RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index 05596980c3..5b4817e3c3 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -27,8 +27,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server # update dubbo-go to current commit id -RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" -RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} +RUN test ${PR_ORIGIN_REPO} && cho "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN test ${PR_ORIGIN_REPO} && o mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server From 01ba7495235686117c6b9ff145695064409d7d12 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 15:06:26 +0800 Subject: [PATCH 153/167] Fix shell script name --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee5f6a50cb..566c88ece0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ script: - chmod u+x before_ut.sh && ./before_ut.sh - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic # integrate-test - - chmod +x integrate_test.sh && ./integtrate_test.sh + - chmod +x integrate_test.sh && ./integrate_test.sh after_success: - bash <(curl -s https://codecov.io/bash) From b0a1a4e7dfd26e57e1521928817086fffe612fca Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 15:15:46 +0800 Subject: [PATCH 154/167] Fix Dockerfile BUG --- test/integrate/dubbo/go-server/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index 5b4817e3c3..d4708f5928 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -27,8 +27,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server # update dubbo-go to current commit id -RUN test ${PR_ORIGIN_REPO} && cho "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" -RUN test ${PR_ORIGIN_REPO} && o mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} +RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server From fd9fb388aa41218276890cb0bf5e98bc7350aeeb Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 15:54:48 +0800 Subject: [PATCH 155/167] Finish docker integrate ci --- integrate_test.sh | 2 +- test/integrate/dubbo/go-client/Dockerfile | 4 ++-- test/integrate/dubbo/go-server/Dockerfile | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integrate_test.sh b/integrate_test.sh index 6480ffeeb2..2c024c0f5e 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -16,8 +16,8 @@ #!/bin/bash -# stop integrate test when command return !0 set -e +set -x echo 'start integrate-test' diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index dbe7608cc8..d48df36dc7 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -28,8 +28,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client # update dubbo-go to current commit id -RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" -RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} +RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" || echo 'go get github.com/apache/dubbo-go@develop' +RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} || go get -u github.com/apache/dubbo-go@develop RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index d4708f5928..c2f2d63462 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -27,8 +27,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server # update dubbo-go to current commit id -RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" -RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} +RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" || echo 'go get github.com/apache/dubbo-go@develop' +RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} || go get -u github.com/apache/dubbo-go@develop RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server From 4c2907b54fccf18ee1442c2f7c30adec013f7dff Mon Sep 17 00:00:00 2001 From: wangxiang Date: Thu, 21 May 2020 16:32:51 +0800 Subject: [PATCH 156/167] Revert "Fix docker ci bug" --- .travis.yml | 17 +++++- integrate_test.sh | 72 ----------------------- test/integrate/dubbo/go-client/Dockerfile | 4 +- test/integrate/dubbo/go-server/Dockerfile | 4 +- 4 files changed, 20 insertions(+), 77 deletions(-) delete mode 100644 integrate_test.sh diff --git a/.travis.yml b/.travis.yml index 566c88ece0..7fb7420d8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,22 @@ script: - chmod u+x before_ut.sh && ./before_ut.sh - go mod vendor && go test ./... -coverprofile=coverage.txt -covermode=atomic # integrate-test - - chmod +x integrate_test.sh && ./integrate_test.sh + - echo 'start integrate-test' + # start zookeeper registry insecure listen in [:]:2181 + - docker run -d --network host zookeeper + - ROOTDIR=$(pwd) + - cd ./test/integrate/dubbo/go-client && docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - cd ./test/integrate/dubbo/go-server && docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} && cd $ROOTDIR + - docker run -d --network host ci-provider + - docker run -it --network host ci-consumer + + # another registry instance, start it by dep + # start etcd registry insecure listen in [:]:2379 + #- docker run -d --network host k8s.gcr.io/etcd:3.3.10 etcd + # start consul registry insecure listen in [:]:8500 + #- docker run -d --network host consul + # start nacos registry insecure listen in [:]:8848 + #- docker run -d --network host nacos/nacos-server:latest after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/integrate_test.sh b/integrate_test.sh deleted file mode 100644 index 2c024c0f5e..0000000000 --- a/integrate_test.sh +++ /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. - -#!/bin/bash - -set -e -set -x - -echo 'start integrate-test' - -# set root workspace -ROOT_DIR=$(pwd) - - -echo "integrate-test root work-space -> ${ROOT_DIR}" -echo "travis current commit id -> ${TRAVIS_COMMIT}" -echo "travis pull request -> ${TRAVIS_PULL_REQUEST}" -echo "travis pull request branch -> ${TRAVIS_PULL_REQUEST_BRANCH}" -echo "travis pull request slug -> ${TRAVIS_PULL_REQUEST_SLUG}" -echo "travis pull request sha -> ${TRAVIS_PULL_REQUEST_SHA}" -echo "travis pull request repo slug -> ${TRAVIS_REPO_SLUG}" - - -# #start etcd registry insecure listen in [:]:2379 -# docker run -d --network host k8s.gcr.io/etcd:3.3.10 etcd -# echo "etcdv3 listen in [:]2379" - -# #start consul registry insecure listen in [:]:8500 -# docker run -d --network host consul -# echo "consul listen in [:]8500" - -# #start nacos registry insecure listen in [:]:8848 -# docker run -d --network host nacos/nacos-server:latest -# echo "ncacos listen in [:]8848" - -# default use zk as registry -#start zookeeper registry insecure listen in [:]:2181 -docker run -d --network host zookeeper -echo "zookeeper listen in [:]2181" - -if [ ${TRAVIS_PULL_REQUEST_SLUG} ] -then - # this is a pull-request commit - # build go-client image - cd ./test/integrate/dubbo/go-client - docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} - cd ${ROOT_DIR} - # build go-server image - cd ./test/integrate/dubbo/go-server - docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} - cd ${ROOT_DIR} - # run provider - docker run -d --network host ci-provider - # check consumer status - docker run -it --network host ci-consumer -else - # this is merge pull-request to local-repo - echo '' -fi diff --git a/test/integrate/dubbo/go-client/Dockerfile b/test/integrate/dubbo/go-client/Dockerfile index d48df36dc7..1c683613f5 100644 --- a/test/integrate/dubbo/go-client/Dockerfile +++ b/test/integrate/dubbo/go-client/Dockerfile @@ -28,8 +28,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-client # update dubbo-go to current commit id -RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" || echo 'go get github.com/apache/dubbo-go@develop' -RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} || go get -u github.com/apache/dubbo-go@develop +RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-client diff --git a/test/integrate/dubbo/go-server/Dockerfile b/test/integrate/dubbo/go-server/Dockerfile index c2f2d63462..05596980c3 100644 --- a/test/integrate/dubbo/go-server/Dockerfile +++ b/test/integrate/dubbo/go-server/Dockerfile @@ -27,8 +27,8 @@ ARG PR_ORIGIN_COMMITID ADD . /go/src/github.com/apache/dubbo-go/test/integrate/dubbo/go-server # update dubbo-go to current commit id -RUN test ${PR_ORIGIN_REPO} && echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" || echo 'go get github.com/apache/dubbo-go@develop' -RUN test ${PR_ORIGIN_REPO} && go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} || go get -u github.com/apache/dubbo-go@develop +RUN echo "github.com/apache/dubbo-go will be replace to github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID}" +RUN go mod edit -replace=github.com/apache/dubbo-go=github.com/${PR_ORIGIN_REPO}@${PR_ORIGIN_COMMITID} RUN go install github.com/apache/dubbo-go/test/integrate/dubbo/go-server From bc76c31479978777c78e472c6ee4c153f1fa83c6 Mon Sep 17 00:00:00 2001 From: "scott.wang" Date: Thu, 21 May 2020 17:16:36 +0800 Subject: [PATCH 157/167] local test pass --- integrate_test.sh | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/integrate_test.sh b/integrate_test.sh index 2c024c0f5e..fef4d03443 100644 --- a/integrate_test.sh +++ b/integrate_test.sh @@ -51,22 +51,16 @@ echo "travis pull request repo slug -> ${TRAVIS_REPO_SLUG}" docker run -d --network host zookeeper echo "zookeeper listen in [:]2181" -if [ ${TRAVIS_PULL_REQUEST_SLUG} ] -then - # this is a pull-request commit - # build go-client image - cd ./test/integrate/dubbo/go-client - docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} - cd ${ROOT_DIR} - # build go-server image - cd ./test/integrate/dubbo/go-server - docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} - cd ${ROOT_DIR} - # run provider - docker run -d --network host ci-provider - # check consumer status - docker run -it --network host ci-consumer -else - # this is merge pull-request to local-repo - echo '' -fi +# build go-server image +cd ./test/integrate/dubbo/go-server +docker build . -t ci-provider --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} +cd ${ROOT_DIR} +docker run -d --network host ci-provider + +# build go-client image +cd ./test/integrate/dubbo/go-client +docker build . -t ci-consumer --build-arg PR_ORIGIN_REPO=${TRAVIS_PULL_REQUEST_SLUG} --build-arg PR_ORIGIN_COMMITID=${TRAVIS_PULL_REQUEST_SHA} +cd ${ROOT_DIR} +# run provider +# check consumer status +docker run -it --network host ci-consumer From 47bba48c19690f5123bdc233958d2852c8e16f1a Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Fri, 22 May 2020 17:06:03 +0800 Subject: [PATCH 158/167] Opt: optimize error handling --- config/metadata_report_config.go | 2 +- registry/directory/directory.go | 17 ++++++++++++----- registry/directory/directory_test.go | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index 41fb6b4769..2b926c0b94 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -103,7 +103,7 @@ func startMetadataReport(metadataType string, metadataReportConfig *MetadataRepo if url, err := metadataReportConfig.ToUrl(); err == nil { instance.GetMetadataReportInstance(url) } else { - return perrors.New("MetadataConfig is invalid!") + return perrors.Wrap(err, "Start MetadataReport failed.") } return nil diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 552aa57061..322ae9afd2 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -152,9 +152,11 @@ func (dir *RegistryDirectory) refreshInvokers(res *registry.ServiceEvent) { } func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { - newInvokersList := []protocol.Invoker{} + var ( + err error + newInvokersList []protocol.Invoker + ) groupInvokersMap := make(map[string][]protocol.Invoker) - groupInvokersList := []protocol.Invoker{} dir.cacheInvokersMap.Range(func(key, value interface{}) bool { newInvokersList = append(newInvokersList, value.(protocol.Invoker)) @@ -170,6 +172,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { groupInvokersMap[group] = []protocol.Invoker{invoker} } } + groupInvokersList := make([]protocol.Invoker, 0, len(groupInvokersMap)) if len(groupInvokersMap) == 1 { //len is 1 it means no group setting ,so do not need cluster again for _, invokers := range groupInvokersMap { @@ -178,9 +181,13 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { } else { for _, invokers := range groupInvokersMap { staticDir := directory.NewStaticDirectory(invokers) - cluster := extension.GetCluster(dir.GetUrl().SubURL.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) - staticDir.BuildRouterChain(invokers) - groupInvokersList = append(groupInvokersList, cluster.Join(staticDir)) + cst := extension.GetCluster(dir.GetUrl().SubURL.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) + err = staticDir.BuildRouterChain(invokers) + if err != nil { + logger.Error(err) + continue + } + groupInvokersList = append(groupInvokersList, cst.Join(staticDir)) } } diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index f1d5ce434a..f70fce1751 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,6 +18,8 @@ package directory import ( + "github.com/apache/dubbo-go/protocol/mock" + "github.com/golang/mock/gomock" "net/url" "strconv" "testing" @@ -169,7 +171,21 @@ Loop1: break Loop1 } } +} +func Test_toGroupInvokers(t *testing.T) { + registryDirectory, _ := normalRegistryDir() + ctrl := gomock.NewController(t) + defer ctrl.Finish() + invoker := mock.NewMockInvoker(ctrl) + newUrl, _ := common.NewURL("dubbo://192.168.1.1:20000/com.ikurento.user.UserProvider") + invoker.EXPECT().GetUrl().Return(newUrl).AnyTimes() + + registryDirectory.cacheInvokersMap.Store("group1", invoker) + registryDirectory.cacheInvokersMap.Store("group2", invoker) + registryDirectory.cacheInvokersMap.Store("group1", invoker) + groupInvokers := registryDirectory.toGroupInvokers() + assert.Len(t, groupInvokers, 2) } func normalRegistryDir(noMockEvent ...bool) (*RegistryDirectory, *registry.MockRegistry) { From def16afbd97028ba1d4d9a9e1adff5848bba746e Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Fri, 22 May 2020 17:11:36 +0800 Subject: [PATCH 159/167] Modify the order of import packages --- registry/directory/directory_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index f70fce1751..ac3f7124c1 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,8 +18,6 @@ package directory import ( - "github.com/apache/dubbo-go/protocol/mock" - "github.com/golang/mock/gomock" "net/url" "strconv" "testing" @@ -27,6 +25,7 @@ import ( ) import ( + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" ) @@ -39,6 +38,7 @@ import ( "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" "github.com/apache/dubbo-go/protocol/protocolwrapper" "github.com/apache/dubbo-go/registry" "github.com/apache/dubbo-go/remoting" From 2ffbe96899e2fdcabf96c594e66240647504397b Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Fri, 22 May 2020 18:00:22 +0800 Subject: [PATCH 160/167] Mod: modify the comments in the directory of common --- common/config/environment.go | 18 ++++++++-------- common/extension/auth.go | 6 +++--- common/extension/cluster.go | 4 ++-- common/extension/config_center.go | 4 ++-- common/extension/config_center_factory.go | 4 ++-- common/extension/config_reader.go | 6 +++--- common/extension/configurator.go | 6 +++--- common/extension/filter.go | 8 +++---- common/extension/graceful_shutdown.go | 2 +- common/extension/health_checker.go | 4 ++-- common/extension/loadbalance.go | 4 ++-- common/extension/metadata_report_factory.go | 4 ++-- common/extension/metrics.go | 4 ++-- common/extension/protocol.go | 4 ++-- common/extension/proxy_factory.go | 4 ++-- common/extension/registry.go | 4 ++-- common/extension/registry_directory.go | 4 ++-- common/extension/rest_client.go | 4 ++-- common/extension/rest_server.go | 4 ++-- common/extension/router_factory.go | 8 +++---- common/extension/tps_limit.go | 8 +++---- common/proxy/proxy.go | 4 ++-- common/proxy/proxy_factory/default.go | 14 ++++++------ common/rpc_service.go | 24 ++++++++++----------- 24 files changed, 78 insertions(+), 78 deletions(-) diff --git a/common/config/environment.go b/common/config/environment.go index 793512cfbb..4a84885128 100644 --- a/common/config/environment.go +++ b/common/config/environment.go @@ -46,7 +46,7 @@ var ( once sync.Once ) -// GetEnvInstance get env instance by singleton +// GetEnvInstance gets env instance by singleton func GetEnvInstance() *Environment { once.Do(func() { instance = &Environment{configCenterFirst: true} @@ -67,14 +67,14 @@ func NewEnvInstance() { // return env.configCenterFirst //} -// UpdateExternalConfigMap update env externalConfigMap field +// UpdateExternalConfigMap updates env externalConfigMap field func (env *Environment) UpdateExternalConfigMap(externalMap map[string]string) { for k, v := range externalMap { env.externalConfigMap.Store(k, v) } } -// UpdateAppExternalConfigMap update env appExternalConfigMap field +// UpdateAppExternalConfigMap updates env appExternalConfigMap field func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string) { for k, v := range externalMap { env.appExternalConfigMap.Store(k, v) @@ -82,7 +82,7 @@ func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string } // List represents a doubly linked list. -// Configuration put externalConfigMap and appExternalConfigMap into list +// Configuration puts externalConfigMap and appExternalConfigMap into list func (env *Environment) Configuration() *list.List { cfgList := list.New() // The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration @@ -91,17 +91,17 @@ func (env *Environment) Configuration() *list.List { return cfgList } -// SetDynamicConfiguration use to set value for dynamicConfiguration +// SetDynamicConfiguration is used to set value for dynamicConfiguration func (env *Environment) SetDynamicConfiguration(dc config_center.DynamicConfiguration) { env.dynamicConfiguration = dc } -// GetDynamicConfiguration use to get dynamicConfiguration +// GetDynamicConfiguration is used to get dynamicConfiguration func (env *Environment) GetDynamicConfiguration() config_center.DynamicConfiguration { return env.dynamicConfiguration } -// InmemoryConfiguration use to store config in memory +// InmemoryConfiguration is used to store config in memory type InmemoryConfiguration struct { store *sync.Map } @@ -110,7 +110,7 @@ func newInmemoryConfiguration(p *sync.Map) *InmemoryConfiguration { return &InmemoryConfiguration{store: p} } -// GetProperty use the key to get value from InmemoryConfiguration instance +// GetProperty is used the key to get value from InmemoryConfiguration instance func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) { if conf.store == nil { return false, "" @@ -124,7 +124,7 @@ func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) { return false, "" } -// GetSubProperty use the subkey to get sub property from InmemoryConfiguration instance +// GetSubProperty is used the subkey to get sub property from InmemoryConfiguration instance func (conf *InmemoryConfiguration) GetSubProperty(subKey string) map[string]struct{} { if conf.store == nil { return nil diff --git a/common/extension/auth.go b/common/extension/auth.go index d7900045d3..ce9b676c04 100644 --- a/common/extension/auth.go +++ b/common/extension/auth.go @@ -26,12 +26,12 @@ var ( accesskeyStorages = make(map[string]func() filter.AccessKeyStorage) ) -// SetAuthenticator put the fcn into map with name +// SetAuthenticator puts the fcn into map with name func SetAuthenticator(name string, fcn func() filter.Authenticator) { authenticators[name] = fcn } -// GetAuthenticator find the Authenticator with name +// GetAuthenticator finds the Authenticator with name // if not found, it will panic func GetAuthenticator(name string) filter.Authenticator { if authenticators[name] == nil { @@ -45,7 +45,7 @@ func SetAccesskeyStorages(name string, fcn func() filter.AccessKeyStorage) { accesskeyStorages[name] = fcn } -// GetAccesskeyStorages find the storage with the name. +// GetAccesskeyStorages finds the storage with the name. // If not found, it will panic. func GetAccesskeyStorages(name string) filter.AccessKeyStorage { if accesskeyStorages[name] == nil { diff --git a/common/extension/cluster.go b/common/extension/cluster.go index 0e7c537cd3..cbbf8c8d51 100644 --- a/common/extension/cluster.go +++ b/common/extension/cluster.go @@ -25,13 +25,13 @@ var ( clusters = make(map[string]func() cluster.Cluster) ) -// SetCluster set the cluster fault-tolerant mode with name +// SetCluster sets the cluster fault-tolerant mode with name // For example: available/failfast/broadcast/failfast/failsafe/... func SetCluster(name string, fcn func() cluster.Cluster) { clusters[name] = fcn } -// GetCluster find the cluster fault-tolerant mode with name +// GetCluster finds the cluster fault-tolerant mode with name func GetCluster(name string) cluster.Cluster { if clusters[name] == nil { panic("cluster for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/config_center.go b/common/extension/config_center.go index b18f0f9522..1c33708077 100644 --- a/common/extension/config_center.go +++ b/common/extension/config_center.go @@ -26,12 +26,12 @@ var ( configCenters = make(map[string]func(config *common.URL) (config_center.DynamicConfiguration, error)) ) -// SetConfigCenter set the DynamicConfiguration with name +// SetConfigCenter sets the DynamicConfiguration with name func SetConfigCenter(name string, v func(config *common.URL) (config_center.DynamicConfiguration, error)) { configCenters[name] = v } -// GetConfigCenter find the DynamicConfiguration with name +// GetConfigCenter finds the DynamicConfiguration with name func GetConfigCenter(name string, config *common.URL) (config_center.DynamicConfiguration, error) { if configCenters[name] == nil { panic("config center for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/config_center_factory.go b/common/extension/config_center_factory.go index 67ecf0fe5c..05e1a7c566 100644 --- a/common/extension/config_center_factory.go +++ b/common/extension/config_center_factory.go @@ -25,12 +25,12 @@ var ( configCenterFactories = make(map[string]func() config_center.DynamicConfigurationFactory) ) -// SetConfigCenterFactory set the DynamicConfigurationFactory with name +// SetConfigCenterFactory sets the DynamicConfigurationFactory with name func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigurationFactory) { configCenterFactories[name] = v } -// GetConfigCenterFactory find the DynamicConfigurationFactory with name +// 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.") diff --git a/common/extension/config_reader.go b/common/extension/config_reader.go index aced5b0281..a765060b53 100644 --- a/common/extension/config_reader.go +++ b/common/extension/config_reader.go @@ -26,12 +26,12 @@ var ( defaults = make(map[string]string) ) -// SetConfigReaders set a creator of config reader. +// SetConfigReaders sets a creator of config reader. func SetConfigReaders(name string, v func() interfaces.ConfigReader) { configReaders[name] = v } -// GetConfigReaders get a config reader by name. +// GetConfigReaders gets a config reader by name. func GetConfigReaders(name string) interfaces.ConfigReader { if configReaders[name] == nil { panic("config reader for " + name + " is not existing, make sure you have imported the package.") @@ -39,7 +39,7 @@ func GetConfigReaders(name string) interfaces.ConfigReader { return configReaders[name]() } -// SetDefaultConfigReader set {name} to default config reader for {module} +// SetDefaultConfigReader sets {name} to default config reader for {module} func SetDefaultConfigReader(module, name string) { defaults[module] = name } diff --git a/common/extension/configurator.go b/common/extension/configurator.go index d24863ae84..ca60328b68 100644 --- a/common/extension/configurator.go +++ b/common/extension/configurator.go @@ -33,12 +33,12 @@ var ( configurator = make(map[string]getConfiguratorFunc) ) -// SetConfigurator set the getConfiguratorFunc with name +// SetConfigurator sets the getConfiguratorFunc with name func SetConfigurator(name string, v getConfiguratorFunc) { configurator[name] = v } -// GetConfigurator find the Configurator with name +// GetConfigurator finds the Configurator with name func GetConfigurator(name string, url *common.URL) config_center.Configurator { if configurator[name] == nil { panic("configurator for " + name + " is not existing, make sure you have import the package.") @@ -47,7 +47,7 @@ func GetConfigurator(name string, url *common.URL) config_center.Configurator { } -// SetDefaultConfigurator set the default Configurator +// SetDefaultConfigurator sets the default Configurator func SetDefaultConfigurator(v getConfiguratorFunc) { configurator[DefaultKey] = v } diff --git a/common/extension/filter.go b/common/extension/filter.go index 849aa1ba7b..42f36ebbd7 100644 --- a/common/extension/filter.go +++ b/common/extension/filter.go @@ -26,13 +26,13 @@ var ( rejectedExecutionHandler = make(map[string]func() filter.RejectedExecutionHandler) ) -// SetFilter set the filter extension with name +// SetFilter sets the filter extension with name // For example: hystrix/metrics/token/tracing/limit/... func SetFilter(name string, v func() filter.Filter) { filters[name] = v } -// GetFilter find the filter extension with name +// GetFilter finds the filter extension with name func GetFilter(name string) filter.Filter { if filters[name] == nil { panic("filter for " + name + " is not existing, make sure you have imported the package.") @@ -40,12 +40,12 @@ func GetFilter(name string) filter.Filter { return filters[name]() } -// SetRejectedExecutionHandler set the RejectedExecutionHandler with name +// SetRejectedExecutionHandler sets the RejectedExecutionHandler with name func SetRejectedExecutionHandler(name string, creator func() filter.RejectedExecutionHandler) { rejectedExecutionHandler[name] = creator } -// GetRejectedExecutionHandler find the RejectedExecutionHandler with name +// GetRejectedExecutionHandler finds the RejectedExecutionHandler with name func GetRejectedExecutionHandler(name string) filter.RejectedExecutionHandler { creator, ok := rejectedExecutionHandler[name] if !ok { diff --git a/common/extension/graceful_shutdown.go b/common/extension/graceful_shutdown.go index 04f0146595..cb55419aab 100644 --- a/common/extension/graceful_shutdown.go +++ b/common/extension/graceful_shutdown.go @@ -49,7 +49,7 @@ func AddCustomShutdownCallback(callback func()) { customShutdownCallbacks.PushBack(callback) } -// GetAllCustomShutdownCallbacks get all custom shutdown callbacks +// GetAllCustomShutdownCallbacks gets all custom shutdown callbacks func GetAllCustomShutdownCallbacks() *list.List { return customShutdownCallbacks } diff --git a/common/extension/health_checker.go b/common/extension/health_checker.go index 365c5d0910..3052f680a2 100644 --- a/common/extension/health_checker.go +++ b/common/extension/health_checker.go @@ -26,12 +26,12 @@ var ( healthCheckers = make(map[string]func(url *common.URL) router.HealthChecker) ) -// SethealthChecker set the HealthChecker with name +// SethealthChecker sets the HealthChecker with name func SethealthChecker(name string, fcn func(url *common.URL) router.HealthChecker) { healthCheckers[name] = fcn } -// GetHealthChecker get the HealthChecker with name +// GetHealthChecker gets the HealthChecker with name func GetHealthChecker(name string, url *common.URL) router.HealthChecker { if healthCheckers[name] == nil { panic("healthCheckers for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/loadbalance.go b/common/extension/loadbalance.go index 2d6380750d..5e582fe23c 100644 --- a/common/extension/loadbalance.go +++ b/common/extension/loadbalance.go @@ -25,13 +25,13 @@ var ( loadbalances = make(map[string]func() cluster.LoadBalance) ) -// SetLoadbalance set the loadbalance extension with name +// SetLoadbalance sets the loadbalance extension with name // For example: random/round_robin/consistent_hash/least_active/... func SetLoadbalance(name string, fcn func() cluster.LoadBalance) { loadbalances[name] = fcn } -// GetLoadbalance find the loadbalance extension with name +// GetLoadbalance finds the loadbalance extension with name func GetLoadbalance(name string) cluster.LoadBalance { if loadbalances[name] == nil { panic("loadbalance for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/metadata_report_factory.go b/common/extension/metadata_report_factory.go index 715c2c701f..9928949b14 100644 --- a/common/extension/metadata_report_factory.go +++ b/common/extension/metadata_report_factory.go @@ -25,12 +25,12 @@ var ( metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory, 8) ) -// SetMetadataReportFactory set the MetadataReportFactory with name +// SetMetadataReportFactory sets the MetadataReportFactory with name func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFactory) { metaDataReportFactories[name] = v } -// GetMetadataReportFactory find the MetadataReportFactory with name +// GetMetadataReportFactory finds the MetadataReportFactory with name func GetMetadataReportFactory(name string) metadata.MetadataReportFactory { if metaDataReportFactories[name] == nil { panic("metadata report for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/metrics.go b/common/extension/metrics.go index 42fca7a2db..11c65ef818 100644 --- a/common/extension/metrics.go +++ b/common/extension/metrics.go @@ -27,12 +27,12 @@ var ( metricReporterMap = make(map[string]func() metrics.Reporter, 4) ) -// SetMetricReporter set a reporter with the name +// SetMetricReporter sets a reporter with the name func SetMetricReporter(name string, reporterFunc func() metrics.Reporter) { metricReporterMap[name] = reporterFunc } -// GetMetricReporter find the reporter with name. +// GetMetricReporter finds the reporter with name. // if not found, it will panic. // we should know that this method usually is called when system starts, so we should panic func GetMetricReporter(name string) metrics.Reporter { diff --git a/common/extension/protocol.go b/common/extension/protocol.go index 34e659aca3..bed90cfb5b 100644 --- a/common/extension/protocol.go +++ b/common/extension/protocol.go @@ -25,12 +25,12 @@ var ( protocols = make(map[string]func() protocol.Protocol) ) -// SetProtocol set the protocol extension with name +// SetProtocol sets the protocol extension with name func SetProtocol(name string, v func() protocol.Protocol) { protocols[name] = v } -// GetProtocol find the protocol extension with name +// GetProtocol finds the protocol extension with name func GetProtocol(name string) protocol.Protocol { if protocols[name] == nil { panic("protocol for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go index 6006dd5d97..7d0f9914e0 100644 --- a/common/extension/proxy_factory.go +++ b/common/extension/proxy_factory.go @@ -25,12 +25,12 @@ var ( proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory) ) -// SetProxyFactory set the ProxyFactory extension with name +// SetProxyFactory sets the ProxyFactory extension with name func SetProxyFactory(name string, f func(...proxy.Option) proxy.ProxyFactory) { proxyFactories[name] = f } -// GetProxyFactory find the ProxyFactory extension with name +// GetProxyFactory finds the ProxyFactory extension with name func GetProxyFactory(name string) proxy.ProxyFactory { if name == "" { name = "default" diff --git a/common/extension/registry.go b/common/extension/registry.go index c94f913f25..b5f97e8bce 100644 --- a/common/extension/registry.go +++ b/common/extension/registry.go @@ -26,12 +26,12 @@ var ( registrys = make(map[string]func(config *common.URL) (registry.Registry, error)) ) -// SetRegistry set the registry extension with name +// SetRegistry sets the registry extension with name func SetRegistry(name string, v func(config *common.URL) (registry.Registry, error)) { registrys[name] = v } -// GetRegistry find the registry extension with name +// GetRegistry finds the registry extension with name func GetRegistry(name string, config *common.URL) (registry.Registry, error) { if registrys[name] == nil { panic("registry 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 86155f9117..330fc46400 100644 --- a/common/extension/registry_directory.go +++ b/common/extension/registry_directory.go @@ -27,12 +27,12 @@ type registryDirectory func(url *common.URL, registry registry.Registry) (cluste var defaultRegistry registryDirectory -// SetDefaultRegistryDirectory set the default registryDirectory +// SetDefaultRegistryDirectory sets the default registryDirectory func SetDefaultRegistryDirectory(v registryDirectory) { defaultRegistry = v } -// GetDefaultRegistryDirectory find the registryDirectory with url and registry +// GetDefaultRegistryDirectory finds the registryDirectory with url and registry func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (cluster.Directory, error) { if defaultRegistry == nil { panic("registry directory is not existing, make sure you have import the package.") diff --git a/common/extension/rest_client.go b/common/extension/rest_client.go index e2b9918683..d4d319bdbe 100644 --- a/common/extension/rest_client.go +++ b/common/extension/rest_client.go @@ -25,12 +25,12 @@ var ( restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8) ) -// SetRestClient set the RestClient with name +// SetRestClient sets the RestClient with name func SetRestClient(name string, fun func(restOptions *client.RestOptions) client.RestClient) { restClients[name] = fun } -// GetNewRestClient find the RestClient with name +// GetNewRestClient finds the RestClient with name func GetNewRestClient(name string, restOptions *client.RestOptions) client.RestClient { if restClients[name] == nil { panic("restClient for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/rest_server.go b/common/extension/rest_server.go index 2ad661a9fe..67df19d00b 100644 --- a/common/extension/rest_server.go +++ b/common/extension/rest_server.go @@ -25,12 +25,12 @@ var ( restServers = make(map[string]func() server.RestServer, 8) ) -// SetRestServer set the RestServer with name +// SetRestServer sets the RestServer with name func SetRestServer(name string, fun func() server.RestServer) { restServers[name] = fun } -// GetNewRestServer find the RestServer with name +// GetNewRestServer finds the RestServer with name func GetNewRestServer(name string) server.RestServer { if restServers[name] == nil { panic("restServer for " + name + " is not existing, make sure you have import the package.") diff --git a/common/extension/router_factory.go b/common/extension/router_factory.go index 1339228618..acb4f19e52 100644 --- a/common/extension/router_factory.go +++ b/common/extension/router_factory.go @@ -31,12 +31,12 @@ var ( fileRouterFactories = make(map[string]router.FileRouterFactory) ) -// SetRouterFactory Set create router factory function by name +// SetRouterFactory sets create router factory function by name func SetRouterFactory(name string, fun func() router.RouterFactory) { routers[name] = fun } -// GetRouterFactory Get create router factory function by name +// GetRouterFactory gets create router factory function by name func GetRouterFactory(name string) router.RouterFactory { if routers[name] == nil { panic("router_factory for " + name + " is not existing, make sure you have import the package.") @@ -44,12 +44,12 @@ func GetRouterFactory(name string) router.RouterFactory { return routers[name]() } -// GetRouterFactories Get all create router factory function +// GetRouterFactories gets all create router factory function func GetRouterFactories() map[string]func() router.RouterFactory { return routers } -// GetFileRouterFactories Get all create file router factory instance +// GetFileRouterFactories gets all create file router factory instance func GetFileRouterFactories() map[string]router.FileRouterFactory { l := len(routers) if l == 0 { diff --git a/common/extension/tps_limit.go b/common/extension/tps_limit.go index 036debc335..2cec0ff9d2 100644 --- a/common/extension/tps_limit.go +++ b/common/extension/tps_limit.go @@ -26,12 +26,12 @@ var ( tpsLimiter = make(map[string]func() filter.TpsLimiter) ) -// SetTpsLimiter set the TpsLimiter with name +// SetTpsLimiter sets the TpsLimiter with name func SetTpsLimiter(name string, creator func() filter.TpsLimiter) { tpsLimiter[name] = creator } -// GetTpsLimiter find the TpsLimiter with name +// GetTpsLimiter finds the TpsLimiter with name func GetTpsLimiter(name string) filter.TpsLimiter { creator, ok := tpsLimiter[name] if !ok { @@ -41,12 +41,12 @@ func GetTpsLimiter(name string) filter.TpsLimiter { return creator() } -// SetTpsLimitStrategy set the TpsLimitStrategyCreator with name +// SetTpsLimitStrategy sets the TpsLimitStrategyCreator with name func SetTpsLimitStrategy(name string, creator filter.TpsLimitStrategyCreator) { tpsLimitStrategy[name] = creator } -// GetTpsLimitStrategyCreator find the TpsLimitStrategyCreator with name +// GetTpsLimitStrategyCreator finds the TpsLimitStrategyCreator with name func GetTpsLimitStrategyCreator(name string) filter.TpsLimitStrategyCreator { creator, ok := tpsLimitStrategy[name] if !ok { diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index a77d26d110..520cef690b 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -205,12 +205,12 @@ func (p *Proxy) Implement(v common.RPCService) { } -// Get get rpc service instance. +// Get gets rpc service instance. func (p *Proxy) Get() common.RPCService { return p.rpc } -// GetCallback get callback. +// GetCallback gets callback. func (p *Proxy) GetCallback() interface{} { return p.callBack } diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 013b399110..1bb1e29c5c 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -40,7 +40,7 @@ func init() { extension.SetProxyFactory("default", NewDefaultProxyFactory) } -// DefaultProxyFactory ... +// DefaultProxyFactory is the default proxy factory type DefaultProxyFactory struct { //delegate ProxyFactory } @@ -53,17 +53,17 @@ type DefaultProxyFactory struct { // } //} -// NewDefaultProxyFactory ... +// NewDefaultProxyFactory returns a proxy factory instance func NewDefaultProxyFactory(options ...proxy.Option) proxy.ProxyFactory { return &DefaultProxyFactory{} } -// GetProxy ... +// GetProxy gets a proxy func (factory *DefaultProxyFactory) GetProxy(invoker protocol.Invoker, url *common.URL) *proxy.Proxy { return factory.GetAsyncProxy(invoker, nil, url) } -// GetAsyncProxy ... +// GetAsyncProxy gets a async proxy func (factory *DefaultProxyFactory) GetAsyncProxy(invoker protocol.Invoker, callBack interface{}, url *common.URL) *proxy.Proxy { //create proxy attachments := map[string]string{} @@ -71,19 +71,19 @@ func (factory *DefaultProxyFactory) GetAsyncProxy(invoker protocol.Invoker, call return proxy.NewProxy(invoker, callBack, attachments) } -// GetInvoker ... +// GetInvoker gets a invoker func (factory *DefaultProxyFactory) GetInvoker(url common.URL) protocol.Invoker { return &ProxyInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), } } -// ProxyInvoker ... +// ProxyInvoker is a invoker struct type ProxyInvoker struct { protocol.BaseInvoker } -// Invoke ... +// Invoke is used to call service method by invocation func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { result := &protocol.RPCResult{} result.SetAttachments(invocation.Attachments()) diff --git a/common/rpc_service.go b/common/rpc_service.go index 232f2120a9..211e4eae9c 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -87,27 +87,27 @@ type MethodType struct { replyType reflect.Type // return value, otherwise it is nil } -// Method get @m.method. +// Method gets @m.method. func (m *MethodType) Method() reflect.Method { return m.method } -// CtxType get @m.ctxType. +// CtxType gets @m.ctxType. func (m *MethodType) CtxType() reflect.Type { return m.ctxType } -// ArgsType get @m.argsType. +// ArgsType gets @m.argsType. func (m *MethodType) ArgsType() []reflect.Type { return m.argsType } -// ReplyType get @m.replyType. +// ReplyType gets @m.replyType. func (m *MethodType) ReplyType() reflect.Type { return m.replyType } -// SuiteContext tranfer @ctx to reflect.Value type or get it from @m.ctxType. +// SuiteContext tranfers @ctx to reflect.Value type or get it from @m.ctxType. func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value { if contextv := reflect.ValueOf(ctx); contextv.IsValid() { return contextv @@ -127,17 +127,17 @@ type Service struct { methods map[string]*MethodType } -// Method get @s.methods. +// Method gets @s.methods. func (s *Service) Method() map[string]*MethodType { return s.methods } -// RcvrType get @s.rcvrType. +// RcvrType gets @s.rcvrType. func (s *Service) RcvrType() reflect.Type { return s.rcvrType } -// Rcvr get @s.rcvr. +// Rcvr gets @s.rcvr. func (s *Service) Rcvr() reflect.Value { return s.rcvr } @@ -152,7 +152,7 @@ type serviceMap struct { interfaceMap map[string][]*Service // interface -> service } -// GetService get a service defination by protocol and name +// GetService gets a service defination by protocol and name func (sm *serviceMap) GetService(protocol, name string) *Service { sm.mutex.RLock() defer sm.mutex.RUnlock() @@ -165,7 +165,7 @@ func (sm *serviceMap) GetService(protocol, name string) *Service { return nil } -// GetInterface get an interface defination by interface name +// GetInterface gets an interface defination by interface name func (sm *serviceMap) GetInterface(interfaceName string) []*Service { sm.mutex.RLock() defer sm.mutex.RUnlock() @@ -175,7 +175,7 @@ func (sm *serviceMap) GetInterface(interfaceName string) []*Service { return nil } -// Register register a service by @interfaceName and @protocol +// Register registers a service by @interfaceName and @protocol func (sm *serviceMap) Register(interfaceName, protocol string, rcvr RPCService) (string, error) { if sm.serviceMap[protocol] == nil { sm.serviceMap[protocol] = make(map[string]*Service) @@ -223,7 +223,7 @@ func (sm *serviceMap) Register(interfaceName, protocol string, rcvr RPCService) return strings.TrimSuffix(methods, ","), nil } -// UnRegister cancel a service by @interfaceName, @protocol and @serviceId +// UnRegister cancels a service by @interfaceName, @protocol and @serviceId func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) error { if protocol == "" || serviceId == "" { return perrors.New("protocol or serviceName is nil") From 1800a672e7aa70d9704ced158b4884075b35c363 Mon Sep 17 00:00:00 2001 From: haohongfan Date: Fri, 22 May 2020 19:46:58 +0800 Subject: [PATCH 161/167] feat: change %s to %+v --- cluster/directory/base_directory.go | 2 +- filter/filter_impl/hystrix_filter.go | 2 +- registry/kubernetes/registry_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index cff0a983a1..0f941fdccf 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -92,7 +92,7 @@ func (dir *BaseDirectory) SetRouters(urls []*common.URL) { factory := extension.GetRouterFactory(url.Protocol) r, err := factory.NewRouter(url) if err != nil { - logger.Errorf("Create router fail. router key: %s, url:%s, error: %s", routerKey, url.Service(), err.Error()) + logger.Errorf("Create router fail. router key: %s, url:%s, error: %+v", routerKey, url.Service(), err) return } routers = append(routers, r) diff --git a/filter/filter_impl/hystrix_filter.go b/filter/filter_impl/hystrix_filter.go index ff4b405f48..4c872bed3e 100644 --- a/filter/filter_impl/hystrix_filter.go +++ b/filter/filter_impl/hystrix_filter.go @@ -124,7 +124,7 @@ func (hf *HystrixFilter) Invoke(ctx context.Context, invoker protocol.Invoker, i _, _, err := hystrix.GetCircuit(cmdName) configLoadMutex.RUnlock() if err != nil { - logger.Errorf("[Hystrix Filter]Errors occurred getting circuit for %s , will invoke without hystrix, error is: %s", cmdName, err.Error()) + logger.Errorf("[Hystrix Filter]Errors occurred getting circuit for %s , will invoke without hystrix, error is: %+v", cmdName, err) return invoker.Invoke(ctx, invocation) } logger.Infof("[Hystrix Filter]Using hystrix filter: %s", cmdName) diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go index 3360532f1f..a650b189c3 100644 --- a/registry/kubernetes/registry_test.go +++ b/registry/kubernetes/registry_test.go @@ -68,9 +68,9 @@ func (s *KubernetesRegistryTestSuite) TestSubscribe() { time.Sleep(1e9) go func() { - err = r.Register(url) - if err != nil { - t.Fatal(err) + registerErr := r.Register(url) + if registerErr != nil { + t.Fatal(registerErr) } }() From ed4e7ba95e4369256ea80017fbe6bd6b35762923 Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Fri, 22 May 2020 17:11:36 +0800 Subject: [PATCH 162/167] Modify the order of import packages --- registry/directory/directory_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index f70fce1751..ac3f7124c1 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -18,8 +18,6 @@ package directory import ( - "github.com/apache/dubbo-go/protocol/mock" - "github.com/golang/mock/gomock" "net/url" "strconv" "testing" @@ -27,6 +25,7 @@ import ( ) import ( + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" ) @@ -39,6 +38,7 @@ import ( "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/mock" "github.com/apache/dubbo-go/protocol/protocolwrapper" "github.com/apache/dubbo-go/registry" "github.com/apache/dubbo-go/remoting" From 6489acfec0a0be23894ca452088ea6129ab266a4 Mon Sep 17 00:00:00 2001 From: watermelo <80680489@qq.com> Date: Sat, 23 May 2020 00:54:52 +0800 Subject: [PATCH 163/167] Mod: modify inappropriate comments after review --- common/config/environment.go | 2 +- common/extension/configurator.go | 2 +- common/logger/logger.go | 6 +++--- common/node.go | 2 +- common/url.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/config/environment.go b/common/config/environment.go index 4a84885128..7453ec5977 100644 --- a/common/config/environment.go +++ b/common/config/environment.go @@ -81,8 +81,8 @@ func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string } } -// List represents a doubly linked list. // Configuration puts externalConfigMap and appExternalConfigMap into list +// List represents a doubly linked list. func (env *Environment) Configuration() *list.List { cfgList := list.New() // The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration diff --git a/common/extension/configurator.go b/common/extension/configurator.go index ca60328b68..05e63dc1ef 100644 --- a/common/extension/configurator.go +++ b/common/extension/configurator.go @@ -61,7 +61,7 @@ func GetDefaultConfigurator(url *common.URL) config_center.Configurator { } -// GetDefaultConfiguratorFunc default configurator function +// GetDefaultConfiguratorFunc gets default configurator function func GetDefaultConfiguratorFunc() getConfiguratorFunc { if configurator[DefaultKey] == nil { panic("configurator for default is not existing, make sure you have import the package.") diff --git a/common/logger/logger.go b/common/logger/logger.go index 7510b1eb8f..fcdd450dc4 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -136,7 +136,7 @@ func GetLogger() Logger { return logger } -// SetLoggerLevel used to set logger level +// SetLoggerLevel use for set logger level func SetLoggerLevel(level string) bool { if l, ok := logger.(OpsLogger); ok { l.SetLoggerLevel(level) @@ -145,13 +145,13 @@ func SetLoggerLevel(level string) bool { return false } -// OpsLogger used by the SetLoggerLevel +// OpsLogger use for the SetLoggerLevel type OpsLogger interface { Logger SetLoggerLevel(level string) } -// SetLoggerLevel used to set logger level +// SetLoggerLevel use for set logger level func (dl *DubboLogger) SetLoggerLevel(level string) { l := new(zapcore.Level) l.Set(level) diff --git a/common/node.go b/common/node.go index f812d1bcce..4febd78536 100644 --- a/common/node.go +++ b/common/node.go @@ -17,7 +17,7 @@ package common -// Node is used to process dubbo node +// Node use for process dubbo node type Node interface { GetUrl() URL IsAvailable() bool diff --git a/common/url.go b/common/url.go index ae8a63d995..fa076104af 100644 --- a/common/url.go +++ b/common/url.go @@ -86,7 +86,7 @@ type baseUrl struct { PrimitiveURL string } -// URL is used to locate resourse to transfer data between nodes +// URL use for locate resourse to transfer data between nodes type URL struct { baseUrl Path string // like /com.ikurento.dubbo.UserProvider3 @@ -434,7 +434,7 @@ func (c URL) GetParamAndDecoded(key string) (string, error) { return value, err } -// GetRawParam is used to get raw param +// GetRawParam use for get raw param func (c URL) GetRawParam(key string) string { switch key { case "protocol": From 67e8e4154cba967b77e89510523d43d2efdc49bb Mon Sep 17 00:00:00 2001 From: cvictory Date: Sun, 24 May 2020 14:32:16 +0800 Subject: [PATCH 164/167] add attribute into Invocation --- protocol/invocation.go | 3 +++ protocol/invocation/rpcinvocation.go | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/protocol/invocation.go b/protocol/invocation.go index f32f2c3449..eedf5f0253 100644 --- a/protocol/invocation.go +++ b/protocol/invocation.go @@ -30,5 +30,8 @@ type Invocation interface { Reply() interface{} Attachments() map[string]string AttachmentsByKey(string, string) string + // Refer to dubbo 2.7.6. It is different from attachment. It is used in internal process. + Attributes() map[string]interface{} + AttributeByKey(string, interface{}) interface{} Invoker() Invoker } diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index b207fd0b0c..10c0efe9cd 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -40,8 +40,10 @@ type RPCInvocation struct { reply interface{} callBack interface{} attachments map[string]string - invoker protocol.Invoker - lock sync.RWMutex + // Refer to dubbo 2.7.6. It is different from attachment. It is used in internal process. + attributes map[string]interface{} + invoker protocol.Invoker + lock sync.RWMutex } // NewRPCInvocation ... @@ -111,6 +113,25 @@ func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string return defaultValue } +// get attributes +func (r *RPCInvocation) Attributes() map[string]interface{} { + return r.attributes +} + +// get attribute by key. If it is not exist, it will return default value +func (r *RPCInvocation) AttributeByKey(key string, defaultValue interface{}) interface{} { + r.lock.RLock() + defer r.lock.RUnlock() + if r.attributes == nil { + return defaultValue + } + value, ok := r.attributes[key] + if ok { + return value + } + return defaultValue +} + // SetAttachments ... func (r *RPCInvocation) SetAttachments(key string, value string) { r.lock.Lock() From 5246e5666b1bd8b727efc3a5cd2aa96054fc4c2a Mon Sep 17 00:00:00 2001 From: cvictory Date: Sun, 24 May 2020 19:20:40 +0800 Subject: [PATCH 165/167] add default value of attribute --- protocol/invocation/rpcinvocation.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index 10c0efe9cd..35474e54e6 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -52,6 +52,7 @@ func NewRPCInvocation(methodName string, arguments []interface{}, attachments ma methodName: methodName, arguments: arguments, attachments: attachments, + attributes: make(map[string]interface{}, 8), } } @@ -142,6 +143,16 @@ func (r *RPCInvocation) SetAttachments(key string, value string) { r.attachments[key] = value } +// SetAttribute. If Attributes is nil, it will be inited. +func (r *RPCInvocation) SetAttribute(key string, value interface{}) { + r.lock.Lock() + defer r.lock.Unlock() + if r.attributes == nil { + r.attributes = make(map[string]interface{}) + } + r.attributes[key] = value +} + // Invoker ... func (r *RPCInvocation) Invoker() protocol.Invoker { return r.invoker @@ -217,6 +228,12 @@ func WithAttachments(attachments map[string]string) option { } } +func WithAttributes(attributes map[string]interface{}) option { + return func(invo *RPCInvocation) { + invo.attributes = attributes + } +} + // WithInvoker ... func WithInvoker(invoker protocol.Invoker) option { return func(invo *RPCInvocation) { From 41c9d899e4948812ed2a789aebe64d3e7a30afa8 Mon Sep 17 00:00:00 2001 From: cvictory Date: Thu, 28 May 2020 13:55:12 +0800 Subject: [PATCH 166/167] fix review issue: add default construct in --- protocol/invocation/rpcinvocation.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index 35474e54e6..68fe7b9204 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -62,6 +62,9 @@ func NewRPCInvocationWithOptions(opts ...option) *RPCInvocation { for _, opt := range opts { opt(invo) } + if invo.attributes == nil { + invo.attributes = make(map[string]interface{}) + } return invo } @@ -123,9 +126,6 @@ func (r *RPCInvocation) Attributes() map[string]interface{} { func (r *RPCInvocation) AttributeByKey(key string, defaultValue interface{}) interface{} { r.lock.RLock() defer r.lock.RUnlock() - if r.attributes == nil { - return defaultValue - } value, ok := r.attributes[key] if ok { return value @@ -147,9 +147,6 @@ func (r *RPCInvocation) SetAttachments(key string, value string) { func (r *RPCInvocation) SetAttribute(key string, value interface{}) { r.lock.Lock() defer r.lock.Unlock() - if r.attributes == nil { - r.attributes = make(map[string]interface{}) - } r.attributes[key] = value } @@ -228,12 +225,6 @@ func WithAttachments(attachments map[string]string) option { } } -func WithAttributes(attributes map[string]interface{}) option { - return func(invo *RPCInvocation) { - invo.attributes = attributes - } -} - // WithInvoker ... func WithInvoker(invoker protocol.Invoker) option { return func(invo *RPCInvocation) { From 517b5211ab65b7ff06b0d06b45c46004dbb3ef22 Mon Sep 17 00:00:00 2001 From: YuzeZhang Date: Fri, 29 May 2020 16:46:22 +0800 Subject: [PATCH 167/167] Add comments for config_center --- config_center/apollo/listener.go | 6 +++--- config_center/configuration_listener.go | 4 ++-- config_center/configurator.go | 2 +- config_center/configurator/mock.go | 6 +++--- config_center/dynamic_configuration.go | 6 +++--- config_center/dynamic_configuration_factory.go | 2 +- config_center/mock_dynamic_config.go | 16 ++++++++-------- config_center/parser/configuration_parser.go | 4 ++-- config_center/zookeeper/listener.go | 8 ++++---- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go index fb257a4828..1cf65ed22b 100644 --- a/config_center/apollo/listener.go +++ b/config_center/apollo/listener.go @@ -29,7 +29,7 @@ type apolloListener struct { listeners map[config_center.ConfigurationListener]struct{} } -// NewApolloListener ... +// NewApolloListener creates a new apolloListener func NewApolloListener() *apolloListener { return &apolloListener{ listeners: make(map[config_center.ConfigurationListener]struct{}, 0), @@ -49,7 +49,7 @@ func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) { } } -// AddListener ... +// AddListener adds a listener for apollo func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { if _, ok := a.listeners[l]; !ok { a.listeners[l] = struct{}{} @@ -57,7 +57,7 @@ func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { } } -// RemoveListener ... +// RemoveListener removes listeners of apollo func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) { delete(a.listeners, l) } diff --git a/config_center/configuration_listener.go b/config_center/configuration_listener.go index e70e4f6807..541cc09286 100644 --- a/config_center/configuration_listener.go +++ b/config_center/configuration_listener.go @@ -25,12 +25,12 @@ import ( "github.com/apache/dubbo-go/remoting" ) -// ConfigurationListener ... +// ConfigurationListener for changing listener's event type ConfigurationListener interface { Process(*ConfigChangeEvent) } -// ConfigChangeEvent ... +// ConfigChangeEvent for changing listener's event type ConfigChangeEvent struct { Key string Value interface{} diff --git a/config_center/configurator.go b/config_center/configurator.go index ffa9034e05..9db4804365 100644 --- a/config_center/configurator.go +++ b/config_center/configurator.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/common" ) -// Configurator ... +// Configurator supports GetUrl and constructor type Configurator interface { GetUrl() *common.URL Configure(url *common.URL) diff --git a/config_center/configurator/mock.go b/config_center/configurator/mock.go index d294b9195d..7ec7179634 100644 --- a/config_center/configurator/mock.go +++ b/config_center/configurator/mock.go @@ -23,7 +23,7 @@ import ( "github.com/apache/dubbo-go/config_center" ) -// NewMockConfigurator ... +// NewMockConfigurator creates a new mockConfigurator func NewMockConfigurator(url *common.URL) config_center.Configurator { return &mockConfigurator{configuratorUrl: url} } @@ -32,12 +32,12 @@ type mockConfigurator struct { configuratorUrl *common.URL } -// GetUrl ... +// GetUrl gets a configuratorUrl func (c *mockConfigurator) GetUrl() *common.URL { return c.configuratorUrl } -// Configure ... +// Configure sets up param CLUSTER_KEY and cluster for url func (c *mockConfigurator) Configure(url *common.URL) { if cluster := c.GetUrl().GetParam(constant.CLUSTER_KEY, ""); cluster != "" { url.SetParam(constant.CLUSTER_KEY, cluster) diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index d6c3b06b32..ea51d9fce0 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -36,7 +36,7 @@ const ( DEFAULT_CONFIG_TIMEOUT = "10s" ) -// DynamicConfiguration ... +// DynamicConfiguration for modify listener and get properties file type DynamicConfiguration interface { Parser() parser.ConfigurationParser SetParser(parser.ConfigurationParser) @@ -61,14 +61,14 @@ type Options struct { // Option ... type Option func(*Options) -// WithGroup ... +// WithGroup assigns group to opt.Group func WithGroup(group string) Option { return func(opt *Options) { opt.Group = group } } -// WithTimeout ... +// WithTimeout assigns time to opt.Timeout func WithTimeout(time time.Duration) Option { return func(opt *Options) { opt.Timeout = time diff --git a/config_center/dynamic_configuration_factory.go b/config_center/dynamic_configuration_factory.go index 9f9b13227f..46faf86444 100644 --- a/config_center/dynamic_configuration_factory.go +++ b/config_center/dynamic_configuration_factory.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/common" ) -// DynamicConfigurationFactory ... +// DynamicConfigurationFactory gets the DynamicConfiguration type DynamicConfigurationFactory interface { GetDynamicConfiguration(*common.URL) (DynamicConfiguration, error) } diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 4d972b629a..25e2373041 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -42,7 +42,7 @@ var ( dynamicConfiguration *MockDynamicConfiguration ) -// GetDynamicConfiguration ... +// GetDynamicConfiguration returns a DynamicConfiguration func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(_ *common.URL) (DynamicConfiguration, error) { var err error once.Do(func() { @@ -88,16 +88,16 @@ type MockDynamicConfiguration struct { listener map[string]ConfigurationListener } -// AddListener ... +// AddListener adds a listener for MockDynamicConfiguration func (c *MockDynamicConfiguration) AddListener(key string, listener ConfigurationListener, _ ...Option) { c.listener[key] = listener } -// RemoveListener ... +// RemoveListener removes the listener for MockDynamicConfiguration func (c *MockDynamicConfiguration) RemoveListener(_ string, _ ConfigurationListener, _ ...Option) { } -// GetConfig ... +// GetConfig returns content of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetConfig(_ string, _ ...Option) (string, error) { return c.content, nil @@ -108,17 +108,17 @@ func (c *MockDynamicConfiguration) GetConfigs(key string, opts ...Option) (strin return c.GetConfig(key, opts...) } -// Parser ... +// Parser returns a parser of MockDynamicConfiguration func (c *MockDynamicConfiguration) Parser() parser.ConfigurationParser { return c.parser } -// SetParser ... +// SetParser sets parser of MockDynamicConfiguration func (c *MockDynamicConfiguration) SetParser(p parser.ConfigurationParser) { c.parser = p } -// GetProperties ... +// GetProperties gets content of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetProperties(_ string, _ ...Option) (string, error) { return c.content, nil } @@ -128,7 +128,7 @@ func (c *MockDynamicConfiguration) GetInternalProperty(key string, opts ...Optio return c.GetProperties(key, opts...) } -// GetRule ... +// GetRule gets properties of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetRule(key string, opts ...Option) (string, error) { return c.GetProperties(key, opts...) } diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go index f33b4ba866..6fbdc27d43 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -47,7 +47,7 @@ type ConfigurationParser interface { ParseToUrls(content string) ([]*common.URL, error) } -// DefaultConfigurationParser for support properties file in config center +// DefaultConfigurationParser for supporting properties file in config center type DefaultConfigurationParser struct{} // ConfiguratorConfig ... @@ -71,7 +71,7 @@ type ConfigItem struct { Side string `yaml:"side"` } -// Parse ... +// Parse load content func (parser *DefaultConfigurationParser) Parse(content string) (map[string]string, error) { pps, err := properties.LoadString(content) if err != nil { diff --git a/config_center/zookeeper/listener.go b/config_center/zookeeper/listener.go index 122dfaf4f2..747c4be352 100644 --- a/config_center/zookeeper/listener.go +++ b/config_center/zookeeper/listener.go @@ -33,12 +33,12 @@ type CacheListener struct { rootPath string } -// NewCacheListener ... +// NewCacheListener creates a new CacheListener func NewCacheListener(rootPath string) *CacheListener { return &CacheListener{rootPath: rootPath} } -// AddListener ... +// AddListener will add a listener if loaded func (l *CacheListener) AddListener(key string, listener config_center.ConfigurationListener) { // reference from https://stackoverflow.com/questions/34018908/golang-why-dont-we-have-a-set-datastructure @@ -50,7 +50,7 @@ func (l *CacheListener) AddListener(key string, listener config_center.Configura } } -// RemoveListener ... +// RemoveListener will delete a listener if loaded func (l *CacheListener) RemoveListener(key string, listener config_center.ConfigurationListener) { listeners, loaded := l.keyListeners.Load(key) if loaded { @@ -58,7 +58,7 @@ func (l *CacheListener) RemoveListener(key string, listener config_center.Config } } -// DataChange ... +// DataChange changes all listeners' event func (l *CacheListener) DataChange(event remoting.Event) bool { if event.Content == "" { //meanings new node