diff --git a/cluster/directory.go b/cluster/directory.go index c3a67e9473adbdc96f5729fa589f3f67e9502ebc..5a03b3a4490ce0b3aadece8a9ef43395f845dd12 100644 --- a/cluster/directory.go +++ b/cluster/directory.go @@ -22,7 +22,8 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// Directory: Extension - Directory +// Directory +//Extension - Directory type Directory interface { common.Node List(invocation protocol.Invocation) []protocol.Invoker diff --git a/cluster/loadbalance.go b/cluster/loadbalance.go index 33170ac99fa7ba3092d7dda5cdcf3a84bd2e3344..fb3641a77377eabbd692729a32e2c0c096282f18 100644 --- a/cluster/loadbalance.go +++ b/cluster/loadbalance.go @@ -21,7 +21,8 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// LoadBalance: Extension - LoadBalance +// LoadBalance +//Extension - LoadBalance type LoadBalance interface { Select([]protocol.Invoker, protocol.Invocation) protocol.Invoker } diff --git a/cluster/router/condition_router.go b/cluster/router/condition_router.go index c4561130c2a5a91b833d2c206fa70bba30fc2714..c38e9718cca6d5e67a874a61225bac7d27d5d352 100644 --- a/cluster/router/condition_router.go +++ b/cluster/router/condition_router.go @@ -37,7 +37,7 @@ import ( ) const ( - //ROUTE_PATTERN: route pattern regex + //ROUTE_PATTERN route pattern regex ROUTE_PATTERN = `([&!=,]*)\\s*([^&!=,\\s]+)` // FORCE ... FORCE = "force" @@ -107,7 +107,8 @@ func newConditionRouter(url *common.URL) (*ConditionRouter, error) { }, nil } -//Route: Router determine the target server list. +// Route +// Router determine the target server list. func (c *ConditionRouter) Route(invokers []protocol.Invoker, url common.URL, invocation protocol.Invocation) []protocol.Invoker { if len(invokers) == 0 { return invokers diff --git a/cluster/router/condition_router_test.go b/cluster/router/condition_router_test.go index 3844f503fae27a25f2379a6f20298a8baeb947d4..43e74317e3e07caff4a6e7021352ca417e66ccfb 100644 --- a/cluster/router/condition_router_test.go +++ b/cluster/router/condition_router_test.go @@ -93,12 +93,12 @@ type rest struct { var count int -func (bi *MockInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { +func (bi *MockInvoker) Invoke(_ context.Context, _ protocol.Invocation) protocol.Result { count++ var ( success bool - err error = nil + err error ) if count >= bi.successCount { success = true diff --git a/common/config/environment.go b/common/config/environment.go index ec03ccf3eea4068ab527c05373be1556291af768..071af31152ba4ce3c579f70aa23df59d718ce506 100644 --- a/common/config/environment.go +++ b/common/config/environment.go @@ -27,7 +27,7 @@ import ( "github.com/apache/dubbo-go/config_center" ) -// Environment: +// Environment // There is dubbo.properties file and application level config center configuration which higner than normal config center in java. So in java the // configuration sequence will be config center > application level config center > dubbo.properties > spring bean configuration. // But in go, neither the dubbo.properties file or application level config center configuration will not support for the time being. @@ -83,11 +83,11 @@ func (env *Environment) UpdateAppExternalConfigMap(externalMap map[string]string // Configuration ... func (env *Environment) Configuration() *list.List { - list := list.New() + cfgList := list.New() // The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration - list.PushFront(newInmemoryConfiguration(&(env.externalConfigMap))) - list.PushFront(newInmemoryConfiguration(&(env.appExternalConfigMap))) - return list + cfgList.PushFront(newInmemoryConfiguration(&(env.externalConfigMap))) + cfgList.PushFront(newInmemoryConfiguration(&(env.appExternalConfigMap))) + return cfgList } // SetDynamicConfiguration ... diff --git a/common/constant/version.go b/common/constant/version.go index f0c38f6864da16180b41b62ec006ff24bfe2cf75..730224376054a36b0c7cfeda7d5ea5e7ce058618 100644 --- a/common/constant/version.go +++ b/common/constant/version.go @@ -18,10 +18,10 @@ package constant const ( - // Version: apache/dubbo-go version + // Version apache/dubbo-go version Version = "1.3.0" - // Name: module name + // Name module name Name = "dubbogo" - // Date: release date + // Date release date DATE = "2020/01/12" ) diff --git a/common/extension/graceful_shutdown.go b/common/extension/graceful_shutdown.go index 1a1fb92058f5140bbd9ee2c64a7c31ec1835420e..3abd75c0aa328f3553c3d83340ae440b8dfe3356 100644 --- a/common/extension/graceful_shutdown.go +++ b/common/extension/graceful_shutdown.go @@ -26,7 +26,8 @@ var ( ) /** - * AddCustomShutdownCallback: you should not make any assumption about the order. + * AddCustomShutdownCallback + * you should not make any assumption about the order. * For example, if you have more than one callbacks, and you wish the order is: * callback1() * callback2() diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index b9e85a03fb6f9f3dad928e10052f07d0ced16eb0..43ca720d0e71577a446829f702c1d2fe23a32905 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -40,7 +40,9 @@ type Proxy struct { once sync.Once } -var typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type() +var ( + typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type() +) // NewProxy ... func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[string]string) *Proxy { @@ -51,7 +53,8 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str } } -// Implement: proxy implement +// Implement +// proxy implement // In consumer, RPCService like: // type XxxProvider struct { // Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error diff --git a/common/rpc_service.go b/common/rpc_service.go index 5fec12b2975338c41e3c9c06ae10ccc1f478369f..b235c32abc9a971d7144605c8b4b82953ac8f3c4 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -34,7 +34,8 @@ import ( "github.com/apache/dubbo-go/common/logger" ) -// RPCService: rpc service interface +// RPCService +//rpc service interface type RPCService interface { // Reference: // rpc service id or reference id @@ -67,8 +68,8 @@ var ( // because Typeof takes an empty interface value. This is annoying. typeOfError = reflect.TypeOf((*error)(nil)).Elem() - // todo: lowerecas? // ServiceMap ... + // todo: lowerecas? ServiceMap = &serviceMap{ serviceMap: make(map[string]map[string]*Service), } @@ -232,8 +233,8 @@ func (sm *serviceMap) UnRegister(protocol, serviceId string) error { // Is this an exported - upper case - name func isExported(name string) bool { - rune, _ := utf8.DecodeRuneInString(name) - return unicode.IsUpper(rune) + s, _ := utf8.DecodeRuneInString(name) + return unicode.IsUpper(s) } // Is this type exported or a builtin? diff --git a/config/config_loader.go b/config/config_loader.go index a6df1a638edd13508ec5ad255f72ecab6415c662..d6eb7ff524a53c6949d22a2b34eb965274a75232 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -69,7 +69,7 @@ func checkApplicationName(config *ApplicationConfig) { } } -// Load: Dubbo Init +// Load Dubbo Init func Load() { // reference config if consumerConfig == nil { @@ -153,12 +153,12 @@ func Load() { GracefulShutdownInit() } -// GetRPCService: get rpc service for consumer +// GetRPCService get rpc service for consumer func GetRPCService(name string) common.RPCService { return consumerConfig.References[name].GetRPCService() } -// RPCService: create rpc service for consumer +// RPCService create rpc service for consumer func RPCService(service common.RPCService) { consumerConfig.References[service.Reference()].Implement(service) } diff --git a/config/reference_config.go b/config/reference_config.go index fe3a72ca23e65631da422c4e6102dcdb43bad196..07b7e8f125c4a31b668d06bfcea8cb835385fd9a 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -70,7 +70,7 @@ func (c *ReferenceConfig) Prefix() string { return constant.ReferenceConfigPrefix + c.InterfaceName + "." } -// NewReferenceConfig: The only way to get a new ReferenceConfig +// NewReferenceConfig The only way to get a new ReferenceConfig func NewReferenceConfig(id string, ctx context.Context) *ReferenceConfig { return &ReferenceConfig{id: id, context: ctx} } @@ -93,8 +93,9 @@ func (c *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error } // Refer ... -func (c *ReferenceConfig) Refer(impl interface{}) { - url := common.NewURLWithOptions(common.WithPath(c.id), +func (c *ReferenceConfig) Refer(_ interface{}) { + cfgURL := common.NewURLWithOptions( + common.WithPath(c.id), common.WithProtocol(c.Protocol), common.WithParams(c.getUrlMap()), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), @@ -109,14 +110,14 @@ func (c *ReferenceConfig) Refer(impl interface{}) { panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) } if serviceUrl.Protocol == constant.REGISTRY_PROTOCOL { - serviceUrl.SubURL = url + serviceUrl.SubURL = cfgURL c.urls = append(c.urls, &serviceUrl) } else { if serviceUrl.Path == "" { serviceUrl.Path = "/" + c.id } // merge url need to do - newUrl := common.MergeUrl(&serviceUrl, url) + newUrl := common.MergeUrl(&serviceUrl, cfgURL) c.urls = append(c.urls, newUrl) } @@ -127,7 +128,7 @@ func (c *ReferenceConfig) Refer(impl interface{}) { //set url to regUrls for _, regUrl := range c.urls { - regUrl.SubURL = url + regUrl.SubURL = cfgURL } } if len(c.urls) == 1 { @@ -153,12 +154,13 @@ func (c *ReferenceConfig) Refer(impl interface{}) { //create proxy if c.Async { callback := GetCallback(c.id) - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, url) + c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetAsyncProxy(c.invoker, callback, cfgURL) } else { - c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetProxy(c.invoker, url) + c.pxy = extension.GetProxyFactory(consumerConfig.ProxyFactory).GetProxy(c.invoker, cfgURL) } } +// Implement // @v is service provider implemented RPCService func (c *ReferenceConfig) Implement(v common.RPCService) { c.pxy.Implement(v) diff --git a/config/service_config.go b/config/service_config.go index 92977307ab68282beaebc1d9b0257e864007e9b4..37ec3a3ae611d60d71f5679c1d501bb699351849 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -92,7 +92,7 @@ func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } -// NewServiceConfig: The only way to get a new ServiceConfig +// NewServiceConfig The only way to get a new ServiceConfig func NewServiceConfig(id string, context context.Context) *ServiceConfig { return &ServiceConfig{ @@ -134,7 +134,8 @@ func (c *ServiceConfig) Export() error { logger.Errorf(err.Error()) return err } - url := common.NewURLWithOptions(common.WithPath(c.id), + ivkURL := common.NewURLWithOptions( + common.WithPath(c.id), common.WithProtocol(proto.Name), common.WithIp(proto.Ip), common.WithPort(proto.Port), @@ -146,11 +147,11 @@ func (c *ServiceConfig) Export() error { if len(regUrls) > 0 { for _, regUrl := range regUrls { - regUrl.SubURL = url + regUrl.SubURL = ivkURL c.cacheMutex.Lock() if c.cacheProtocol == nil { - logger.Infof(fmt.Sprintf("First load the registry protocol , url is {%v}!", url)) + logger.Infof(fmt.Sprintf("First load the registry protocol , url is {%v}!", ivkURL)) c.cacheProtocol = extension.GetProtocol("registry") } c.cacheMutex.Unlock() @@ -158,14 +159,14 @@ func (c *ServiceConfig) Export() error { invoker := extension.GetProxyFactory(providerConfig.ProxyFactory).GetInvoker(*regUrl) exporter := c.cacheProtocol.Export(invoker) if exporter == nil { - panic(perrors.New(fmt.Sprintf("Registry protocol new exporter error,registry is {%v},url is {%v}", regUrl, url))) + panic(perrors.New(fmt.Sprintf("Registry protocol new exporter error,registry is {%v},url is {%v}", regUrl, ivkURL))) } } } else { - invoker := extension.GetProxyFactory(providerConfig.ProxyFactory).GetInvoker(*url) + invoker := extension.GetProxyFactory(providerConfig.ProxyFactory).GetInvoker(*ivkURL) exporter := extension.GetProtocol(protocolwrapper.FILTER).Export(invoker) if exporter == nil { - panic(perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error,url is {%v}", url))) + panic(perrors.New(fmt.Sprintf("Filter protocol without registry new exporter error,url is {%v}", ivkURL))) } } diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go index 2b366206199f6e5c76dfb3bb0ac5b1ca7d5b2067..820d02fb48e2204c3f1eb74fd5624132a63d367e 100644 --- a/config_center/apollo/listener.go +++ b/config_center/apollo/listener.go @@ -29,6 +29,14 @@ type apolloListener struct { listeners map[config_center.ConfigurationListener]struct{} } +// NewApolloListener ... +func NewApolloListener() *apolloListener { + return &apolloListener{ + listeners: make(map[config_center.ConfigurationListener]struct{}, 0), + } +} + +// OnChange ... func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) { for key, change := range changeEvent.Changes { for listener := range a.listeners { @@ -41,22 +49,15 @@ func (a *apolloListener) OnChange(changeEvent *agollo.ChangeEvent) { } } -// NewApolloListener ... -func NewApolloListener() *apolloListener { - return &apolloListener{ - listeners: make(map[config_center.ConfigurationListener]struct{}, 0), - } -} - // AddListener ... -func (al *apolloListener) AddListener(l config_center.ConfigurationListener) { - if _, ok := al.listeners[l]; !ok { - al.listeners[l] = struct{}{} - agollo.AddChangeListener(al) +func (a *apolloListener) AddListener(l config_center.ConfigurationListener) { + if _, ok := a.listeners[l]; !ok { + a.listeners[l] = struct{}{} + agollo.AddChangeListener(a) } } // RemoveListener ... -func (al *apolloListener) RemoveListener(l config_center.ConfigurationListener) { - delete(al.listeners, l) +func (a *apolloListener) RemoveListener(l config_center.ConfigurationListener) { + delete(a.listeners, l) } diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go index 6f66570540a696abfd4050646d0bd4ec3f336ce4..4d972b629abb7abd7cc0d0018026e4ccc04a1e4f 100644 --- a/config_center/mock_dynamic_config.go +++ b/config_center/mock_dynamic_config.go @@ -43,7 +43,7 @@ var ( ) // GetDynamicConfiguration ... -func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(url *common.URL) (DynamicConfiguration, error) { +func (f *MockDynamicConfigurationFactory) GetDynamicConfiguration(_ *common.URL) (DynamicConfiguration, error) { var err error once.Do(func() { dynamicConfiguration = &MockDynamicConfiguration{listener: map[string]ConfigurationListener{}} @@ -89,21 +89,21 @@ type MockDynamicConfiguration struct { } // AddListener ... -func (c *MockDynamicConfiguration) AddListener(key string, listener ConfigurationListener, opions ...Option) { +func (c *MockDynamicConfiguration) AddListener(key string, listener ConfigurationListener, _ ...Option) { c.listener[key] = listener } // RemoveListener ... -func (c *MockDynamicConfiguration) RemoveListener(key string, listener ConfigurationListener, opions ...Option) { +func (c *MockDynamicConfiguration) RemoveListener(_ string, _ ConfigurationListener, _ ...Option) { } // GetConfig ... -func (c *MockDynamicConfiguration) GetConfig(key string, opts ...Option) (string, error) { +func (c *MockDynamicConfiguration) GetConfig(_ string, _ ...Option) (string, error) { return c.content, nil } -// GetConfigs: For zookeeper, getConfig and getConfigs have the same meaning. +// GetConfigs For zookeeper, getConfig and getConfigs have the same meaning. func (c *MockDynamicConfiguration) GetConfigs(key string, opts ...Option) (string, error) { return c.GetConfig(key, opts...) } @@ -119,11 +119,11 @@ func (c *MockDynamicConfiguration) SetParser(p parser.ConfigurationParser) { } // GetProperties ... -func (c *MockDynamicConfiguration) GetProperties(key string, opts ...Option) (string, error) { +func (c *MockDynamicConfiguration) GetProperties(_ string, _ ...Option) (string, error) { return c.content, nil } -// GetInternalProperty: For zookeeper, getConfig and getConfigs have the same meaning. +// GetInternalProperty For zookeeper, getConfig and getConfigs have the same meaning. func (c *MockDynamicConfiguration) GetInternalProperty(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 55f23225e607721d867c348f161d8cdd7d74fc21..9aaa1f700f7eb581e952485681d90c051ea516f4 100644 --- a/config_center/parser/configuration_parser.go +++ b/config_center/parser/configuration_parser.go @@ -48,7 +48,7 @@ type ConfigurationParser interface { ParseToUrls(content string) ([]*common.URL, error) } -//for support properties file in config center +// DefaultConfigurationParser for support properties file in config center type DefaultConfigurationParser struct{} // ConfiguratorConfig ... @@ -74,12 +74,12 @@ type ConfigItem struct { // Parse ... func (parser *DefaultConfigurationParser) Parse(content string) (map[string]string, error) { - properties, err := properties.LoadString(content) + pps, err := properties.LoadString(content) if err != nil { logger.Errorf("Parse the content {%v} in DefaultConfigurationParser error ,error message is {%v}", content, err) return nil, err } - return properties.Map(), nil + return pps.Map(), nil } // ParseToUrls ... diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index b0274d6a8a736d2c561c520b533b381bb85ec0e1..6842d9e37711e954a93c7982bc959aa0798a9c93 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -38,7 +38,8 @@ import ( ) const ( - // ZkClient: zookeeper client name + // ZkClient + //zookeeper client name ZkClient = "zk config_center" ) @@ -137,10 +138,9 @@ func (c *zookeeperDynamicConfiguration) GetProperties(key string, opts ...config content, _, err := c.client.GetContent(c.rootPath + "/" + key) if err != nil { return "", perrors.WithStack(err) - } else { - return string(content), nil } + return string(content), nil } //For zookeeper, getConfig and getConfigs have the same meaning. diff --git a/filter/filter.go b/filter/filter.go index 0da0d800fc126fc562b06218bdec022c6adaf8f6..c069510498c7ac68b2bb2169dfe7132a4ef63229 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -24,7 +24,8 @@ import ( "github.com/apache/dubbo-go/protocol" ) -// Filter: Extension - Filter +// Filter +// Extension - Filter type Filter interface { Invoke(context.Context, protocol.Invoker, protocol.Invocation) protocol.Result OnResponse(context.Context, protocol.Result, protocol.Invoker, protocol.Invocation) protocol.Result diff --git a/filter/filter_impl/access_log_filter.go b/filter/filter_impl/access_log_filter.go index a2367254d9b7367664ea04eb3556fc9612cb411f..fbfe7565170c7df468f755a4bd1aadde166a79c1 100644 --- a/filter/filter_impl/access_log_filter.go +++ b/filter/filter_impl/access_log_filter.go @@ -35,6 +35,7 @@ import ( const ( //used in URL. + // FileDateFormat ... FileDateFormat = "2006-01-02" // MessageDateLayout ... @@ -45,6 +46,7 @@ const ( LogFileMode = 0600 // those fields are the data collected by this filter + // Types ... Types = "types" // Arguments ... @@ -56,6 +58,7 @@ func init() { } /* + * AccessLogFilter * Although the access log filter is a default filter, * you should config "accesslog" in service's config to tell the filter where store the access log. * for example: @@ -94,7 +97,7 @@ func (ef *AccessLogFilter) logIntoChannel(accessLogData AccessLogData) { } } -func (ef *AccessLogFilter) buildAccessLogData(invoker protocol.Invoker, invocation protocol.Invocation) map[string]string { +func (ef *AccessLogFilter) buildAccessLogData(_ protocol.Invoker, invocation protocol.Invocation) map[string]string { dataMap := make(map[string]string, 16) attachments := invocation.Attachments() dataMap[constant.INTERFACE_KEY] = attachments[constant.INTERFACE_KEY] @@ -128,7 +131,7 @@ func (ef *AccessLogFilter) buildAccessLogData(invoker protocol.Invoker, invocati } // OnResponse ... -func (ef *AccessLogFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (ef *AccessLogFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result { return result } diff --git a/filter/filter_impl/echo_filter.go b/filter/filter_impl/echo_filter.go index e1181e412a0a96cd8a175652ba5ad85e78a12d2a..a12800a21a8ebe4545b4a8b5bd0f8a30c1462105 100644 --- a/filter/filter_impl/echo_filter.go +++ b/filter/filter_impl/echo_filter.go @@ -30,7 +30,7 @@ import ( ) const ( - // ECHO: echo module name + // ECHO echo module name ECHO = "echo" ) @@ -38,7 +38,7 @@ func init() { extension.SetFilter(ECHO, GetFilter) } -// EchoFilter: +// EchoFilter // RPCService need a Echo method in consumer, if you want to use EchoFilter // eg: // Echo func(ctx context.Context, arg interface{}, rsp *Xxx) error @@ -59,7 +59,9 @@ func (ef *EchoFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invo } // OnResponse ... -func (ef *EchoFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (ef *EchoFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, + _ protocol.Invocation) protocol.Result { + return result } diff --git a/filter/filter_impl/execute_limit_filter.go b/filter/filter_impl/execute_limit_filter.go index 4c5805a79b6dffc197d9605020466ebce27dac4c..434c378045456eb13317e0a48630ebd33f244c05 100644 --- a/filter/filter_impl/execute_limit_filter.go +++ b/filter/filter_impl/execute_limit_filter.go @@ -46,7 +46,8 @@ func init() { } /** - * ExecuteLimitFilter: The filter will limit the number of in-progress request and it's thread-safe. + * ExecuteLimitFilter + * The filter will limit the number of in-progress request and it's thread-safe. * example: * "UserProvider": * registry: "hangzhouzk" @@ -82,17 +83,17 @@ type ExecuteState struct { // Invoke ... func (ef *ExecuteLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { methodConfigPrefix := "methods." + invocation.MethodName() + "." - url := invoker.GetUrl() - limitTarget := url.ServiceKey() + ivkURL := invoker.GetUrl() + limitTarget := ivkURL.ServiceKey() limitRateConfig := constant.DEFAULT_EXECUTE_LIMIT - methodLevelConfig := url.GetParam(methodConfigPrefix+constant.EXECUTE_LIMIT_KEY, "") + methodLevelConfig := ivkURL.GetParam(methodConfigPrefix+constant.EXECUTE_LIMIT_KEY, "") if len(methodLevelConfig) > 0 { // we have the method-level configuration limitTarget = limitTarget + "#" + invocation.MethodName() limitRateConfig = methodLevelConfig } else { - limitRateConfig = url.GetParam(constant.EXECUTE_LIMIT_KEY, constant.DEFAULT_EXECUTE_LIMIT) + limitRateConfig = ivkURL.GetParam(constant.EXECUTE_LIMIT_KEY, constant.DEFAULT_EXECUTE_LIMIT) } limitRate, err := strconv.ParseInt(limitRateConfig, 0, 0) @@ -112,17 +113,17 @@ func (ef *ExecuteLimitFilter) Invoke(ctx context.Context, invoker protocol.Invok concurrentCount := state.(*ExecuteState).increase() defer state.(*ExecuteState).decrease() if concurrentCount > limitRate { - logger.Errorf("The invocation was rejected due to over the execute limitation, url: %s ", url.String()) - rejectedHandlerConfig := url.GetParam(methodConfigPrefix+constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, - url.GetParam(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, constant.DEFAULT_KEY)) - return extension.GetRejectedExecutionHandler(rejectedHandlerConfig).RejectedExecution(url, invocation) + logger.Errorf("The invocation was rejected due to over the execute limitation, url: %s ", ivkURL.String()) + rejectedHandlerConfig := ivkURL.GetParam(methodConfigPrefix+constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, + ivkURL.GetParam(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, constant.DEFAULT_KEY)) + return extension.GetRejectedExecutionHandler(rejectedHandlerConfig).RejectedExecution(ivkURL, invocation) } return invoker.Invoke(ctx, invocation) } // OnResponse ... -func (ef *ExecuteLimitFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (ef *ExecuteLimitFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, _ protocol.Invocation) protocol.Result { return result } diff --git a/filter/filter_impl/generic_filter.go b/filter/filter_impl/generic_filter.go index 9dfd125547c4de0628058a8e37dac71f9df5e1ae..e8ff2679b0294d6519aecd1cc1fe37bdeab89e46 100644 --- a/filter/filter_impl/generic_filter.go +++ b/filter/filter_impl/generic_filter.go @@ -36,7 +36,8 @@ import ( ) const ( - // GENERIC: generic module name + // GENERIC + //generic module name GENERIC = "generic" ) @@ -73,7 +74,8 @@ func (ef *GenericFilter) Invoke(ctx context.Context, invoker protocol.Invoker, i } // OnResponse ... -func (ef *GenericFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (ef *GenericFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, + _ protocol.Invocation) protocol.Result { return result } diff --git a/filter/filter_impl/generic_service_filter_test.go b/filter/filter_impl/generic_service_filter_test.go index 0ba5e27d04099514063c4075944602010046f61e..24ed3b95fcab6111f5c432a12c41dd0b60b4a5a2 100644 --- a/filter/filter_impl/generic_service_filter_test.go +++ b/filter/filter_impl/generic_service_filter_test.go @@ -49,11 +49,10 @@ func (c *TestStruct) JavaClassName() string { return "com.test.testStruct" } -type TestService struct { -} +type TestService struct{} // MethodOne ... -func (ts *TestService) MethodOne(ctx context.Context, test1 *TestStruct, test2 []TestStruct, +func (ts *TestService) MethodOne(_ context.Context, test1 *TestStruct, test2 []TestStruct, test3 interface{}, test4 []interface{}, test5 *string) (*TestStruct, error) { if test1 == nil { return nil, errors.New("param test1 is nil") @@ -74,7 +73,7 @@ func (ts *TestService) MethodOne(ctx context.Context, test1 *TestStruct, test2 [ } // Reference ... -func (s *TestService) Reference() string { +func (*TestService) Reference() string { return "com.test.Path" } diff --git a/filter/filter_impl/tps/tps_limit_fix_window_strategy.go b/filter/filter_impl/tps/tps_limit_fix_window_strategy.go index 96eede8531b13cbd564726d50d12dd20e3c3e29c..a9c2ac15a417ffa6ff8f5b8d78d5c6a94877db30 100644 --- a/filter/filter_impl/tps/tps_limit_fix_window_strategy.go +++ b/filter/filter_impl/tps/tps_limit_fix_window_strategy.go @@ -40,7 +40,7 @@ func init() { } /** - * FixedWindowTpsLimitStrategyImpl: + * FixedWindowTpsLimitStrategyImpl * It's the same as default implementation in Java * It's not a thread-safe implementation. * It you want to use the thread-safe implementation, please use ThreadSafeFixedWindowTpsLimitStrategyImpl diff --git a/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go b/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go index 251b11e23b8617b0f4b707ce7df6aecc1b997a20..a781cc7bfbf297d0b9cf84ca0aa9dcfbbef7e14b 100644 --- a/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go +++ b/filter/filter_impl/tps/tps_limit_sliding_window_strategy.go @@ -33,7 +33,7 @@ func init() { } /** - * SlidingWindowTpsLimitStrategyImpl: + * SlidingWindowTpsLimitStrategyImpl * it's thread-safe. * "UserProvider": * registry: "hangzhouzk" diff --git a/filter/filter_impl/tps/tps_limit_thread_safe_fix_window_strategy.go b/filter/filter_impl/tps/tps_limit_thread_safe_fix_window_strategy.go index 259cbfcd07bcf5296a9134346a94651bcccc087b..16624836e6397df5adda3f2aa5a80966721a97fb 100644 --- a/filter/filter_impl/tps/tps_limit_thread_safe_fix_window_strategy.go +++ b/filter/filter_impl/tps/tps_limit_thread_safe_fix_window_strategy.go @@ -33,7 +33,7 @@ func init() { } /** - * ThreadSafeFixedWindowTpsLimitStrategyImpl: + * ThreadSafeFixedWindowTpsLimitStrategyImpl * it's the thread-safe implementation. * Also, it's a thread-safe decorator of FixedWindowTpsLimitStrategyImpl * "UserProvider": diff --git a/filter/filter_impl/tps/tps_limiter_method_service.go b/filter/filter_impl/tps/tps_limiter_method_service.go index 709bb68c42a2dcb703cad1bbf0da7339d9f89c91..7fe8de9237b82415a09083c2be59df5e232ecaf0 100644 --- a/filter/filter_impl/tps/tps_limiter_method_service.go +++ b/filter/filter_impl/tps/tps_limiter_method_service.go @@ -35,7 +35,9 @@ import ( "github.com/apache/dubbo-go/protocol" ) -const name = "method-service" +const ( + name = "method-service" +) func init() { extension.SetTpsLimiter(constant.DEFAULT_KEY, GetMethodServiceTpsLimiter) @@ -43,7 +45,7 @@ func init() { } /** - * MethodServiceTpsLimiterImpl: + * MethodServiceTpsLimiterImpl * This implementation allows developer to config both method-level and service-level tps limiter. * for example: * "UserProvider": diff --git a/filter/filter_impl/tps_limit_filter.go b/filter/filter_impl/tps_limit_filter.go index 52ac5d147904011bd5286c90bc565584f1869f33..fa78288f9678d67d0eb0d025a83b75493f7fda80 100644 --- a/filter/filter_impl/tps_limit_filter.go +++ b/filter/filter_impl/tps_limit_filter.go @@ -31,6 +31,7 @@ import ( ) const ( + // TpsLimitFilterKey key TpsLimitFilterKey = "tps" ) @@ -39,6 +40,7 @@ func init() { } /** + * TpsLimitFilter * if you wish to use the TpsLimiter, please add the configuration into your service provider configuration: * for example: * "UserProvider": @@ -71,7 +73,8 @@ func (t TpsLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, in } // OnResponse ... -func (t TpsLimitFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { +func (t TpsLimitFilter) OnResponse(_ context.Context, result protocol.Result, _ protocol.Invoker, + _ protocol.Invocation) protocol.Result { return result } diff --git a/filter/handler/rejected_execution_handler_only_log.go b/filter/handler/rejected_execution_handler_only_log.go index 18a22d3d0d6d94edb49d0166553463b6569a0e48..0f9003c7df2165a2f3a364a5afc47f578db1d243 100644 --- a/filter/handler/rejected_execution_handler_only_log.go +++ b/filter/handler/rejected_execution_handler_only_log.go @@ -30,7 +30,10 @@ import ( "github.com/apache/dubbo-go/protocol" ) -const HandlerName = "log" +const ( + // HandlerName handler name + HandlerName = "log" +) func init() { extension.SetRejectedExecutionHandler(HandlerName, GetOnlyLogRejectedExecutionHandler) @@ -41,6 +44,7 @@ var onlyLogHandlerInstance *OnlyLogRejectedExecutionHandler var onlyLogHandlerOnce sync.Once /** + * OnlyLogRejectedExecutionHandler * This implementation only logs the invocation info. * it always return en error inside the result. * "UserProvider": @@ -57,7 +61,9 @@ type OnlyLogRejectedExecutionHandler struct { } // RejectedExecution ... -func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL, invocation protocol.Invocation) protocol.Result { +func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url common.URL, + _ protocol.Invocation) protocol.Result { + logger.Errorf("The invocation was rejected. url: %s", url.String()) return &protocol.RPCResult{} } diff --git a/filter/rejected_execution_handler.go b/filter/rejected_execution_handler.go index 2507596e9818082833616cd0b200f8a1c6c9015c..caeea1db6631d0968fd58f59f9577ee9272f3ca0 100644 --- a/filter/rejected_execution_handler.go +++ b/filter/rejected_execution_handler.go @@ -23,7 +23,7 @@ import ( ) /** - * RejectedExecutionHandler: + * RejectedExecutionHandler * If the invocation cannot pass any validation in filter, like ExecuteLimitFilter and TpsLimitFilter, * the implementation will be used. * The common case is that sometimes you want to return the default value when the request was rejected. diff --git a/filter/tps_limit_strategy.go b/filter/tps_limit_strategy.go index f002ab2ded2e631128fc22bff20668d68d66f164..5edf32ce1912642c7ad0ea0b3f6144b45c267eb4 100644 --- a/filter/tps_limit_strategy.go +++ b/filter/tps_limit_strategy.go @@ -18,7 +18,8 @@ package filter /* - * TpsLimitStrategy: please register your implementation by invoking SetTpsLimitStrategy + * TpsLimitStrategy + * please register your implementation by invoking SetTpsLimitStrategy * "UserProvider": * registry: "hangzhouzk" * protocol : "dubbo" diff --git a/filter/tps_limiter.go b/filter/tps_limiter.go index 584b22922de52a6035b1c9dc90cb5960c486b346..dbc9f76838a4406b4788e7757453098613253d58 100644 --- a/filter/tps_limiter.go +++ b/filter/tps_limiter.go @@ -23,7 +23,8 @@ import ( ) /* - * TpsLimiter: please register your implementation by invoking SetTpsLimiter + * TpsLimiter + * please register your implementation by invoking SetTpsLimiter * The usage, for example: * "UserProvider": * registry: "hangzhouzk" diff --git a/protocol/dubbo/client.go b/protocol/dubbo/client.go index a9b2981f1d71f8d72f962abef1dc33dc667ac5da..3923b7e4e7e543f4c60a89aaebf67f6238916722 100644 --- a/protocol/dubbo/client.go +++ b/protocol/dubbo/client.go @@ -191,13 +191,13 @@ func NewResponse(reply interface{}, atta map[string]string) *Response { } } -// CallOneway: call one way +// CallOneway call one way func (c *Client) CallOneway(request *Request) error { return perrors.WithStack(c.call(CT_OneWay, request, NewResponse(nil, nil), nil)) } -// Call: if @response is nil, the transport layer will get the response without notify the invoker. +// Call if @response is nil, the transport layer will get the response without notify the invoker. func (c *Client) Call(request *Request, response *Response) error { ct := CT_TwoWay diff --git a/protocol/dubbo/codec.go b/protocol/dubbo/codec.go index c626053943fe1cbf31de6f6930eef7649ff9ed9c..3e50eb901dbe1e549aea4ea7414d9617851b5363 100644 --- a/protocol/dubbo/codec.go +++ b/protocol/dubbo/codec.go @@ -30,23 +30,23 @@ import ( perrors "github.com/pkg/errors" ) -// serial ID +//SerialID serial ID type SerialID byte const ( - // S_Dubbo: dubbo serial id + // S_Dubbo dubbo serial id S_Dubbo SerialID = 2 ) -// call type +//CallType call type type CallType int32 const ( - // CT_UNKNOWN: unknown call type + // CT_UNKNOWN unknown call type CT_UNKNOWN CallType = 0 - // CT_OneWay: call one way + // CT_OneWay call one way CT_OneWay CallType = 1 - // CT_TwoWay: call in request/response + // CT_TwoWay call in request/response CT_TwoWay CallType = 2 ) diff --git a/protocol/dubbo/config.go b/protocol/dubbo/config.go index 8c1a363ad12f7cef04768927d56835b70fb8493a..dbc6989c54780afacef717f1d110833d92967f9f 100644 --- a/protocol/dubbo/config.go +++ b/protocol/dubbo/config.go @@ -47,7 +47,8 @@ type ( SessionName string `default:"rpc" yaml:"session_name" json:"session_name,omitempty"` } - // ServerConfig: Config holds supported types by the multiconfig package + // ServerConfig + //Config holds supported types by the multiconfig package ServerConfig struct { // session SessionTimeout string `default:"60s" yaml:"session_timeout" json:"session_timeout,omitempty"` @@ -63,7 +64,8 @@ type ( GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"` } - // ClientConfig: Config holds supported types by the multiconfig package + // ClientConfig + //Config holds supported types by the multiconfig package ClientConfig struct { ReconnectInterval int `default:"0" yaml:"reconnect_interval" json:"reconnect_interval,omitempty"` diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go index 1c1cca3b7ba6badb84d88ab1414e27d4425b4462..0f5625c152cc366289143b8a29d11cafb513b2f2 100644 --- a/protocol/grpc/grpc_protocol.go +++ b/protocol/grpc/grpc_protocol.go @@ -29,7 +29,7 @@ import ( ) const ( - // GRPC: module name + // GRPC module name GRPC = "grpc" ) diff --git a/protocol/grpc/internal/client.go b/protocol/grpc/internal/client.go index 5ff409ac0557979e421c4ec9ec983c6a9880f52a..d236e3046a90e9179fba07a0be5edb07f8c2a3e8 100644 --- a/protocol/grpc/internal/client.go +++ b/protocol/grpc/internal/client.go @@ -33,7 +33,8 @@ func init() { config.SetConsumerService(&GrpcGreeterImpl{}) } -// GrpcGreeterImpl: used for dubbo-grpc biz client +// GrpcGreeterImpl +//used for dubbo-grpc biz client type GrpcGreeterImpl struct { SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error } diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index da3df3297217cb23e9013696460b5d0a765ae011..b207fd0b0cc4eb7de8409a8c46c6fc9ef0baa5c7 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -29,6 +29,7 @@ import ( // /////////////////////////// // Invocation Impletment of RPC // /////////////////////////// + // todo: is it necessary to separate fields of consumer(provider) from RPCInvocation // RPCInvocation ... type RPCInvocation struct { diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index eac32f11767f4e80c8b93509ddee4fa9c1daf6e8..ba7197dbc857c2ed7acda1a9f246a5b826e86915 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -159,7 +159,7 @@ func (c *HTTPClient) Call(ctx context.Context, service common.URL, req *Request, return perrors.WithStack(codec.Read(rspBody, rsp)) } -// Do: +// Do // !!The high level of complexity and the likelihood that the fasthttp client has not been extensively used // in production means that you would need to expect a very large benefit to justify the adoption of fasthttp today. func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte) ([]byte, error) { diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go index cd6498e772a85a21d39f46715fdbae8dc081c33a..d1c2a858b4e4223ac32fc1160b56f6ee1862c8ce 100644 --- a/protocol/jsonrpc/json.go +++ b/protocol/jsonrpc/json.go @@ -31,9 +31,9 @@ import ( ) const ( - // MAX_JSONRPC_ID: max jsonrpc request/response id + // MAX_JSONRPC_ID max jsonrpc request/response id MAX_JSONRPC_ID = 0x7FFFFFFF - // VERSION : jsonrpc version + // VERSION jsonrpc version VERSION = "2.0" ) @@ -57,7 +57,7 @@ const ( codeServerErrorEnd = -32000 ) -// Error: response Error +// Error response Error type Error struct { Code int `json:"code"` Message string `json:"message"` diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 17607ab41701f1cf9944bee4a910160142d845f2..bed7099ab60a6c05c3799f993c0bb348a4b00f02 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -33,7 +33,8 @@ import ( ) const ( - // JSONRPC: module name + // JSONRPC + //module name JSONRPC = "jsonrpc" ) diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index a50780040e0c71ed60b7dd65112d55122a4193b3..8600f02dad3d32d797613823de0bbe40261d2e71 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -51,7 +51,7 @@ var ( ) const ( - // DefaultMaxSleepTime: max sleep interval in accept + // DefaultMaxSleepTime max sleep interval in accept DefaultMaxSleepTime = 1 * time.Second // DefaultHTTPRspBufferSize ... DefaultHTTPRspBufferSize = 1024 diff --git a/protocol/protocol.go b/protocol/protocol.go index 152550a184a43325d56f0f7371ac9e5e3d3e1c01..a873469a8ba361c9dfc922b071ffbf256c6a8b98 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -26,14 +26,16 @@ import ( "github.com/apache/dubbo-go/common/logger" ) -// Protocol: Extension - protocol +// Protocol +// Extension - protocol type Protocol interface { Export(invoker Invoker) Exporter Refer(url common.URL) Invoker Destroy() } -// Exporter: wrapping invoker +// Exporter +// wrapping invoker type Exporter interface { GetInvoker() Invoker Unexport() diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go index a630e99f2ac43828e934b2dd89c7bc8e8064f3fe..70d2da0faed3bc9797eb23cec653bea05d445d91 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper.go @@ -39,6 +39,7 @@ func init() { extension.SetProtocol(FILTER, GetProtocol) } +// ProtocolFilterWrapper // protocol in url decide who ProtocolFilterWrapper.protocol is type ProtocolFilterWrapper struct { protocol protocol.Protocol @@ -77,8 +78,8 @@ func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker { // The order of filters is from left to right, so loading from right to left for i := len(filtNames) - 1; i >= 0; i-- { - filter := extension.GetFilter(filtNames[i]) - fi := &FilterInvoker{next: next, invoker: invoker, filter: filter} + flt := extension.GetFilter(filtNames[i]) + fi := &FilterInvoker{next: next, invoker: invoker, filter: flt} next = fi } diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go index 8c0b5708fe42587c768a505c9e24754f06298a81..0320579286a9bdb4cecadb50430c850d6ae3e61f 100644 --- a/registry/etcdv3/registry.go +++ b/registry/etcdv3/registry.go @@ -48,7 +48,7 @@ var ( ) const ( - // Name: module name + // Name module name Name = "etcdv3" // RegistryConnDelay ... RegistryConnDelay = 3 @@ -77,21 +77,32 @@ type etcdV3Registry struct { done chan struct{} } +// Client get the etcdv3 client func (r *etcdV3Registry) Client() *etcdv3.Client { return r.client } + +//SetClient set the etcdv3 client func (r *etcdV3Registry) SetClient(client *etcdv3.Client) { r.client = client } + +// func (r *etcdV3Registry) ClientLock() *sync.Mutex { return &r.cltLock } + +//WaitGroup return the wait group handle func (r *etcdV3Registry) WaitGroup() *sync.WaitGroup { return &r.wg } + +// GetDone return the done channel func (r *etcdV3Registry) GetDone() chan struct{} { return r.done } + +//RestartCallBack restart callback func (r *etcdV3Registry) RestartCallBack() bool { services := []common.URL{} @@ -150,10 +161,12 @@ func newETCDV3Registry(url *common.URL) (registry.Registry, error) { return r, nil } +// GetUrl get registry url func (r *etcdV3Registry) GetUrl() common.URL { return *r.URL } +// IsAvailable check the register client is available func (r *etcdV3Registry) IsAvailable() bool { select { @@ -164,6 +177,7 @@ func (r *etcdV3Registry) IsAvailable() bool { } } +// Destroy destroy client func (r *etcdV3Registry) Destroy() { if r.configListener != nil { @@ -185,6 +199,7 @@ func (r *etcdV3Registry) stop() { r.cltLock.Unlock() } +// Register ... func (r *etcdV3Registry) Register(svc common.URL) error { role, err := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, "")) @@ -349,7 +364,7 @@ func (r *etcdV3Registry) subscribe(svc *common.URL) (registry.Listener, error) { return configListener, nil } -//subscribe from registry +//Subscribe from registry func (r *etcdV3Registry) Subscribe(url *common.URL, notifyListener registry.NotifyListener) { for { if !r.IsAvailable() { @@ -369,16 +384,14 @@ func (r *etcdV3Registry) Subscribe(url *common.URL, notifyListener registry.Noti } for { - if serviceEvent, err := listener.Next(); err != nil { + serviceEvent, err := listener.Next() + if err != nil { logger.Warnf("Selector.watch() = error{%v}", perrors.WithStack(err)) listener.Close() return - } else { - logger.Infof("update begin, service event: %v", serviceEvent.String()) - notifyListener.Notify(serviceEvent) } - + logger.Infof("update begin, service event: %v", serviceEvent.String()) + notifyListener.Notify(serviceEvent) } - } } diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 5a1ae60ef5edbc0b38259309c6acd541aa3ef983..965e91e894ac61562bfd25c8f564f789afd6c8a1 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -47,7 +47,7 @@ var ( ) const ( - // RegistryConnDelay: registry connection delay + //RegistryConnDelay registry connection delay RegistryConnDelay = 3 ) diff --git a/registry/registry.go b/registry/registry.go index f9e686004f7ff7e2634bf6d4a99051dac60f6e9f..863e781ac7bfa1c09561a6a4ab59c7f7a14e89d2 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -21,7 +21,7 @@ import ( "github.com/apache/dubbo-go/common" ) -// Registry: Extension - Registry +// Registry Extension - Registry type Registry interface { common.Node //used for service provider calling , register services to registry @@ -44,7 +44,7 @@ type NotifyListener interface { Notify(*ServiceEvent) } -// Listener: Deprecated! +// Listener Deprecated! type Listener interface { Next() (*ServiceEvent, error) Close() diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index b7c83c5409fbfeebca08cf0ab672a4acc35f3767..ebd63694b7772715c1f6140b12389bfa526d21c6 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -44,11 +44,11 @@ import ( ) const ( - // RegistryZkClient: zk client name + // RegistryZkClient zk client name RegistryZkClient = "zk registry" - // RegistryConnDelay: connection delay + // RegistryConnDelay connection delay RegistryConnDelay = 3 - // MaxWaitInterval: max wait interval + // MaxWaitInterval max wait interval MaxWaitInterval = 3 * time.Second ) diff --git a/remoting/etcdv3/client.go b/remoting/etcdv3/client.go index ae9ba05f0027cc9dddedfc8487557b32f0da5c05..ba3ea6e864923b1e70cc4a0d31ee98415807699c 100644 --- a/remoting/etcdv3/client.go +++ b/remoting/etcdv3/client.go @@ -36,11 +36,11 @@ import ( ) const ( - // ConnDelay: connection dalay + // ConnDelay connection dalay ConnDelay = 3 - // MaxFailTimes: max failure times + // MaxFailTimes max failure times MaxFailTimes = 15 - // RegistryETCDV3Client: client name + // RegistryETCDV3Client client name RegistryETCDV3Client = "etcd registry" ) diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go index 47416e598628be67eb06f5cb88bd2345a7729687..a51a68bce78f4f24658f96dac5dc8778a07a6d9a 100644 --- a/remoting/etcdv3/listener.go +++ b/remoting/etcdv3/listener.go @@ -49,7 +49,7 @@ func NewEventListener(client *Client) *EventListener { } } -// ListenServiceNodeEvent: Listen on a spec key +// ListenServiceNodeEvent Listen on a spec key // this method will return true when spec key deleted, // this method will return false when deep layer connection lose func (l *EventListener) ListenServiceNodeEvent(key string, listener ...remoting.DataListener) bool { @@ -136,7 +136,7 @@ func (l *EventListener) handleEvents(event *clientv3.Event, listeners ...remotin panic("unreachable") } -// ListenServiceNodeEventWithPrefix: Listen on a set of key with spec prefix +// ListenServiceNodeEventWithPrefix Listen on a set of key with spec prefix func (l *EventListener) ListenServiceNodeEventWithPrefix(prefix string, listener ...remoting.DataListener) { l.wg.Add(1) diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 8d2cbd016a219e08a0d20d64190901248ca1bc98..b5f02281e9dfc5b5b6f1a289164e85d2b457d1a8 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -35,8 +35,9 @@ import ( ) const ( - // ConnDelay: connection delay interval - ConnDelay = 3 + // ConnDelay connection delay interval + ConnDelay = 3 + // MaxFailTimes max fail times MaxFailTimes = 15 )