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

60 lines
2.1 KiB

  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. RedisQueueType = "redis"
  14. )
  15. var (
  16. // Indexer settings
  17. Indexer = struct {
  18. IssueType string
  19. IssuePath string
  20. RepoIndexerEnabled bool
  21. RepoPath string
  22. UpdateQueueLength int
  23. MaxIndexerFileSize int64
  24. IssueQueueType string
  25. IssueQueueDir string
  26. IssueQueueConnStr string
  27. IssueQueueBatchNumber int
  28. }{
  29. IssueType: "bleve",
  30. IssuePath: "indexers/issues.bleve",
  31. IssueQueueType: LevelQueueType,
  32. IssueQueueDir: "indexers/issues.queue",
  33. IssueQueueConnStr: "",
  34. IssueQueueBatchNumber: 20,
  35. }
  36. )
  37. func newIndexerService() {
  38. sec := Cfg.Section("indexer")
  39. Indexer.IssueType = sec.Key("ISSUE_INDEXER_TYPE").MustString("bleve")
  40. Indexer.IssuePath = sec.Key("ISSUE_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/issues.bleve"))
  41. if !filepath.IsAbs(Indexer.IssuePath) {
  42. Indexer.IssuePath = path.Join(AppWorkPath, Indexer.IssuePath)
  43. }
  44. Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
  45. Indexer.RepoPath = sec.Key("REPO_INDEXER_PATH").MustString(path.Join(AppDataPath, "indexers/repos.bleve"))
  46. if !filepath.IsAbs(Indexer.RepoPath) {
  47. Indexer.RepoPath = path.Join(AppWorkPath, Indexer.RepoPath)
  48. }
  49. Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(20)
  50. Indexer.MaxIndexerFileSize = sec.Key("MAX_FILE_SIZE").MustInt64(1024 * 1024)
  51. Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(LevelQueueType)
  52. Indexer.IssueQueueDir = sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(path.Join(AppDataPath, "indexers/issues.queue"))
  53. Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString(path.Join(AppDataPath, ""))
  54. Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(20)
  55. }