diff options
author | Lauris BH <lauris@nix.lv> | 2022-01-27 10:30:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-27 10:30:51 +0200 |
commit | 8038610a4279862a87e630e4f1d1077c510f9d15 (patch) | |
tree | 802489f8ddde899e76643ea157f9020f12ca1490 /modules/indexer/code/search.go | |
parent | 2649eddcf0bb1190abab49c9d79ce19bfcf19e87 (diff) | |
download | gitea-8038610a4279862a87e630e4f1d1077c510f9d15.tar.gz gitea-8038610a4279862a87e630e4f1d1077c510f9d15.zip |
Automatically pause queue if index service is unavailable (#15066)
* Handle keyword search error when issue indexer service is not available
* Implement automatic disabling and resume of code indexer queue
Diffstat (limited to 'modules/indexer/code/search.go')
-rw-r--r-- | modules/indexer/code/search.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/indexer/code/search.go b/modules/indexer/code/search.go index bb8dcf16b3..bb7715bafc 100644 --- a/modules/indexer/code/search.go +++ b/modules/indexer/code/search.go @@ -6,6 +6,7 @@ package code import ( "bytes" + "context" "strings" "code.gitea.io/gitea/modules/highlight" @@ -106,12 +107,12 @@ func searchResult(result *SearchResult, startIndex, endIndex int) (*Result, erro } // PerformSearch perform a search on a repository -func PerformSearch(repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int, []*Result, []*SearchResultLanguages, error) { +func PerformSearch(ctx context.Context, repoIDs []int64, language, keyword string, page, pageSize int, isMatch bool) (int, []*Result, []*SearchResultLanguages, error) { if len(keyword) == 0 { return 0, nil, nil, nil } - total, results, resultLanguages, err := indexer.Search(repoIDs, language, keyword, page, pageSize, isMatch) + total, results, resultLanguages, err := indexer.Search(ctx, repoIDs, language, keyword, page, pageSize, isMatch) if err != nil { return 0, nil, nil, err } |