summaryrefslogtreecommitdiffstats
path: root/modules/indexer/issues/queue_disk.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-21 08:54:05 +0800
committerGitHub <noreply@github.com>2019-02-21 08:54:05 +0800
commit0751153613bfd2e39cf28e83bbe04b76641d222f (patch)
tree91ec0e2bd81c9007f15f9ab255e177d2be138f24 /modules/indexer/issues/queue_disk.go
parenteaf9ded18201d8ad2587860ed98763ca040f0b71 (diff)
downloadgitea-0751153613bfd2e39cf28e83bbe04b76641d222f.tar.gz
gitea-0751153613bfd2e39cf28e83bbe04b76641d222f.zip
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
Diffstat (limited to 'modules/indexer/issues/queue_disk.go')
-rw-r--r--modules/indexer/issues/queue_disk.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/modules/indexer/issues/queue_disk.go b/modules/indexer/issues/queue_disk.go
index 97e9a3d965..97bacdf99d 100644
--- a/modules/indexer/issues/queue_disk.go
+++ b/modules/indexer/issues/queue_disk.go
@@ -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 {