MCPcopy
hub / github.com/CodisLabs/codis / newRedisStats

Method newRedisStats

pkg/topom/topom_stats.go:27–47  ·  view source on GitHub ↗
(addr string, timeout time.Duration, do func(addr string) (*RedisStats, error))

Source from the content-addressed store, hash-verified

25}
26
27func (s *Topom) newRedisStats(addr string, timeout time.Duration, do func(addr string) (*RedisStats, error)) *RedisStats {
28 var ch = make(chan struct{})
29 stats := &RedisStats{}
30
31 go func() {
32 defer close(ch)
33 p, err := do(addr)
34 if err != nil {
35 stats.Error = rpc.NewRemoteError(err)
36 } else {
37 stats.Stats, stats.Sentinel = p.Stats, p.Sentinel
38 }
39 }()
40
41 select {
42 case <-ch:
43 return stats
44 case <-time.After(timeout):
45 return &RedisStats{Timeout: true}
46 }
47}
48
49func (s *Topom) RefreshRedisStats(timeout time.Duration) (*sync2.Future, error) {
50 s.mu.Lock()

Callers 1

RefreshRedisStatsMethod · 0.95

Calls 1

AfterMethod · 0.65

Tested by

no test coverage detected