diff --git a/config/application_config.go b/config/application_config.go index 33b47c81dd..16e841792c 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -25,9 +25,9 @@ import ( "github.com/apache/dubbo-go/common/constant" ) -// ApplicationConfig ... +// ApplicationConfig is a configuration for current application, whether the application is a provider or a consumer type ApplicationConfig struct { - Organization string `yaml:"organization" json:"organization,omitempty" property:"organization"` + Organization string `yaml:"organization" json:"organization,omitempty" property:"organization"` Name string `yaml:"name" json:"name,omitempty" property:"name"` Module string `yaml:"module" json:"module,omitempty" property:"module"` Version string `yaml:"version" json:"version,omitempty" property:"version"` @@ -36,22 +36,12 @@ type ApplicationConfig struct { MetadataType string `default:"local" yaml:"metadataType" json:"metadataType,omitempty" property:"metadataType"` //field for metadata report } -// Prefix ... +// nolint func (*ApplicationConfig) Prefix() string { return constant.DUBBO + ".application." } -// Id ... -func (c *ApplicationConfig) Id() string { - return "" -} - -// SetId ... -func (c *ApplicationConfig) SetId(id string) { - -} - -// UnmarshalYAML ... +// 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 93c0ce6a66..cf490019b2 100644 --- a/config/base_config.go +++ b/config/base_config.go @@ -69,7 +69,6 @@ func (c *BaseConfig) startConfigCenter() error { } func (c *BaseConfig) prepareEnvironment() error { - factory := extension.GetConfigCenterFactory(c.ConfigCenterConfig.Protocol) dynamicConfig, err := factory.GetDynamicConfiguration(c.configCenterUrl) config.GetEnvInstance().SetDynamicConfiguration(dynamicConfig) @@ -323,7 +322,7 @@ func (c *BaseConfig) freshInternalConfig(config *config.InmemoryConfiguration) { setFieldValue(val, reflect.Value{}, config) } -// SetFatherConfig ... +// SetFatherConfig sets father config by @fatherConfig func (c *BaseConfig) SetFatherConfig(fatherConfig interface{}) { c.fatherConfig = fatherConfig } diff --git a/config/config_center_config.go b/config/config_center_config.go index 40b9b65171..56d575e204 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -31,7 +31,13 @@ import ( "github.com/apache/dubbo-go/common/constant" ) -// ConfigCenterConfig ... +// ConfigCenterConfig is configuration for config center +// +// ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group, +// those configs are already built-in in many professional third-party configuration centers. +// In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups. +// +// ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo type ConfigCenterConfig struct { context context.Context Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` @@ -48,7 +54,7 @@ type ConfigCenterConfig struct { timeout time.Duration } -// UnmarshalYAML ... +// 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 @@ -60,7 +66,7 @@ func (c *ConfigCenterConfig) UnmarshalYAML(unmarshal func(interface{}) error) er return nil } -// GetUrlMap ... +// GetUrlMap gets url map from ConfigCenterConfig func (c *ConfigCenterConfig) GetUrlMap() url.Values { urlMap := url.Values{} urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace) diff --git a/config/consumer_config.go b/config/consumer_config.go index 1b563054ec..1453628ab5 100644 --- a/config/consumer_config.go +++ b/config/consumer_config.go @@ -38,7 +38,7 @@ import ( // consumerConfig ///////////////////////// -// ConsumerConfig ... +// ConsumerConfig is Consumer default configuration type ConsumerConfig struct { BaseConfig `yaml:",inline"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` @@ -63,7 +63,7 @@ type ConsumerConfig struct { ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } -// UnmarshalYAML ... +// UnmarshalYAML unmarshals the ConsumerConfig by @unmarshal function func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err @@ -75,17 +75,17 @@ func (c *ConsumerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix ... +// nolint func (*ConsumerConfig) Prefix() string { return constant.ConsumerConfigPrefix } -// SetConsumerConfig ... +// SetConsumerConfig sets consumerConfig by @c func SetConsumerConfig(c ConsumerConfig) { consumerConfig = &c } -// ConsumerInit ... +// 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/generic_service.go b/config/generic_service.go index b66e399f9e..a3332afe04 100644 --- a/config/generic_service.go +++ b/config/generic_service.go @@ -19,18 +19,18 @@ package config import "context" -// GenericService ... +// GenericService uses for generic invoke for service call type GenericService struct { Invoke func(ctx context.Context, req []interface{}) (interface{}, error) `dubbo:"$invoke"` referenceStr string } -// NewGenericService ... +// NewGenericService returns a GenericService instance func NewGenericService(referenceStr string) *GenericService { return &GenericService{referenceStr: referenceStr} } -// Reference ... +// Reference gets referenceStr from GenericService func (u *GenericService) Reference() string { return u.referenceStr } diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go index 382f05c8d5..aa102f35e9 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 ... +// nolint func GracefulShutdownInit() { signals := make(chan os.Signal, 1) @@ -83,7 +83,7 @@ func GracefulShutdownInit() { }() } -// BeforeShutdown ... +// BeforeShutdown provides processing flow before shutdown func BeforeShutdown() { destroyAllRegistries() @@ -126,10 +126,8 @@ func destroyConsumerProtocols(consumerProtocols *gxset.HashSet) { } } -/** - * destroy the provider's protocol. - * if the protocol is consumer's protocol too, we will keep it. - */ +// destroyProviderProtocols destroys the provider's protocol. +// if the protocol is consumer's protocol too, we will keep it func destroyProviderProtocols(consumerProtocols *gxset.HashSet) { logger.Info("Graceful shutdown --- Destroy provider's protocols. ") @@ -215,9 +213,7 @@ func totalTimeout() time.Duration { return timeout } -/* - * we can not get the protocols from consumerConfig because some protocol don't have configuration, like jsonrpc. - */ +// we can not get the protocols from consumerConfig because some protocol don't have configuration, like jsonrpc. func getConsumerProtocols() *gxset.HashSet { result := gxset.NewSet() if consumerConfig == nil || consumerConfig.References == nil { diff --git a/config/graceful_shutdown_config.go b/config/graceful_shutdown_config.go index 6bbabebf25..87175166b7 100644 --- a/config/graceful_shutdown_config.go +++ b/config/graceful_shutdown_config.go @@ -31,7 +31,7 @@ const ( defaultStepTimeout = 10 * time.Second ) -// ShutdownConfig ... +// 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 ... +// nolint func (config *ShutdownConfig) Prefix() string { return constant.ShutdownConfigPrefix } -// GetTimeout ... +// 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 ... +// nolint func (config *ShutdownConfig) GetStepTimeout() time.Duration { result, err := time.ParseDuration(config.StepTimeout) if err != nil { diff --git a/config/graceful_shutdown_signal_darwin.go b/config/graceful_shutdown_signal_darwin.go index 8ad79ffa62..6f1fa982a3 100644 --- a/config/graceful_shutdown_signal_darwin.go +++ b/config/graceful_shutdown_signal_darwin.go @@ -23,12 +23,12 @@ import ( ) var ( - // ShutdownSignals ... + // ShutdownSignals receives shutdown signals to process ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS} - // DumpHeapShutdownSignals ... + // DumpHeapShutdownSignals receives shutdown signals to process DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS} ) diff --git a/config/graceful_shutdown_signal_linux.go b/config/graceful_shutdown_signal_linux.go index 8ad79ffa62..6f1fa982a3 100644 --- a/config/graceful_shutdown_signal_linux.go +++ b/config/graceful_shutdown_signal_linux.go @@ -23,12 +23,12 @@ import ( ) var ( - // ShutdownSignals ... + // ShutdownSignals receives shutdown signals to process ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS} - // DumpHeapShutdownSignals ... + // DumpHeapShutdownSignals receives shutdown signals to process DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS} ) diff --git a/config/graceful_shutdown_signal_windows.go b/config/graceful_shutdown_signal_windows.go index 815a05ecb2..3136e5ae15 100644 --- a/config/graceful_shutdown_signal_windows.go +++ b/config/graceful_shutdown_signal_windows.go @@ -23,11 +23,11 @@ import ( ) var ( - // ShutdownSignals ... + // ShutdownSignals receives shutdown signals to process ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT} - // DumpHeapShutdownSignals ... + // DumpHeapShutdownSignals receives shutdown signals to process DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT} ) diff --git a/config/instance/metadata_report.go b/config/instance/metadata_report.go index cd54b0a794..4c935d7332 100644 --- a/config/instance/metadata_report.go +++ b/config/instance/metadata_report.go @@ -32,7 +32,7 @@ var ( once sync.Once ) -// GetMetadataReportInstance ... +// GetMetadataReportInstance gets metadata report instance by @url func GetMetadataReportInstance(url *common.URL) metadata.MetadataReport { once.Do(func() { instance = extension.GetMetadataReportFactory(url.Protocol).CreateMetadataReport(url) diff --git a/config/interfaces/config_reader.go b/config/interfaces/config_reader.go index 8b79a17d89..b23f989cc2 100644 --- a/config/interfaces/config_reader.go +++ b/config/interfaces/config_reader.go @@ -19,7 +19,7 @@ package interfaces import "bytes" -// ConfigReader +// 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 2b926c0b94..11fb0cd65c 100644 --- a/config/metadata_report_config.go +++ b/config/metadata_report_config.go @@ -32,7 +32,7 @@ import ( "github.com/apache/dubbo-go/config/instance" ) -// MethodConfig ... +// MethodConfig is method level configuration type MetadataReportConfig struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"` Address string `yaml:"address" json:"address,omitempty" property:"address"` @@ -43,12 +43,12 @@ type MetadataReportConfig struct { Group string `yaml:"group" json:"group,omitempty" property:"group"` } -// Prefix ... +// nolint func (c *MetadataReportConfig) Prefix() string { return constant.MetadataReportPrefix } -// UnmarshalYAML ... +// UnmarshalYAML unmarshal the MetadataReportConfig by @unmarshal function func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return perrors.WithStack(err) @@ -60,7 +60,7 @@ func (c *MetadataReportConfig) UnmarshalYAML(unmarshal func(interface{}) error) return nil } -// ToUrl ... +// 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 8f196d9e2c..e64773eb13 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 ... +// 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 ... +// 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/mock_rpcservice.go b/config/mock_rpcservice.go index 6c43699128..1e21b252f5 100644 --- a/config/mock_rpcservice.go +++ b/config/mock_rpcservice.go @@ -21,20 +21,20 @@ import ( "context" ) -// MockService ... +// MockService mocks the rpc service for test type MockService struct{} -// Reference ... +// Reference mocks the Reference method func (*MockService) Reference() string { return "MockService" } -// GetUser ... +// GetUser mocks the GetUser method func (*MockService) GetUser(ctx context.Context, itf []interface{}, str *struct{}) error { return nil } -// GetUser1 ... +// GetUser1 mocks the GetUser1 method func (*MockService) GetUser1(ctx context.Context, itf []interface{}, str *struct{}) error { return nil } diff --git a/config/protocol_config.go b/config/protocol_config.go index 33de976bc6..cee5b7aa75 100644 --- a/config/protocol_config.go +++ b/config/protocol_config.go @@ -25,14 +25,14 @@ import ( "github.com/apache/dubbo-go/common/constant" ) -// ProtocolConfig ... +// ProtocolConfig is protocol configuration type ProtocolConfig struct { Name string `required:"true" yaml:"name" json:"name,omitempty" property:"name"` Ip string `required:"true" yaml:"ip" json:"ip,omitempty" property:"ip"` Port string `required:"true" yaml:"port" json:"port,omitempty" property:"port"` } -// Prefix ... +// nolint func (c *ProtocolConfig) Prefix() string { return constant.ProtocolConfigPrefix } diff --git a/config/provider_config.go b/config/provider_config.go index 7956991745..97d037ede0 100644 --- a/config/provider_config.go +++ b/config/provider_config.go @@ -36,7 +36,7 @@ import ( // providerConfig ///////////////////////// -// ProviderConfig ... +// ProviderConfig is the default configuration of service provider type ProviderConfig struct { BaseConfig `yaml:",inline"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` @@ -55,7 +55,7 @@ type ProviderConfig struct { ConfigType map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"` } -// UnmarshalYAML ... +// 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,17 +67,17 @@ func (c *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix ... +// nolint func (*ProviderConfig) Prefix() string { return constant.ProviderConfigPrefix } -// SetProviderConfig ... +// SetProviderConfig sets provider config by @p func SetProviderConfig(p ProviderConfig) { providerConfig = &p } -// ProviderInit ... +// 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 3710cbc4bc..5b7a8e9eac 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -39,7 +39,7 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// ReferenceConfig ... +// ReferenceConfig is the configuration of service consumer type ReferenceConfig struct { context context.Context pxy *proxy.Proxy @@ -66,7 +66,7 @@ type ReferenceConfig struct { ForceTag bool `yaml:"force.tag" json:"force.tag,omitempty" property:"force.tag"` } -// Prefix ... +// nolint func (c *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + c.InterfaceName + "." } @@ -76,7 +76,7 @@ func NewReferenceConfig(id string, ctx context.Context) *ReferenceConfig { return &ReferenceConfig{id: id, context: ctx} } -// UnmarshalYAML ... +// UnmarshalYAML unmarshals the ReferenceConfig by @unmarshal function func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type rf ReferenceConfig raw := rf{} // Put your defaults here @@ -168,7 +168,7 @@ func (c *ReferenceConfig) Implement(v common.RPCService) { c.pxy.Implement(v) } -// GetRPCService ... +// GetRPCService gets RPCService from proxy func (c *ReferenceConfig) GetRPCService() common.RPCService { return c.pxy.Get() } diff --git a/config/registry_config.go b/config/registry_config.go index e877a2c19d..ef527c827e 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -33,7 +33,7 @@ import ( "github.com/apache/dubbo-go/common/logger" ) -// RegistryConfig ... +// RegistryConfig is the configuration of the registry center type RegistryConfig struct { Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` // I changed "type" to "protocol" ,the same as "protocol" field in java class RegistryConfig @@ -47,7 +47,7 @@ type RegistryConfig struct { Params map[string]string `yaml:"params" json:"params,omitempty" property:"params"` } -// UnmarshalYAML ... +// UnmarshalYAML unmarshals the RegistryConfig by @unmarshal function func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { if err := defaults.Set(c); err != nil { return err @@ -59,7 +59,7 @@ func (c *RegistryConfig) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -// Prefix ... +// nolint func (*RegistryConfig) Prefix() string { return constant.RegistryConfigPrefix + "|" + constant.SingleRegistryConfigPrefix } diff --git a/config/service.go b/config/service.go index b7e7dc2a42..b746141dd0 100644 --- a/config/service.go +++ b/config/service.go @@ -36,17 +36,17 @@ func SetProviderService(service common.RPCService) { proServices[service.Reference()] = service } -// GetConsumerService ... +// GetConsumerService gets ConsumerService by @name func GetConsumerService(name string) common.RPCService { return conServices[name] } -// GetProviderService ... +// GetProviderService gets ProviderService by @name func GetProviderService(name string) common.RPCService { return proServices[name] } -// GetCallback ... +// GetCallback gets CallbackResponse by @name func GetCallback(name string) func(response common.CallbackResponse) { service := GetConsumerService(name) if sv, ok := service.(common.AsyncCallbackService); ok { diff --git a/config/service_config.go b/config/service_config.go index 09308d032e..70a344c7b8 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -44,7 +44,7 @@ import ( "github.com/apache/dubbo-go/protocol/protocolwrapper" ) -// ServiceConfig ... +// ServiceConfig is the configuration of the service provider type ServiceConfig struct { context context.Context id string @@ -80,12 +80,12 @@ type ServiceConfig struct { cacheMutex sync.Mutex } -// Prefix ... +// nolint func (c *ServiceConfig) Prefix() string { return constant.ServiceConfigPrefix + c.InterfaceName + "." } -// UnmarshalYAML ... +// 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