Package sentinel implements Redis Sentinel pub/sub watcher for golang
Install go-sentinel using the "go get" command:
go get github.com/ncade/go-sentinel
See godoc for package and API descriptions
// create sentinel watcher with minimal config
snt := sentinel.New(sentinel.Config{
Password: "password",
Addrs: []string{"localhost:26379"},
Groups: []string{"redis01", "redis02", "redis03"},
RefreshInterval: 45 * time.Second,
HeartbeatInterval: 10 * time.Second,
HeartbeatTimeout: 5 * time.Second,
})
// run redis instances discovery for configured groups
// and pub/sub listening for +switch-master, +slave, +sdown, -sdown events
go snt.Run()
defer snt.Stop()
// get master address for 'redis01' master name
master, err := snt.GetMasterAddr("redis01")
// get slaves addresses for 'redis01' master name
slaves, err := snt.GetSlavesAddrs("redis01")