Skip to content

Commit db33aba

Browse files
committed
refactor: simplify cluster and sentinel initialization functions
- Remove the boolean parameter from `WithCluster` and always enable the cluster. - Remove the boolean parameter from `WithSentinel` and always enable the sentinel. - Update tests to reflect the changes in `WithCluster` and `WithSentinel` functions. Signed-off-by: appleboy <[email protected]>
1 parent 142493e commit db33aba

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

options.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ func WithDB(db int) Option {
4343
}
4444

4545
// WithCluster redis cluster
46-
func WithCluster(enable bool) Option {
46+
func WithCluster() Option {
4747
return func(w *options) {
48-
w.cluster = enable
48+
w.cluster = true
4949
}
5050
}
5151

5252
// WithSentinel redis sentinel
53-
func WithSentinel(enable bool) Option {
53+
func WithSentinel() Option {
5454
return func(w *options) {
55-
w.sentinel = enable
55+
w.sentinel = true
5656
}
5757
}
5858

redis_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func TestRedisCluster(t *testing.T) {
226226
w := NewWorker(
227227
WithAddr(strings.Join(hosts, ",")),
228228
WithChannel("testCluster"),
229-
WithCluster(true),
229+
WithCluster(),
230230
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
231231
time.Sleep(500 * time.Millisecond)
232232
return nil
@@ -280,7 +280,7 @@ func TestRedisSentinel(t *testing.T) {
280280
WithAddr(strings.Join(hosts, ",")),
281281
WithMasterName("mymaster"),
282282
WithChannel("testSentinel"),
283-
WithSentinel(true),
283+
WithSentinel(),
284284
WithRunFunc(func(ctx context.Context, m core.QueuedMessage) error {
285285
time.Sleep(500 * time.Millisecond)
286286
return nil

0 commit comments

Comments
 (0)