mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
Unexport helper command
This commit is contained in:
parent
d47e48f8ab
commit
573638ff0c
@ -1,6 +1,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://uptrace.dev/?utm_source=gh-redis&utm_campaign=gh-redis-banner1">
|
<a href="https://uptrace.dev/?utm_source=gh-redis&utm_campaign=gh-redis-banner1">
|
||||||
<img src="https://raw.githubusercontent.com/uptrace/roadmap/master/banner1.png">
|
<img src="https://raw.githubusercontent.com/uptrace/roadmap/master/banner1.png" alt="All-in-one tool to optimize performance and monitor errors & logs">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8/internal"
|
||||||
"github.com/go-redis/redis/v8/internal/hashtag"
|
"github.com/go-redis/redis/v8/internal/hashtag"
|
||||||
"github.com/go-redis/redis/v8/internal/pool"
|
"github.com/go-redis/redis/v8/internal/pool"
|
||||||
)
|
)
|
||||||
@ -82,3 +83,13 @@ func (state *clusterState) IsConsistent(ctx context.Context) bool {
|
|||||||
|
|
||||||
return true
|
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)
|
||||||
|
}
|
||||||
|
10
sentinel.go
10
sentinel.go
@ -317,16 +317,6 @@ func (c *SentinelClient) GetMasterAddrByName(ctx context.Context, name string) *
|
|||||||
return cmd
|
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 {
|
func (c *SentinelClient) Sentinels(ctx context.Context, name string) *SliceCmd {
|
||||||
cmd := NewSliceCmd(ctx, "sentinel", "sentinels", name)
|
cmd := NewSliceCmd(ctx, "sentinel", "sentinels", name)
|
||||||
_ = c.Process(ctx, cmd)
|
_ = c.Process(ctx, cmd)
|
||||||
|
@ -68,7 +68,7 @@ var _ = Describe("Sentinel", func() {
|
|||||||
// Verify master->slaves sync.
|
// Verify master->slaves sync.
|
||||||
var slavesAddr []string
|
var slavesAddr []string
|
||||||
Eventually(func() []string {
|
Eventually(func() []string {
|
||||||
slavesAddr = sentinel.GetSlavesAddrByName(ctx, sentinelName)
|
slavesAddr = redis.GetSlavesAddrByName(ctx, sentinel, sentinelName)
|
||||||
return slavesAddr
|
return slavesAddr
|
||||||
}, "15s", "100ms").Should(HaveLen(2))
|
}, "15s", "100ms").Should(HaveLen(2))
|
||||||
Eventually(func() bool {
|
Eventually(func() bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user