@@ -19,45 +19,50 @@ import (
19
19
//
20
20
// Example of the simplest usage to contact master "mymaster":
21
21
//
22
- // func newSentinelPool() *redis.Pool {
23
- // sntnl := &sentinel.Sentinel{
24
- // Addrs: []string{":26379", ":26380", ":26381"},
25
- // MasterName: "mymaster",
26
- // Dial: func(addr string) (redis.Conn, error) {
27
- // timeout := 500 * time.Millisecond
28
- // c, err := redis.DialTimeout("tcp", addr, timeout, timeout, timeout)
29
- // if err != nil {
30
- // return nil, err
31
- // }
32
- // return c, nil
33
- // },
34
- // }
35
- // return &redis.Pool{
36
- // MaxIdle: 3,
37
- // MaxActive: 64,
38
- // Wait: true,
39
- // IdleTimeout: 240 * time.Second,
40
- // Dial: func() (redis.Conn, error) {
41
- // masterAddr, err := sntnl.MasterAddr()
42
- // if err != nil {
43
- // return nil, err
44
- // }
45
- // c, err := redis.Dial("tcp", masterAddr)
46
- // if err != nil {
47
- // return nil, err
48
- // }
49
- // if _, err = c.Do("AUTH", "your-Password"); err != nil {
50
- // c.Close()
51
- // return nil, err
52
- // }
53
- // if !sentinel.TestRole(c, "master") {
54
- // c.Close()
55
- // return nil, fmt.Errorf("%s is not redis master", masterAddr)
56
- // }
57
- // return c, nil
58
- // },
59
- // }
60
- // }
22
+ // func newSentinelPool() *redis.Pool {
23
+ // sntnl := &sentinel.Sentinel{
24
+ // Addrs: []string{":26379", ":26380", ":26381"},
25
+ // MasterName: "mymaster",
26
+ // Dial: func(addr string) (redis.Conn, error) {
27
+ // timeout := 500 * time.Millisecond
28
+ // c, err := redis.DialTimeout("tcp", addr, timeout, timeout, timeout)
29
+ // if err != nil {
30
+ // return nil, err
31
+ // }
32
+ // return c, nil
33
+ // },
34
+ // }
35
+ // return &redis.Pool{
36
+ // MaxIdle: 3,
37
+ // MaxActive: 64,
38
+ // Wait: true,
39
+ // IdleTimeout: 240 * time.Second,
40
+ // Dial: func() (redis.Conn, error) {
41
+ // masterAddr, err := sntnl.MasterAddr()
42
+ // if err != nil {
43
+ // return nil, err
44
+ // }
45
+ // c, err := redis.Dial("tcp", masterAddr)
46
+ // if err != nil {
47
+ // return nil, err
48
+ // }
49
+ // if _, err = c.Do("AUTH", "your-Password"); err != nil {
50
+ // c.Close()
51
+ // return nil, err
52
+ // }
53
+ // isMaster, err := sentinel.TestRole(c, "master")
54
+ // if err != nil {
55
+ // c.Close()
56
+ // return nil, err
57
+ // }
58
+ // if !isMaster {
59
+ // c.Close()
60
+ // return nil, fmt.Errorf("%s is not redis master", masterAddr)
61
+ // }
62
+ // return c, nil
63
+ // },
64
+ // }
65
+ // }
61
66
type Sentinel struct {
62
67
// Addrs is a slice with known Sentinel addresses.
63
68
Addrs []string
0 commit comments