Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments for common directory #530

Merged
merged 7 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mod: modify inappropriate comments after review & merge develop branch
  • Loading branch information
watermelo committed May 24, 2020
commit 51ec3df1051d0ed187b65642ac3310d67b2ba4a9
10 changes: 5 additions & 5 deletions common/config/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ func (env *Environment) Configuration() *list.List {
return cfgList
}

// SetDynamicConfiguration is used to set value for dynamicConfiguration
// SetDynamicConfiguration sets value for dynamicConfiguration
func (env *Environment) SetDynamicConfiguration(dc config_center.DynamicConfiguration) {
env.dynamicConfiguration = dc
}

// GetDynamicConfiguration is used to get dynamicConfiguration
// GetDynamicConfiguration gets dynamicConfiguration
func (env *Environment) GetDynamicConfiguration() config_center.DynamicConfiguration {
return env.dynamicConfiguration
}

// InmemoryConfiguration is used to store config in memory
// InmemoryConfiguration stores config in memory
type InmemoryConfiguration struct {
store *sync.Map
}
Expand All @@ -110,7 +110,7 @@ func newInmemoryConfiguration(p *sync.Map) *InmemoryConfiguration {
return &InmemoryConfiguration{store: p}
}

// GetProperty is used the key to get value from InmemoryConfiguration instance
// GetProperty gets value from InmemoryConfiguration instance by @key
func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) {
if conf.store == nil {
return false, ""
Expand All @@ -124,7 +124,7 @@ func (conf *InmemoryConfiguration) GetProperty(key string) (bool, string) {
return false, ""
}

// GetSubProperty is used the subkey to get sub property from InmemoryConfiguration instance
// GetSubProperty gets sub property from InmemoryConfiguration instance by @subkey
func (conf *InmemoryConfiguration) GetSubProperty(subKey string) map[string]struct{} {
if conf.store == nil {
return nil
Expand Down
8 changes: 4 additions & 4 deletions common/extension/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var (
accesskeyStorages = make(map[string]func() filter.AccessKeyStorage)
)

// SetAuthenticator puts the fcn into map with name
// SetAuthenticator puts the @fcn into map with name
func SetAuthenticator(name string, fcn func() filter.Authenticator) {
authenticators[name] = fcn
}

// GetAuthenticator finds the Authenticator with name
// GetAuthenticator finds the Authenticator with @name
// if not found, it will panic
func GetAuthenticator(name string) filter.Authenticator {
if authenticators[name] == nil {
Expand All @@ -40,12 +40,12 @@ func GetAuthenticator(name string) filter.Authenticator {
return authenticators[name]()
}

// SetAccesskeyStorages will set the fcn into map with this name
// SetAccesskeyStorages will set the @fcn into map with this name
func SetAccesskeyStorages(name string, fcn func() filter.AccessKeyStorage) {
accesskeyStorages[name] = fcn
}

// GetAccesskeyStorages finds the storage with the name.
// GetAccesskeyStorages finds the storage with the @name.
// If not found, it will panic.
func GetAccesskeyStorages(name string) filter.AccessKeyStorage {
if accesskeyStorages[name] == nil {
Expand Down
4 changes: 2 additions & 2 deletions common/extension/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ var (
clusters = make(map[string]func() cluster.Cluster)
)

// SetCluster sets the cluster fault-tolerant mode with name
// SetCluster sets the cluster fault-tolerant mode with @name
// For example: available/failfast/broadcast/failfast/failsafe/...
func SetCluster(name string, fcn func() cluster.Cluster) {
clusters[name] = fcn
}

// GetCluster finds the cluster fault-tolerant mode with name
// GetCluster finds the cluster fault-tolerant mode with @name
func GetCluster(name string) cluster.Cluster {
if clusters[name] == nil {
panic("cluster for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/config_center.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var (
configCenters = make(map[string]func(config *common.URL) (config_center.DynamicConfiguration, error))
)

// SetConfigCenter sets the DynamicConfiguration with name
// SetConfigCenter sets the DynamicConfiguration with @name
func SetConfigCenter(name string, v func(config *common.URL) (config_center.DynamicConfiguration, error)) {
configCenters[name] = v
}

// GetConfigCenter finds the DynamicConfiguration with name
// GetConfigCenter finds the DynamicConfiguration with @name
func GetConfigCenter(name string, config *common.URL) (config_center.DynamicConfiguration, error) {
if configCenters[name] == nil {
panic("config center for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/config_center_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
configCenterFactories = make(map[string]func() config_center.DynamicConfigurationFactory)
)

// SetConfigCenterFactory sets the DynamicConfigurationFactory with name
// SetConfigCenterFactory sets the DynamicConfigurationFactory with @name
func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigurationFactory) {
configCenterFactories[name] = v
}

// GetConfigCenterFactory finds the DynamicConfigurationFactory with name
// GetConfigCenterFactory finds the DynamicConfigurationFactory with @name
func GetConfigCenterFactory(name string) config_center.DynamicConfigurationFactory {
if configCenterFactories[name] == nil {
panic("config center for " + name + " is not existing, make sure you have import the package.")
Expand Down
8 changes: 4 additions & 4 deletions common/extension/config_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ var (
defaults = make(map[string]string)
)

// SetConfigReaders sets a creator of config reader.
// SetConfigReaders sets a creator of config reader with @name
func SetConfigReaders(name string, v func() interfaces.ConfigReader) {
configReaders[name] = v
}

// GetConfigReaders gets a config reader by name.
// GetConfigReaders gets a config reader with @name
func GetConfigReaders(name string) interfaces.ConfigReader {
if configReaders[name] == nil {
panic("config reader for " + name + " is not existing, make sure you have imported the package.")
}
return configReaders[name]()
}

// SetDefaultConfigReader sets {name} to default config reader for {module}
// SetDefaultConfigReader sets @name for @module in default config reader
func SetDefaultConfigReader(module, name string) {
defaults[module] = name
}

// GetDefaultConfigReader
// GetDefaultConfigReader gets default config reader
func GetDefaultConfigReader() map[string]string {
return defaults
}
6 changes: 3 additions & 3 deletions common/extension/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ var (
configurator = make(map[string]getConfiguratorFunc)
)

// SetConfigurator sets the getConfiguratorFunc with name
// SetConfigurator sets the getConfiguratorFunc with @name
func SetConfigurator(name string, v getConfiguratorFunc) {
configurator[name] = v
}

// GetConfigurator finds the Configurator with name
// GetConfigurator finds the Configurator with @name
func GetConfigurator(name string, url *common.URL) config_center.Configurator {
if configurator[name] == nil {
panic("configurator for " + name + " is not existing, make sure you have import the package.")
Expand All @@ -52,7 +52,7 @@ func SetDefaultConfigurator(v getConfiguratorFunc) {
configurator[DefaultKey] = v
}

// GetDefaultConfigurator get default configurator
// GetDefaultConfigurator gets default configurator
func GetDefaultConfigurator(url *common.URL) config_center.Configurator {
if configurator[DefaultKey] == nil {
panic("configurator for default is not existing, make sure you have import the package.")
Expand Down
8 changes: 4 additions & 4 deletions common/extension/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ var (
rejectedExecutionHandler = make(map[string]func() filter.RejectedExecutionHandler)
)

// SetFilter sets the filter extension with name
// SetFilter sets the filter extension with @name
// For example: hystrix/metrics/token/tracing/limit/...
func SetFilter(name string, v func() filter.Filter) {
filters[name] = v
}

// GetFilter finds the filter extension with name
// GetFilter finds the filter extension with @name
func GetFilter(name string) filter.Filter {
if filters[name] == nil {
panic("filter for " + name + " is not existing, make sure you have imported the package.")
}
return filters[name]()
}

// SetRejectedExecutionHandler sets the RejectedExecutionHandler with name
// SetRejectedExecutionHandler sets the RejectedExecutionHandler with @name
func SetRejectedExecutionHandler(name string, creator func() filter.RejectedExecutionHandler) {
rejectedExecutionHandler[name] = creator
}

// GetRejectedExecutionHandler finds the RejectedExecutionHandler with name
// GetRejectedExecutionHandler finds the RejectedExecutionHandler with @name
func GetRejectedExecutionHandler(name string) filter.RejectedExecutionHandler {
creator, ok := rejectedExecutionHandler[name]
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions common/extension/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var (
healthCheckers = make(map[string]func(url *common.URL) router.HealthChecker)
)

// SethealthChecker sets the HealthChecker with name
// SethealthChecker sets the HealthChecker with @name
func SethealthChecker(name string, fcn func(url *common.URL) router.HealthChecker) {
healthCheckers[name] = fcn
}

// GetHealthChecker gets the HealthChecker with name
// GetHealthChecker gets the HealthChecker with @name
func GetHealthChecker(name string, url *common.URL) router.HealthChecker {
if healthCheckers[name] == nil {
panic("healthCheckers for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/loadbalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ var (
loadbalances = make(map[string]func() cluster.LoadBalance)
)

// SetLoadbalance sets the loadbalance extension with name
// SetLoadbalance sets the loadbalance extension with @name
// For example: random/round_robin/consistent_hash/least_active/...
func SetLoadbalance(name string, fcn func() cluster.LoadBalance) {
loadbalances[name] = fcn
}

// GetLoadbalance finds the loadbalance extension with name
// GetLoadbalance finds the loadbalance extension with @name
func GetLoadbalance(name string) cluster.LoadBalance {
if loadbalances[name] == nil {
panic("loadbalance for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/metadata_report_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
metaDataReportFactories = make(map[string]func() metadata.MetadataReportFactory, 8)
)

// SetMetadataReportFactory sets the MetadataReportFactory with name
// SetMetadataReportFactory sets the MetadataReportFactory with @name
func SetMetadataReportFactory(name string, v func() metadata.MetadataReportFactory) {
metaDataReportFactories[name] = v
}

// GetMetadataReportFactory finds the MetadataReportFactory with name
// GetMetadataReportFactory finds the MetadataReportFactory with @name
func GetMetadataReportFactory(name string) metadata.MetadataReportFactory {
if metaDataReportFactories[name] == nil {
panic("metadata report for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ var (
metricReporterMap = make(map[string]func() metrics.Reporter, 4)
)

// SetMetricReporter sets a reporter with the name
// SetMetricReporter sets a reporter with the @name
func SetMetricReporter(name string, reporterFunc func() metrics.Reporter) {
metricReporterMap[name] = reporterFunc
}

// GetMetricReporter finds the reporter with name.
// GetMetricReporter finds the reporter with @name.
// if not found, it will panic.
// we should know that this method usually is called when system starts, so we should panic
func GetMetricReporter(name string) metrics.Reporter {
Expand Down
4 changes: 2 additions & 2 deletions common/extension/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
protocols = make(map[string]func() protocol.Protocol)
)

// SetProtocol sets the protocol extension with name
// SetProtocol sets the protocol extension with @name
func SetProtocol(name string, v func() protocol.Protocol) {
protocols[name] = v
}

// GetProtocol finds the protocol extension with name
// GetProtocol finds the protocol extension with @name
func GetProtocol(name string) protocol.Protocol {
if protocols[name] == nil {
panic("protocol for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/proxy_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory)
)

// SetProxyFactory sets the ProxyFactory extension with name
// SetProxyFactory sets the ProxyFactory extension with @name
func SetProxyFactory(name string, f func(...proxy.Option) proxy.ProxyFactory) {
proxyFactories[name] = f
}

// GetProxyFactory finds the ProxyFactory extension with name
// GetProxyFactory finds the ProxyFactory extension with @name
func GetProxyFactory(name string) proxy.ProxyFactory {
if name == "" {
name = "default"
Expand Down
4 changes: 2 additions & 2 deletions common/extension/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var (
registrys = make(map[string]func(config *common.URL) (registry.Registry, error))
)

// SetRegistry sets the registry extension with name
// SetRegistry sets the registry extension with @name
func SetRegistry(name string, v func(config *common.URL) (registry.Registry, error)) {
registrys[name] = v
}

// GetRegistry finds the registry extension with name
// GetRegistry finds the registry extension with @name
func GetRegistry(name string, config *common.URL) (registry.Registry, error) {
if registrys[name] == nil {
panic("registry for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8)
)

// SetRestClient sets the RestClient with name
// SetRestClient sets the RestClient with @name
func SetRestClient(name string, fun func(restOptions *client.RestOptions) client.RestClient) {
restClients[name] = fun
}

// GetNewRestClient finds the RestClient with name
// GetNewRestClient finds the RestClient with @name
func GetNewRestClient(name string, restOptions *client.RestOptions) client.RestClient {
if restClients[name] == nil {
panic("restClient for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/rest_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ var (
restServers = make(map[string]func() server.RestServer, 8)
)

// SetRestServer sets the RestServer with name
// SetRestServer sets the RestServer with @name
func SetRestServer(name string, fun func() server.RestServer) {
restServers[name] = fun
}

// GetNewRestServer finds the RestServer with name
// GetNewRestServer finds the RestServer with @name
func GetNewRestServer(name string) server.RestServer {
if restServers[name] == nil {
panic("restServer for " + name + " is not existing, make sure you have import the package.")
Expand Down
4 changes: 2 additions & 2 deletions common/extension/router_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ var (
fileRouterFactories = make(map[string]router.FileRouterFactory)
)

// SetRouterFactory sets create router factory function by name
// SetRouterFactory sets create router factory function with @name
func SetRouterFactory(name string, fun func() router.RouterFactory) {
routers[name] = fun
}

// GetRouterFactory gets create router factory function by name
// GetRouterFactory gets create router factory function by @name
func GetRouterFactory(name string) router.RouterFactory {
if routers[name] == nil {
panic("router_factory for " + name + " is not existing, make sure you have import the package.")
Expand Down
2 changes: 1 addition & 1 deletion common/extension/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
discoveryCreatorMap = make(map[string]func(url *common.URL) (registry.ServiceDiscovery, error), 4)
)

// SetServiceDiscovery will store the creator and name
// SetServiceDiscovery will store the @creator and @name
func SetServiceDiscovery(name string, creator func(url *common.URL) (registry.ServiceDiscovery, error)) {
discoveryCreatorMap[name] = creator
}
Expand Down
8 changes: 4 additions & 4 deletions common/extension/tps_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var (
tpsLimiter = make(map[string]func() filter.TpsLimiter)
)

// SetTpsLimiter sets the TpsLimiter with name
// SetTpsLimiter sets the TpsLimiter with @name
func SetTpsLimiter(name string, creator func() filter.TpsLimiter) {
tpsLimiter[name] = creator
}

// GetTpsLimiter finds the TpsLimiter with name
// GetTpsLimiter finds the TpsLimiter with @name
func GetTpsLimiter(name string) filter.TpsLimiter {
creator, ok := tpsLimiter[name]
if !ok {
Expand All @@ -41,12 +41,12 @@ func GetTpsLimiter(name string) filter.TpsLimiter {
return creator()
}

// SetTpsLimitStrategy sets the TpsLimitStrategyCreator with name
// SetTpsLimitStrategy sets the TpsLimitStrategyCreator with @name
func SetTpsLimitStrategy(name string, creator filter.TpsLimitStrategyCreator) {
tpsLimitStrategy[name] = creator
}

// GetTpsLimitStrategyCreator finds the TpsLimitStrategyCreator with name
// GetTpsLimitStrategyCreator finds the TpsLimitStrategyCreator with @name
func GetTpsLimitStrategyCreator(name string) filter.TpsLimitStrategyCreator {
creator, ok := tpsLimitStrategy[name]
if !ok {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.