Skip to content

Commit

Permalink
Move to Valkey
Browse files Browse the repository at this point in the history
  • Loading branch information
secwall committed Jan 15, 2025
1 parent 7799596 commit 9df7bae
Show file tree
Hide file tree
Showing 68 changed files with 2,577 additions and 2,462 deletions.
48 changes: 24 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ unittests:
go test ./cmd/... ./internal/...
go test ./cmd/... ./tests/testutil/matchers/

redis/src/redis-server:
docker run --rm -v ${CURDIR}:/app -w /app ubuntu:noble /app/redis_patches/build.sh

test: base_image redis/src/redis-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/redis/rdsync && cp cmd/rdsync/rdsync ./tests/images/redis/rdsync
rm -rf ./tests/images/redis/redis-server && cp redis/src/redis-server ./tests/images/redis/redis-server
rm -rf ./tests/images/redis/redis-senticache && cp redis/src/redis-senticache ./tests/images/redis/redis-senticache
rm -rf ./tests/images/redis/redis-cli && cp redis/src/redis-cli ./tests/images/redis/redis-cli
valkey/src/valkey-server:
docker run --rm -v ${CURDIR}:/app -w /app ubuntu:noble /app/valkey_patches/build.sh

test: base_image valkey/src/valkey-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/valkey/rdsync && cp cmd/rdsync/rdsync ./tests/images/valkey/rdsync
rm -rf ./tests/images/valkey/valkey-server && cp valkey/src/valkey-server ./tests/images/valkey/valkey-server
rm -rf ./tests/images/valkey/valkey-senticache && cp valkey/src/valkey-senticache ./tests/images/valkey/valkey-senticache
rm -rf ./tests/images/valkey/valkey-cli && cp valkey/src/valkey-cli ./tests/images/valkey/valkey-cli
go build ./tests/...
(cd tests; go test -timeout 150m)

Expand All @@ -41,32 +41,32 @@ base_image: tests/images/zookeeper/zookeeper.tar.gz
docker build tests/images/base -t rdsync-base:latest;\
fi

start_sentinel_env: base_image redis/src/redis-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/redis/rdsync && cp cmd/rdsync/rdsync ./tests/images/redis/rdsync
rm -rf ./tests/images/redis/redis-server && cp redis/src/redis-server ./tests/images/redis/redis-server
rm -rf ./tests/images/redis/redis-senticache && cp redis/src/redis-senticache ./tests/images/redis/redis-senticache
rm -rf ./tests/images/redis/redis-cli && cp redis/src/redis-cli ./tests/images/redis/redis-cli
start_sentinel_env: base_image valkey/src/valkey-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/valkey/rdsync && cp cmd/rdsync/rdsync ./tests/images/valkey/rdsync
rm -rf ./tests/images/valkey/valkey-server && cp valkey/src/valkey-server ./tests/images/valkey/valkey-server
rm -rf ./tests/images/valkey/valkey-senticache && cp valkey/src/valkey-senticache ./tests/images/valkey/valkey-senticache
rm -rf ./tests/images/valkey/valkey-cli && cp valkey/src/valkey-cli ./tests/images/valkey/valkey-cli
docker compose -p $(PROJECT) -f ./tests/images/jepsen-compose.yaml up -d --force-recreate --build
timeout 600 docker exec rdsync-zoo1-1 setup_zk.sh
timeout 600 docker exec rdsync-redis1-1 setup_sentinel.sh
timeout 600 docker exec rdsync-redis2-1 setup_sentinel.sh redis1
timeout 600 docker exec rdsync-redis3-1 setup_sentinel.sh redis1
timeout 600 docker exec rdsync-valkey1-1 setup_sentinel.sh
timeout 600 docker exec rdsync-valkey2-1 setup_sentinel.sh valkey1
timeout 600 docker exec rdsync-valkey3-1 setup_sentinel.sh valkey1

run_jepsen_sentinel_test: recreate_logs start_sentinel_env
(docker exec rdsync-jepsen-1 /root/jepsen/run.sh >tests/logs/jepsen.log 2>&1 && tail -n 4 tests/logs/jepsen.log) || ./tests/images/jepsen/save_logs.sh

jepsen_sentinel_test: run_jepsen_sentinel_test clean

