Skip to content

Commit 857fbcc

Browse files
authored
Merge pull request #1033 from timvaillancourt/additional-sentinel-funcs
Add .Master(), .Slaves() and .CkQuorum() funcs for Sentinel
2 parents 75795aa + 2ff1db2 commit 857fbcc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sentinel.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,30 @@ func (c *SentinelClient) Master(name string) *StringStringMapCmd {
195195
return cmd
196196
}
197197

198+
// Masters shows a list of monitored masters and their state.
199+
func (c *SentinelClient) Masters() *SliceCmd {
200+
cmd := NewSliceCmd("sentinel", "masters")
201+
c.Process(cmd)
202+
return cmd
203+
}
204+
205+
// Slaves shows a list of slaves for the specified master and their state.
206+
func (c *SentinelClient) Slaves(name string) *SliceCmd {
207+
cmd := NewSliceCmd("sentinel", "slaves", name)
208+
c.Process(cmd)
209+
return cmd
210+
}
211+
212+
// CkQuorum checks if the current Sentinel configuration is able to reach the
213+
// quorum needed to failover a master, and the majority needed to authorize the
214+
// failover. This command should be used in monitoring systems to check if a
215+
// Sentinel deployment is ok.
216+
func (c *SentinelClient) CkQuorum(name string) *StringCmd {
217+
cmd := NewStringCmd("sentinel", "ckquorum", name)
218+
c.Process(cmd)
219+
return cmd
220+
}
221+
198222
type sentinelFailover struct {
199223
sentinelAddrs []string
200224

0 commit comments

Comments
 (0)