Skip to content
Snippets Groups Projects
Commit d4ee2bfc authored by flycash's avatar flycash
Browse files

Move GetXXXConfig to config_load file

parent 5e74a2c3
No related branches found
No related tags found
No related merge requests found
......@@ -35,16 +35,6 @@ type ApplicationConfig struct {
Environment string `yaml:"environment" json:"environment,omitempty" property:"environment"`
}
// find the application config
// if not, we will create one
// Usually applicationConfig will be initialized when system start
func GetApplicationConfig() *ApplicationConfig {
if applicationConfig == nil {
applicationConfig = &ApplicationConfig{}
}
return applicationConfig
}
// Prefix ...
func (*ApplicationConfig) Prefix() string {
return constant.DUBBO + ".application."
......
......@@ -173,3 +173,42 @@ func GetRPCService(name string) common.RPCService {
func RPCService(service common.RPCService) {
consumerConfig.References[service.Reference()].Implement(service)
}
// GetMetricConfig find the MetricConfig
// if it is nil, create a new one
func GetMetricConfig() *MetricConfig {
if metricConfig == nil {
metricConfig = &MetricConfig{}
}
return metricConfig
}
// GetApplicationConfig find the application config
// if not, we will create one
// Usually applicationConfig will be initialized when system start
func GetApplicationConfig() *ApplicationConfig {
if applicationConfig == nil {
applicationConfig = &ApplicationConfig{}
}
return applicationConfig
}
// GetProviderConfig find the provider config
// if not found, create new one
func GetProviderConfig() ProviderConfig {
if providerConfig == nil {
logger.Warnf("providerConfig is nil!")
return ProviderConfig{}
}
return *providerConfig
}
// GetConsumerConfig find the consumer config
// if not found, create new one
func GetConsumerConfig() ConsumerConfig {
if consumerConfig == nil {
logger.Warnf("consumerConfig is nil!")
return ConsumerConfig{}
}
return *consumerConfig
}
......@@ -85,15 +85,6 @@ func SetConsumerConfig(c ConsumerConfig) {
consumerConfig = &c
}
// GetConsumerConfig ...
func GetConsumerConfig() ConsumerConfig {
if consumerConfig == nil {
logger.Warnf("consumerConfig is nil!")
return ConsumerConfig{}
}
return *consumerConfig
}
// ConsumerInit ...
func ConsumerInit(confConFile string) error {
if confConFile == "" {
......
......@@ -27,15 +27,6 @@ type MetricConfig struct {
HistogramBucket []float64 `yaml:"histogram_bucket" json:"histogram_bucket,omitempty"`
}
// find the MetricConfig
// if it is nil, create a new one
func GetMetricConfig() *MetricConfig {
if metricConfig == nil {
metricConfig = &MetricConfig{}
}
return metricConfig
}
// find the histogram bucket
// if it's empty, the default value will be return
func (mc *MetricConfig) GetHistogramBucket() []float64 {
......
......@@ -76,15 +76,6 @@ func SetProviderConfig(p ProviderConfig) {
providerConfig = &p
}
// GetProviderConfig ...
func GetProviderConfig() ProviderConfig {
if providerConfig == nil {
logger.Warnf("providerConfig is nil!")
return ProviderConfig{}
}
return *providerConfig
}
// ProviderInit ...
func ProviderInit(confProFile string) error {
if len(confProFile) == 0 {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment