Skip to content

Commit e7f7887

Browse files
authored
Merge pull request #1035 from timvaillancourt/add-sentinel-ping-remove-monitor
Add SentinelClient Ping, Monitor, Remove and Set funcs
2 parents 857fbcc + bd3a783 commit e7f7887

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sentinel.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ func (c *SentinelClient) pubSub() *PubSub {
130130
return pubsub
131131
}
132132

133+
// Ping is used to test if a connection is still alive, or to
134+
// measure latency.
135+
func (c *SentinelClient) Ping() *StringCmd {
136+
cmd := NewStringCmd("ping")
137+
c.Process(cmd)
138+
return cmd
139+
}
140+
133141
// Subscribe subscribes the client to the specified channels.
134142
// Channels can be omitted to create empty subscription.
135143
func (c *SentinelClient) Subscribe(channels ...string) *PubSub {
@@ -219,6 +227,30 @@ func (c *SentinelClient) CkQuorum(name string) *StringCmd {
219227
return cmd
220228
}
221229

230+
// Monitor tells the Sentinel to start monitoring a new master with the specified
231+
// name, ip, port, and quorum.
232+
func (c *SentinelClient) Monitor(name, ip, port, quorum string) *StringCmd {
233+
cmd := NewStringCmd("sentinel", "monitor", name, ip, port, quorum)
234+
c.Process(cmd)
235+
return cmd
236+
}
237+
238+
// Set is used in order to change configuration parameters of a specific master.
239+
func (c *SentinelClient) Set(name, option, value string) *StringCmd {
240+
cmd := NewStringCmd("sentinel", "set", name, option, value)
241+
c.Process(cmd)
242+
return cmd
243+
}
244+
245+
// Remove is used in order to remove the specified master: the master will no
246+
// longer be monitored, and will totally be removed from the internal state of
247+
// the Sentinel.
248+
func (c *SentinelClient) Remove(name string) *StringCmd {
249+
cmd := NewStringCmd("sentinel", "remove", name)
250+
c.Process(cmd)
251+
return cmd
252+
}
253+
222254
type sentinelFailover struct {
223255
sentinelAddrs []string
224256

0 commit comments

Comments
 (0)