start_cluster_env: base_image redis/src/redis-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/redis/rdsync && cp cmd/rdsync/rdsync ./tests/images/redis/rdsync
rm -rf ./tests/images/redis/redis-server && cp redis/src/redis-server ./tests/images/redis/redis-server
rm -rf ./tests/images/redis/redis-senticache && cp redis/src/redis-senticache ./tests/images/redis/redis-senticache
rm -rf ./tests/images/redis/redis-cli && cp redis/src/redis-cli ./tests/images/redis/redis-cli
start_cluster_env: base_image valkey/src/valkey-server cmd/rdsync/rdsync recreate_logs
rm -rf ./tests/images/valkey/rdsync && cp cmd/rdsync/rdsync ./tests/images/valkey/rdsync
rm -rf ./tests/images/valkey/valkey-server && cp valkey/src/valkey-server ./tests/images/valkey/valkey-server
rm -rf ./tests/images/valkey/valkey-senticache && cp valkey/src/valkey-senticache ./tests/images/valkey/valkey-senticache
rm -rf ./tests/images/valkey/valkey-cli && cp valkey/src/valkey-cli ./tests/images/valkey/valkey-cli
docker compose -p $(PROJECT) -f ./tests/images/jepsen-compose.yaml up -d --force-recreate --build
timeout 600 docker exec rdsync-zoo1-1 setup_zk.sh
timeout 600 docker exec rdsync-redis1-1 setup_cluster.sh
timeout 600 docker exec rdsync-redis2-1 setup_cluster.sh redis1
timeout 600 docker exec rdsync-redis3-1 setup_cluster.sh redis1
timeout 600 docker exec rdsync-valkey1-1 setup_cluster.sh
timeout 600 docker exec rdsync-valkey2-1 setup_cluster.sh valkey1
timeout 600 docker exec rdsync-valkey3-1 setup_cluster.sh valkey1

run_jepsen_cluster_test: recreate_logs start_cluster_env
(docker exec rdsync-jepsen-1 /root/jepsen/run.sh >tests/logs/jepsen.log 2>&1 && tail -n 4 tests/logs/jepsen.log) || ./tests/images/jepsen/save_logs.sh
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

# rdsync

Rdsync is a redis high-availability tool.
It uses a patched redis version to make a cluster or sentinel-like setup less prone to data loss.
Rdsync is a valkey high-availability tool.
It uses a patched valkey version to make a cluster or sentinel-like setup less prone to data loss.

## Limitations and requirements

* Patched redis (patches for redis 7.2 are included in this repo)
* Patched valkey (patches for valkey 8.0 are included in this repo)
* ZooKeeper as DCS
* Single redis instance per host
* Single valkey instance per host
* In clustered setup each shard must have it's own DCS prefix
* Client application must use `WAITQUORUM` command to make data loss less usual (check jepsen test for example).

Expand Down
6 changes: 3 additions & 3 deletions cmd/rdsync/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var priority int
var dryRun bool
var skipRedisCheck bool
var skipValkeyCheck bool

var hostListCmd = &cobra.Command{
Use: "host",
Expand Down Expand Up @@ -47,7 +47,7 @@ var hostAddCmd = &cobra.Command{
}
})

os.Exit(app.CliHostAdd(args[0], priorityVal, dryRun, skipRedisCheck))
os.Exit(app.CliHostAdd(args[0], priorityVal, dryRun, skipValkeyCheck))
},
}

