You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

indexer.go 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "path"
  7. "path/filepath"
  8. )
  9. // enumerates all the indexer queue types
  10. const (
  11. LevelQueueType = "levelqueue"
  12. ChannelQueueType = "channel"
  13. )
  14. var (
  15. // Indexer settings
  16. Indexer = struct {
  17. IssueType string
  18. IssuePath string
  19. RepoIndexerEnabled bool
  20. RepoPath string
  21. UpdateQueueLength int
  22. MaxIndexerFileSize int64
  23. IssueIndexerQueueType string
  24. IssueIndexerQueueDir string
  25. IssueIndexerQueueBatchNumber int
  26. }{
  27. IssueType: "bleve",
  28. IssuePath: "indexers/issues.bleve",
  29. IssueIndexerQueueType: LevelQueueType,
  30. IssueIndexerQueueDir: "indexers/issues.queue",
  31. IssueIndexerQueueBatchNumber: 20,
  32. }
  33. )
  34. func newIndexerService() {
  35. sec := Cfg.Section("indexer")
  36. Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/issues.bleve"))
  37. if !filepath.IsAbs(Indexer.IssuePath) {
  38. Indexer.IssuePath = path.Join(AppWorkPath, Indexer.IssuePath)
  39. }
  40. Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
  41. Indexer.RepoPath = sec.Key("REPO_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/repos.bleve"))
  42. if !filepath.IsAbs(Indexer.RepoPath) {
  43. Indexer.RepoPath = path.Join(AppWorkPath, Indexer.RepoPath)
  44. }
  45. Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(20)
  46. Indexer.MaxIndexerFileSize = sec.Key("MAX_FILE_SIZE").MustInt64(1024 * 1024)
  47. Indexer.IssueIndexerQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(LevelQueueType)
  48. Indexer.IssueIndexerQueueDir = sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(path.Join(AppDataPath, "indexers/issues.queue"))
  49. Indexer.IssueIndexerQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(20)
  50. }