You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2020/01/25 15:53:35 UTC
[dubbo-go] branch develop updated: Fix: golint by goreportcard.com
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new ea95e04 Fix: golint by goreportcard.com
ea95e04 is described below
commit ea95e04b691e67136cd00f987990b1499cdfd630
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sat Jan 25 23:53:08 2020 +0800
Fix: golint by goreportcard.com
Signed-off-by: AlexStocks <al...@foxmail.com>
---
cluster/directory.go | 3 ++-
cluster/loadbalance.go | 3 ++-
cluster/router/condition_router.go | 5 ++--
cluster/router/condition_router_test.go | 4 +--
common/config/environment.go | 10 ++++----
common/constant/version.go | 6 ++---
common/extension/graceful_shutdown.go | 3 ++-
common/proxy/proxy.go | 7 ++++--
common/rpc_service.go | 9 ++++---
config/config_loader.go | 6 ++---
config/reference_config.go | 18 ++++++++------
config/service_config.go | 15 +++++------
config_center/apollo/listener.go | 27 ++++++++++----------
config_center/mock_dynamic_config.go | 14 +++++------
config_center/parser/configuration_parser.go | 6 ++---
config_center/zookeeper/impl.go | 6 ++---
filter/filter.go | 3 ++-
filter/filter_impl/access_log_filter.go | 7 ++++--
filter/filter_impl/echo_filter.go | 8 +++---
filter/filter_impl/execute_limit_filter.go | 21 ++++++++--------
filter/filter_impl/generic_filter.go | 6 +++--
filter/filter_impl/generic_service_filter_test.go | 7 +++---
.../tps/tps_limit_fix_window_strategy.go | 2 +-
.../tps/tps_limit_sliding_window_strategy.go | 2 +-
.../tps_limit_thread_safe_fix_window_strategy.go | 2 +-
.../filter_impl/tps/tps_limiter_method_service.go | 6 +++--
filter/filter_impl/tps_limit_filter.go | 5 +++-
.../handler/rejected_execution_handler_only_log.go | 10 ++++++--
filter/rejected_execution_handler.go | 2 +-
filter/tps_limit_strategy.go | 3 ++-
filter/tps_limiter.go | 3 ++-
protocol/dubbo/client.go | 4 +--
protocol/dubbo/codec.go | 12 ++++-----
protocol/dubbo/config.go | 6 +++--
protocol/grpc/grpc_protocol.go | 2 +-
protocol/grpc/internal/client.go | 3 ++-
protocol/invocation/rpcinvocation.go | 1 +
protocol/jsonrpc/http.go | 2 +-
protocol/jsonrpc/json.go | 6 ++---
protocol/jsonrpc/jsonrpc_protocol.go | 3 ++-
protocol/jsonrpc/server.go | 2 +-
protocol/protocol.go | 6 +++--
.../protocolwrapper/protocol_filter_wrapper.go | 5 ++--
registry/etcdv3/registry.go | 29 ++++++++++++++++------
registry/nacos/registry.go | 2 +-
registry/registry.go | 4 +--
registry/zookeeper/registry.go | 6 ++---
remoting/etcdv3/client.go | 6 ++---
remoting/etcdv3/listener.go | 4 +--
remoting/zookeeper/client.go | 5 ++--
50 files changed, 196 insertions(+), 141 deletions(-)
diff --git a/cluster/directory.go b/cluster/directory.go
index c3a67e9..5a03b3a 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 33170ac..fb3641a 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 c456113..c38e971 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 3844f50..43e7431 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 ec03ccf..071af31 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 f0c38f6..7302243 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 1a1fb92..3abd75c 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 b9e85a0..43ca720 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 5fec12b..b235c32 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 a6df1a6..d6eb7ff 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 fe3a72c..07b7e8f 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 9297730..37ec3a3 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 2b36620..820d02f 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 6f66570..4d972b6 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 55f2322..9aaa1f7 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 b0274d6..6842d9e 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 0da0d80..c069510 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 a236725..fbfe756 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 e1181e4..a12800a 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 4c5805a..434c378 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 9dfd125..e8ff267 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 0ba5e27..24ed3b9 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 96eede8..a9c2ac1 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 251b11e..a781cc7 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 259cbfc..1662483 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 709bb68..7fe8de9 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 52ac5d1..fa78288 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 18a22d3..0f9003c 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 2507596..caeea1d 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 f002ab2..5edf32c 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 584b229..dbc9f76 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 a9b2981..3923b7e 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 c626053..3e50eb9 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 8c1a363..dbc6989 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 1c1cca3..0f5625c 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 5ff409a..d236e30 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 da3df32..b207fd0 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 eac32f1..ba7197d 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 cd6498e..d1c2a85 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 17607ab..bed7099 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 a507800..8600f02 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 152550a..a873469 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 a630e99..70d2da0 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 8c0b570..0320579 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 5a1ae60..965e91e 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 f9e6860..863e781 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 b7c83c5..ebd6369 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 ae9ba05..ba3ea6e 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 47416e5..a51a68b 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 8d2cbd0..b5f0228 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
)