1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-02 23:58:35 +00:00

refactor issue indexer, add some testing and fix a bug (#6131)

* refactor issue indexer, add some testing and fix a bug

* fix error copyright year on comment header

* issues indexer package import keep consistent
This commit is contained in:
Lunny Xiao
2019-02-21 08:54:05 +08:00
committed by GitHub
parent eaf9ded182
commit 0751153613
11 changed files with 231 additions and 171 deletions

View File

@@ -42,18 +42,21 @@ func (l *LevelQueue) Run() error {
var i int
var datas = make([]*IndexerData, 0, l.batchNumber)
for {
bs, err := l.queue.RPop()
if err != nil {
log.Error(4, "RPop: %v", err)
time.Sleep(time.Millisecond * 100)
continue
}
i++
if len(datas) > l.batchNumber || (len(datas) > 0 && i > 3) {
l.indexer.Index(datas)
datas = make([]*IndexerData, 0, l.batchNumber)
i = 0
continue
}
bs, err := l.queue.RPop()
if err != nil {
if err != levelqueue.ErrNotFound {
log.Error(4, "RPop: %v", err)
}
time.Sleep(time.Millisecond * 100)
continue
}
if len(bs) <= 0 {
@@ -69,7 +72,7 @@ func (l *LevelQueue) Run() error {
continue
}
log.Trace("LedisLocalQueue: task found: %#v", data)
log.Trace("LevelQueue: task found: %#v", data)
if data.IsDelete {
if data.ID > 0 {