Merge pull request #147 from GaoJiasheng/master

delete useless lock
This commit is contained in:
Gavin Gao 2020-05-16 08:47:20 +08:00 committed by GitHub
commit c610d645bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 29 deletions

View File

@ -3,8 +3,6 @@ package config
import (
"bytes"
"fmt"
"sync"
"github.com/didi/nightingale/src/modules/collector/log/worker"
"github.com/didi/nightingale/src/modules/collector/stra"
"github.com/didi/nightingale/src/modules/collector/sys"
@ -24,15 +22,12 @@ type ConfYaml struct {
var (
Config *ConfYaml
lock = new(sync.RWMutex)
Endpoint string
Cwd string
)
// Get configuration file
func Get() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config
}
@ -42,9 +37,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
}
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil {

View File

@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"strconv"
"sync"
"github.com/didi/nightingale/src/modules/index/cache"
"github.com/didi/nightingale/src/toolkits/address"
@ -35,12 +34,9 @@ type RPCSection struct {
var (
Config *ConfYaml
lock = new(sync.RWMutex)
)
func GetCfgYml() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config
}
@ -50,9 +46,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
}
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil {

View File

@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"sort"
"sync"
"github.com/spf13/viper"
"github.com/toolkits/pkg/file"
@ -87,13 +86,10 @@ type ldapAttributes struct {
var (
yaml *Config
lock = new(sync.RWMutex)
)
// Get configuration file
func Get() *Config {
lock.RLock()
defer lock.RUnlock()
return yaml
}
@ -153,9 +149,7 @@ func Parse(ymlfile string) error {
c.Queue.EventQueues = append(c.Queue.EventQueues, prefix+prios[i])
}
lock.Lock()
yaml = &c
lock.Unlock()
return nil
}

View File

@ -3,8 +3,6 @@ package config
import (
"bytes"
"fmt"
"sync"
"github.com/didi/nightingale/src/modules/tsdb/backend/rpc"
"github.com/didi/nightingale/src/modules/tsdb/cache"
"github.com/didi/nightingale/src/modules/tsdb/index"
@ -45,12 +43,9 @@ type RpcSection struct {
var (
Config *ConfYaml
lock = new(sync.RWMutex)
)
func GetCfgYml() *ConfYaml {
lock.RLock()
defer lock.RUnlock()
return Config
}
@ -60,9 +55,6 @@ func Parse(conf string) error {
return fmt.Errorf("cannot read yml[%s]: %v", conf, err)
}
lock.Lock()
defer lock.Unlock()
viper.SetConfigType("yaml")
err = viper.ReadConfig(bytes.NewBuffer(bs))
if err != nil {