Skip to content

Commit

Permalink
feat: prioritize DBS over cluster enabled in scan mode (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
suxb201 committed Aug 28, 2024
1 parent f1c4696 commit 6093348
Showing 1 changed file with 9 additions and 10 deletions.
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

0 comments on commit 6093348

Please sign in to comment.