Skip to content

Commit d65bf58

Browse files
committed
update example to match v2 changes
1 parent 6de3638 commit d65bf58

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

sentinel.go

+44-39
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,50 @@ import (
1919
//
2020
// Example of the simplest usage to contact master "mymaster":
2121
//
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+
// }
6166
type Sentinel struct {
6267
// Addrs is a slice with known Sentinel addresses.
6368
Addrs []string

0 commit comments

Comments
 (0)