Skip to content
Snippets Groups Projects
Commit aa3121ce authored by watermelo's avatar watermelo
Browse files

Merge branch 'develop' into featue/addCommentForConfig

parents dcbd11e1 4256d4ee
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 37 deletions
...@@ -36,12 +36,12 @@ type ApplicationConfig struct { ...@@ -36,12 +36,12 @@ type ApplicationConfig struct {
MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` //field for metadata report MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` //field for metadata report
} }
// Prefix returns ApplicationConfig prefix // nolint
func (*ApplicationConfig) Prefix() string { func (*ApplicationConfig) Prefix() string {
return constant.DUBBO + ".application." return constant.DUBBO + ".application."
} }
// UnmarshalYAML unmarshal the ApplicationConfig by @unmarshal function // UnmarshalYAML unmarshals the ApplicationConfig by @unmarshal function
func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { func (c *ApplicationConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil { if err := defaults.Set(c); err != nil {
return err return err
......
...@@ -68,7 +68,6 @@ func (c *BaseConfig) startConfigCenter() error { ...@@ -68,7 +68,6 @@ func (c *BaseConfig) startConfigCenter() error {
return err return err
} }
// prepareEnvironment prepare the environment
func (c *BaseConfig) prepareEnvironment() error { func (c *BaseConfig) prepareEnvironment() error {
factory := extension.GetConfigCenterFactory(c.ConfigCenterConfig.Protocol) factory := extension.GetConfigCenterFactory(c.ConfigCenterConfig.Protocol)
dynamicConfig, err := factory.GetDynamicConfiguration(c.configCenterUrl) dynamicConfig, err := factory.GetDynamicConfiguration(c.configCenterUrl)
......
...@@ -54,7 +54,7 @@ type ConfigCenterConfig struct { ...@@ -54,7 +54,7 @@ type ConfigCenterConfig struct {
timeout time.Duration timeout time.Duration
} }
// UnmarshalYAML unmarshal the ConfigCenterConfig by @unmarshal function // UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function
func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil { if err := defaults.Set(c); err != nil {
return err return err
......
...@@ -75,7 +75,7 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error ...@@ -75,7 +75,7 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
return nil return nil
} }
// Prefix returns ConsumerConfig prefix // nolint
func (*ConsumerConfig) Prefix() string { func (*ConsumerConfig) Prefix() string {
return constant.ConsumerConfigPrefix return constant.ConsumerConfigPrefix
} }
...@@ -85,7 +85,7 @@ func SetConsumerConfig(c ConsumerConfig) { ...@@ -85,7 +85,7 @@ func SetConsumerConfig(c ConsumerConfig) {
consumerConfig = &c consumerConfig = &c
} }
// ConsumerInit Load config file to init consumer config // ConsumerInit loads config file to init consumer config
func ConsumerInit(confConFile string) error { func ConsumerInit(confConFile string) error {
if confConFile == "" { if confConFile == "" {
return perrors.Errorf("application configure(consumer) file name is nil") return perrors.Errorf("application configure(consumer) file name is nil")
......
...@@ -52,7 +52,7 @@ import ( ...@@ -52,7 +52,7 @@ import (
* We define them by using 'package build' feature https://golang.org/pkg/go/build/ * We define them by using 'package build' feature https://golang.org/pkg/go/build/
*/ */
// GracefulShutdownInit init for graceful shutdown // nolint
func GracefulShutdownInit() { func GracefulShutdownInit() {
signals := make(chan os.Signal, 1) signals := make(chan os.Signal, 1)
...@@ -126,7 +126,7 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { ...@@ -126,7 +126,7 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) {
} }
} }
// destroy the provider's protocol. // destroyProviderProtocols destroys the provider's protocol.
// if the protocol is consumer's protocol too, we will keep it // if the protocol is consumer's protocol too, we will keep it
func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { func destroyProviderProtocols(consumerProtocols *gxset.HashSet) {
......
...@@ -31,7 +31,7 @@ const ( ...@@ -31,7 +31,7 @@ const (
defaultStepTimeout = 10 * time.Second defaultStepTimeout = 10 * time.Second
) )
// ShutdownConfig is configuration for graceful shutdown // ShutdownConfig is used as configuration for graceful shutdown
type ShutdownConfig struct { type ShutdownConfig struct {
/* /*
* Total timeout. Even though we don't release all resources, * Total timeout. Even though we don't release all resources,
...@@ -58,12 +58,12 @@ type ShutdownConfig struct { ...@@ -58,12 +58,12 @@ type ShutdownConfig struct {
RequestsFinished bool RequestsFinished bool
} }
// Prefix returns ShutdownConfig prefix // nolint
func (config *ShutdownConfig) Prefix() string { func (config *ShutdownConfig) Prefix() string {
return constant.ShutdownConfigPrefix return constant.ShutdownConfigPrefix
} }
// GetTimeout gets timeout in ShutdownConfig // nolint
func (config *ShutdownConfig) GetTimeout() time.Duration { func (config *ShutdownConfig) GetTimeout() time.Duration {
result, err := time.ParseDuration(config.Timeout) result, err := time.ParseDuration(config.Timeout)
if err != nil { if err != nil {
...@@ -74,7 +74,7 @@ func (config *ShutdownConfig) GetTimeout() time.Duration { ...@@ -74,7 +74,7 @@ func (config *ShutdownConfig) GetTimeout() time.Duration {
return result return result
} }
// GetStepTimeout gets StepTimeout in ShutdownConfig // nolint
func (config *ShutdownConfig) GetStepTimeout() time.Duration { func (config *ShutdownConfig) GetStepTimeout() time.Duration {
result, err := time.ParseDuration(config.StepTimeout) result, err := time.ParseDuration(config.StepTimeout)
if err != nil { if err != nil {
......
...@@ -19,7 +19,7 @@ package interfaces ...@@ -19,7 +19,7 @@ package interfaces
import "bytes" import "bytes"
// A ConfigReader interface is used to read config from consumer or provider // ConfigReader is used to read config from consumer or provider
type ConfigReader interface { type ConfigReader interface {
ReadConsumerConfig(reader *bytes.Buffer) error ReadConsumerConfig(reader *bytes.Buffer) error
ReadProviderConfig(reader *bytes.Buffer) error ReadProviderConfig(reader *bytes.Buffer) error
......
...@@ -43,7 +43,7 @@ type MetadataReportConfig struct { ...@@ -43,7 +43,7 @@ type MetadataReportConfig struct {
Group string `yaml:"group" json:"group,omitempty" property:"group"` Group string `yaml:"group" json:"group,omitempty" property:"group"`
} }
// Prefix returns MetadataReportConfig prefix // nolint
func (c *MetadataReportConfig) Prefix() string { func (c *MetadataReportConfig) Prefix() string {
return constant.MetadataReportPrefix return constant.MetadataReportPrefix
} }
...@@ -60,7 +60,7 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) ...@@ -60,7 +60,7 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error)
return nil return nil
} }
// ToUrl transforms MetadataReportConfig to url // nolint
func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { func (c *MetadataReportConfig) ToUrl() (*common.URL, error) {
urlMap := make(url.Values) urlMap := make(url.Values)
......
...@@ -42,7 +42,7 @@ type MethodConfig struct { ...@@ -42,7 +42,7 @@ type MethodConfig struct {
RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"`
} }
// Prefix returns MethodConfig prefix // nolint
func (c *MethodConfig) Prefix() string { func (c *MethodConfig) Prefix() string {
if len(c.InterfaceId) != 0 { if len(c.InterfaceId) != 0 {
return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "." return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "."
...@@ -51,7 +51,7 @@ func (c *MethodConfig) Prefix() string { ...@@ -51,7 +51,7 @@ func (c *MethodConfig) Prefix() string {
return constant.DUBBO + "." + c.InterfaceName + "." + c.Name + "." return constant.DUBBO + "." + c.InterfaceName + "." + c.Name + "."
} }
// UnmarshalYAML unmarshal the MethodConfig by @unmarshal function // UnmarshalYAML unmarshals the MethodConfig by @unmarshal function
func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil { if err := defaults.Set(c); err != nil {
return err return err
......
...@@ -32,7 +32,7 @@ type ProtocolConfig struct { ...@@ -32,7 +32,7 @@ type ProtocolConfig struct {
Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"`
} }
// Prefix returns ProtocolConfig prefix // nolint
func (c *ProtocolConfig) Prefix() string { func (c *ProtocolConfig) Prefix() string {
return constant.ProtocolConfigPrefix return constant.ProtocolConfigPrefix
} }
......
...@@ -55,7 +55,7 @@ type ProviderConfig struct { ...@@ -55,7 +55,7 @@ type ProviderConfig struct {
ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"`
} }
// UnmarshalYAML unmarshal the ProviderConfig by @unmarshal function // UnmarshalYAML unmarshals the ProviderConfig by @unmarshal function
func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil { if err := defaults.Set(c); err != nil {
return err return err
...@@ -67,7 +67,7 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error ...@@ -67,7 +67,7 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
return nil return nil
} }
// Prefix returns ProviderConfig prefix // nolint
func (*ProviderConfig) Prefix() string { func (*ProviderConfig) Prefix() string {
return constant.ProviderConfigPrefix return constant.ProviderConfigPrefix
} }
...@@ -77,7 +77,7 @@ func SetProviderConfig(p ProviderConfig) { ...@@ -77,7 +77,7 @@ func SetProviderConfig(p ProviderConfig) {
providerConfig = &p providerConfig = &p
} }
// ProviderInit load config file to init provider config // ProviderInit loads config file to init provider config
func ProviderInit(confProFile string) error { func ProviderInit(confProFile string) error {
if len(confProFile) == 0 { if len(confProFile) == 0 {
return perrors.Errorf("application configure(provider) file name is nil") return perrors.Errorf("application configure(provider) file name is nil")
......
...@@ -66,7 +66,7 @@ type ReferenceConfig struct { ...@@ -66,7 +66,7 @@ type ReferenceConfig struct {
ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"`
} }
// Prefix is ReferenceConfig prefix // nolint
func (c *ReferenceConfig) Prefix() string { func (c *ReferenceConfig) Prefix() string {
return constant.ReferenceConfigPrefix + c.InterfaceName + "." return constant.ReferenceConfigPrefix + c.InterfaceName + "."
} }
......
...@@ -59,7 +59,7 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error ...@@ -59,7 +59,7 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
return nil return nil
} }
// Prefix returns RegistryConfig prefix // nolint
func (*RegistryConfig) Prefix() string { func (*RegistryConfig) Prefix() string {
return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix
} }
......
...@@ -80,12 +80,12 @@ type ServiceConfig struct { ...@@ -80,12 +80,12 @@ type ServiceConfig struct {
cacheMutex sync.Mutex cacheMutex sync.Mutex
} }
// Prefix returns ServiceConfig prefix // nolint
func (c *ServiceConfig) Prefix() string { func (c *ServiceConfig) Prefix() string {
return constant.ServiceConfigPrefix + c.InterfaceName + "." return constant.ServiceConfigPrefix + c.InterfaceName + "."
} }
// UnmarshalYAML unmarshal the ServiceConfig by @unmarshal function // UnmarshalYAML unmarshals the ServiceConfig by @unmarshal function
func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := defaults.Set(c); err != nil { if err := defaults.Set(c); err != nil {
return err return err
......
...@@ -29,7 +29,7 @@ type apolloListener struct { ...@@ -29,7 +29,7 @@ type apolloListener struct {
listeners map[config_center.ConfigurationListener]struct{} listeners map[config_center.ConfigurationListener]struct{}
} }
// NewApolloListener ... // NewApolloListener creates a new apolloListener
func NewApolloListener() *apolloListener { func NewApolloListener() *apolloListener {
return &apolloListener{ return &apolloListener{
listeners: make(map[config_center.ConfigurationListener]struct{}, 0), listeners: make(map[config_center.ConfigurationListener]struct{}, 0),
...@@ -49,7 +49,7 @@ func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) { ...@@ -49,7 +49,7 @@ func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) {
} }
} }
// AddListener ... // AddListener adds a listener for apollo
func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { func (a *apolloListener) AddListener(l config_center.ConfigurationListener) {
if _, ok := a.listeners[l]; !ok { if _, ok := a.listeners[l]; !ok {
a.listeners[l] = struct{}{} a.listeners[l] = struct{}{}
...@@ -57,7 +57,7 @@ func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { ...@@ -57,7 +57,7 @@ func (a *apolloListener) AddListener(l config_center.ConfigurationListener) {
} }
} }
// RemoveListener ... // RemoveListener removes listeners of apollo
func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) { func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) {
delete(a.listeners, l) delete(a.listeners, l)
} }
...@@ -25,12 +25,12 @@ import ( ...@@ -25,12 +25,12 @@ import (
"github.com/apache/dubbo-go/remoting" "github.com/apache/dubbo-go/remoting"
) )
// ConfigurationListener ... // ConfigurationListener for changing listener's event
type ConfigurationListener interface { type ConfigurationListener interface {
Process(*ConfigChangeEvent) Process(*ConfigChangeEvent)
} }
// ConfigChangeEvent ... // ConfigChangeEvent for changing listener's event
type ConfigChangeEvent struct { type ConfigChangeEvent struct {
Key string Key string
Value interface{} Value interface{}
......
...@@ -21,7 +21,7 @@ import ( ...@@ -21,7 +21,7 @@ import (
"github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common"
) )
// Configurator ... // Configurator supports GetUrl and constructor
type Configurator interface { type Configurator interface {
GetUrl() *common.URL GetUrl() *common.URL
Configure(url *common.URL) Configure(url *common.URL)
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
"github.com/apache/dubbo-go/config_center" "github.com/apache/dubbo-go/config_center"
) )
// NewMockConfigurator ... // NewMockConfigurator creates a new mockConfigurator
func NewMockConfigurator(url *common.URL) config_center.Configurator { func NewMockConfigurator(url *common.URL) config_center.Configurator {
return &mockConfigurator{configuratorUrl: url} return &mockConfigurator{configuratorUrl: url}
} }
...@@ -32,12 +32,12 @@ type mockConfigurator struct { ...@@ -32,12 +32,12 @@ type mockConfigurator struct {
configuratorUrl *common.URL configuratorUrl *common.URL
} }
// GetUrl ... // GetUrl gets a configuratorUrl
func (c *mockConfigurator) GetUrl() *common.URL { func (c *mockConfigurator) GetUrl() *common.URL {
return c.configuratorUrl return c.configuratorUrl
} }
// Configure ... // Configure sets up param CLUSTER_KEY and cluster for url
func (c *mockConfigurator) Configure(url *common.URL) { func (c *mockConfigurator) Configure(url *common.URL) {
if cluster := c.GetUrl().GetParam(constant.CLUSTER_KEY, ""); cluster != "" { if cluster := c.GetUrl().GetParam(constant.CLUSTER_KEY, ""); cluster != "" {
url.SetParam(constant.CLUSTER_KEY, cluster) url.SetParam(constant.CLUSTER_KEY, cluster)
......
...@@ -40,7 +40,7 @@ const ( ...@@ -40,7 +40,7 @@ const (
DEFAULT_CONFIG_TIMEOUT = "10s" DEFAULT_CONFIG_TIMEOUT = "10s"
) )
// DynamicConfiguration ... // DynamicConfiguration for modify listener and get properties file
type DynamicConfiguration interface { type DynamicConfiguration interface {
Parser() parser.ConfigurationParser Parser() parser.ConfigurationParser
SetParser(parser.ConfigurationParser) SetParser(parser.ConfigurationParser)
...@@ -71,14 +71,14 @@ type Options struct { ...@@ -71,14 +71,14 @@ type Options struct {
// Option ... // Option ...
type Option func(*Options) type Option func(*Options)
// WithGroup ... // WithGroup assigns group to opt.Group
func WithGroup(group string) Option { func WithGroup(group string) Option {
return func(opt *Options) { return func(opt *Options) {
opt.Group = group opt.Group = group
} }
} }
// WithTimeout ... // WithTimeout assigns time to opt.Timeout
func WithTimeout(time time.Duration) Option { func WithTimeout(time time.Duration) Option {
return func(opt *Options) { return func(opt *Options) {
opt.Timeout = time opt.Timeout = time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment