Skip to content

Commit ffbf35b

Browse files
Clean-up the settings hierarchy for issue_indexer queue (#16001)
There are a couple of settings in `[indexer]` relating to the `issue_indexer` queue which override settings in unpredictable ways. This PR adjusts this hierarchy and makes explicit that these settings are deprecated. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 5f4522c commit ffbf35b

File tree

4 files changed

+34
-33
lines changed

4 files changed

+34
-33
lines changed

custom/conf/app.example.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,20 +1155,20 @@ PATH =
11551155
;STARTUP_TIMEOUT = 30s
11561156
;;
11571157
;; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue (deprecated - use [queue.issue_indexer])
1158-
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue
1158+
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11591159
;;
11601160
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11611161
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
11621162
;; default is queues/common
1163-
;ISSUE_INDEXER_QUEUE_DIR = queues/common
1163+
;ISSUE_INDEXER_QUEUE_DIR = queues/common; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11641164
;;
11651165
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11661166
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
11671167
;; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
1168-
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
1168+
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11691169
;;
11701170
;; Batch queue number, default is 20
1171-
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
1171+
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11721172

11731173
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11741174
;; Repository Indexer settings
@@ -1197,7 +1197,7 @@ PATH =
11971197
;REPO_INDEXER_EXCLUDE =
11981198
;;
11991199
;;
1200-
;UPDATE_BUFFER_LEN = 20
1200+
;UPDATE_BUFFER_LEN = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
12011201
;MAX_FILE_SIZE = 1048576
12021202

12031203
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ relation to port exhaustion.
356356
- `ISSUE_INDEXER_NAME`: **gitea_issues**: Issue indexer name, available when ISSUE_INDEXER_TYPE is elasticsearch
357357
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
358358
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
359-
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
360-
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. (Previously this was `indexers/issues.queue`.)
361-
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
362-
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
359+
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
360+
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. **DEPRECATED** use settings in `[queue.issue_indexer]`.
361+
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
362+
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number. **DEPRECATED** use settings in `[queue.issue_indexer]`.
363363

364364
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
365365
- `REPO_INDEXER_TYPE`: **bleve**: Code search engine type, could be `bleve` or `elasticsearch`.
@@ -370,7 +370,7 @@ relation to port exhaustion.
370370
- `REPO_INDEXER_INCLUDE`: **empty**: A comma separated list of glob patterns (see https://github.com/gobwas/glob) to **include** in the index. Use `**.txt` to match any files with .txt extension. An empty list means include all files.
371371
- `REPO_INDEXER_EXCLUDE`: **empty**: A comma separated list of glob patterns (see https://github.com/gobwas/glob) to **exclude** from the index. Files that match this list will not be indexed, even if they match in `REPO_INDEXER_INCLUDE`.
372372
- `REPO_INDEXER_EXCLUDE_VENDORED`: **true**: Exclude vendored files from index.
373-
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request.
373+
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request. **DEPRECATED** use settings in `[queue.issue_indexer]`.
374374
- `MAX_FILE_SIZE`: **1048576**: Maximum size in bytes of files to be indexed.
375375
- `STARTUP_TIMEOUT`: **30s**: If the indexer takes longer than this timeout to start - fail. (This timeout will be added to the hammer time above for child processes - as bleve will not start until the previous parent is shutdown.) Set to zero to never timeout.
376376

modules/setting/indexer.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,28 @@ var (
2828
IssuePath string
2929
IssueConnStr string
3030
IssueIndexerName string
31-
IssueQueueType string
32-
IssueQueueDir string
33-
IssueQueueConnStr string
34-
IssueQueueBatchNumber int
31+
IssueQueueType string // DEPRECATED - replaced by queue.issue_indexer
32+
IssueQueueDir string // DEPRECATED - replaced by queue.issue_indexer
33+
IssueQueueConnStr string // DEPRECATED - replaced by queue.issue_indexer
34+
IssueQueueBatchNumber int // DEPRECATED - replaced by queue.issue_indexer
3535
StartupTimeout time.Duration
3636

3737
RepoIndexerEnabled bool
3838
RepoType string
3939
RepoPath string
4040
RepoConnStr string
4141
RepoIndexerName string
42-
UpdateQueueLength int
42+
UpdateQueueLength int // DEPRECATED - replaced by queue.issue_indexer
4343
MaxIndexerFileSize int64
4444
IncludePatterns []glob.Glob
4545
ExcludePatterns []glob.Glob
4646
ExcludeVendored bool
4747
}{
48-
IssueType: "bleve",
49-
IssuePath: "indexers/issues.bleve",
50-
IssueConnStr: "",
51-
IssueIndexerName: "gitea_issues",
52-
IssueQueueType: LevelQueueType,
53-
IssueQueueDir: "queues/common",
54-
IssueQueueConnStr: "",
55-
IssueQueueBatchNumber: 20,
48+
IssueType: "bleve",
49+
IssuePath: "indexers/issues.bleve",
50+
IssueConnStr: "",
51+
IssueIndexerName: "gitea_issues",
52+
IssueQueueType: LevelQueueType,
5653

5754
RepoIndexerEnabled: false,
5855
RepoType: "bleve",
@@ -74,10 +71,12 @@ func newIndexerService() {
7471
Indexer.IssueConnStr = sec.Key("ISSUE_INDEXER_CONN_STR").MustString(Indexer.IssueConnStr)
7572
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
7673

77-
Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(LevelQueueType)
78-
Indexer.IssueQueueDir = filepath.ToSlash(sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "queues/common"))))
74+
// The following settings are deprecated and can be overridden by settings in [queue] or [queue.issue_indexer]
75+
Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString("")
76+
Indexer.IssueQueueDir = filepath.ToSlash(sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(""))
7977
Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("")
80-
Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(20)
78+
Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0)
79+
Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(0)
8180

8281
Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false)
8382
Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve")
@@ -91,7 +90,6 @@ func newIndexerService() {
9190
Indexer.IncludePatterns = IndexerGlobFromString(sec.Key("REPO_INDEXER_INCLUDE").MustString(""))
9291
Indexer.ExcludePatterns = IndexerGlobFromString(sec.Key("REPO_INDEXER_EXCLUDE").MustString(""))
9392
Indexer.ExcludeVendored = sec.Key("REPO_INDEXER_EXCLUDE_VENDORED").MustBool(true)
94-
Indexer.UpdateQueueLength = sec.Key("UPDATE_BUFFER_LEN").MustInt(20)
9593
Indexer.MaxIndexerFileSize = sec.Key("MAX_FILE_SIZE").MustInt64(1024 * 1024)
9694
Indexer.StartupTimeout = sec.Key("STARTUP_TIMEOUT").MustDuration(30 * time.Second)
9795
}

modules/setting/queue.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func GetQueueSettings(name string) QueueSettings {
6565
q.SetName = q.QueueName + Queue.SetName
6666
}
6767
if !filepath.IsAbs(q.DataDir) {
68-
q.DataDir = filepath.Join(AppDataPath, q.DataDir)
68+
q.DataDir = filepath.ToSlash(filepath.Join(AppDataPath, q.DataDir))
6969
}
7070
_, _ = sec.NewKey("DATADIR", q.DataDir)
7171

@@ -98,6 +98,7 @@ func NewQueueService() {
9898
Queue.QueueLength = sec.Key("LENGTH").MustInt(20)
9999
Queue.BatchLength = sec.Key("BATCH_LENGTH").MustInt(20)
100100
Queue.ConnectionString = sec.Key("CONN_STR").MustString("")
101+
defaultType := sec.Key("TYPE").String()
101102
Queue.Type = sec.Key("TYPE").MustString("persistable-channel")
102103
Queue.Network, Queue.Addresses, Queue.Password, Queue.DBIndex, _ = ParseQueueConnStr(Queue.ConnectionString)
103104
Queue.WrapIfNecessary = sec.Key("WRAP_IF_NECESSARY").MustBool(true)
@@ -117,29 +118,31 @@ func NewQueueService() {
117118
for _, key := range section.Keys() {
118119
sectionMap[key.Name()] = true
119120
}
120-
if _, ok := sectionMap["TYPE"]; !ok {
121+
if _, ok := sectionMap["TYPE"]; !ok && defaultType == "" {
121122
switch Indexer.IssueQueueType {
122123
case LevelQueueType:
123124
_, _ = section.NewKey("TYPE", "level")
124125
case ChannelQueueType:
125126
_, _ = section.NewKey("TYPE", "persistable-channel")
126127
case RedisQueueType:
127128
_, _ = section.NewKey("TYPE", "redis")
129+
case "":
130+
_, _ = section.NewKey("TYPE", "level")
128131
default:
129132
log.Fatal("Unsupported indexer queue type: %v",
130133
Indexer.IssueQueueType)
131134
}
132135
}
133-
if _, ok := sectionMap["LENGTH"]; !ok {
136+
if _, ok := sectionMap["LENGTH"]; !ok && Indexer.UpdateQueueLength != 0 {
134137
_, _ = section.NewKey("LENGTH", fmt.Sprintf("%d", Indexer.UpdateQueueLength))
135138
}
136-
if _, ok := sectionMap["BATCH_LENGTH"]; !ok {
139+
if _, ok := sectionMap["BATCH_LENGTH"]; !ok && Indexer.IssueQueueBatchNumber != 0 {
137140
_, _ = section.NewKey("BATCH_LENGTH", fmt.Sprintf("%d", Indexer.IssueQueueBatchNumber))
138141
}
139-
if _, ok := sectionMap["DATADIR"]; !ok {
142+
if _, ok := sectionMap["DATADIR"]; !ok && Indexer.IssueQueueDir != "" {
140143
_, _ = section.NewKey("DATADIR", Indexer.IssueQueueDir)
141144
}
142-
if _, ok := sectionMap["CONN_STR"]; !ok {
145+
if _, ok := sectionMap["CONN_STR"]; !ok && Indexer.IssueQueueConnStr != "" {
143146
_, _ = section.NewKey("CONN_STR", Indexer.IssueQueueConnStr)
144147
}
145148

0 commit comments

Comments
 (0)