delete useless lock
This commit is contained in:
parent
806a392d0f
commit
5207b2fcba
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue