mirror of
https://github.com/redis/go-redis.git
synced 2025-04-16 09:23:06 +03:00
* chore: extract benchmark tests * wip * enable pubsub tests * enable ring tests * stop tests with build redis from source * start all tests * mix of makefile and action * add sentinel configs * fix example test * stop debug on re * wip * enable gears for redis 7.2 * wip * enable sentinel, they are expected to fail * fix: linter configuration * chore: update re versions * return older redis enterprise version * add basic codeql * wip: increase timeout, focus only sentinel tests * sentinels with docker network host * enable all tests * fix flanky test * enable example tests * tidy docker compose * add debug output * stop shutingdown masters * don't test sentinel for re * skip unsuported addscores * Update README bump go version in CI * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update CONTRIBUTING.md add information about new test setup --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
200 lines
5.7 KiB
Go
200 lines
5.7 KiB
Go
package redis
|
|
|
|
import "context"
|
|
|
|
type ClusterCmdable interface {
|
|
ClusterMyShardID(ctx context.Context) *StringCmd
|
|
ClusterMyID(ctx context.Context) *StringCmd
|
|
ClusterSlots(ctx context.Context) *ClusterSlotsCmd
|
|
ClusterShards(ctx context.Context) *ClusterShardsCmd
|
|
ClusterLinks(ctx context.Context) *ClusterLinksCmd
|
|
ClusterNodes(ctx context.Context) *StringCmd
|
|
ClusterMeet(ctx context.Context, host, port string) *StatusCmd
|
|
ClusterForget(ctx context.Context, nodeID string) *StatusCmd
|
|
ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd
|
|
ClusterResetSoft(ctx context.Context) *StatusCmd
|
|
ClusterResetHard(ctx context.Context) *StatusCmd
|
|
ClusterInfo(ctx context.Context) *StringCmd
|
|
ClusterKeySlot(ctx context.Context, key string) *IntCmd
|
|
ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd
|
|
ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd
|
|
ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd
|
|
ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd
|
|
ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd
|
|
ClusterSaveConfig(ctx context.Context) *StatusCmd
|
|
ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd
|
|
ClusterFailover(ctx context.Context) *StatusCmd
|
|
ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd
|
|
ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd
|
|
ReadOnly(ctx context.Context) *StatusCmd
|
|
ReadWrite(ctx context.Context) *StatusCmd
|
|
}
|
|
|
|
func (c cmdable) ClusterMyShardID(ctx context.Context) *StringCmd {
|
|
cmd := NewStringCmd(ctx, "cluster", "myshardid")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterMyID(ctx context.Context) *StringCmd {
|
|
cmd := NewStringCmd(ctx, "cluster", "myid")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterSlots(ctx context.Context) *ClusterSlotsCmd {
|
|
cmd := NewClusterSlotsCmd(ctx, "cluster", "slots")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterShards(ctx context.Context) *ClusterShardsCmd {
|
|
cmd := NewClusterShardsCmd(ctx, "cluster", "shards")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterLinks(ctx context.Context) *ClusterLinksCmd {
|
|
cmd := NewClusterLinksCmd(ctx, "cluster", "links")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterNodes(ctx context.Context) *StringCmd {
|
|
cmd := NewStringCmd(ctx, "cluster", "nodes")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterMeet(ctx context.Context, host, port string) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "meet", host, port)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterForget(ctx context.Context, nodeID string) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "forget", nodeID)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "replicate", nodeID)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterResetSoft(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "reset", "soft")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterResetHard(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "reset", "hard")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterInfo(ctx context.Context) *StringCmd {
|
|
cmd := NewStringCmd(ctx, "cluster", "info")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterKeySlot(ctx context.Context, key string) *IntCmd {
|
|
cmd := NewIntCmd(ctx, "cluster", "keyslot", key)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd {
|
|
cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", slot, count)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd {
|
|
cmd := NewIntCmd(ctx, "cluster", "count-failure-reports", nodeID)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd {
|
|
cmd := NewIntCmd(ctx, "cluster", "countkeysinslot", slot)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd {
|
|
args := make([]interface{}, 2+len(slots))
|
|
args[0] = "cluster"
|
|
args[1] = "delslots"
|
|
for i, slot := range slots {
|
|
args[2+i] = slot
|
|
}
|
|
cmd := NewStatusCmd(ctx, args...)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd {
|
|
size := max - min + 1
|
|
slots := make([]int, size)
|
|
for i := 0; i < size; i++ {
|
|
slots[i] = min + i
|
|
}
|
|
return c.ClusterDelSlots(ctx, slots...)
|
|
}
|
|
|
|
func (c cmdable) ClusterSaveConfig(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "saveconfig")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd {
|
|
cmd := NewStringSliceCmd(ctx, "cluster", "slaves", nodeID)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterFailover(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "cluster", "failover")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd {
|
|
args := make([]interface{}, 2+len(slots))
|
|
args[0] = "cluster"
|
|
args[1] = "addslots"
|
|
for i, num := range slots {
|
|
args[2+i] = num
|
|
}
|
|
cmd := NewStatusCmd(ctx, args...)
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd {
|
|
size := max - min + 1
|
|
slots := make([]int, size)
|
|
for i := 0; i < size; i++ {
|
|
slots[i] = min + i
|
|
}
|
|
return c.ClusterAddSlots(ctx, slots...)
|
|
}
|
|
|
|
func (c cmdable) ReadOnly(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "readonly")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|
|
|
|
func (c cmdable) ReadWrite(ctx context.Context) *StatusCmd {
|
|
cmd := NewStatusCmd(ctx, "readwrite")
|
|
_ = c(ctx, cmd)
|
|
return cmd
|
|
}
|