Skip to content

Commit 39c8e1a

Browse files
committed
Clean-up the settings hierarchy for issue_indexer queue
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]>
1 parent 6d6a65c commit 39c8e1a

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
@@ -1141,20 +1141,20 @@ PATH =
11411141
;STARTUP_TIMEOUT = 30s
11421142
;;
11431143
;; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue (deprecated - use [queue.issue_indexer])
1144-
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue
1144+
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11451145
;;
11461146
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11471147
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
11481148
;; default is indexers/issues.queue
1149-
;ISSUE_INDEXER_QUEUE_DIR = indexers/issues.queue
1149+
;ISSUE_INDEXER_QUEUE_DIR = queues/common; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11501150
;;
11511151
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11521152
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
11531153
;; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
1154-
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
1154+
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11551155
;;
11561156
;; Batch queue number, default is 20
1157-
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
1157+
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11581158

11591159
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11601160
;; Repository Indexer settings
@@ -1183,7 +1183,7 @@ PATH =
11831183
;REPO_INDEXER_EXCLUDE =
11841184
;;
11851185
;;
1186-
;UPDATE_BUFFER_LEN = 20
1186+
;UPDATE_BUFFER_LEN = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11871187
;MAX_FILE_SIZE = 1048576
11881188

11891189
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ relation to port exhaustion.
349349
- `ISSUE_INDEXER_NAME`: **gitea_issues**: Issue indexer name, available when ISSUE_INDEXER_TYPE is elasticsearch
350350
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
351351
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
352-
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
353-
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved.
354-
- `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`.
355-
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
352+
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
353+
- `ISSUE_INDEXER_QUEUE_DIR`: **indexers/issues.queue**: 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]`.
354+
- `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]`.
355+
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number. **DEPRECATED** use settings in `[queue.issue_indexer]`.
356356

357357
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
358358
- `REPO_INDEXER_TYPE`: **bleve**: Code search engine type, could be `bleve` or `elasticsearch`.
@@ -363,7 +363,7 @@ relation to port exhaustion.
363363
- `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.
364364
- `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`.
365365
- `REPO_INDEXER_EXCLUDE_VENDORED`: **true**: Exclude vendored files from index.
366-
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request.
366+
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request. **DEPRECATED** use settings in `[queue.issue_indexer]`.
367367
- `MAX_FILE_SIZE`: **1048576**: Maximum size in bytes of files to be indexed.
368368
- `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.
369369

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)