(addr string, timeout time.Duration, do func(addr string) (*RedisStats, error))
| 25 | } |
| 26 | |
| 27 | func (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 | |
| 49 | func (s *Topom) RefreshRedisStats(timeout time.Duration) (*sync2.Future, error) { |
| 50 | s.mu.Lock() |
no test coverage detected