Skip to content
Snippets Groups Projects
Unverified Commit 8941796c authored by wangxiang's avatar wangxiang Committed by GitHub
Browse files

Merge pull request #1 from apache/develop

sync code
parents a7ae33fa cfbd042e
No related branches found
No related tags found
No related merge requests found
Showing
with 388 additions and 65 deletions
# 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
......
......@@ -3,6 +3,8 @@
[![Build Status](https://travis-ci.org/apache/dubbo-go.svg?branch=master)](https://travis-ci.org/apache/dubbo-go)
[![codecov](https://codecov.io/gh/apache/dubbo-go/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/apache/dubbo-go)](https://goreportcard.com/report/github.com/apache/dubbo-go)
![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)
---
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
* [Conditional 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,9 +109,8 @@ 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).
......
......@@ -3,6 +3,8 @@
[![Build Status](https://travis-ci.org/apache/dubbo-go.svg?branch=master)](https://travis-ci.org/apache/dubbo-go)
[![codecov](https://codecov.io/gh/apache/dubbo-go/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/dubbo-go)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/apache/dubbo-go?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/apache/dubbo-go)](https://goreportcard.com/report/github.com/apache/dubbo-go)
![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)
---
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)
- 路由器
* [Conditional 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,9 +107,8 @@ 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 的信息。
......
......@@ -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%
......
......@@ -41,6 +41,8 @@ const (
DEFAULT_FAILBACK_TIMES = "3"
DEFAULT_FAILBACK_TIMES_INT = 3
DEFAULT_FAILBACK_TASKS = 100
DEFAULT_REST_CLIENT = "resty"
DEFAULT_REST_SERVER = "go-restful"
)
const (
......
......@@ -174,21 +174,36 @@ const (
)
const (
CONSUMER_SIGN_FILTER = "sign"
PROVIDER_AUTH_FILTER = "auth"
SERVICE_AUTH_KEY = "auth"
AUTHENTICATOR_KEY = "authenticator"
DEFAULT_AUTHENTICATOR = "accesskeys"
DEFAULT_ACCESS_KEY_STORAGE = "urlstorage"
ACCESS_KEY_STORAGE_KEY = "accessKey.storage"
REQUEST_TIMESTAMP_KEY = "timestamp"
REQUEST_SIGNATURE_KEY = "signature"
AK_KEY = "ak"
SIGNATURE_STRING_FORMAT = "%s#%s#%s#%s"
// name of consumer sign filter
CONSUMER_SIGN_FILTER = "sign"
// name of consumer sign filter
PROVIDER_AUTH_FILTER = "auth"
// name of service filter
SERVICE_AUTH_KEY = "auth"
// key of authenticator
AUTHENTICATOR_KEY = "authenticator"
// name of default authenticator
DEFAULT_AUTHENTICATOR = "accesskeys"
// name of default url storage
DEFAULT_ACCESS_KEY_STORAGE = "urlstorage"
// key of storage
ACCESS_KEY_STORAGE_KEY = "accessKey.storage"
// key of request timestamp
REQUEST_TIMESTAMP_KEY = "timestamp"
// key of request signature
REQUEST_SIGNATURE_KEY = "signature"
// AK key
AK_KEY = "ak"
// signature format
SIGNATURE_STRING_FORMAT = "%s#%s#%s#%s"
// key whether enable signature
PARAMTER_SIGNATURE_ENABLE_KEY = "param.sign"
CONSUMER = "consumer"
ACCESS_KEY_ID_KEY = "accessKeyId"
SECRET_ACCESS_KEY_KEY = "secretAccessKey"
// consumer
CONSUMER = "consumer"
// key of access key id
ACCESS_KEY_ID_KEY = "accessKeyId"
// key of secret access key
SECRET_ACCESS_KEY_KEY = "secretAccessKey"
)
// HealthCheck Router
......
......@@ -22,5 +22,7 @@ import (
)
var (
// The value will be 10^6
// 1ms = 10^6ns
MsToNanoRate = int64(time.Millisecond / time.Nanosecond)
)
......@@ -9,10 +9,13 @@ var (
accesskeyStorages = make(map[string]func() filter.AccessKeyStorage)
)
// SetAuthenticator put the fcn into map with name
func SetAuthenticator(name string, fcn func() filter.Authenticator) {
authenticators[name] = fcn
}
// GetAuthenticator find the Authenticator with name
// if not found, it will panic
func GetAuthenticator(name string) filter.Authenticator {
if authenticators[name] == nil {
panic("authenticator for " + name + " is not existing, make sure you have import the package.")
......@@ -20,10 +23,13 @@ func GetAuthenticator(name string) filter.Authenticator {
return authenticators[name]()
}
// SetAccesskeyStorages will set the fcn into map with this name
func SetAccesskeyStorages(name string, fcn func() filter.AccessKeyStorage) {
accesskeyStorages[name] = fcn
}
// GetAccesskeyStorages find the storage with the name.
// If not found, it will panic.
func GetAccesskeyStorages(name string) filter.AccessKeyStorage {
if accesskeyStorages[name] == nil {
panic("accesskeyStorages for " + name + " is not existing, make sure you have import the package.")
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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/config/interfaces"
)
var (
configReaders = make(map[string]func() interfaces.ConfigReader)
defaults = make(map[string]string)
)
// SetConfigReaders set a creator of config reader.
func SetConfigReaders(name string, v func() interfaces.ConfigReader) {
configReaders[name] = v
}
// 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.")
}
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
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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/protocol/rest/client"
)
var (
restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8)
)
func SetRestClient(name string, fun func(restOptions *client.RestOptions) client.RestClient) {
restClients[name] = fun
}
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.")
}
return restClients[name](restOptions)
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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/protocol/rest/server"
)
var (
restServers = make(map[string]func() server.RestServer, 8)
)
func SetRestServer(name string, fun func() server.RestServer) {
restServers[name] = fun
}
func GetNewRestServer(name string) server.RestServer {
if restServers[name] == nil {
panic("restServer for " + name + " is not existing, make sure you have import the package.")
}
return restServers[name]()
}
......@@ -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()
......
intTest: 11
booleanTest: false
strTest: "strTest"
child:
strTest: "childStrTest"
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 yaml
import (
"io/ioutil"
"path"
)
import (
perrors "github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
// loadYMLConfig Load yml config byte from file
func LoadYMLConfig(confProFile string) ([]byte, error) {
if len(confProFile) == 0 {
return nil, perrors.Errorf("application configure(provider) file name is nil")
}
if path.Ext(confProFile) != ".yml" {
return nil, perrors.Errorf("application configure file name{%v} suffix must be .yml", confProFile)
}
return ioutil.ReadFile(confProFile)
}
// unmarshalYMLConfig Load yml config byte from file , then unmarshal to object
func UnmarshalYMLConfig(confProFile string, out interface{}) ([]byte, error) {
confFileStream, err := LoadYMLConfig(confProFile)
if err != nil {
return confFileStream, perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err))
}
return confFileStream, yaml.Unmarshal(confFileStream, out)
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 yaml
import (
"path/filepath"
"testing"
)
import (
"github.com/stretchr/testify/assert"
)
func TestUnmarshalYMLConfig(t *testing.T) {
conPath, err := filepath.Abs("./testdata/config.yml")
assert.NoError(t, err)
c := &Config{}
_, 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)
assert.Equal(t, "childStrTest", c.ChildConfig.StrTest)
}
func TestUnmarshalYMLConfig_Error(t *testing.T) {
c := &Config{}
_, err := UnmarshalYMLConfig("./testdata/config", c)
assert.Error(t, err)
_, err = UnmarshalYMLConfig("", c)
assert.Error(t, err)
}
type Config struct {
StrTest string `yaml:"strTest" default:"default" json:"strTest,omitempty" property:"strTest"`
IntTest int `default:"109" yaml:"intTest" json:"intTest,omitempty" property:"intTest"`
BooleanTest bool `yaml:"booleanTest" default:"true" json:"booleanTest,omitempty"`
ChildConfig ChildConfig `yaml:"child" json:"child,omitempty"`
}
type ChildConfig struct {
StrTest string `default:"strTest" default:"default" yaml:"strTest" json:"strTest,omitempty"`
}
......@@ -18,8 +18,7 @@
package config
import (
"io/ioutil"
"path"
"bytes"
"reflect"
"strconv"
"strings"
......@@ -27,7 +26,6 @@ import (
import (
perrors "github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
import (
......@@ -50,6 +48,8 @@ type BaseConfig struct {
fatherConfig interface{}
MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`
fileStream *bytes.Buffer
}
// startConfigCenter will start the config center.
......@@ -364,27 +364,4 @@ func initializeStruct(t reflect.Type, v reflect.Value) {
}
}
}
// loadYMLConfig Load yml config byte from file
func loadYMLConfig(confProFile string) ([]byte, error) {
if len(confProFile) == 0 {
return nil, perrors.Errorf("application configure(provider) file name is nil")
}
if path.Ext(confProFile) != ".yml" {
return nil, perrors.Errorf("application configure file name{%v} suffix must be .yml", confProFile)
}
return ioutil.ReadFile(confProFile)
}
// unmarshalYMLConfig Load yml config byte from file , then unmarshal to object
func unmarshalYMLConfig(confProFile string, out interface{}) error {
confFileStream, err := loadYMLConfig(confProFile)
if err != nil {
return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confProFile, perrors.WithStack(err))
}
return yaml.Unmarshal(confFileStream, out)
}
......@@ -18,7 +18,6 @@ package config
import (
"fmt"
"path/filepath"
"reflect"
"testing"
)
......@@ -518,13 +517,3 @@ func Test_initializeStruct(t *testing.T) {
return consumerConfig.References != nil
})
}
func TestUnmarshalYMLConfig(t *testing.T) {
conPath, err := filepath.Abs("./testdata/consumer_config_with_configcenter.yml")
assert.NoError(t, err)
c := &ConsumerConfig{}
assert.NoError(t, unmarshalYMLConfig(conPath, c))
assert.Equal(t, "default", c.ProxyFactory)
assert.Equal(t, "dubbo.properties", c.ConfigCenterConfig.ConfigFile)
assert.Equal(t, "100ms", c.Connect_Timeout)
}
......@@ -25,12 +25,13 @@ import (
"github.com/apache/dubbo-go/cluster/directory"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/common/yaml"
)
//RouterInit Load config file to init router config
func RouterInit(confRouterFile string) error {
fileRouterFactories := extension.GetFileRouterFactories()
bytes, err := loadYMLConfig(confRouterFile)
bytes, err := yaml.LoadYMLConfig(confRouterFile)
if err != nil {
return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confRouterFile, perrors.WithStack(err))
}
......
......@@ -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"
)
......@@ -78,6 +83,7 @@ func checkApplicationName(config *ApplicationConfig) {
// Load Dubbo Init
func Load() {
// init router
if confRouterFile != "" {
if errPro := RouterInit(confRouterFile); errPro != nil {
......@@ -89,6 +95,18 @@ func Load() {
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)
}
}
metricConfig = consumerConfig.MetricConfig
applicationConfig = consumerConfig.ApplicationConfig
......@@ -150,6 +168,18 @@ func Load() {
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)
}
}
// so, you should know that the consumer's config will be override
metricConfig = providerConfig.MetricConfig
......
......@@ -18,6 +18,7 @@
package config
import (
"bytes"
"time"
)
......@@ -30,6 +31,7 @@ import (
import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/common/yaml"
)
/////////////////////////
......@@ -57,6 +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" `
ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"`
}
// UnmarshalYAML ...
......@@ -86,13 +89,12 @@ func ConsumerInit(confConFile string) error {
if confConFile == "" {
return perrors.Errorf("application configure(consumer) file name is nil")
}
consumerConfig = &ConsumerConfig{}
err := unmarshalYMLConfig(confConFile, consumerConfig)
fileStream, err := yaml.UnmarshalYMLConfig(confConFile, consumerConfig)
if err != nil {
return perrors.Errorf("yaml.Unmarshal() = error:%v", perrors.WithStack(err))
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
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment