Skip to content
Snippets Groups Projects
Commit 9d803c1c authored by vito.he's avatar vito.he
Browse files

Mod:resolve ci

parent aca6f801
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ import (
)
var (
metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory)
metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory, 8)
)
// SetMetadataReportFactory ...
......@@ -30,7 +30,7 @@ func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFacto
metaDataReportFactories[name] = v
}
// GetConfigCenterFactory ...
// GetMetadataReportFactory ...
func GetMetadataReportFactory(name string) metadata.MetadataReportFactory {
if metaDataReportFactories[name] == nil {
panic("metadata report for " + name + " is not existing, make sure you have import the package.")
......
......@@ -45,8 +45,6 @@ type ConsumerConfig struct {
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
// application
ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
// metadata-report
MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"`
// client
Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"`
......@@ -130,10 +128,6 @@ func ConsumerInit(confConFile string) error {
}
}
//start the metadata report if config set
if err := startMetadataReport(); err != nil {
return perrors.WithMessagef(err, "Consumer start metadata report error ,error is {%#v}", err)
}
logger.Debugf("consumer config{%#v}\n", consumerConfig)
return nil
}
......
......@@ -51,21 +51,23 @@ func (c *MetadataReportConfig) Prefix() string {
// UnmarshalYAML ...
func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil {
return err
return perrors.WithStack(err)
}
type plain MetadataReportConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
return perrors.WithStack(err)
}
return nil
}
// ToUrl ...
func (c *MetadataReportConfig) ToUrl() (*common.URL, error) {
urlMap := url.Values{}
urlMap := make(url.Values)
for k, v := range c.Params {
urlMap.Set(k, v)
if c.Params != nil {
for k, v := range c.Params {
urlMap.Set(k, v)
}
}
url, err := common.NewURL(c.Address,
......@@ -75,29 +77,34 @@ func (c *MetadataReportConfig) ToUrl() (*common.URL, error) {
common.WithLocation(c.Address),
common.WithProtocol(c.Protocol),
)
if err != nil {
if err != nil || len(url.Protocol) == 0 {
return nil, perrors.New("Invalid MetadataReportConfig.")
}
url.SetParam("metadata", url.Protocol)
return &url, nil
}
func (c *MetadataReportConfig) IsValid() bool {
return len(c.Protocol) != 0
}
// StartMetadataReport: The entry of metadata report start
func startMetadataReport() error {
metadataConfig := consumerConfig.ApplicationConfig.MetadataType
if consumerConfig.MetadataReportConfig == nil {
func startMetadataReport(metadataType string, metadataReportConfig *MetadataReportConfig) error {
if metadataReportConfig == nil || metadataReportConfig.IsValid() {
return nil
}
if metadataType == constant.METACONFIG_REMOTE {
return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.")
} else if metadataType == constant.METACONFIG_REMOTE && len(metadataReportConfig.Address) == 0 {
return perrors.New("MetadataConfig address can not be empty.")
}
if url, err := metadataReportConfig.ToUrl(); err == nil {
instance.GetMetadataReportInstance(url)
} else {
if metadataConfig == constant.METACONFIG_REMOTE {
return perrors.New("No MetadataConfig found, you must specify the remote Metadata Center address when 'metadata=remote' is enabled.")
} else if metadataConfig == constant.METACONFIG_REMOTE && len(consumerConfig.MetadataReportConfig.Address) == 0 {
return perrors.New("MetadataConfig address can not be empty.")
}
if url, err := consumerConfig.MetadataReportConfig.ToUrl(); err == nil {
instance.GetMetadataReportInstance(url)
} else {
return perrors.New("MetadataConfig is invalid!")
}
return perrors.New("MetadataConfig is invalid!")
}
return nil
}
......@@ -42,6 +42,8 @@ type ProviderConfig struct {
BaseConfig `yaml:",inline"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"`
// metadata-report
MetadataReportConfig *MetadataReportConfig `yaml:"metadata_report" json:"metadata_report,omitempty" property:"metadata_report"`
ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
Registry *RegistryConfig `yaml:"registry" json:"registry,omitempty" property:"registry"`
......@@ -104,8 +106,8 @@ func ProviderInit(confProFile string) error {
}
}
//start the metadata report if config set
if err := startMetadataReport(); err != nil {
return perrors.WithMessagef(err, "Provider start metadata report error ,error is {%#v}", err)
if err := startMetadataReport(providerConfig.ApplicationConfig.MetadataType, providerConfig.MetadataReportConfig); err != nil {
return perrors.WithMessagef(err, "Provider starts metadata report error, and the error is {%#v}", err)
}
logger.Debugf("provider config{%#v}\n", providerConfig)
......
......@@ -17,7 +17,9 @@
package metadata
import "github.com/apache/dubbo-go/common"
import (
"github.com/apache/dubbo-go/common"
)
type MetadataExporter interface {
Export() MetadataExporter
......
......@@ -56,7 +56,7 @@ func (mdi *BaseServiceMetadataIdentifier) getIdentifierKey(params ...string) str
joinParams(constant.KEY_SEPARATOR, params)
}
// getIdentifierKey...
// getFilePathKey...
func (mdi *BaseServiceMetadataIdentifier) getFilePathKey(params ...string) string {
path := serviceToPath(mdi.serviceInterface)
......
......@@ -17,7 +17,9 @@
package identifier
import "github.com/apache/dubbo-go/common/constant"
import (
"github.com/apache/dubbo-go/common/constant"
)
type ServiceMetadataIdentifier struct {
revision string
......
......@@ -17,7 +17,9 @@
package metadata
import "github.com/apache/dubbo-go/common"
import (
"github.com/apache/dubbo-go/common"
)
var (
MetadataReportInstance MetadataReport
......
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