chroe: polish code according to golangci-lint hint
This commit is contained in:
parent
c2aa81769a
commit
56abca8417
|
@ -150,10 +150,7 @@ func (ld *Loader) LoadSingleAppendOnlyFile(ctx context.Context, timestamp int64)
|
|||
argString = argString[:v64]
|
||||
argv = append(argv, string(argString))
|
||||
}
|
||||
|
||||
for _, value := range argv {
|
||||
e.Argv = append(e.Argv, value)
|
||||
}
|
||||
e.Argv = append(e.Argv, argv...)
|
||||
ld.ch <- e
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,8 +110,9 @@ func (ld *Loader) parseRDBEntry(ctx context.Context, rd *bufio.Reader) {
|
|||
defer updateProcessSize()
|
||||
|
||||
// read one entry
|
||||
tick := time.Tick(time.Second * 1)
|
||||
for true {
|
||||
ticker := time.NewTicker(time.Second * 1)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
typeByte := structure.ReadByte(rd)
|
||||
switch typeByte {
|
||||
case kFlagIdle:
|
||||
|
@ -197,7 +198,7 @@ func (ld *Loader) parseRDBEntry(ctx context.Context, rd *bufio.Reader) {
|
|||
ld.freq = 0
|
||||
}
|
||||
select {
|
||||
case <-tick:
|
||||
case <-ticker.C:
|
||||
updateProcessSize()
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
|
|
@ -61,11 +61,9 @@ func ReadModuleString(rd io.Reader) string {
|
|||
return ReadString(rd)
|
||||
}
|
||||
|
||||
func ReadModuleEof(rd io.Reader) error {
|
||||
func ReadModuleEof(rd io.Reader) {
|
||||
eof := ReadLength(rd)
|
||||
if eof != rdbModuleOpcodeEOF {
|
||||
log.Panicf("The RDB file is not teminated by the proper module value EOF marker")
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@ func (o *BloomObject) LoadFromBuffer(rd io.Reader, key string, typeByte byte) {
|
|||
}
|
||||
o.sb = sb
|
||||
structure.ReadModuleEof(rd)
|
||||
return
|
||||
}
|
||||
|
||||
func readUnsigned(rd io.Reader) uint64 {
|
||||
|
|
|
@ -563,7 +563,7 @@ func (aofInfo *INFO) LoadAppendOnlyFile(ctx context.Context, am *AOFManifest, AO
|
|||
status := AOFOk
|
||||
ret := AOFOk
|
||||
var start int64
|
||||
var totalSize int64 = 0
|
||||
var totalSize int64
|
||||
var BaseSize int64 = 0
|
||||
var AOFName string
|
||||
var totalNum, AOFNum int
|
||||
|
@ -693,7 +693,6 @@ func (aofInfo *INFO) LoadAppendOnlyFile(ctx context.Context, am *AOFManifest, AO
|
|||
}
|
||||
|
||||
func (aofInfo *INFO) ParsingSingleAppendOnlyFile(ctx context.Context, FileName string, AOFTimeStamp int64) int {
|
||||
ret := AOFOk
|
||||
AOFFilepath := path.Join(aofInfo.AOFDirName, FileName)
|
||||
println(AOFFilepath)
|
||||
fp, err := os.Open(AOFFilepath)
|
||||
|
@ -719,8 +718,7 @@ func (aofInfo *INFO) ParsingSingleAppendOnlyFile(ctx context.Context, FileName s
|
|||
if n, err := fp.Read(sig); err != nil || n != 5 || !bytes.Equal(sig, []byte("REDIS")) {
|
||||
if _, err := fp.Seek(0, 0); err != nil {
|
||||
log.Infof("Unrecoverable error reading the append only File %v: %v", FileName, err)
|
||||
ret = AOFFailed
|
||||
return ret
|
||||
return AOFFailed
|
||||
}
|
||||
} else { //Skipped RDB checksum and has not been processed yet.
|
||||
log.Infof("Reading RDB Base File on AOF loading...")
|
||||
|
@ -731,7 +729,5 @@ func (aofInfo *INFO) ParsingSingleAppendOnlyFile(ctx context.Context, FileName s
|
|||
}
|
||||
// load single aof file
|
||||
aofSingleReader := aof.NewLoader(MakePath(aofInfo.AOFDirName, FileName), aofInfo.ch)
|
||||
ret = aofSingleReader.LoadSingleAppendOnlyFile(ctx, AOFTimeStamp)
|
||||
return ret
|
||||
|
||||
return aofSingleReader.LoadSingleAppendOnlyFile(ctx, AOFTimeStamp)
|
||||
}
|
||||
|
|
|
@ -311,7 +311,9 @@ func (r *syncStandaloneReader) sendAOF(offset int64) {
|
|||
|
||||
// sendReplconfAck send replconf ack to master to keep heartbeat between redis-shake and source redis.
|
||||
func (r *syncStandaloneReader) sendReplconfAck() {
|
||||
for range time.Tick(time.Millisecond * 100) {
|
||||
ticker := time.NewTicker(time.Millisecond * 100)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
select {
|
||||
case <-r.ctx.Done():
|
||||
return
|
||||
|
|
|
@ -73,9 +73,7 @@ func Init(r Statusable, w Statusable) {
|
|||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
lastConsistent := false
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
for range ticker.C {
|
||||
ch <- func() {
|
||||
// update reader/writer stat
|
||||
stat.Reader = theReader.Status()
|
||||
|
@ -89,7 +87,6 @@ func Init(r Statusable, w Statusable) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// for log to screen
|
||||
|
@ -100,14 +97,11 @@ func Init(r Statusable, w Statusable) {
|
|||
}
|
||||
ticker := time.NewTicker(time.Duration(config.Opt.Advanced.LogInterval) * time.Second)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
for range ticker.C {
|
||||
ch <- func() {
|
||||
log.Infof("%s, %s", stat.TotalEntriesCount.String(), theReader.StatusString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// run all func in ch
|
||||
|
|
Loading…
Reference in New Issue