diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-04-08 17:05:15 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-04-08 12:05:15 +0300 |
commit | e7d7dcb0901b32bed90061e7bc8ae1d2e3c75654 (patch) | |
tree | 1287587835fadda43f03f03ebb8b873091f356c8 /modules/indexer/issues/indexer.go | |
parent | 6e4af4985e60de2f7946be6b0fa5a5d24cdad78a (diff) | |
download | gitea-e7d7dcb0901b32bed90061e7bc8ae1d2e3c75654.tar.gz gitea-e7d7dcb0901b32bed90061e7bc8ae1d2e3c75654.zip |
Issue indexer queue redis support (#6218)
* add redis queue
* finished indexer redis queue
* add redis vendor
* fix vet
* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md
Co-Authored-By: lunny <xiaolunwen@gmail.com>
* switch to go mod
* Update required changes for new logging func signatures
Diffstat (limited to 'modules/indexer/issues/indexer.go')
-rw-r--r-- | modules/indexer/issues/indexer.go | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go index 3d066ca3fa..75e6893b87 100644 --- a/modules/indexer/issues/indexer.go +++ b/modules/indexer/issues/indexer.go @@ -46,9 +46,9 @@ type Indexer interface { } var ( - // issueIndexerUpdateQueue queue of issue ids to be updated - issueIndexerUpdateQueue Queue - issueIndexer Indexer + // issueIndexerQueue queue of issue ids to be updated + issueIndexerQueue Queue + issueIndexer Indexer ) // InitIssueIndexer initialize issue indexer, syncReindex is true then reindex until @@ -72,27 +72,36 @@ func InitIssueIndexer(syncReindex bool) error { } if dummyQueue { - issueIndexerUpdateQueue = &DummyQueue{} + issueIndexerQueue = &DummyQueue{} return nil } var err error - switch setting.Indexer.IssueIndexerQueueType { + switch setting.Indexer.IssueQueueType { case setting.LevelQueueType: - issueIndexerUpdateQueue, err = NewLevelQueue( + issueIndexerQueue, err = NewLevelQueue( issueIndexer, - setting.Indexer.IssueIndexerQueueDir, - setting.Indexer.IssueIndexerQueueBatchNumber) + setting.Indexer.IssueQueueDir, + setting.Indexer.IssueQueueBatchNumber) if err != nil { return err } case setting.ChannelQueueType: - issueIndexerUpdateQueue = NewChannelQueue(issueIndexer, setting.Indexer.IssueIndexerQueueBatchNumber) + issueIndexerQueue = NewChannelQueue(issueIndexer, setting.Indexer.IssueQueueBatchNumber) + case setting.RedisQueueType: + addrs, pass, idx, err := parseConnStr(setting.Indexer.IssueQueueConnStr) + if err != nil { + return err + } + issueIndexerQueue, err = NewRedisQueue(addrs, pass, idx, issueIndexer, setting.Indexer.IssueQueueBatchNumber) + if err != nil { + return err + } default: - return fmt.Errorf("Unsupported indexer queue type: %v", setting.Indexer.IssueIndexerQueueType) + return fmt.Errorf("Unsupported indexer queue type: %v", setting.Indexer.IssueQueueType) } - go issueIndexerUpdateQueue.Run() + go issueIndexerQueue.Run() if populate { if syncReindex { @@ -152,7 +161,7 @@ func UpdateIssueIndexer(issue *models.Issue) { comments = append(comments, comment.Content) } } - issueIndexerUpdateQueue.Push(&IndexerData{ + issueIndexerQueue.Push(&IndexerData{ ID: issue.ID, RepoID: issue.RepoID, Title: issue.Title, @@ -174,7 +183,7 @@ func DeleteRepoIssueIndexer(repo *models.Repository) { return } - issueIndexerUpdateQueue.Push(&IndexerData{ + issueIndexerQueue.Push(&IndexerData{ IDs: ids, IsDelete: true, }) |