diff --git a/config/application_config.go b/config/application_config.go index f03fc1ec7401c47c4cdef563841ed26c12995bcc..16e841792c7bffaa6f847d73c336c6a43431bc49 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -36,12 +36,12 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` //field for metadata report } -// Prefix returns ApplicationConfig prefix +// nolint func (*ApplicationConfig) Prefix() string { 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 { if err := defaults.Set(c); err != nil { return err diff --git a/config/base_config.go b/config/base_config.go index 7d9ea30a0653fff65d5a348e26482e8e715e2859..cf490019b2a48b98ffb6fab1036bfd6218fe7343 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -68,7 +68,6 @@ func (c *BaseConfig) startConfigCenter() error { return err } -// prepareEnvironment prepare the environment func (c *BaseConfig) prepareEnvironment() error { factory := extension.GetConfigCenterFactory(c.ConfigCenterConfig.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(c.configCenterUrl) diff --git a/config/config_center_config.go b/config/config_center_config.go index 975e86e91cd732cd8b015e92149fd330c0149577..58b010e35f0d05fd70518da96789b69734df8c50 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -54,7 +54,7 @@ type ConfigCenterConfig struct { 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 { if err := defaults.Set(c); err != nil { return err diff --git a/config/consumer_config.go b/config/consumer_config.go index 07af0f68f0f5cb283b893e5a789d7392659c081c..95108090275dea907cbd71c63ec1bfb4f009edad 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -75,7 +75,7 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix returns ConsumerConfig prefix +// nolint func (*ConsumerConfig) Prefix() string { return constant.ConsumerConfigPrefix } @@ -85,7 +85,7 @@ func SetConsumerConfig(c ConsumerConfig) { consumerConfig = &c } -// ConsumerInit Load config file to init consumer config +// ConsumerInit loads config file to init consumer config func ConsumerInit(confConFile string) error { if confConFile == "" { return perrors.Errorf("application configure(consumer) file name is nil") diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index f36625b05826bd631cd7b1e1ca00c780cc8e1d68..aa102f35e9048dbc6fbcb10db19cb802b2f3147b 100644 --- a/config/graceful_shutdown.go +++ b/config/graceful_shutdown.go @@ -52,7 +52,7 @@ import ( * We define them by using 'package build' feature https://golang.org/pkg/go/build/ */ -// GracefulShutdownInit init for graceful shutdown +// nolint func GracefulShutdownInit() { signals := make(chan os.Signal, 1) @@ -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 func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index a1489714f42e5df8e34c7ebc4b5b4f42f151b896..87175166b7011e27985eac404819a1aba3522e49 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -31,7 +31,7 @@ const ( defaultStepTimeout = 10 * time.Second ) -// ShutdownConfig is configuration for graceful shutdown +// ShutdownConfig is used as configuration for graceful shutdown type ShutdownConfig struct { /* * Total timeout. Even though we don't release all resources, @@ -58,12 +58,12 @@ type ShutdownConfig struct { RequestsFinished bool } -// Prefix returns ShutdownConfig prefix +// nolint func (config *ShutdownConfig) Prefix() string { return constant.ShutdownConfigPrefix } -// GetTimeout gets timeout in ShutdownConfig +// nolint func (config *ShutdownConfig) GetTimeout() time.Duration { result, err := time.ParseDuration(config.Timeout) if err != nil { @@ -74,7 +74,7 @@ func (config *ShutdownConfig) GetTimeout() time.Duration { return result } -// GetStepTimeout gets StepTimeout in ShutdownConfig +// nolint func (config *ShutdownConfig) GetStepTimeout() time.Duration { result, err := time.ParseDuration(config.StepTimeout) if err != nil { diff --git a/config/instance/metedata_report.go b/config/instance/metadata_report.go similarity index 100% rename from config/instance/metedata_report.go rename to config/instance/metadata_report.go diff --git a/config/interfaces/config_reader.go b/config/interfaces/config_reader.go index 26f5f3f8f8cfdbdd8f10078b1d696cb1728cd63d..b23f989cc29b42de349d1d80ae594de32ab4abbd 100644 --- a/config/interfaces/config_reader.go +++ b/config/interfaces/config_reader.go @@ -19,7 +19,7 @@ package interfaces 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 { ReadConsumerConfig(reader *bytes.Buffer) error ReadProviderConfig(reader *bytes.Buffer) error diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go index e9a9488a8fe2bf08853305e9d458e6883c075330..11fb0cd65cf5500c09c51268115e5f7c60916657 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -43,7 +43,7 @@ type MetadataReportConfig struct { Group string `yaml:"group" json:"group,omitempty" property:"group"` } -// Prefix returns MetadataReportConfig prefix +// nolint func (c *MetadataReportConfig) Prefix() string { return constant.MetadataReportPrefix } @@ -60,7 +60,7 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) return nil } -// ToUrl transforms MetadataReportConfig to url +// nolint func (c *MetadataReportConfig) ToUrl() (*common.URL, error) { urlMap := make(url.Values) diff --git a/config/method_config.go b/config/method_config.go index 37078db0635480052e16bb16ea4d66660fa9b838..e64773eb135b2f9ec55377bded815147e2e192af 100644 --- a/config/method_config.go +++ b/config/method_config.go @@ -42,7 +42,7 @@ type MethodConfig struct { RequestTimeout string `yaml:"timeout" json:"timeout,omitempty" property:"timeout"` } -// Prefix returns MethodConfig prefix +// nolint func (c *MethodConfig) Prefix() string { if len(c.InterfaceId) != 0 { return constant.DUBBO + "." + c.InterfaceName + "." + c.InterfaceId + "." + c.Name + "." @@ -51,7 +51,7 @@ func (c *MethodConfig) Prefix() string { 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 { if err := defaults.Set(c); err != nil { return err diff --git a/config/protocol_config.go b/config/protocol_config.go index 4391e3ece1bde213fd7e4ebcc0c5fc389e87cb97..cee5b7aa7518ff55a15d05de4733cefbbc9c0a1c 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -32,7 +32,7 @@ type ProtocolConfig struct { Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` } -// Prefix returns ProtocolConfig prefix +// nolint func (c *ProtocolConfig) Prefix() string { return constant.ProtocolConfigPrefix } diff --git a/config/provider_config.go b/config/provider_config.go index b5c3a93e64bd1b9302c49f8fe94ff27b4d312cdc..97d037ede008b5fc8cab2febb2177a4e8c3dbd1b 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -55,7 +55,7 @@ type ProviderConfig struct { 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 { if err := defaults.Set(c); err != nil { return err @@ -67,7 +67,7 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix returns ProviderConfig prefix +// nolint func (*ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } @@ -77,7 +77,7 @@ func SetProviderConfig(p ProviderConfig) { providerConfig = &p } -// ProviderInit load config file to init provider config +// ProviderInit loads config file to init provider config func ProviderInit(confProFile string) error { if len(confProFile) == 0 { return perrors.Errorf("application configure(provider) file name is nil") diff --git a/config/reference_config.go b/config/reference_config.go index b245f0e52cfd968734e87ac293edda31b9c3850f..fe588188bb976eb692cbfc72e35bb9a1141fc795 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -66,7 +66,7 @@ type ReferenceConfig struct { ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` } -// Prefix is ReferenceConfig prefix +// nolint func (c *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + c.InterfaceName + "." } diff --git a/config/registry_config.go b/config/registry_config.go index 7979972d0edb4c5a5777d123ac21e2d39e62993e..f95c3004f05f552d82c7620d5899eca01e9c310b 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -59,7 +59,7 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix returns RegistryConfig prefix +// nolint func (*RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix } diff --git a/config/service_config.go b/config/service_config.go index 96bdef4295d1458421c59eb0d1546b7c0d486710..70a344c7b8c858a25e9a556ac6f4e899b1626ab4 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -80,12 +80,12 @@ type ServiceConfig struct { cacheMutex sync.Mutex } -// Prefix returns ServiceConfig prefix +// nolint func (c *ServiceConfig) Prefix() string { 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 { if err := defaults.Set(c); err != nil { return err diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go index fb257a4828aed077f61568685ee7823e9c215cf9..1cf65ed22ba0a1f765af66191ed19a04f81b0fe6 100644 --- a/config_center/apollo/listener.go +++ b/config_center/apollo/listener.go @@ -29,7 +29,7 @@ type apolloListener struct { listeners map[config_center.ConfigurationListener]struct{} } -// NewApolloListener ... +// NewApolloListener creates a new apolloListener func NewApolloListener() *apolloListener { return &apolloListener{ listeners: make(map[config_center.ConfigurationListener]struct{}, 0), @@ -49,7 +49,7 @@ func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) { } } -// AddListener ... +// AddListener adds a listener for apollo func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { if _, ok := a.listeners[l]; !ok { a.listeners[l] = struct{}{} @@ -57,7 +57,7 @@ func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { } } -// RemoveListener ... +// RemoveListener removes listeners of apollo func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) { delete(a.listeners, l) } diff --git a/config_center/configuration_listener.go b/config_center/configuration_listener.go index e70e4f68075c51c33f1110ef44a7b703e36fb78d..541cc09286bb83fa5b66db3745e45ad0a9df5e2f 100644 --- a/config_center/configuration_listener.go +++ b/config_center/configuration_listener.go @@ -25,12 +25,12 @@ import ( "github.com/apache/dubbo-go/remoting" ) -// ConfigurationListener ... +// ConfigurationListener for changing listener's event type ConfigurationListener interface { Process(*ConfigChangeEvent) } -// ConfigChangeEvent ... +// ConfigChangeEvent for changing listener's event type ConfigChangeEvent struct { Key string Value interface{} diff --git a/config_center/configurator.go b/config_center/configurator.go index ffa9034e05c4c3d4cc254886e2ed19576f155dec..9db4804365689d8eb357965973a2916e86383cf8 100644 --- a/config_center/configurator.go +++ b/config_center/configurator.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/common" ) -// Configurator ... +// Configurator supports GetUrl and constructor type Configurator interface { GetUrl() *common.URL Configure(url *common.URL) diff --git a/config_center/configurator/mock.go b/config_center/configurator/mock.go index d294b9195db9cfe60056bc29ec26816f740ea396..7ec7179634cfd967cd27e85ed248e2075c387cb5 100644 --- a/config_center/configurator/mock.go +++ b/config_center/configurator/mock.go @@ -23,7 +23,7 @@ import ( "github.com/apache/dubbo-go/config_center" ) -// NewMockConfigurator ... +// NewMockConfigurator creates a new mockConfigurator func NewMockConfigurator(url *common.URL) config_center.Configurator { return &mockConfigurator{configuratorUrl: url} } @@ -32,12 +32,12 @@ type mockConfigurator struct { configuratorUrl *common.URL } -// GetUrl ... +// GetUrl gets a configuratorUrl func (c *mockConfigurator) GetUrl() *common.URL { return c.configuratorUrl } -// Configure ... +// Configure sets up param CLUSTER_KEY and cluster for url func (c *mockConfigurator) Configure(url *common.URL) { if cluster := c.GetUrl().GetParam(constant.CLUSTER_KEY, ""); cluster != "" { url.SetParam(constant.CLUSTER_KEY, cluster) diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go index 9013d7140e757520f2e8f048ce53a5ac2a13f982..540febc9d38e164afcc62538478df140b7d671c7 100644 --- a/config_center/dynamic_configuration.go +++ b/config_center/dynamic_configuration.go @@ -40,7 +40,7 @@ const ( DEFAULT_CONFIG_TIMEOUT = "10s" ) -// DynamicConfiguration ... +// DynamicConfiguration for modify listener and get properties file type DynamicConfiguration interface { Parser() parser.ConfigurationParser SetParser(parser.ConfigurationParser) @@ -71,14 +71,14 @@ type Options struct { // Option ... type Option func(*Options) -// WithGroup ... +// WithGroup assigns group to opt.Group func WithGroup(group string) Option { return func(opt *Options) { opt.Group = group } } -// WithTimeout ... +// WithTimeout assigns time to opt.Timeout func WithTimeout(time time.Duration) Option { return func(opt *Options) { opt.Timeout = time diff --git a/config_center/dynamic_configuration_factory.go b/config_center/dynamic_configuration_factory.go index 9f9b13227f6623a02b0261c46d8d1e43624005f8..46faf864443b7f8780584213b758f26395224956 100644 --- a/config_center/dynamic_configuration_factory.go +++ b/config_center/dynamic_configuration_factory.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/common" ) -// DynamicConfigurationFactory ... +// DynamicConfigurationFactory gets the DynamicConfiguration type DynamicConfigurationFactory interface { GetDynamicConfiguration(*common.URL) (DynamicConfiguration, error) } diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 59c788b65bce2a4773975ea1a96a314649781832..9cfb9e6078be60fbe2072e8e293143e8b111df58 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -43,7 +43,7 @@ var ( dynamicConfiguration *MockDynamicConfiguration ) -// GetDynamicConfiguration ... +// GetDynamicConfiguration returns a DynamicConfiguration func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(_ *common.URL) (DynamicConfiguration, error) { var err error once.Do(func() { @@ -99,16 +99,16 @@ type MockDynamicConfiguration struct { listener map[string]ConfigurationListener } -// AddListener ... +// AddListener adds a listener for MockDynamicConfiguration func (c *MockDynamicConfiguration) AddListener(key string, listener ConfigurationListener, _ ...Option) { c.listener[key] = listener } -// RemoveListener ... +// RemoveListener removes the listener for MockDynamicConfiguration func (c *MockDynamicConfiguration) RemoveListener(_ string, _ ConfigurationListener, _ ...Option) { } -// GetConfig ... +// GetConfig returns content of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetConfig(_ string, _ ...Option) (string, error) { return c.content, nil @@ -119,17 +119,17 @@ func (c *MockDynamicConfiguration) GetConfigs(key string, opts ...Option) (strin return c.GetConfig(key, opts...) } -// Parser ... +// Parser returns a parser of MockDynamicConfiguration func (c *MockDynamicConfiguration) Parser() parser.ConfigurationParser { return c.parser } -// SetParser ... +// SetParser sets parser of MockDynamicConfiguration func (c *MockDynamicConfiguration) SetParser(p parser.ConfigurationParser) { c.parser = p } -// GetProperties ... +// GetProperties gets content of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetProperties(_ string, _ ...Option) (string, error) { return c.content, nil } @@ -139,7 +139,7 @@ func (c *MockDynamicConfiguration) GetInternalProperty(key string, opts ...Optio return c.GetProperties(key, opts...) } -// GetRule ... +// GetRule gets properties of MockDynamicConfiguration func (c *MockDynamicConfiguration) GetRule(key string, opts ...Option) (string, error) { return c.GetProperties(key, opts...) } diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go index f33b4ba866da69e1d23b493f42152bbb0f437878..6fbdc27d4339150bfec624f7dc5ea0f6a608d7a7 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -47,7 +47,7 @@ type ConfigurationParser interface { ParseToUrls(content string) ([]*common.URL, error) } -// DefaultConfigurationParser for support properties file in config center +// DefaultConfigurationParser for supporting properties file in config center type DefaultConfigurationParser struct{} // ConfiguratorConfig ... @@ -71,7 +71,7 @@ type ConfigItem struct { Side string `yaml:"side"` } -// Parse ... +// Parse load content func (parser *DefaultConfigurationParser) Parse(content string) (map[string]string, error) { pps, err := properties.LoadString(content) if err != nil { diff --git a/config_center/zookeeper/listener.go b/config_center/zookeeper/listener.go index 122dfaf4f268a706151de6acdaa78bb46e59f8fb..747c4be352add3f549eaf02e83da6442a8a84c6a 100644 --- a/config_center/zookeeper/listener.go +++ b/config_center/zookeeper/listener.go @@ -33,12 +33,12 @@ type CacheListener struct { rootPath string } -// NewCacheListener ... +// NewCacheListener creates a new CacheListener func NewCacheListener(rootPath string) *CacheListener { return &CacheListener{rootPath: rootPath} } -// AddListener ... +// AddListener will add a listener if loaded func (l *CacheListener) AddListener(key string, listener config_center.ConfigurationListener) { // reference from https://stackoverflow.com/questions/34018908/golang-why-dont-we-have-a-set-datastructure @@ -50,7 +50,7 @@ func (l *CacheListener) AddListener(key string, listener config_center.Configura } } -// RemoveListener ... +// RemoveListener will delete a listener if loaded func (l *CacheListener) RemoveListener(key string, listener config_center.ConfigurationListener) { listeners, loaded := l.keyListeners.Load(key) if loaded { @@ -58,7 +58,7 @@ func (l *CacheListener) RemoveListener(key string, listener config_center.Config } } -// DataChange ... +// DataChange changes all listeners' event func (l *CacheListener) DataChange(event remoting.Event) bool { if event.Content == "" { //meanings new node diff --git a/metadata/report.go b/metadata/report.go index 3fcc71241411d4a8f9577bb5fb3233e67942cd52..f2380f50cd0eb15182c137f02e5f78b4ba8e4fd2 100644 --- a/metadata/report.go +++ b/metadata/report.go @@ -25,7 +25,7 @@ import ( type MetadataReport interface { StoreProviderMetadata(*identifier.MetadataIdentifier, *definition.ServiceDefinition) - StoreConsumeretadata(*identifier.MetadataIdentifier, map[string]string) + StoreConsumerMetadata(*identifier.MetadataIdentifier, map[string]string) SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) GetExportedURLs(*identifier.ServiceMetadataIdentifier) []string diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 1636b14da2fe5ab714853aa662eaa774ddbc1791..bd1e7986ca709a4e10dfcad04d2380931308d568 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -68,9 +68,8 @@ func init() { extension.SetMetricReporter(reporterName, newPrometheusReporter) } -// PrometheusReporter -// it will collect the data for Prometheus -// if you want to use this, you should initialize your prometheus. +// PrometheusReporter will collect the data for Prometheus +// if you want to use this feature, you need to initialize your prometheus. // https://prometheus.io/docs/guides/go-application/ type PrometheusReporter struct { @@ -85,7 +84,7 @@ type PrometheusReporter struct { consumerHistogramVec *prometheus.HistogramVec } -// Report report the duration to Prometheus +// Report reports the duration to Prometheus // the role in url must be consumer or provider // or it will be ignored func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) { @@ -99,7 +98,7 @@ func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol sumVec = reporter.consumerSummaryVec hisVec = reporter.consumerHistogramVec } else { - logger.Warnf("The url is not the consumer's or provider's, "+ + logger.Warnf("The url belongs neither the consumer nor the provider, "+ "so the invocation will be ignored. url: %s", url.String()) return } diff --git a/metrics/reporter.go b/metrics/reporter.go index 85ef1dcdf0dad275edecc1f3a85502c1493c1395..9a7094fa62d9c0fa3e6ee0a8ef373f91c28d2c90 100644 --- a/metrics/reporter.go +++ b/metrics/reporter.go @@ -29,7 +29,7 @@ const ( NameSpace = "dubbo" ) -// it will be use to report the invocation's duration +// Reporter will be used to report the invocation's duration type Reporter interface { // report the duration of an invocation Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation,