diff --git a/CHANGE.md b/CHANGE.md index ea2fe351cfffb81e0f89f340f402ce218b32fbf1..ad8bc594cd92ea0c72a284a262cc0cb3630cbeac 100644 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,34 @@ # Release Notes --- +## 1.4.0 +### New Features + +- [Condition router](https://github.com/apache/dubbo-go/pull/294) +- [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) +- [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) +- [Healthy instance first router](https://github.com/apache/dubbo-go/pull/389) +- [User can add attachments for dubbo protocol](https://github.com/apache/dubbo-go/pull/398) +- [K8s as registry](https://github.com/apache/dubbo-go/pull/400) +- [Rest protocol](https://github.com/apache/dubbo-go/pull/352) + +### Enhancement + +- [Reduce the scope of lock in zk listener](https://github.com/apache/dubbo-go/pull/346) +- [Trace error of getGettyRpcClient](https://github.com/apache/dubbo-go/pull/384) +- [Refactor to add base_registry](https://github.com/apache/dubbo-go/pull/348) +- [Do not listen to directory event if zkPath ends with providers/ or consumers/](https://github.com/apache/dubbo-go/pull/359) + +### Bugfixes + +- [Handle the panic when invoker was destroyed](https://github.com/apache/dubbo-go/pull/358) +- [HessianCodec failed to check package header length](https://github.com/apache/dubbo-go/pull/381) + + ## 1.3.0 ### New Features diff --git a/README.md b/README.md index 1dde951d350e6ee51f3f2aeeac7bb516b1b999be..e43b1e9aed6b82b2e367edf43728aee24a521d68 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [](https://travis-ci.org/apache/dubbo-go) [](https://codecov.io/gh/apache/dubbo-go) [](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc) +[](https://goreportcard.com/report/github.com/apache/dubbo-go) + --- Apache Dubbo Go Implementation. @@ -50,16 +52,22 @@ Finished List: * Dubbo * Jsonrpc2.0 * [gRPC](https://github.com/apache/dubbo-go/pull/311) + * [RESTful](https://github.com/apache/dubbo-go/pull/352) + +- Router + * [Condition router](https://github.com/apache/dubbo-go/pull/294) - Registry * ZooKeeper * [etcd v3](https://github.com/apache/dubbo-go/pull/148) * [nacos](https://github.com/apache/dubbo-go/pull/151) * [consul](https://github.com/apache/dubbo-go/pull/121) + * [k8s](https://github.com/apache/dubbo-go/pull/400) - Dynamic Configure Center & Service Management Configurator * Zookeeper * [apollo](https://github.com/apache/dubbo-go/pull/250) + * [nacos](https://github.com/apache/dubbo-go/pull/357) - Cluster Strategy * Failover @@ -86,6 +94,10 @@ Finished List: - Invoke * [generic invoke](https://github.com/apache/dubbo-go/pull/122) + +- Monitor + * Opentracing API + * Prometheus - Others: * start check @@ -97,13 +109,12 @@ Finished List: Working List: -- Registry: k8s - Metadata Center (dubbo v2.7.x) -- Metrics: Opentracing/Promethus(dubbo v2.7.x) +- Service Discovery (dubbo v2.7.x) You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap). - + ## Document diff --git a/README_CN.md b/README_CN.md index ade924e7a9a6206b6e935e084d68679957dd7fcb..e70e6786313d6a012f377f2e349880740b30c50b 100644 --- a/README_CN.md +++ b/README_CN.md @@ -3,6 +3,8 @@ [](https://travis-ci.org/apache/dubbo-go) [](https://codecov.io/gh/apache/dubbo-go) [](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc) +[](https://goreportcard.com/report/github.com/apache/dubbo-go) + --- Apache Dubbo Go 璇█瀹炵幇 @@ -49,16 +51,22 @@ Apache License, Version 2.0 * Dubbo * Jsonrpc2.0 * [gRPC](https://github.com/apache/dubbo-go/pull/311) - + * [RESTful](https://github.com/apache/dubbo-go/pull/352) + +- 璺敱鍣� + * [Condition router](https://github.com/apache/dubbo-go/pull/294) + - 娉ㄥ唽涓績 * ZooKeeper * [etcd v3](https://github.com/apache/dubbo-go/pull/148) * [nacos](https://github.com/apache/dubbo-go/pull/151) * [consul](https://github.com/apache/dubbo-go/pull/121) + * [k8s](https://github.com/apache/dubbo-go/pull/400) - 鍔ㄦ€侀厤缃腑蹇冧笌鏈嶅姟娌荤悊閰嶇疆鍣� * Zookeeper * [apollo](https://github.com/apache/dubbo-go/pull/250) + * [nacos](https://github.com/apache/dubbo-go/pull/357) - 闆嗙兢绛栫暐 * Failover @@ -84,6 +92,10 @@ Apache License, Version 2.0 - 璋冪敤 * [娉涘寲璋冪敤](https://github.com/apache/dubbo-go/pull/122) + +- 鐩戞帶 + * Opentracing API + * Prometheus - 鍏朵粬鍔熻兘鏀寔: * 鍚姩鏃舵鏌� @@ -95,13 +107,12 @@ Apache License, Version 2.0 寮€鍙戜腑鍒楄〃: -- 娉ㄥ唽涓績: k8s - 鍏冩暟鎹腑蹇� (dubbo v2.7.x) -- Metrics: Opentracing/Promethus(dubbo v2.7.x) +- 鏈嶅姟鍙戠幇 (dubbo v2.7.x) 浣犲彲浠ラ€氳繃璁块棶 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 鐭ラ亾鏇村鍏充簬 dubbo-go 鐨勪俊鎭€� - + ## 鏂囨。 diff --git a/before_ut.bat b/before_ut.bat index abe7fc250ef44bf01396ae20c4dacc9db3f60ce2..5e1c877af229b2b30bffc8b802cc35b6aab6c80a 100644 --- a/before_ut.bat +++ b/before_ut.bat @@ -14,10 +14,10 @@ :: See the License for the specific language governing permissions and :: limitations under the License. -set zkJarName="zookeeper-3.4.9-fatjar.jar" +set zkJarName=zookeeper-3.4.9-fatjar.jar set remoteJarUrl="https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/%zkJarName%" -set zkJarPath="remoting/zookeeper/zookeeper-4unittest/contrib/fatjar" -set zkJar="%zkJarPath%/%zkJarName%" +set zkJarPath=remoting/zookeeper/zookeeper-4unittest/contrib/fatjar +set zkJar=%zkJarPath%/%zkJarName% if not exist "%zkJar%" ( md %zkJarPath% diff --git a/common/extension/rest_config_reader.go b/common/extension/config_reader.go similarity index 50% rename from common/extension/rest_config_reader.go rename to common/extension/config_reader.go index 1bd338cc203583636a8c2c94213ea4c14bea2ae5..aced5b0281ff9313461425e5ec6d70d562c6c947 100644 --- a/common/extension/rest_config_reader.go +++ b/common/extension/config_reader.go @@ -18,24 +18,33 @@ package extension import ( - "github.com/apache/dubbo-go/config/rest/config_reader" + "github.com/apache/dubbo-go/config/interfaces" ) var ( - restConfigReaders = make(map[string]func() config_reader.RestConfigReader) + configReaders = make(map[string]func() interfaces.ConfigReader) + defaults = make(map[string]string) ) -func SetRestConfigReader(name string, fun func() config_reader.RestConfigReader) { - restConfigReaders[name] = fun +// SetConfigReaders set a creator of config reader. +func SetConfigReaders(name string, v func() interfaces.ConfigReader) { + configReaders[name] = v } -func GetSingletonRestConfigReader(name string) config_reader.RestConfigReader { - if name == "" { - name = "default" +// GetConfigReaders get 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.") } - if restConfigReaders[name] == nil { - panic("restConfigReaders for " + name + " is not existing, make sure you have import the package.") - } - return restConfigReaders[name]() + return configReaders[name]() +} + +// SetDefaultConfigReader set {name} to default config reader for {module} +func SetDefaultConfigReader(module, name string) { + defaults[module] = name +} +// GetDefaultConfigReader +func GetDefaultConfigReader() map[string]string { + return defaults } diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 6765a810a5ed48d95f49b5b97fbf660dd8587715..68ba3ff7882837a9419c5e47228461af11fd79ba 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -140,6 +140,14 @@ func (p *Proxy) Implement(v common.RPCService) { inv.SetAttachments(k, value) } + // add user setAttachment + atm := invCtx.Value("attachment") + if m, ok := atm.(map[string]string); ok { + for k, value := range m { + inv.SetAttachments(k, value) + } + } + result := p.invoke.Invoke(invCtx, inv) err = result.Error() diff --git a/common/yaml/yaml.go b/common/yaml/yaml.go index 1d8ac65e90d0e041647c70db07b92b9df5d9644d..7c31d71c35fff547d2ed0a765e8245717148a451 100644 --- a/common/yaml/yaml.go +++ b/common/yaml/yaml.go @@ -41,10 +41,10 @@ func LoadYMLConfig(confProFile string) ([]byte, error) { } // unmarshalYMLConfig Load yml config byte from file , then unmarshal to object -func UnmarshalYMLConfig(confProFile string, out interface{}) error { +func UnmarshalYMLConfig(confProFile string, out interface{}) ([]byte, error) { confFileStream, err := LoadYMLConfig(confProFile) if err != nil { - return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err)) + return confFileStream, perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err)) } - return yaml.Unmarshal(confFileStream, out) + return confFileStream, yaml.Unmarshal(confFileStream, out) } diff --git a/common/yaml/yaml_test.go b/common/yaml/yaml_test.go index 994e1595c44c3de6745707835866411163b8934c..45eee59048c1c074b9c386e26cc7a2252896e6ea 100644 --- a/common/yaml/yaml_test.go +++ b/common/yaml/yaml_test.go @@ -30,7 +30,8 @@ func TestUnmarshalYMLConfig(t *testing.T) { conPath, err := filepath.Abs("./testdata/config.yml") assert.NoError(t, err) c := &Config{} - assert.NoError(t, UnmarshalYMLConfig(conPath, c)) + _, err = UnmarshalYMLConfig(conPath, c) + assert.NoError(t, err) assert.Equal(t, "strTest", c.StrTest) assert.Equal(t, 11, c.IntTest) assert.Equal(t, false, c.BooleanTest) @@ -39,8 +40,10 @@ func TestUnmarshalYMLConfig(t *testing.T) { func TestUnmarshalYMLConfig_Error(t *testing.T) { c := &Config{} - assert.Error(t, UnmarshalYMLConfig("./testdata/config", c)) - assert.Error(t, UnmarshalYMLConfig("", c)) + _, err := UnmarshalYMLConfig("./testdata/config", c) + assert.Error(t, err) + _, err = UnmarshalYMLConfig("", c) + assert.Error(t, err) } type Config struct { diff --git a/config/base_config.go b/config/base_config.go index 787297c1857647aa570f4404d2365e49174bda1c..93c0ce6a6692193e7ea7b1b9f2f74e9eaed0c858 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -18,6 +18,7 @@ package config import ( + "bytes" "reflect" "strconv" "strings" @@ -47,6 +48,8 @@ type BaseConfig struct { fatherConfig interface{} MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"` + + fileStream *bytes.Buffer } // startConfigCenter will start the config center. @@ -361,5 +364,4 @@ func initializeStruct(t reflect.Type, v reflect.Value) { } } - } diff --git a/config/config_loader.go b/config/config_loader.go index 138106541c6acd691c9dffd209191ffe0c07e886..c0687d8fc162331afc5098e347d4bbba6a1750c6 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -24,9 +24,14 @@ import ( "time" ) +import ( + 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" "github.com/apache/dubbo-go/common/logger" ) @@ -90,10 +95,19 @@ func Load() { if consumerConfig == nil { logger.Warnf("consumerConfig is nil!") } else { - // init rest consumer config - if err := ConsumerRestConfigInit(consumerConfig.RestConfigType); err != nil { - log.Printf("[initConsumerRestConfig] %#v", err) + // 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 @@ -154,10 +168,19 @@ func Load() { if providerConfig == nil { logger.Warnf("providerConfig is nil!") } else { - // init rest provider config - if err := ProviderRestConfigInit(providerConfig.RestConfigType); err != nil { - log.Printf("[initProviderRestConfig] %#v", err) + // 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 diff --git a/config/consumer_config.go b/config/consumer_config.go index c3fe12d7036371636cd0d4531b49fec976b906d8..1fa68415bfc3c7e622c0b455e9945c926fed4df2 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -18,6 +18,7 @@ package config import ( + "bytes" "time" ) @@ -58,7 +59,7 @@ type ConsumerConfig struct { ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf"` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" ` ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf" ` - RestConfigType string `default:"default" yaml:"rest_config_type" json:"rest_config_type,omitempty" property:"rest_config_type"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML ... @@ -89,10 +90,11 @@ func ConsumerInit(confConFile string) error { return perrors.Errorf("application configure(consumer) file name is nil") } consumerConfig = &ConsumerConfig{} - err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) + fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig) if err != nil { return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) } + consumerConfig.fileStream = bytes.NewBuffer(fileStream) //set method interfaceId & interfaceName for k, v := range consumerConfig.References { //set id for reference @@ -116,6 +118,7 @@ func ConsumerInit(confConFile string) error { } } logger.Debugf("consumer config{%#v}\n", consumerConfig) + return nil } @@ -139,5 +142,6 @@ func configCenterRefreshConsumer() error { return perrors.WithMessagef(err, "time.ParseDuration(Connect_Timeout{%#v})", consumerConfig.Connect_Timeout) } } - return err + + return nil } diff --git a/config/generic_service.go b/config/generic_service.go index 9895486e977a9848e576597f31b724d51d144d4e..b66e399f9e5f467e51c8eccf465f926ac44299d5 100644 --- a/config/generic_service.go +++ b/config/generic_service.go @@ -17,9 +17,11 @@ package config +import "context" + // GenericService ... type GenericService struct { - Invoke func(req []interface{}) (interface{}, error) `dubbo:"$invoke"` + Invoke func(ctx context.Context, req []interface{}) (interface{}, error) `dubbo:"$invoke"` referenceStr string } diff --git a/config/interfaces/config_reader.go b/config/interfaces/config_reader.go new file mode 100644 index 0000000000000000000000000000000000000000..23f2225e1bd670d43065f3b6eca08385a5c964a2 --- /dev/null +++ b/config/interfaces/config_reader.go @@ -0,0 +1,9 @@ +package interfaces + +import "bytes" + +// ConfigReader +type ConfigReader interface { + ReadConsumerConfig(reader *bytes.Buffer) error + ReadProviderConfig(reader *bytes.Buffer) error +} diff --git a/config/provider_config.go b/config/provider_config.go index d8562863ed8da68c3688afa739bed63b7a82b343..14b77cafb3487754b9583d3b4e64ff605394b7db 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -17,6 +17,10 @@ package config +import ( + "bytes" +) + import ( "github.com/creasty/defaults" perrors "github.com/pkg/errors" @@ -46,7 +50,7 @@ type ProviderConfig struct { ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty" property:"protocol_conf" ` FilterConf interface{} `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf" ` ShutdownConfig *ShutdownConfig `yaml:"shutdown_conf" json:"shutdown_conf,omitempty" property:"shutdown_conf" ` - RestConfigType string `default:"default" yaml:"rest_config_type" json:"rest_config_type,omitempty" property:"rest_config_type"` + ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } // UnmarshalYAML ... @@ -77,10 +81,12 @@ func ProviderInit(confProFile string) error { return perrors.Errorf("application configure(provider) file name is nil") } providerConfig = &ProviderConfig{} - err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) + fileStream, err := yaml.UnmarshalYMLConfig(confProFile, providerConfig) if err != nil { return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err)) } + + providerConfig.fileStream = bytes.NewBuffer(fileStream) //set method interfaceId & interfaceName for k, v := range providerConfig.Services { //set id for reference diff --git a/config/rest/config_reader/reader_impl/default_config_reader.go b/config/rest/config_reader/reader_impl/default_config_reader.go deleted file mode 100644 index 89cf247483485092057c505c9b80eae0e6d23f8f..0000000000000000000000000000000000000000 --- a/config/rest/config_reader/reader_impl/default_config_reader.go +++ /dev/null @@ -1,83 +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 reader_impl - -import ( - "os" -) - -import ( - perrors "github.com/pkg/errors" -) - -import ( - "github.com/apache/dubbo-go/common/constant" - "github.com/apache/dubbo-go/common/extension" - "github.com/apache/dubbo-go/common/yaml" - "github.com/apache/dubbo-go/config/rest" - "github.com/apache/dubbo-go/config/rest/config_reader" -) - -var ( - defaultConfigReader *DefaultConfigReader -) - -func init() { - extension.SetRestConfigReader(constant.DEFAULT_KEY, GetDefaultConfigReader) -} - -type DefaultConfigReader struct { -} - -func NewDefaultConfigReader() *DefaultConfigReader { - return &DefaultConfigReader{} -} - -func (dcr *DefaultConfigReader) ReadConsumerConfig() (*rest.RestConsumerConfig, error) { - confConFile := os.Getenv(constant.CONF_CONSUMER_FILE_PATH) - if len(confConFile) == 0 { - return nil, nil - } - restConsumerConfig := &rest.RestConsumerConfig{} - err := yaml.UnmarshalYMLConfig(confConFile, restConsumerConfig) - if err != nil { - return nil, perrors.Errorf("[Rest Config] unmarshal Consumer RestYmlConfig error %v", perrors.WithStack(err)) - } - return restConsumerConfig, nil -} - -func (dcr *DefaultConfigReader) ReadProviderConfig() (*rest.RestProviderConfig, error) { - confProFile := os.Getenv(constant.CONF_PROVIDER_FILE_PATH) - if len(confProFile) == 0 { - return nil, nil - } - restProviderConfig := &rest.RestProviderConfig{} - err := yaml.UnmarshalYMLConfig(confProFile, restProviderConfig) - if err != nil { - return nil, perrors.Errorf("[Rest Config] unmarshal Provider RestYmlConfig error %v", perrors.WithStack(err)) - - } - return restProviderConfig, nil -} - -func GetDefaultConfigReader() config_reader.RestConfigReader { - if defaultConfigReader == nil { - defaultConfigReader = NewDefaultConfigReader() - } - return defaultConfigReader -} diff --git a/config/rest/config_reader/rest_config_reader.go b/config/rest/config_reader/rest_config_reader.go deleted file mode 100644 index 366cde6a0db561140570068f4a5f9d2c9690d409..0000000000000000000000000000000000000000 --- a/config/rest/config_reader/rest_config_reader.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config_reader - -import "github.com/apache/dubbo-go/config/rest" - -type RestConfigReader interface { - ReadConsumerConfig() (*rest.RestConsumerConfig, error) - ReadProviderConfig() (*rest.RestProviderConfig, error) -} diff --git a/config/rest_config_loader_test.go b/config/rest_config_loader_test.go deleted file mode 100644 index 7b2491a501428f7e5c1701d8d49fbd0048913c6f..0000000000000000000000000000000000000000 --- a/config/rest_config_loader_test.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "os" - "testing" -) - -import ( - "github.com/stretchr/testify/assert" -) - -import ( - "github.com/apache/dubbo-go/common/constant" -) - -func TestGetRestConsumerServiceConfig(t *testing.T) { - err := os.Setenv(constant.CONF_CONSUMER_FILE_PATH, "./rest/config_reader/reader_impl/testdata/consumer_config.yml") - assert.NoError(t, err) - err = ConsumerRestConfigInit("default") - assert.NoError(t, err) - serviceConfig := GetRestConsumerServiceConfig("UserProvider") - assert.NotEmpty(t, serviceConfig) - assert.NotEmpty(t, serviceConfig.RestMethodConfigsMap) - assert.NotEmpty(t, serviceConfig.RestMethodConfigsMap["GetUser"]) - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].QueryParamsMap[1], "userid") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].HeadersMap[3], "age") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].PathParamsMap[4], "time") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Body, 0) - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Produces, "application/xml") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Consumes, "application/xml") - assert.Equal(t, serviceConfig.Client, "resty1") -} - -func TestGetRestProviderServiceConfig(t *testing.T) { - err := os.Setenv(constant.CONF_PROVIDER_FILE_PATH, "./rest/config_reader/reader_impl/testdata/provider_config.yml") - assert.NoError(t, err) - err = ProviderRestConfigInit("default") - assert.NoError(t, err) - serviceConfig := GetRestProviderServiceConfig("UserProvider") - assert.NotEmpty(t, serviceConfig) - assert.NotEmpty(t, serviceConfig.RestMethodConfigsMap) - assert.NotEmpty(t, serviceConfig.RestMethodConfigsMap["GetUser"]) - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].QueryParamsMap[1], "userid") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].HeadersMap[3], "age") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].PathParamsMap[4], "time") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Body, 0) - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Produces, "application/xml") - assert.Equal(t, serviceConfig.RestMethodConfigsMap["GetUser"].Consumes, "application/xml") - assert.Equal(t, serviceConfig.Server, "go-restful1") - -} diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go index f342dc62e765f8d38c9e64ba3be03f3362f0bf61..f33b4ba866da69e1d23b493f42152bbb0f437878 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -233,18 +233,10 @@ func getParamString(item ConfigItem) (string, error) { "you want to change in the rule.") } for k, v := range params { - retStr = retStr + "&" - retStr = retStr + k - retStr = retStr + "=" - retStr = retStr + v + retStr += "&" + k + "=" + v } - if len(item.ProviderAddresses) >= 0 { - retStr = retStr + "&" - retStr = retStr + constant.OVERRIDE_PROVIDERS_KEY - retStr = retStr + "=" - retStr = retStr + strings.Join(item.ProviderAddresses, ",") - } + retStr += "&" + constant.OVERRIDE_PROVIDERS_KEY + "=" + strings.Join(item.ProviderAddresses, ",") return retStr, nil } diff --git a/doc/apache/apache-release-procedure-20200306.md b/doc/apache/apache-release-procedure-20200306.md new file mode 100644 index 0000000000000000000000000000000000000000..3f677ff56b8a97f881ae3d1b9bf842754ddb05ab --- /dev/null +++ b/doc/apache/apache-release-procedure-20200306.md @@ -0,0 +1,448 @@ + +# Apache 杞欢鍙戠増娴佺▼ + +> author: wongoo@apache.org +> last updated: 2020-03-06 + +Apache寮€婧愯蒋浠舵槸鏈夌ぞ鍖洪┍鍔ㄧ殑锛屼负浜嗘彁楂樺彂甯冭蒋浠惰川閲忚€屾寚瀹氫簡杞欢鍙戝竷娴佺▼锛屾湰鏂囦富瑕佷粙缁嶆娴佺▼锛屼互缁欑涓€娆″彂甯冩墦鍖呯殑apacher鍙傝€冦€� + +濡傛灉浣犺鍑嗗鎵撳寘涓€涓猘pache杞欢浜嗭紝鎯冲繀浣犲凡缁忔槸涓€涓」鐩殑committer浜嗭紝鑰屼笖鐭ラ亾绀惧尯銆丳MC杩欎簺姒傚康锛岃€屼綘鐜板湪杩樻媴浠绘湰娆″彂甯冪殑 release manager 涓€鑱屻€� + +鍙戠増娴佺▼鍏跺疄涔熷緢绠€鍗曪紝鏃犻潪濡備笅锛� +1. 鏁寸悊鍙樻洿鍐呭锛屾墦鍖呭苟瀵规墦鍖呮枃浠剁鍚嶏紱 +2. 灏嗙鍚嶆枃浠朵笂浼燼pache svn浠撳簱锛� +3. 鍙戦偖浠惰绀惧尯PMC澶т浆鎶曠エ锛� +4. 鎶曠エ閫氳繃鍚庡彂涓€涓姇绁ㄧ粨鏋滈€氬憡閭欢锛� +5. 鍙戠増 +6. 鍙戠増閭欢閫氬憡绀惧尯鏂扮増鏈彂甯冿紱 + +涓嬮潰璇︾粏鏁寸悊鍙戠増鐨勪竴浜涙祦绋嬫楠わ紝浣跨敤 dubbo 鐨勫瓙椤圭洰 dubbog-go-hessian2 鍙戠増涓轰緥锛� + + +## 1. 鍙戠増鍑嗗 + +鍙戠増鏂囦欢闇€瑕佺鍚嶏紝闇€瑕佸畨瑁卲gp宸ュ叿. + +```bash +$ brew install gpg +$ gpg --version +$ gpg --full-gen-key + (1) RSA and RSA (default) <-- RSA 绫诲瀷 + What keysize do you want? (2048) 4096 <-- key澶у皬涓�4096 + 0 = key does not expire <-- 姘镐笉杩囨湡 + Real name: Liu Yang + Email address: wongoo@apache.org + Comment: CODE SIGNING KEY + + gpg: /Users/gelnyang/.gnupg/trustdb.gpg: trustdb created + gpg: key 7DB68550D366E4C0 marked as ultimately trusted + gpg: revocation certificate stored as '/Users/gelnyang/.gnupg/openpgp-revocs.d/1376A2FF67E4C477573909BD7DB68550D366E4C0.rev' + public and secret key created and signed. + + pub rsa4096 2019-10-17 [SC] + 1376A2FF67E4C477573909BD7DB68550D366E4C0 + uid Liu Yang (CODE SIGNING KEY) <wongoo@apache.org> + sub rsa4096 2019-10-17 [E] + +$ gpg --list-keys + gpg: checking the trustdb + gpg: marginals needed: 3 completes needed: 1 trust model: pgp + gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u + /Users/gelnyang/.gnupg/pubring.kbx + ---------------------------------- + pub rsa4096 2019-10-17 [SC] + 1376A2FF67E4C477573909BD7DB68550D366E4C0 + uid [ultimate] Liu Yang (CODE SIGNING KEY) <wongoo@apache.org> + sub rsa4096 2019-10-17 [E] + + +# 鍏挜鏈嶅姟鍣ㄦ槸缃戠粶涓婁笓闂ㄥ偍瀛樼敤鎴峰叕閽ョ殑鏈嶅姟鍣� +# 閫氳繃key id鍙戦€乸ublic key鍒発eyserver +$ gpg --keyserver pgpkeys.mit.edu --send-key 1376A2FF67E4C477573909BD7DB68550D366E4C0 + gpg: sending key 7DB68550D366E4C0 to hkp://pgpkeys.mit.edu +# 鍏朵腑锛宲gpkeys.mit.edu涓洪殢鎰忔寫閫夌殑keyserver锛宬eyserver鍒楄〃涓猴細https://sks-keyservers.net/status/锛屼负鐩镐簰涔嬮棿鏄嚜鍔ㄥ悓姝ョ殑锛岄€変换鎰忎竴涓兘鍙互銆� + +# 濡傛灉鏈夊涓猵ublic key锛岃缃粯璁ey銆備慨鏀� ~/.gnupg/gpg.conf +$ vi ~/.gnupg/gpg.conf +default-key 7DB68550D366E4C0 + +# 濡傛灉鏈夊涓猵ublic key, 涔熷彲浠ュ垹闄ゆ棤鐢ㄧ殑key锛� +### 鍏堝垹闄ょ閽ワ紝鍐嶅垹闄ゅ叕閽� +$ gpg --yes --delete-secret-keys shenglicao2@gmail.com ###鑰佺殑绉侀挜锛屾寚鏄庨偖绠卞嵆鍙� +$ gpg --delete-keys 1808C6444C781C0AEA0AAD4C4D6A8007D20DB8A4 + +## 鐢变簬鍏挜鏈嶅姟鍣ㄦ病鏈夋鏌ユ満鍒讹紝浠讳綍浜洪兘鍙互鐢ㄤ綘鐨勫悕涔変笂浼犲叕閽ワ紝鎵€浠ユ病鏈夊姙娉曚繚璇佹湇鍔″櫒涓婄殑鍏挜鐨勫彲闈犳€с€� +## 閫氬父锛屼綘鍙互鍦ㄧ綉绔欎笂鍏竷涓€涓叕閽ユ寚绾癸紝璁╁叾浠栦汉鏍稿涓嬭浇鍒扮殑鍏挜鏄惁涓虹湡銆� +# fingerprint鍙傛暟鐢熸垚鍏挜鎸囩汗锛� +$ gpg --fingerprint wongoo + + pub rsa4096 2019-10-17 [SC] + 1376 A2FF 67E4 C477 5739 09BD 7DB6 8550 D366 E4C0 + uid [ultimate] Liu Yang (CODE SIGNING KEY) <wongoo@apache.org> + sub rsa4096 2019-10-17 [E] + # 灏嗕笂闈㈢殑 fingerprint 锛堝嵆 1376 A2FF 67E4 C477 5739 09BD 7DB6 8550 D366 E4C0锛夌矘璐村埌鑷繁鐨勭敤鎴蜂俊鎭腑锛� + # https://id.apache.org OpenPGP Public Key Primary Fingerprint: +``` + +> 璇︾粏鍙傝€冿細 +> - 鍙戝竷绛惧悕: http://www.apache.org/dev/release-signing.html +> - 鍙戝竷绛栫暐: http://www.apache.org/dev/release-distribution +> - 灏嗗瘑閽ヤ笂浼犲埌鍏叡瀵嗛挜鏈嶅姟鍣�: https://www.apache.org/dev/openpgp.html#generate-key + +## 2. 鎵撳寘绛惧悕 + +鍑嗗鎵撳寘鍓嶏紙灏ゅ叾鎻愮涓€娆℃墦鍖咃級闇€瑕佹敞鎰忎互涓嬪唴瀹�: +- 姣忎釜鏂囦欢鐨凩ICENSE澶撮儴鏄惁姝g‘, 鍖呮嫭 `*.java`, `*.go`, `*.xml`, `Makefile` 绛� +- LICENSE 鏂囦欢鏄惁瀛樺湪 +- NOTICE 鏂囦欢鏄惁瀛樺湪 +- CHANGE.md 鏄惁瀛樺湪 锛堝彉鏇村唴瀹规牸寮忕鍚堣鑼冿級 + +浠ヤ笂鍙互鍙傝€冨叾浠栧凡鍙戝竷椤圭洰鐨勯厤缃€� + + +``` + +# NOTICE: 杩欓噷鍒囧垎鏀紝鍒嗘敮鍚嶇О涓嶈鍜岀増鏈彿锛坱ag鐢級绫讳技锛屼笉鐒朵細鏈夊啿绐� +$ git checkout -b 1.4 + +$ git tag -a v1.4.0-rc1 -m "v1.4.0 release candidate 1" + +$ git push --tags + +# 鎵撳寘 +$ git archive --format=tar 1.4 --prefix=dubbo-go-hessian2-v1.4.0/ | gzip > dubbo-go-hessian2-v1.4.0-src.tar.gz + +# 绛惧悕 +$ gpg -u wongoo@apache.org --armor --output dubbo-go-hessian2-v1.4.0-src.tar.gz.asc --detach-sign dubbo-go-hessian2-v1.4.0-src.tar.gz + +# 楠岃瘉绛惧悕 +$ gpg --verify dubbo-go-hessian2-v1.4.0-src.tar.gz.asc dubbo-go-hessian2-v1.4.0-src.tar.gz + +# hash +$ shasum -a 512 dubbo-go-hessian2-v1.4.0-src.tar.gz > dubbo-go-hessian2-v1.4.0-src.tar.gz.sha512 + +# 楠岃瘉 hash +$ shasum --check dubbo-go-hessian2-v1.4.0-src.tar.gz.sha512 + +``` + +> 鍙戝竷鐗堟湰: http://www.apache.org/dev/release-publishing.html + +## 3. 涓婁紶鎵撳寘鏂囦欢鍒皊vn浠撳簱 + +``` +$ svn checkout https://dist.apache.org/repos/dist/dev/dubbo + +$ cd dubbo + +# 鏇存柊 +$ svn update + +# 娣诲姞 绛惧悕 鍜� public key 鍒癒EYS鏂囦欢骞舵彁浜ゅ埌SVN浠撳簱 +# 杩欓噷鏄皢鍏挜KEYS鏀惧埌鏍圭洰褰�, 鏈夌殑椤圭洰鏀惧埌鏈鎵撳寘鏂囦欢鐩綍 +$ (gpg --list-sigs wongoo && gpg --armor --export wongoo) >> KEYS + +$ mkdir -p dubbo-go-hessian2/v1.4.0-rc1 + +# 鎷疯礉鐩稿叧鏂囦欢鍒版柊寤虹洰褰曚笅 + +$ tree dubbo-go-hessian2 +dubbo-go-hessian2 +鈹斺攢鈹€ v1.4.0-rc1 + 鈹溾攢鈹€ dubbo-go-hessian2-v1.4.0-src.tar.gz + 鈹溾攢鈹€ dubbo-go-hessian2-v1.4.0-src.tar.gz.asc + 鈹斺攢鈹€ dubbo-go-hessian2-v1.4.0-src.tar.gz.sha512 + +$ svn add dubbo-go-hessian2 +$ svn add dubbo-go-hessian2/* +$ svn status +$ svn commit --username wongoo -m "Release dubbo-go-hessian2 v1.4.0-rc1" +``` + +> 璇︾粏鍙傝€�: svn鐗堟湰绠$悊 https://www.apache.org/dev/version-control.html + + +## 4. 鍙戞姇绁� [VOTE] 閭欢 + +鍙戜换浣曢偖浠堕兘鏄湁涓€瀹氭牸寮忕殑锛屼綘鍔犲叆绀惧尯閭欢鍒楄〃鍚庯紝灏变細鏀跺埌寰堝杩欐牱鐨勯偖浠讹紝澶氱湅鐪嬪氨鐭ラ亾浜嗭紝鍏蜂綋閭欢鑼冩湰鍙傝€冩枃绔犲悗闈㈢殑閭欢鑼冩湰銆� + +鍙戝畬銆怴OTE銆戦偖浠讹紝绉佷笅娌熼€氱兢閲岄潰璇峰ぇ浣琍MC鎶曠エ銆� +PMC鎶曠エ浼氬浣犱笂浼犳墦鍖呮枃浠惰繘琛岀浉鍏虫鏌�, +璇︾粏鍙互浜嗚В瀛靛寲涓殑椤圭洰鍙戝竷瀹屾暣鐨勬鏌ラ」鍙傝€冿細 https://cwiki.apache.org/confluence/display/INCUBATOR2/IncubatorReleaseChecklist + +鏀跺埌3涓猙inding閭欢涓旇秴杩�72灏忔椂鍚庯紝灏卞彲浠ュ彂 鎶曠エ缁撴灉 [RESULT] [VOTE] 閭欢浜嗐€� + +> 鍘熷垯涓婂彧鏈塒MC鐨勬姇绁ㄦ墠绠梑inding閭欢, 褰撶劧涔熷彲浠ョ敱绀惧尯鍐冲畾銆� + +杩欎竴姝ラ鏈€甯歌鏈変互涓嬮棶棰橈細 +- 鏂囦欢绛惧悕鏈夐棶棰� +- 寮曠敤椤圭洰LICENSE闂 +- 鍗曞厓娴嬭瘯涓嶉€氳繃 + +> 鍙﹀闇€瑕佹敞鎰�: 涓€涓猘pache椤圭洰鍙兘鍖呭惈寰堝瀛愰」鐩紝椤圭洰鐨凱MC鍙兘鍙涓婚」鐩瘮杈冧簡瑙o紝 浠栦滑骞朵笉娓呮濡備綍灏嗗瓙椤圭洰璺戣捣鏉ワ紝涔熶笉鐭ラ亾濡備綍璺戝崟鍏冩祴璇曪紝鏈€濂藉湪閭欢涓檮甯︿竴涓浣曡繘琛屽崟鍏冩祴璇曠殑杩炴帴銆備緥濡� PMC 鏈€浜嗚В java锛屼絾瀛愰」鐩槸golang锛宲ython锛宩s绛夛紝浣犻渶瑕佸憡璇変粬浠浣曟祴璇曚綘鐨勯」鐩€� + +鍙互鍙傝€冩姇绁ㄨ鍒�: https://www.apache.org/foundation/voting.html + +## 5. 鍙戝竷鐗堟湰 + +褰撴寮忓彂甯冩姇绁ㄦ垚鍔熷悗锛屽厛鍙慬Result]閭欢锛岀劧鍚庡氨鍑嗗 release package銆� +灏嗕箣鍓嶅湪dev涓嬪彂甯冪殑瀵瑰簲rc鏂囦欢澶逛笅鐨勬簮鐮佸寘銆佺鍚嶆枃浠跺拰hash鏂囦欢鎷疯礉鍒板彟涓€涓洰褰� v1.4.0锛� +娉ㄦ剰鏂囦欢鍚嶅瓧涓笉瑕乺cxx (鍙互rename锛屼絾涓嶈閲嶆柊璁$畻绛惧悕锛宧ash鍙互閲嶆柊璁$畻锛岀粨鏋滀笉浼氬彉)銆� + +灏唕elease鍖呯Щ鍔ㄥ埌姝e紡鐗堢洰褰曘€傚鏋滀綘鐨勮蒋浠舵槸闇€瑕佸鎴蜂粠apache涓嬭浇鐨勶紝鍒欒繖涓€姝ユ槸蹇呴』鐨勩€傚鏋滀笉鏄紝姣斿golang寮曠敤github鎵撳寘鍦板潃鐨勫垯鍙互蹇界暐銆� +``` +svn up +cd dubbo-go-hessian2 +svn move v1.4.0-rc1 v1.4.0 +svn status +svn commit --username wongoo -m "Release dubbo-go-hessian2 v1.4.0" +``` + +绉诲埌鍙戠増鐩綍鍚庯紝杩橀渶瑕佽繘琛岀浉搴旂殑姝e紡鐗堟湰鍙戝竷锛� 杩欓噷灏嗗叿浣撳彂甯冩柟寮忔暣鐞嗗埌鍗曠嫭鐨勭珷鑺� `7. 涓嶅悓璇█鐗堟湰鍙戝竷`锛屽洜涓哄彂甯冩祦绋嬮┈涓婂氨瑕佺粨鏉熶簡 ^v^ + + +## 6. 鏂扮増鏈€氬憡 ANNOUNCE 閭欢 + +鎭枩浣犱綘宸茬粡鍒板彂鐗堟渶鍚庝竴姝ヤ簡锛岄偖浠舵牸寮忓弬鑰冧互涓嬮偖浠惰寖鏈紒 + + +## 7. 涓嶅悓璇█鐗堟湰鍙戝竷 + +### 7.1 golang + +鍦� github 鍩轰簬鎶曠エ鍒嗘敮鍙戝竷浜� release 鐗堟湰銆� + +### 7.2 java + +java椤圭洰鍙戠増闇€鍙戝竷鍒癹ava maven浠撳簱銆� + +TODO + +### 7.3 js + +js椤圭洰鍙戠増闇€鍙戝竷鍒皀pm浠撳簱銆� + +TODO + +### 7.4 python + +TODO + +## 8. 閭欢鑼冩湰 + +### 8.1. 鎻愬嚭鍙戠増鎶曠エ + +- TO: dev@dubbo.apache.org +- Title: [VOTE] Release Apache dubbo-go-hessian2 v1.4.0 RC1 + +``` +Hello Dubbo/Dubbogo Community, + + This is a call for vote to release Apache dubbo-go-hessian2 version v1.4.0 RC1. + + The release candidates: https://dist.apache.org/repos/dist/dev/dubbo/dubbo-go-hessian2/v1.4.0-rc1/ + Git tag for the release: https://github.com/apache/dubbo-go-hessian2/tree/1.4 + Hash for the release tag: 4c31e88c35afe84c0321d9f12f036e6d3c8962d0 + Release Notes: https://github.com/apache/dubbo-go-hessian2/blob/1.4/CHANGE.md + The artifacts have been signed with Key :7DB68550D366E4C0, which can be found in the keys file: + https://dist.apache.org/repos/dist/dev/dubbo/KEYS + + The vote will be open for at least 72 hours or until necessary number of votes are reached. + + Please vote accordingly: + [ ] +1 approve + [ ] +0 no opinion + [ ] -1 disapprove with the reason + + Thanks, + The Apache Dubbo-go Team + ``` + + +### 8.2. PMC 鎶曠エ閭欢鍥炲 + + +鑼冧緥1锛� +``` ++1 approve <-- 棣栧厛琛ㄦ槑鍚屼笉鍚屾剰 + +I have checked: <-- 鍏舵瑕佽鏄庤嚜宸辨鏌ヤ簡鍝簺椤� + +1.source code can build <-- 鑳藉惁鏋勫缓 +2.tests can pass in my local <-- 鍗曞厓娴嬭瘯鑳藉惁閫氳繃 +3. NOTICE LICENSE file exist <-- 鍗忚鏂囦欢鏄惁瀛樺湪 +4.git tag is correct <-- git tag 鏄惁姝g‘ + +there is one minor thing that in change logs file, there is no space +between text And link. I suggest add one to make it looks better. <--- 涓€浜涘叾浠栨敼杩涘缓璁� +``` + +鑼冧緥2锛� +``` ++1 + +I checked the following items: + +[v] Are release files in correct location? <-- 鍙戝竷鏂囦欢鐩綍鏄惁姝g‘ +[v] Do release files have the word incubating in their name? +[v] Are the digital signature and hashes correct? <-- 绛惧悕銆乭ash鏄惁姝g‘ +[v] Do LICENSE and NOTICE files exists? +[v] Is the LICENSE and NOTICE text correct? <-- 鍗忚鏂囨湰鏄惁姝g‘ +[v] Is the NOTICE year correct? <-- 娉ㄦ剰骞翠唤鏄惁姝g‘ +[v] Un-included software dependencies are not mentioned in LICENSE or NOTICE? <-- 娌℃湁鍖呭惈鍗忚鎴栨敞鎰忔病鏈夋彁鍒扮殑杞欢渚濊禆 +[v] License information is not mentioned in NOTICE? <-- 鍗忚淇℃伅娌℃湁鍦ㄦ敞鎰忎腑鎻愬強 +[x] Is there any 3rd party code contained inside the release? If so: <-- 鏄惁鍖呭惈绗笁鏂逛唬鐮� + [ ] Does the software have a compatible license? + [ ] Are all software licenses mentioned in LICENSE? + [ ] Is the full text of the licenses (or pointers to it) in LICENSE? + Is any of this code Apache licensed? Do they have NOTICE files? If so: + [ ] Have relevant parts of those NOTICE files been added to this NOTICE file? +[v] Do all source files have ASF headers? <-- 鏄惁鎵€鏈夋簮鐮侀兘鏈堿SF澶撮儴 +[v] Do the contents of the release match with what's tagged in version control? <-- 鍙戝竷鐨勬枃浠舵槸鍚﹀拰github涓璽ag鏍囪鐨勭増鏈竴鑷� +[x] Are there any unexpected binary files in the release? <-- 鏄惁鍖呭惈涓嶅簲璇ュ瓨鍦ㄧ殑浜岃繘鍒舵枃浠� +[v] Can you compile from source? Are the instruction clear? <-- 鑳藉惁缂栬瘧锛熸寚浠ゆ槸鍚︽槑纭紵 + +On my mac laptop, I could compile successfully but there's one failed unit +test against net.go. I believe this issue [1] can be fixed with [2] in the +next release. <-- 缂栬瘧闂鍙婂缓璁� + +Is the issue minor? <-- 缂栬瘧瀛樺湪鐨勯棶棰樻槸鍚﹂兘鏄緝灏忕殑锛� +[v] Yes [ ] No [ ] Unsure + +Could it possibly be fixed in the next release? <-- 鑳藉惁鍦ㄤ笅涓€鐗堟湰淇锛� +[v] Yes [ ] No [ ] Unsure + +I vote with: <-- 鎴戠殑鎶曠エ +[v] +1 release the software +[ ] +0 not sure if it should be released +[ ] -1 don鈥檛 release the software because... + +Regards, +-Ian. + +1. https://github.com/apache/dubbo-go/issues/207 +2. https://github.com/apache/dubbo-go/pull/209 +``` + +鑼冧緥3锛� +``` ++1 + +I checked the following items: + +[鈭歖 Do LICENSE and NOTICE files exists? +[鈭歖 Is the LICENSE and NOTICE text correct? +[鈭歖 Is the NOTICE year correct? +[鈭歖 Do all source files have ASF headers? +[鈭歖 Do the contents of the release match with what's tagged in version control? +[鈭歖 Can you compile from source? +I could compile successfully but there's failed units test. I run the unit +test refer to :https://github.com/apache/dubbo-go#running-unit-tests . +But I think it is not matter, the test can be fixed in next release. + + +I vote with: +[鈭歖 +1 release the software +``` + +鑼冧緥4: +``` +Great improvement over the previous release but there are still issues from the last vote that have not been resolved. e.g. [6][7][8] + +Can someone tell me if these files [1][2][3][4][5] are just missing ASF headers or have a different license? + +If they are just missing headers and [6][7][8] explained then it +1 form me, otherwise it鈥檚 probably a -1. + +Can people please carefully check the contents, and write down what you checked, rather than just saying +1. + +I checked: +- signatures and hashes good +- LICENSE is missing the appendix (not a major issue) +- LICENSE may be is missing some information[1][2][3][4][5] +- NOTICE is fine +- No binaries in source release +- Some files are missing ASF headers or other license headers [1][2][3][4][5] - please fix + +Thanks, +Justin + +1. dubbo-go-1.1.0/cluster/loadbalance/round_robin_test.go +2. dubbo-go-1.1.0/common/extension/router_factory.go +3. dubbo-go-1.1.0/config_center/configuration_parser.go +4. dubbo-go-1.1.0/config_center/configuration_parser_test.go +5. dubbo-go-1.1.0/registry/zookeeper/listener_test.go +6. dubbo-go-1.1.0/cluster/loadbalance/least_active.go +7. dubbo-go-1.1.0/protocol/RpcStatus.go +8. dubbo-go-1.1.0/filter/impl/active_filter.go +``` + + +### 8.3. 鍙� [RESULT] [VOTE] 鎶曠エ缁撴灉閫氱煡閭欢 + +- TO: dev@dubbo.apache.org +- Title: [RESULT] [VOTE]: Release Apache dubbo-go-hessian2 v1.4.0 RC1 + + +``` +Hello Dubbo/Dubbogo Community, + +The release dubbo-go-hessian2 v1.4.0 RC1 vote finished, We鈥檝e received 3 +1 (binding) votes. + ++1 binding, Stocks Alex ++1 binding, Ian Luo ++1 binding, Jun Liu + +The vote and result thread: +https://lists.apache.org/thread.html/r8070f3b00984888069dd4ddad1bbc424cde51ea68b6ff0520e609e18%40%3Cdev.dubbo.apache.org%3E + + +The vote passed. Thanks all. +I will proceed with the formal release later. + + +Best regards, + +The Apache Dubbogo Team +``` + + +### 8.4. 鍙� Announce 鍙戠増閭欢 + +- TO: dev@dubbo.apache.org +- [ANNOUNCE] Apache Dubbo version 2.7.4 Released + +``` +Hello Community, + +The Apache Dubbo team is pleased to announce that the 2.7.4 has been +released. + +Apache Dubbo鈩� is a high-performance, java based, open source +RPC framework. Dubbo offers three key functionalities, which include +interface based remote call, fault tolerance & load balancing, and +automatic service registration & discovery. + +Both the source release[1] and the maven binary release[2] are available +now, you can also find the detailed release notes in here[3]. + + +If you have any usage questions, or have problems when upgrading or find +any problems about enhancements included in this release, please don鈥檛 +hesitate to let us know by sending feedback to this mailing list or filing +an issue on GitHub[4]. + + + +[1] http://dubbo.apache.org/en-us/blog/download.html +[2] http://central.maven.org/maven2/org/apache/dubbo +[3] https://github.com/apache/dubbo/releases +[4] https://github.com/apache/dubbo/issues +``` + +## 9. 鍙傝€� + +- dubbo鍙戝竷娴佺▼: http://dubbo.apache.org/zh-cn/docs/developers/committer-guide/release-guide_dev.html +- doris鍙戝竷娴佺▼: https://github.com/apache/incubator-doris/blob/master/docs/documentation/cn/community/release-process.md +- spark鍙戝竷娴佺▼: http://spark0apache0org.icopy.site/release-process.html + + diff --git a/doc/apache/release_note.md b/doc/apache/release_note.md new file mode 100644 index 0000000000000000000000000000000000000000..747a3348a1324cc059906fae16cb432b3bc6188d --- /dev/null +++ b/doc/apache/release_note.md @@ -0,0 +1,11 @@ +### How to release a new version? +--- + +* 1 Check the time range of NOTICE; +* 2 Add the features to the feature list of README.md/README_CN.md/CHANGE.md; +* 3 Check whether every code file has the Apache License 2.0 or not; +* 4 There should not be author info(name & email etc) exist in code file; +* 5 Run all unit tests; +* 6 Run all samples in apache/dubbo-samples/golang; +* 7 Write "What's New" by releaser who should be an apache/dubbo-go committer; +* 8 And then, u can release a new version refer to [Apache 杞欢鍙戠増娴佺▼](./apache-release-procedure-20200306.md); \ No newline at end of file diff --git a/doc/pic/arch/dubbo-go-arch.png b/doc/pic/arch/dubbo-go-arch.png index 8f8f19957b2a8639470e5c59a676a22762cc9778..87726d88484c23d6395023bb10e86009d59a1fd7 100644 Binary files a/doc/pic/arch/dubbo-go-arch.png and b/doc/pic/arch/dubbo-go-arch.png differ diff --git a/go.mod b/go.mod index 73046bc1866176d5e6b52b7bbdea70851fe32269..27bcc2b9314eef5268e79a9d0f0754ff6f975252 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.3.1-0.20200302092433-6ae5479d93a3 + github.com/apache/dubbo-go-hessian2 v1.4.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 @@ -26,6 +26,7 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.9.5 // indirect + github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/hashicorp/consul v1.5.3 github.com/hashicorp/consul/api v1.1.0 github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect diff --git a/go.sum b/go.sum index d3570af4839139dc884ff730da333f6fdbe97651..cfde0ef1bd6832cdbdffa08617eb765f88630716 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,8 @@ 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.3.1-0.20200302092433-6ae5479d93a3 h1:1HM47ILUkLaMxLKUub+WHPncqrJGEQ0KRJzSJueMDpY= -github.com/apache/dubbo-go-hessian2 v1.3.1-0.20200302092433-6ae5479d93a3/go.mod h1:VwEnsOMidkM1usya2uPfGpSLO9XUF//WQcWn3y+jFz8= +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/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= @@ -202,6 +202,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92Bcuy github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= 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 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= +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 h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/consul v1.5.3 h1:EmTWRf/cuqZk6Ug9tgFUVE9xNgJPpmBvJwJMvm+agSk= diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go index d35a2c770cd8b9bda805715889791ccf53c562db..6026f0991b926fd38de8aef3774e46b001820edd 100644 --- a/protocol/grpc/client.go +++ b/protocol/grpc/client.go @@ -22,6 +22,8 @@ import ( ) import ( + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" + "github.com/opentracing/opentracing-go" "google.golang.org/grpc" ) @@ -39,7 +41,11 @@ type Client struct { // NewClient ... func NewClient(url common.URL) *Client { - conn, err := grpc.Dial(url.Location, grpc.WithInsecure(), grpc.WithBlock()) + // if global trace instance was set , it means trace function enabled. If not , will return Nooptracer + tracer := opentracing.GlobalTracer() + conn, err := grpc.Dial(url.Location, grpc.WithInsecure(), grpc.WithBlock(), + grpc.WithUnaryInterceptor( + otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads()))) if err != nil { panic(err) } diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go index 19b9db4ac743ceefcf035d399c0bbcdd99f1fa80..cc184bf3cff83e6ed57bc41cba49c184860233dd 100644 --- a/protocol/grpc/server.go +++ b/protocol/grpc/server.go @@ -24,6 +24,8 @@ import ( ) import ( + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" + "github.com/opentracing/opentracing-go" "google.golang.org/grpc" ) @@ -63,7 +65,11 @@ func (s *Server) Start(url common.URL) { if err != nil { panic(err) } - server := grpc.NewServer() + + // if global trace instance was set , then server tracer instance can be get. If not , will return Nooptracer + tracer := opentracing.GlobalTracer() + server := grpc.NewServer( + grpc.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer))) key := url.GetParam(constant.BEAN_NAME_KEY, "") service := config.GetProviderService(key) diff --git a/config/rest_config_loader.go b/protocol/rest/config/reader/rest_config_reader.go similarity index 60% rename from config/rest_config_loader.go rename to protocol/rest/config/reader/rest_config_reader.go index 6596f7b274e8545fc8e053c3c4f88217338db9ea..873af9924b5644158024b22c24aa9eebbf1bf187 100644 --- a/config/rest_config_loader.go +++ b/protocol/rest/config/reader/rest_config_reader.go @@ -15,73 +15,79 @@ * limitations under the License. */ -package config +package reader import ( + "bytes" "strconv" "strings" ) import ( perrors "github.com/pkg/errors" + "gopkg.in/yaml.v2" ) 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/config/rest" - _ "github.com/apache/dubbo-go/config/rest/config_reader/reader_impl" + "github.com/apache/dubbo-go/config/interfaces" + "github.com/apache/dubbo-go/protocol/rest/config" ) -var ( - restConsumerServiceConfigMap map[string]*rest.RestServiceConfig - restProviderServiceConfigMap map[string]*rest.RestServiceConfig -) +const REST = "rest" -// initConsumerRestConfig ... -func ConsumerRestConfigInit(configType string) error { - consumerConfigReader := extension.GetSingletonRestConfigReader(configType) - var restConsumerConfig *rest.RestConsumerConfig - var err error - if restConsumerConfig, err = consumerConfigReader.ReadConsumerConfig(); err != nil { - return err - } - if restConsumerConfig == nil || len(restConsumerConfig.RestServiceConfigsMap) == 0 { - return perrors.New("Consumer don't has RestServiceConfigsMap ") +func init() { + extension.SetConfigReaders(REST, NewRestConfigReader) + extension.SetDefaultConfigReader(REST, REST) +} + +type RestConfigReader struct { +} + +func NewRestConfigReader() interfaces.ConfigReader { + return &RestConfigReader{} +} + +// ReadConsumerConfig read consumer config for rest protocol +func (cr *RestConfigReader) ReadConsumerConfig(reader *bytes.Buffer) error { + restConsumerConfig := &config.RestConsumerConfig{} + err := yaml.Unmarshal(reader.Bytes(), restConsumerConfig) + if err != nil { + return perrors.Errorf("[Rest Config] unmarshal Consumer error %#v", perrors.WithStack(err)) } - restConsumerServiceConfigMap = make(map[string]*rest.RestServiceConfig, len(restConsumerConfig.RestServiceConfigsMap)) + + restConsumerServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restConsumerConfig.RestServiceConfigsMap)) for key, rc := range restConsumerConfig.RestServiceConfigsMap { rc.Client = getNotEmptyStr(rc.Client, restConsumerConfig.Client, constant.DEFAULT_REST_CLIENT) rc.RestMethodConfigsMap = initMethodConfigMap(rc, restConsumerConfig.Consumes, restConsumerConfig.Produces) restConsumerServiceConfigMap[strings.TrimPrefix(key, "/")] = rc } + config.SetRestConsumerServiceConfigMap(restConsumerServiceConfigMap) return nil } -// initProviderRestConfig ... -func ProviderRestConfigInit(configType string) error { - providerConfigReader := extension.GetSingletonRestConfigReader(configType) - var restProviderConfig *rest.RestProviderConfig - var err error - if restProviderConfig, err = providerConfigReader.ReadProviderConfig(); err != nil { - return err +// ReadProviderConfig read provider config for rest protocol +func (cr *RestConfigReader) ReadProviderConfig(reader *bytes.Buffer) error { + restProviderConfig := &config.RestProviderConfig{} + err := yaml.Unmarshal(reader.Bytes(), restProviderConfig) + if err != nil { + return perrors.Errorf("[Rest Config] unmarshal Provider error %#v", perrors.WithStack(err)) } - if restProviderConfig == nil || len(restProviderConfig.RestServiceConfigsMap) == 0 { - return perrors.New("Provider don't has RestServiceConfigsMap") - } - restProviderServiceConfigMap = make(map[string]*rest.RestServiceConfig, len(restProviderConfig.RestServiceConfigsMap)) + restProviderServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restProviderConfig.RestServiceConfigsMap)) for key, rc := range restProviderConfig.RestServiceConfigsMap { rc.Server = getNotEmptyStr(rc.Server, restProviderConfig.Server, constant.DEFAULT_REST_SERVER) rc.RestMethodConfigsMap = initMethodConfigMap(rc, restProviderConfig.Consumes, restProviderConfig.Produces) restProviderServiceConfigMap[strings.TrimPrefix(key, "/")] = rc } + config.SetRestProviderServiceConfigMap(restProviderServiceConfigMap) return nil } // initProviderRestConfig ... -func initMethodConfigMap(rc *rest.RestServiceConfig, consumes string, produces string) map[string]*rest.RestMethodConfig { - mcm := make(map[string]*rest.RestMethodConfig, len(rc.RestMethodConfigs)) +func initMethodConfigMap(rc *config.RestServiceConfig, consumes string, produces string) map[string]*config.RestMethodConfig { + mcm := make(map[string]*config.RestMethodConfig, len(rc.RestMethodConfigs)) for _, mc := range rc.RestMethodConfigs { mc.InterfaceName = rc.InterfaceName mc.Path = rc.Path + mc.Path @@ -107,7 +113,7 @@ func getNotEmptyStr(args ...string) string { } // transformMethodConfig -func transformMethodConfig(methodConfig *rest.RestMethodConfig) *rest.RestMethodConfig { +func transformMethodConfig(methodConfig *config.RestMethodConfig) *config.RestMethodConfig { if len(methodConfig.PathParamsMap) == 0 && len(methodConfig.PathParams) > 0 { paramsMap, err := parseParamsString2Map(methodConfig.PathParams) if err != nil { @@ -150,23 +156,3 @@ func parseParamsString2Map(params string) (map[int]string, error) { } return m, nil } - -// GetRestConsumerServiceConfig ... -func GetRestConsumerServiceConfig(path string) *rest.RestServiceConfig { - return restConsumerServiceConfigMap[path] -} - -// GetRestProviderServiceConfig ... -func GetRestProviderServiceConfig(path string) *rest.RestServiceConfig { - return restProviderServiceConfigMap[path] -} - -// SetRestConsumerServiceConfigMap ... -func SetRestConsumerServiceConfigMap(configMap map[string]*rest.RestServiceConfig) { - restConsumerServiceConfigMap = configMap -} - -// SetRestProviderServiceConfigMap ... -func SetRestProviderServiceConfigMap(configMap map[string]*rest.RestServiceConfig) { - restProviderServiceConfigMap = configMap -} diff --git a/config/rest/config_reader/reader_impl/default_config_reader_test.go b/protocol/rest/config/reader/rest_config_reader_test.go similarity index 56% rename from config/rest/config_reader/reader_impl/default_config_reader_test.go rename to protocol/rest/config/reader/rest_config_reader_test.go index eca7436a1016af5f1500a5ba240fc86d01375730..d2dba40b9b85a6cd7772e0fee619720c79e91eb4 100644 --- a/config/rest/config_reader/reader_impl/default_config_reader_test.go +++ b/protocol/rest/config/reader/rest_config_reader_test.go @@ -15,10 +15,10 @@ * limitations under the License. */ -package reader_impl +package reader import ( - "os" + "bytes" "testing" ) @@ -27,23 +27,24 @@ import ( ) import ( - "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/yaml" + "github.com/apache/dubbo-go/protocol/rest/config" ) -func TestDefaultConfigReader_ReadConsumerConfig(t *testing.T) { - err := os.Setenv(constant.CONF_CONSUMER_FILE_PATH, "./testdata/consumer_config.yml") +func TestRestConfigReader_ReadConsumerConfig(t *testing.T) { + bs, err := yaml.LoadYMLConfig("./testdata/consumer_config.yml") assert.NoError(t, err) - reader := GetDefaultConfigReader() - config, err := reader.ReadConsumerConfig() - assert.Nil(t, err) - assert.NotEmpty(t, config) + configReader := NewRestConfigReader() + err = configReader.ReadConsumerConfig(bytes.NewBuffer(bs)) + assert.NoError(t, err) + assert.NotEmpty(t, config.GetRestConsumerServiceConfigMap()) } -func TestDefaultConfigReader_ReadProviderConfig(t *testing.T) { - err := os.Setenv(constant.CONF_PROVIDER_FILE_PATH, "./testdata/provider_config.yml") +func TestRestConfigReader_ReadProviderConfig(t *testing.T) { + bs, err := yaml.LoadYMLConfig("./testdata/provider_config.yml") + assert.NoError(t, err) + configReader := NewRestConfigReader() + err = configReader.ReadProviderConfig(bytes.NewBuffer(bs)) assert.NoError(t, err) - reader := GetDefaultConfigReader() - config, err := reader.ReadProviderConfig() - assert.Nil(t, err) - assert.NotEmpty(t, config) + assert.NotEmpty(t, config.GetRestProviderServiceConfigMap()) } diff --git a/config/rest/config_reader/reader_impl/testdata/consumer_config.yml b/protocol/rest/config/reader/testdata/consumer_config.yml similarity index 98% rename from config/rest/config_reader/reader_impl/testdata/consumer_config.yml rename to protocol/rest/config/reader/testdata/consumer_config.yml index 4cbb86fd5416817f304fcb9cadfde1989ecda908..27d7fdafeff017ef8ee2720cc06d954056f02f05 100644 --- a/config/rest/config_reader/reader_impl/testdata/consumer_config.yml +++ b/protocol/rest/config/reader/testdata/consumer_config.yml @@ -2,6 +2,9 @@ filter: "" +config_type: + rest: "rest" + # client request_timeout : "100ms" # connect timeout diff --git a/config/rest/config_reader/reader_impl/testdata/provider_config.yml b/protocol/rest/config/reader/testdata/provider_config.yml similarity index 98% rename from config/rest/config_reader/reader_impl/testdata/provider_config.yml rename to protocol/rest/config/reader/testdata/provider_config.yml index 7ca544491af11b7253917bea43352474629e20f4..71d056e7277f1a0420536e282ea31d34dddf3e14 100644 --- a/config/rest/config_reader/reader_impl/testdata/provider_config.yml +++ b/protocol/rest/config/reader/testdata/provider_config.yml @@ -1,6 +1,10 @@ # dubbo server yaml configure file filter: "" + +config_type: + rest: "rest" + # application config application: organization : "ikurento.com" diff --git a/config/rest/rest_config.go b/protocol/rest/config/rest_config.go similarity index 83% rename from config/rest/rest_config.go rename to protocol/rest/config/rest_config.go index 7262776ec3c4ea7ab6ddcd30d93227dacb83d95e..168ec8ce525fc7fd5d4a30d4f11ba7bf42d1c921 100644 --- a/config/rest/rest_config.go +++ b/protocol/rest/config/rest_config.go @@ -15,9 +15,16 @@ * limitations under the License. */ -package rest +package config -import "github.com/creasty/defaults" +import ( + "github.com/creasty/defaults" +) + +var ( + restConsumerServiceConfigMap map[string]*RestServiceConfig + restProviderServiceConfigMap map[string]*RestServiceConfig +) // RestConsumerConfig ... type RestConsumerConfig struct { @@ -114,3 +121,33 @@ func (c *RestMethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) erro } return nil } + +// GetRestConsumerServiceConfig ... +func GetRestConsumerServiceConfig(path string) *RestServiceConfig { + return restConsumerServiceConfigMap[path] +} + +// GetRestProviderServiceConfig ... +func GetRestProviderServiceConfig(path string) *RestServiceConfig { + return restProviderServiceConfigMap[path] +} + +// SetRestConsumerServiceConfigMap ... +func SetRestConsumerServiceConfigMap(configMap map[string]*RestServiceConfig) { + restConsumerServiceConfigMap = configMap +} + +// SetRestProviderServiceConfigMap ... +func SetRestProviderServiceConfigMap(configMap map[string]*RestServiceConfig) { + restProviderServiceConfigMap = configMap +} + +// GetRestConsumerServiceConfigMap ... +func GetRestConsumerServiceConfigMap() map[string]*RestServiceConfig { + return restConsumerServiceConfigMap +} + +// GetRestProviderServiceConfigMap ... +func GetRestProviderServiceConfigMap() map[string]*RestServiceConfig { + return restProviderServiceConfigMap +} diff --git a/protocol/rest/rest_invoker.go b/protocol/rest/rest_invoker.go index 02efba59d95ac6e049279b78dafdf36364b022ed..0c82035ac5eb9a52ab188baa971dbdf1b864e970 100644 --- a/protocol/rest/rest_invoker.go +++ b/protocol/rest/rest_invoker.go @@ -28,19 +28,19 @@ import ( import ( "github.com/apache/dubbo-go/common" - "github.com/apache/dubbo-go/config/rest" "github.com/apache/dubbo-go/protocol" invocation_impl "github.com/apache/dubbo-go/protocol/invocation" "github.com/apache/dubbo-go/protocol/rest/client" + "github.com/apache/dubbo-go/protocol/rest/config" ) type RestInvoker struct { protocol.BaseInvoker client client.RestClient - restMethodConfigMap map[string]*rest.RestMethodConfig + restMethodConfigMap map[string]*config.RestMethodConfig } -func NewRestInvoker(url common.URL, client *client.RestClient, restMethodConfig map[string]*rest.RestMethodConfig) *RestInvoker { +func NewRestInvoker(url common.URL, client *client.RestClient, restMethodConfig map[string]*config.RestMethodConfig) *RestInvoker { return &RestInvoker{ BaseInvoker: *protocol.NewBaseInvoker(url), client: *client, diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index cc6fd26fc6e570f0b2bb3ead1dd1ce1c3fc8cd71..9735e83853ab80c32cf4e1088df704e56e367652 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -31,11 +31,10 @@ import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/extension" "github.com/apache/dubbo-go/config" - "github.com/apache/dubbo-go/config/rest" - _ "github.com/apache/dubbo-go/config/rest/config_reader/reader_impl" "github.com/apache/dubbo-go/protocol/invocation" "github.com/apache/dubbo-go/protocol/rest/client" "github.com/apache/dubbo-go/protocol/rest/client/client_impl" + rest_config "github.com/apache/dubbo-go/protocol/rest/config" "github.com/apache/dubbo-go/protocol/rest/server/server_impl" "github.com/emicklei/go-restful/v3" ) @@ -66,8 +65,8 @@ func TestRestInvoker_Invoke(t *testing.T) { assert.NoError(t, err) con := config.ProviderConfig{} config.SetProviderConfig(con) - configMap := make(map[string]*rest.RestServiceConfig) - methodConfigMap := make(map[string]*rest.RestMethodConfig) + configMap := make(map[string]*rest_config.RestServiceConfig) + methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) queryParamsMap[1] = "age" queryParamsMap[2] = "name" @@ -75,7 +74,7 @@ func TestRestInvoker_Invoke(t *testing.T) { pathParamsMap[0] = "userid" headersMap := make(map[int]string) headersMap[3] = "Content-Type" - methodConfigMap["GetUserOne"] = &rest.RestMethodConfig{ + methodConfigMap["GetUserOne"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUserOne", Path: "/GetUserOne", @@ -88,7 +87,7 @@ func TestRestInvoker_Invoke(t *testing.T) { QueryParamsMap: nil, Body: 0, } - methodConfigMap["GetUserTwo"] = &rest.RestMethodConfig{ + methodConfigMap["GetUserTwo"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUserTwo", Path: "/GetUserTwo", @@ -101,7 +100,7 @@ func TestRestInvoker_Invoke(t *testing.T) { QueryParamsMap: nil, Body: 0, } - methodConfigMap["GetUserThree"] = &rest.RestMethodConfig{ + methodConfigMap["GetUserThree"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUserThree", Path: "/GetUserThree", @@ -114,7 +113,7 @@ func TestRestInvoker_Invoke(t *testing.T) { QueryParamsMap: nil, Body: 0, } - methodConfigMap["GetUserFour"] = &rest.RestMethodConfig{ + methodConfigMap["GetUserFour"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUserFour", Path: "/GetUserFour", @@ -127,7 +126,7 @@ func TestRestInvoker_Invoke(t *testing.T) { QueryParamsMap: nil, Body: 0, } - methodConfigMap["GetUserFive"] = &rest.RestMethodConfig{ + methodConfigMap["GetUserFive"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUserFive", Path: "/GetUserFive", @@ -135,7 +134,7 @@ func TestRestInvoker_Invoke(t *testing.T) { Consumes: "*/*", MethodType: "GET", } - methodConfigMap["GetUser"] = &rest.RestMethodConfig{ + methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUser", Path: "/GetUser/{userid}", @@ -150,16 +149,16 @@ func TestRestInvoker_Invoke(t *testing.T) { HeadersMap: headersMap, } - configMap["com.ikurento.user.UserProvider"] = &rest.RestServiceConfig{ + configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ Server: "go-restful", RestMethodConfigsMap: methodConfigMap, } - config.SetRestProviderServiceConfigMap(configMap) + rest_config.SetRestProviderServiceConfigMap(configMap) proxyFactory := extension.GetProxyFactory("default") proto.Export(proxyFactory.GetInvoker(url)) time.Sleep(5 * time.Second) - configMap = make(map[string]*rest.RestServiceConfig) - configMap["com.ikurento.user.UserProvider"] = &rest.RestServiceConfig{ + configMap = make(map[string]*rest_config.RestServiceConfig) + configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ RestMethodConfigsMap: methodConfigMap, } restClient := client_impl.NewRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second, RequestTimeout: 3 * time.Second}) diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index d068d9b6c41ed2f7c11978773ed436d8fdf46d5c..47ecb6093b4cfa12a1d3397fa45d59b1e173a93a 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -32,6 +32,8 @@ import ( "github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol/rest/client" _ "github.com/apache/dubbo-go/protocol/rest/client/client_impl" + rest_config "github.com/apache/dubbo-go/protocol/rest/config" + _ "github.com/apache/dubbo-go/protocol/rest/config/reader" "github.com/apache/dubbo-go/protocol/rest/server" _ "github.com/apache/dubbo-go/protocol/rest/server/server_impl" ) @@ -66,7 +68,7 @@ func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter { url := invoker.GetUrl() serviceKey := url.ServiceKey() exporter := NewRestExporter(serviceKey, invoker, rp.ExporterMap()) - restServiceConfig := config.GetRestProviderServiceConfig(strings.TrimPrefix(url.Path, "/")) + restServiceConfig := rest_config.GetRestProviderServiceConfig(strings.TrimPrefix(url.Path, "/")) if restServiceConfig == nil { logger.Errorf("%s service doesn't has provider config", url.Path) return nil @@ -85,7 +87,7 @@ func (rp *RestProtocol) Refer(url common.URL) protocol.Invoker { if t, err := time.ParseDuration(requestTimeoutStr); err == nil { requestTimeout = t } - restServiceConfig := config.GetRestConsumerServiceConfig(strings.TrimPrefix(url.Path, "/")) + restServiceConfig := rest_config.GetRestConsumerServiceConfig(strings.TrimPrefix(url.Path, "/")) if restServiceConfig == nil { logger.Errorf("%s service doesn't has consumer config", url.Path) return nil diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 30d41b352be60a8dcee5f2e2a6374035e853541b..8af73a1839c159fdf58c64d12e039c20bb3221c6 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -35,7 +35,7 @@ import ( "github.com/apache/dubbo-go/common/extension" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" - "github.com/apache/dubbo-go/config/rest" + rest_config "github.com/apache/dubbo-go/protocol/rest/config" ) func TestRestProtocol_Refer(t *testing.T) { @@ -52,11 +52,11 @@ func TestRestProtocol_Refer(t *testing.T) { RequestTimeout: 5 * time.Second, } config.SetConsumerConfig(con) - configMap := make(map[string]*rest.RestServiceConfig) - configMap["com.ikurento.user.UserProvider"] = &rest.RestServiceConfig{ + configMap := make(map[string]*rest_config.RestServiceConfig) + configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ Client: "resty", } - config.SetRestConsumerServiceConfigMap(configMap) + rest_config.SetRestConsumerServiceConfigMap(configMap) invoker := proto.Refer(url) // make sure url @@ -84,14 +84,14 @@ func TestRestProtocol_Export(t *testing.T) { assert.NoError(t, err) con := config.ProviderConfig{} config.SetProviderConfig(con) - configMap := make(map[string]*rest.RestServiceConfig) - methodConfigMap := make(map[string]*rest.RestMethodConfig) + configMap := make(map[string]*rest_config.RestServiceConfig) + methodConfigMap := make(map[string]*rest_config.RestMethodConfig) queryParamsMap := make(map[int]string) queryParamsMap[1] = "age" queryParamsMap[2] = "name" pathParamsMap := make(map[int]string) pathParamsMap[0] = "userid" - methodConfigMap["GetUser"] = &rest.RestMethodConfig{ + methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{ InterfaceName: "", MethodName: "GetUser", Path: "/GetUser/{userid}", @@ -104,11 +104,11 @@ func TestRestProtocol_Export(t *testing.T) { QueryParamsMap: queryParamsMap, Body: -1, } - configMap["com.ikurento.user.UserProvider"] = &rest.RestServiceConfig{ + configMap["com.ikurento.user.UserProvider"] = &rest_config.RestServiceConfig{ Server: "go-restful", RestMethodConfigsMap: methodConfigMap, } - config.SetRestProviderServiceConfigMap(configMap) + rest_config.SetRestProviderServiceConfigMap(configMap) proxyFactory := extension.GetProxyFactory("default") exporter := proto.Export(proxyFactory.GetInvoker(url)) // make sure url diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index e938c4d1e0f780cfd6c831bfd89aa46b75aa2fee..c10c98a7b677d47c43b64643a69d5b3768a6c663 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -19,13 +19,13 @@ package server import ( "github.com/apache/dubbo-go/common" - "github.com/apache/dubbo-go/config/rest" "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/rest/config" ) type RestServer interface { Start(url common.URL) - Deploy(invoker protocol.Invoker, restMethodConfig map[string]*rest.RestMethodConfig) - UnDeploy(restMethodConfig map[string]*rest.RestMethodConfig) + Deploy(invoker protocol.Invoker, restMethodConfig map[string]*config.RestMethodConfig) + UnDeploy(restMethodConfig map[string]*config.RestMethodConfig) Destroy() } diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go index a6d223b5bb9ded77b41a71fa69d296980564f61e..dd81b6c49425a91c945c9445b37e7edf2e7e3d7e 100644 --- a/protocol/rest/server/server_impl/go_restful_server.go +++ b/protocol/rest/server/server_impl/go_restful_server.go @@ -20,6 +20,7 @@ package server_impl import ( "context" "fmt" + "github.com/apache/dubbo-go/protocol/rest/server" "net" "net/http" "reflect" @@ -29,7 +30,6 @@ import ( ) import ( - "github.com/apache/dubbo-go/config/rest" "github.com/emicklei/go-restful/v3" perrors "github.com/pkg/errors" ) @@ -41,7 +41,7 @@ import ( "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/server" + "github.com/apache/dubbo-go/protocol/rest/config" ) func init() { @@ -82,7 +82,7 @@ func (grs *GoRestfulServer) Start(url common.URL) { }() } -func (grs *GoRestfulServer) Deploy(invoker protocol.Invoker, restMethodConfig map[string]*rest.RestMethodConfig) { +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 @@ -100,7 +100,7 @@ func (grs *GoRestfulServer) Deploy(invoker protocol.Invoker, restMethodConfig ma } func getFunc(methodName string, invoker protocol.Invoker, argsTypes []reflect.Type, - replyType reflect.Type, config *rest.RestMethodConfig) func(req *restful.Request, resp *restful.Response) { + replyType reflect.Type, config *config.RestMethodConfig) func(req *restful.Request, resp *restful.Response) { return func(req *restful.Request, resp *restful.Response) { var ( err error @@ -126,7 +126,7 @@ func getFunc(methodName string, invoker protocol.Invoker, argsTypes []reflect.Ty } } } -func (grs *GoRestfulServer) UnDeploy(restMethodConfig map[string]*rest.RestMethodConfig) { +func (grs *GoRestfulServer) UnDeploy(restMethodConfig map[string]*config.RestMethodConfig) { for _, config := range restMethodConfig { ws := new(restful.WebService) ws.Path(config.Path) @@ -146,7 +146,7 @@ func (grs *GoRestfulServer) Destroy() { logger.Infof("[Go Restful] Server exiting") } -func getArgsInterfaceFromRequest(req *restful.Request, config *rest.RestMethodConfig) []interface{} { +func getArgsInterfaceFromRequest(req *restful.Request, config *config.RestMethodConfig) []interface{} { argsMap := make(map[int]interface{}, 8) maxKey := 0 for k, v := range config.PathParamsMap { @@ -193,7 +193,7 @@ func getArgsInterfaceFromRequest(req *restful.Request, config *rest.RestMethodCo return args } -func getArgsFromRequest(req *restful.Request, argsTypes []reflect.Type, config *rest.RestMethodConfig) []interface{} { +func getArgsFromRequest(req *restful.Request, argsTypes []reflect.Type, config *config.RestMethodConfig) []interface{} { argsLength := len(argsTypes) args := make([]interface{}, argsLength) for i, t := range argsTypes {