diff --git a/README.md b/README.md index 130b7bb..16ce8c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- + All-in-one tool to optimize performance and monitor errors & logs

diff --git a/export_test.go b/export_test.go index d4c2de8..49c4b94 100644 --- a/export_test.go +++ b/export_test.go @@ -6,6 +6,7 @@ import ( "net" "strings" + "github.com/go-redis/redis/v8/internal" "github.com/go-redis/redis/v8/internal/hashtag" "github.com/go-redis/redis/v8/internal/pool" ) @@ -82,3 +83,13 @@ func (state *clusterState) IsConsistent(ctx context.Context) bool { return true } + +func GetSlavesAddrByName(ctx context.Context, c *SentinelClient, name string) []string { + addrs, err := c.Slaves(ctx, name).Result() + if err != nil { + internal.Logger.Printf(ctx, "sentinel: Slaves name=%q failed: %s", + name, err) + return []string{} + } + return parseSlaveAddrs(addrs, false) +} diff --git a/sentinel.go b/sentinel.go index 590090f..3e8afb7 100644 --- a/sentinel.go +++ b/sentinel.go @@ -317,16 +317,6 @@ func (c *SentinelClient) GetMasterAddrByName(ctx context.Context, name string) * return cmd } -func (c *SentinelClient) GetSlavesAddrByName(ctx context.Context, name string) []string { - addrs, err := c.Slaves(ctx, name).Result() - if err != nil { - internal.Logger.Printf(ctx, "sentinel: Slaves name=%q failed: %s", - name, err) - return []string{} - } - return parseSlaveAddrs(addrs, false) -} - func (c *SentinelClient) Sentinels(ctx context.Context, name string) *SliceCmd { cmd := NewSliceCmd(ctx, "sentinel", "sentinels", name) _ = c.Process(ctx, cmd) diff --git a/sentinel_test.go b/sentinel_test.go index 8949fae..7b4aabd 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -68,7 +68,7 @@ var _ = Describe("Sentinel", func() { // Verify master->slaves sync. var slavesAddr []string Eventually(func() []string { - slavesAddr = sentinel.GetSlavesAddrByName(ctx, sentinelName) + slavesAddr = redis.GetSlavesAddrByName(ctx, sentinel, sentinelName) return slavesAddr }, "15s", "100ms").Should(HaveLen(2)) Eventually(func() bool {