merge ranges

This commit is contained in:
hebo
2019-09-07 19:07:49 +08:00
parent c7833a9df7
commit 07d0c60086
113 changed files with 11865 additions and 95 deletions

View File

@@ -17,14 +17,14 @@ var (
)
var (
configMapLock sync.RWMutex
configMap map[string]configItem
configMapLock sync.RWMutex
configMap map[string]configItem
throwPacketRate *throwPacketRateConfig
)
func init() {
func init() {
flag.IntVar(&communicatePort, "communicate_port", 8088, "http server port. Default is 8088")
configMap = make(map[string]configItem)
tprc := newThrowPacketRateConfig()
configMap[tprc.name] = tprc
throwPacketRate = newThrowPacketRateConfig()
}

View File

@@ -81,3 +81,7 @@ func outletSetConfig(resp http.ResponseWriter, req *http.Request) {
mp.Err = SetConfig(ep.ConfigName, ep.Value)
}
func GetThrowPacketRate() float64 {
return throwPacketRate.value
}

View File

@@ -4,6 +4,11 @@ import "fmt"
// SetConfig set config by config key(name) and value
func SetConfig(key string, val interface{}) (err error) {
if key == throwPacketRate.name {
err = throwPacketRate.setVal(val)
return
}
configMapLock.Lock()
defer configMapLock.Unlock()

View File

@@ -34,3 +34,7 @@ func (tc *throwPacketRateConfig) setVal (val interface{}) (err error){
func (tc *throwPacketRateConfig) getVal () (val interface{}){
return tc.value
}
func (tc *throwPacketRateConfig) GetValFloat64 () (val float64){
return tc.value
}