Skip to content

Commit

Permalink
Imp: add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo344 committed Jul 19, 2020
1 parent 8e409f5 commit 781f97e
Show file tree
Hide file tree
Showing 40 changed files with 126 additions and 100 deletions.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache Dubbo Go
Apache Dubbo-go
Copyright 2018-2020 The Apache Software Foundation

This product includes software developed at
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/broadcast_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func newBroadcastClusterInvoker(directory cluster.Directory) protocol.Invoker {
}
}

// nolint
func (invoker *broadcastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
invokers := invoker.directory.List(invocation)
err := invoker.checkInvokers(invokers, invocation)
Expand Down
1 change: 1 addition & 0 deletions common/constant/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package constant

// nolint
const (
// CONF_CONSUMER_FILE_PATH ...
CONF_CONSUMER_FILE_PATH = "CONF_CONSUMER_FILE_PATH"
Expand Down
8 changes: 4 additions & 4 deletions config/base_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ var baseMockRef = map[string]*ReferenceConfig{
InterfaceName: "com.MockService",
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
{
InterfaceId: "MockService",
InterfaceName: "com.MockService",
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
},
},
Expand Down Expand Up @@ -258,14 +258,14 @@ func TestRefreshProvider(t *testing.T) {
InterfaceName: "com.MockService",
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
{
InterfaceId: "MockService",
InterfaceName: "com.MockService",
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions config/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ func mockInitProviderWithSingleRegistry() {
{
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
{
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
},
Expand Down
4 changes: 2 additions & 2 deletions config/method_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"github.com/apache/dubbo-go/common/constant"
)

// MethodConfig ...
// MethodConfig defines method config
type MethodConfig struct {
InterfaceId string
InterfaceName string
Name string `yaml:"name" json:"name,omitempty" property:"name"`
Retries string `yaml:"retries" json:"retries,omitempty" property:"retries"`
Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"`
LoadBalance string `yaml:"loadbalance" json:"loadbalance,omitempty" property:"loadbalance"`
Weight int64 `yaml:"weight" json:"weight,omitempty" property:"weight"`
TpsLimitInterval string `yaml:"tps.limit.interval" json:"tps.limit.interval,omitempty" property:"tps.limit.interval"`
TpsLimitRate string `yaml:"tps.limit.rate" json:"tps.limit.rate,omitempty" property:"tps.limit.rate"`
Expand Down
2 changes: 1 addition & 1 deletion config/reference_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (c *ReferenceConfig) getUrlMap() url.Values {
urlMap.Set(constant.REFERENCE_FILTER_KEY, mergeValue(consumerConfig.Filter, c.Filter, defaultReferenceFilter))

for _, v := range c.Methods {
urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.Loadbalance)
urlMap.Set("methods."+v.Name+"."+constant.LOADBALANCE_KEY, v.LoadBalance)
urlMap.Set("methods."+v.Name+"."+constant.RETRIES_KEY, v.Retries)
urlMap.Set("methods."+v.Name+"."+constant.STICKY_KEY, strconv.FormatBool(v.Sticky))
if len(v.RequestTimeout) != 0 {
Expand Down
8 changes: 4 additions & 4 deletions config/reference_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func doInitConsumer() {
{
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
{
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Sticky: true,
},
},
Expand Down Expand Up @@ -174,12 +174,12 @@ func doInitConsumerWithSingleRegistry() {
{
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
{
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (c *ServiceConfig) getUrlMap() url.Values {

for _, v := range c.Methods {
prefix := "methods." + v.Name + "."
urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.Loadbalance)
urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.LoadBalance)
urlMap.Set(prefix+constant.RETRIES_KEY, v.Retries)
urlMap.Set(prefix+constant.WEIGHT_KEY, strconv.FormatInt(v.Weight, 10))

Expand Down
8 changes: 4 additions & 4 deletions config/service_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ func doInitProvider() {
{
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
{
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
},
Expand All @@ -81,13 +81,13 @@ func doInitProvider() {
{
Name: "GetUser",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
{
Name: "GetUser1",
Retries: "2",
Loadbalance: "random",
LoadBalance: "random",
Weight: 200,
},
},
Expand Down
1 change: 1 addition & 0 deletions config_center/apollo/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func createDynamicConfigurationFactory() config_center.DynamicConfigurationFacto

type apolloConfigurationFactory struct{}

// GetDynamicConfiguration returns the dynamic configuration
func (f *apolloConfigurationFactory) GetDynamicConfiguration(url *common.URL) (config_center.DynamicConfiguration, error) {
dynamicConfiguration, err := newApolloConfiguration(url)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions config_center/mock_dynamic_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/apache/dubbo-go/remoting"
)

// MockDynamicConfigurationFactory ...
// MockDynamicConfigurationFactory defines content
type MockDynamicConfigurationFactory struct {
Content string
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *MockDynamicConfiguration) GetConfigKeysByGroup(group string) (*gxset.Ha
return gxset.NewSet(c.content), nil
}

// MockDynamicConfiguration ...
// MockDynamicConfiguration uses to parse content and defines listener
type MockDynamicConfiguration struct {
parser parser.ConfigurationParser
content string
Expand Down Expand Up @@ -149,7 +149,7 @@ func (c *MockDynamicConfiguration) GetRule(key string, opts ...Option) (string,
return c.GetProperties(key, opts...)
}

// MockServiceConfigEvent ...
// MockServiceConfigEvent returns ConfiguratorConfig
func (c *MockDynamicConfiguration) MockServiceConfigEvent() {
config := &parser.ConfiguratorConfig{
ConfigVersion: "2.7.1",
Expand All @@ -171,7 +171,7 @@ func (c *MockDynamicConfiguration) MockServiceConfigEvent() {
c.listener[key].Process(&ConfigChangeEvent{Key: key, Value: string(value), ConfigType: remoting.EventTypeAdd})
}

// MockApplicationConfigEvent ...
// MockApplicationConfigEvent returns ConfiguratorConfig
func (c *MockDynamicConfiguration) MockApplicationConfigEvent() {
config := &parser.ConfiguratorConfig{
ConfigVersion: "2.7.1",
Expand Down
17 changes: 11 additions & 6 deletions config_center/parser/configuration_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import (
)

const (
// ScopeApplication ...
// ScopeApplication : scope application
ScopeApplication = "application"
// GeneralType ...
// GeneralType defines the general type
GeneralType = "general"
)

// ConfigurationParser ...
// ConfigurationParser interface
type ConfigurationParser interface {
Parse(string) (map[string]string, error)
ParseToUrls(content string) ([]*common.URL, error)
Expand All @@ -50,7 +50,7 @@ type ConfigurationParser interface {
// DefaultConfigurationParser for supporting properties file in config center
type DefaultConfigurationParser struct{}

// ConfiguratorConfig ...
// ConfiguratorConfig defines configurator config
type ConfiguratorConfig struct {
ConfigVersion string `yaml:"configVersion"`
Scope string `yaml:"scope"`
Expand All @@ -59,7 +59,7 @@ type ConfiguratorConfig struct {
Configs []ConfigItem `yaml:"configs"`
}

// ConfigItem ...
// ConfigItem defines config item
type ConfigItem struct {
Type string `yaml:"type"`
Enabled bool `yaml:"enabled"`
Expand All @@ -81,7 +81,7 @@ func (parser *DefaultConfigurationParser) Parse(content string) (map[string]stri
return pps.Map(), nil
}

// ParseToUrls ...
// ParseToUrls is used to parse content to urls
func (parser *DefaultConfigurationParser) ParseToUrls(content string) ([]*common.URL, error) {
config := ConfiguratorConfig{}
if err := yaml.Unmarshal([]byte(content), &config); err != nil {
Expand Down Expand Up @@ -110,6 +110,7 @@ func (parser *DefaultConfigurationParser) ParseToUrls(content string) ([]*common
return allUrls, nil
}

// serviceItemToUrls is used to transfer item and config to urls
func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
var addresses = item.Addresses
if len(addresses) == 0 {
Expand Down Expand Up @@ -156,6 +157,7 @@ func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.UR
return urls, nil
}

// nolint
func appItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
var addresses = item.Addresses
if len(addresses) == 0 {
Expand Down Expand Up @@ -196,6 +198,7 @@ func appItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, e
return urls, nil
}

// getServiceString returns service string
func getServiceString(service string) (string, error) {
if len(service) == 0 {
return "", perrors.New("service field in configuration is null.")
Expand All @@ -219,6 +222,7 @@ func getServiceString(service string) (string, error) {
return serviceStr, nil
}

// nolint
func getParamString(item ConfigItem) (string, error) {
var retStr string
retStr = retStr + "category="
Expand All @@ -241,6 +245,7 @@ func getParamString(item ConfigItem) (string, error) {
return retStr, nil
}

// getEnabledString returns enabled string
func getEnabledString(item ConfigItem, config ConfiguratorConfig) string {
retStr := "&enabled="
if len(item.Type) == 0 || item.Type == GeneralType {
Expand Down
2 changes: 1 addition & 1 deletion config_center/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/apache/dubbo-go/remoting"
)

// CacheListener ...
// CacheListener defines keyListeners and rootPath
type CacheListener struct {
keyListeners sync.Map
rootPath string
Expand Down
2 changes: 1 addition & 1 deletion filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// Filter interface defines the functions of a filter
// Extension - Filter
type Filter interface {
// Invoke is the core function of a filter, it determins the process of the filter
// Invoke is the core function of a filter, it determines the process of the filter
Invoke(context.Context, protocol.Invoker, protocol.Invocation) protocol.Result
// OnResponse updates the results from Invoke and then returns the modified results.
OnResponse(context.Context, protocol.Result, protocol.Invoker, protocol.Invocation) protocol.Result
Expand Down
12 changes: 6 additions & 6 deletions filter/filter_impl/access_log_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ import (
const (
//used in URL.

// FileDateFormat ...
// nolint
FileDateFormat = "2006-01-02"
// MessageDateLayout ...
// nolint
MessageDateLayout = "2006-01-02 15:04:05"
// LogMaxBuffer ...
// nolint
LogMaxBuffer = 5000
// LogFileMode ...
// nolint
LogFileMode = 0600

// those fields are the data collected by this filter

// Types ...
// nolint
Types = "types"
// Arguments ...
// nolint
Arguments = "arguments"
)

Expand Down
2 changes: 1 addition & 1 deletion filter/filter_impl/echo_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (ef *EchoFilter) OnResponse(_ context.Context, result protocol.Result, _ pr
return result
}

// GetFilter ...
// GetFilter returns the Filter
func GetFilter() filter.Filter {
return &EchoFilter{}
}
2 changes: 1 addition & 1 deletion filter/filter_impl/execute_limit_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type ExecuteLimitFilter struct {
executeState *concurrent.Map
}

// ExecuteState ...
// ExecuteState defines the concurrent count
type ExecuteState struct {
concurrentCount int64
}
Expand Down
2 changes: 1 addition & 1 deletion filter/filter_impl/generic_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {

// when do a generic invoke, struct need to be map

// GenericFilter ...
// nolint
type GenericFilter struct{}

// Invoke turns the parameters to map for generic method
Expand Down
Loading

0 comments on commit 781f97e

Please sign in to comment.