Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prioritize DBS over cluster enabled in scan mode #855

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions internal/reader/scan_standalone_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,24 @@ func NewScanStandaloneReader(ctx context.Context, opts *ScanReaderOptions) Reade
r := new(scanStandaloneReader)
// dbs
c := client.NewRedisClient(ctx, opts.Address, opts.Username, opts.Password, opts.Tls, opts.PreferReplica)
if c.IsCluster() { // not use opts.Cluster, because user may use standalone mode to scan a cluster node
if len(opts.DBS) != 0 {
r.dbs = opts.DBS
} else if c.IsCluster() { // not use opts.Cluster, because user may use standalone mode to scan a cluster node
r.dbs = []int{0}
} else {
if len(opts.DBS) == 0 {
c.Send("info", "keyspace")
info, err := c.Receive()
if err != nil {
log.Panicf(err.Error())
}
r.dbs = utils.ParseDBs(info.(string))
} else {
r.dbs = opts.DBS
c.Send("info", "keyspace")
info, err := c.Receive()
if err != nil {
log.Panicf(err.Error())
}
r.dbs = utils.ParseDBs(info.(string))
}
r.opts = opts
r.ch = make(chan *entry.Entry, 1024)
r.stat.Name = "reader_" + strings.Replace(opts.Address, ":", "_", -1)
r.needDumpQueue = utils.NewUniqueQueue(100000) // cache 100000 keys
r.needRestoreChan = make(chan *needRestoreItem, 1024) // inflight 1024 keys
log.Infof("[%s] scanStandaloneReader init finished. dbs=[%v]", r.stat.Name, r.dbs)
return r
}

Expand Down
Loading