Expand All @@ -67,7 +67,7 @@ var hostRemoveCmd = &cobra.Command{

func init() {
hostAddCmd.Flags().IntVar(&priority, "priority", 100, "host priority")
hostAddCmd.Flags().BoolVar(&skipRedisCheck, "skip-redis-check", false, "do not check redis availability")
hostAddCmd.Flags().BoolVar(&skipValkeyCheck, "skip-valkey-check", false, "do not check valkey availability")
hostAddCmd.Flags().BoolVar(&dryRun, "dry-run", false, "tests suggested changes."+
" Exits codes:"+
" 0 - when no changes detected,"+
Expand Down
2 changes: 1 addition & 1 deletion cmd/rdsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var verbose bool

var rootCmd = &cobra.Command{
Use: "rdsync",
Short: "Rdsync is a Redis HA cluster coordination tool",
Short: "Rdsync is a Valkey HA cluster coordination tool",
Long: `Running without additional arguments will start rdsync service for current node.`,
Run: func(cmd *cobra.Command, args []string) {
app, err := app.NewApp(configFile, "")
Expand Down
2 changes: 1 addition & 1 deletion cmd/rdsync/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var stateCmd = &cobra.Command{
Use: "state",
Short: "Print information from redis hosts",
Short: "Print information from valkey hosts",
Run: func(cmd *cobra.Command, args []string) {
app, err := app.NewApp(configFile, logLevel)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ require (
github.com/go-zookeeper/zk v1.0.4
github.com/gofrs/flock v0.12.1
github.com/heetch/confita v0.10.0
github.com/redis/go-redis/v9 v9.7.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.10.0
github.com/valkey-io/valkey-go v1.0.53
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
github.com/cucumber/messages/go/v21 v21.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
Expand Down
16 changes: 6 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand All @@ -47,8 +41,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/docker v27.5.0+incompatible h1:um++2NcQtGRTz5eEgO6aJimo6/JxrTXC941hd05JO6U=
Expand Down Expand Up @@ -187,6 +179,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
Expand All @@ -212,8 +206,6 @@ github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
Expand Down Expand Up @@ -247,6 +239,8 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/valkey-io/valkey-go v1.0.53 h1:bntDqQVPzkLdE/4ypXBrHalXJB+BOTMk+JwXNRCGudg=
github.com/valkey-io/valkey-go v1.0.53/go.mod h1:BXlVAPIL9rFQinSFM+N32JfWzfCaUAqBpZkc4vPY6fM=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -276,6 +270,8 @@ golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down
4 changes: 2 additions & 2 deletions internal/app/active_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func (app *App) actualizeQuorumReplicas(master string, activeNodes []string) err
continue
}
activeNode := app.shard.Get(host)
expected = append(expected, fmt.Sprintf("%s:%d", host, app.config.Redis.Port))
expected = append(expected, fmt.Sprintf("%s:%d", host, app.config.Valkey.Port))
for _, ip := range activeNode.GetIPs() {
expected = append(expected, fmt.Sprintf("%s:%d", ip, app.config.Redis.Port))
expected = append(expected, fmt.Sprintf("%s:%d", ip, app.config.Valkey.Port))
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/app/aof.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (app *App) adjustAofMode(master string) error {
return err
}
}
if app.config.Redis.AofPath != "" && !targetMode {
if _, err := os.Stat(app.config.Redis.AofPath); err == nil {
return os.RemoveAll(app.config.Redis.AofPath)
if app.config.Valkey.AofPath != "" && !targetMode {
if _, err := os.Stat(app.config.Valkey.AofPath); err == nil {
return os.RemoveAll(app.config.Valkey.AofPath)
}
}
return nil
Expand Down
10 changes: 5 additions & 5 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/yandex/rdsync/internal/config"
"github.com/yandex/rdsync/internal/dcs"
"github.com/yandex/rdsync/internal/redis"
"github.com/yandex/rdsync/internal/valkey"
)

// App is main application structure
Expand All @@ -29,8 +29,8 @@ type App struct {
logger *slog.Logger
config *config.Config
dcs dcs.DCS
shard *redis.Shard
cache *redis.SentiCacheNode
shard *valkey.Shard
cache *valkey.SentiCacheNode
daemonLock *flock.Flock
}

Expand Down Expand Up @@ -136,10 +136,10 @@ func (app *App) Run() int {
defer app.dcs.Close()
app.dcs.SetDisconnectCallback(func() error { return app.handleCritical() })

app.shard = redis.NewShard(app.config, app.logger, app.dcs)
app.shard = valkey.NewShard(app.config, app.logger, app.dcs)
defer app.shard.Close()
if app.mode == modeSentinel {
app.cache, err = redis.NewSentiCacheNode(app.config, app.logger)
app.cache, err = valkey.NewSentiCacheNode(app.config, app.logger)
if err != nil {
app.logger.Error("Unable to init senticache node", "error", err)
return 1
Expand Down
18 changes: 9 additions & 9 deletions internal/app/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
"fmt"
"time"

"github.com/yandex/rdsync/internal/redis"
"github.com/yandex/rdsync/internal/valkey"
)

func (app *App) updateCache(refState map[string]*HostState, cache *redis.SentiCacheNode) error {
var state redis.SentiCacheState
func (app *App) updateCache(refState map[string]*HostState, cache *valkey.SentiCacheNode) error {
var state valkey.SentiCacheState
masterReadOnly := false
for fqdn, hostState := range refState {
if hostState == nil || !hostState.PingOk || hostState.Error != "" {
continue
}

if hostState.SentiCacheState != nil && fqdn != app.config.Hostname {
var sentinel redis.SentiCacheSentinel
var sentinel valkey.SentiCacheSentinel
sentinel.Name = hostState.SentiCacheState.Name
sentinel.RunID = hostState.SentiCacheState.RunID
if app.config.SentinelMode.AnnounceHostname {
Expand Down Expand Up @@ -47,29 +47,29 @@ func (app *App) updateCache(refState map[string]*HostState, cache *redis.SentiCa
} else {
state.Master.IP = hostState.IP
}
state.Master.Port = app.config.Redis.Port
state.Master.Port = app.config.Valkey.Port
state.Master.RunID = hostState.RunID
state.Master.Quorum = len(refState)/2 + 1
state.Master.ParallelSyncs = app.config.Redis.MaxParallelSyncs
state.Master.ParallelSyncs = app.config.Valkey.MaxParallelSyncs
state.Master.ConfigEpoch = 0
} else {
nc, err := app.shard.GetNodeConfiguration(fqdn)
if err != nil {
return err
}
var replica redis.SentiCacheReplica
var replica valkey.SentiCacheReplica
if app.config.SentinelMode.AnnounceHostname {
replica.IP = fqdn
} else {
replica.IP = hostState.IP
}
replica.Port = app.config.Redis.Port
replica.Port = app.config.Valkey.Port
replica.RunID = hostState.RunID
replica.MasterLinkDownTime = hostState.ReplicaState.MasterLinkDownTime
replica.SlavePriority = nc.Priority
replica.ReplicaAnnounced = 1
replica.MasterHost = hostState.ReplicaState.MasterHost
replica.MasterPort = app.config.Redis.Port
replica.MasterPort = app.config.Valkey.Port
if hostState.ReplicaState.MasterLinkState {
replica.SlaveMasterLinkStatus = 0
} else {
Expand Down
Loading

0 comments on commit 9df7bae

Please sign in to comment.