Rename `TwemproxyInstance.StatsAddr` to `TwemproxyInstance.Addr`

This commit is contained in:
Codeb Fan 2015-11-13 00:38:45 +08:00
parent 8f218ba04a
commit 41c8d74ef0
2 changed files with 10 additions and 10 deletions

View File

@ -17,8 +17,8 @@ type Twemproxy struct {
}
type TwemproxyInstance struct {
StatsAddr string
Pools []string
Addr string
Pools []string
}
var sampleConfig = `
@ -26,7 +26,7 @@ var sampleConfig = `
[twemproxy]
[[twemproxy.instances]]
# Twemproxy stats address and port(NO scheme!)
statsAddr = "10.16.29.1:22222"
addr = "10.16.29.1:22222"
# Monitor pool name
pools = ["redis_pool", "mc_pool"]
`
@ -69,7 +69,7 @@ func (t *Twemproxy) Gather(acc plugins.Accumulator) error {
func (ti *TwemproxyInstance) Gather(
acc plugins.Accumulator,
) error {
conn, err := net.DialTimeout("tcp", ti.StatsAddr, 1*time.Second)
conn, err := net.DialTimeout("tcp", ti.Addr, 1*time.Second)
if err != nil {
return err
}
@ -84,7 +84,7 @@ func (ti *TwemproxyInstance) Gather(
}
tags := make(map[string]string)
tags["twemproxy"] = ti.StatsAddr
tags["twemproxy"] = ti.Addr
ti.processStat(acc, tags, stats)
return nil

View File

@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/require"
)
const sampleStatsAddr = "127.0.0.1:22222"
const sampleAddr = "127.0.0.1:22222"
const sampleStats = `{
"total_connections": 276448,
@ -61,7 +61,7 @@ const sampleStats = `{
}`
func mockTwemproxyServer() (net.Listener, error) {
listener, err := net.Listen("tcp", sampleStatsAddr)
listener, err := net.Listen("tcp", sampleAddr)
if err != nil {
return nil, err
}
@ -87,8 +87,8 @@ func TestGather(t *testing.T) {
twemproxy := &Twemproxy{
Instances: []TwemproxyInstance{
TwemproxyInstance{
StatsAddr: sampleStatsAddr,
Pools: []string{"demo"},
Addr: sampleAddr,
Pools: []string{"demo"},
},
},
}
@ -104,7 +104,7 @@ func TestGather(t *testing.T) {
metrics := []string{"total_connections", "curr_connections", "timestamp"}
tags := map[string]string{
"twemproxy": sampleStatsAddr,
"twemproxy": sampleAddr,
"source": sourceData["source"].(string),
}
for _, m := range metrics {