Skip to content

Commit c99ee5d

Browse files
committed
fix config options
1 parent f8fc983 commit c99ee5d

File tree

9 files changed

+110
-322
lines changed

9 files changed

+110
-322
lines changed

custom/conf/app.example.ini

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -926,12 +926,6 @@ ROUTER = console
926926
;; Global limit of repositories per user, applied at creation time. -1 means no limit
927927
;MAX_CREATION_LIMIT = -1
928928
;;
929-
;; Mirror sync queue length, increase if mirror syncing starts hanging (DEPRECATED: please use [queue.mirror] LENGTH instead)
930-
;MIRROR_QUEUE_LENGTH = 1000
931-
;;
932-
;; Patch test queue length, increase if pull request patch testing starts hanging (DEPRECATED: please use [queue.pr_patch_checker] LENGTH instead)
933-
;PULL_REQUEST_QUEUE_LENGTH = 1000
934-
;;
935929
;; Preferred Licenses to place at the top of the List
936930
;; The name here must match the filename in options/license or custom/options/license
937931
;PREFERRED_LICENSES = Apache License 2.0,MIT License
@@ -1376,22 +1370,6 @@ ROUTER = console
13761370
;; Set to -1 to disable timeout.
13771371
;STARTUP_TIMEOUT = 30s
13781372
;;
1379-
;; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue (deprecated - use [queue.issue_indexer])
1380-
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue; **DEPRECATED** use settings in `[queue.issue_indexer]`.
1381-
;;
1382-
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
1383-
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
1384-
;; default is queues/common
1385-
;ISSUE_INDEXER_QUEUE_DIR = queues/common; **DEPRECATED** use settings in `[queue.issue_indexer]`. Relative paths will be made absolute against `%(APP_DATA_PATH)s`.
1386-
;;
1387-
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
1388-
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
1389-
;; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
1390-
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"; **DEPRECATED** use settings in `[queue.issue_indexer]`.
1391-
;;
1392-
;; Batch queue number, default is 20
1393-
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
1394-
13951373
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13961374
;; Repository Indexer settings
13971375
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1418,8 +1396,6 @@ ROUTER = console
14181396
;; A comma separated list of glob patterns to exclude from the index; ; default is empty
14191397
;REPO_INDEXER_EXCLUDE =
14201398
;;
1421-
;;
1422-
;UPDATE_BUFFER_LEN = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
14231399
;MAX_FILE_SIZE = 1048576
14241400

14251401
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1449,37 +1425,16 @@ ROUTER = console
14491425
;; Connection string for redis queues this will store the redis connection string.
14501426
;; When `TYPE` is `persistable-channel`, this provides a directory for the underlying leveldb
14511427
;; or additional options of the form `leveldb://path/to/db?option=value&....`, and will override `DATADIR`.
1452-
;CONN_STR = "addrs=127.0.0.1:6379 db=0"
1428+
;CONN_STR = "redis://127.0.0.1:6379/0"
14531429
;;
14541430
;; Provides the suffix of the default redis/disk queue name - specific queues can be overridden within in their [queue.name] sections.
14551431
;QUEUE_NAME = "_queue"
14561432
;;
14571433
;; Provides the suffix of the default redis/disk unique queue set name - specific queues can be overridden within in their [queue.name] sections.
14581434
;SET_NAME = "_unique"
14591435
;;
1460-
;; If the queue cannot be created at startup - level queues may need a timeout at startup - wrap the queue:
1461-
;WRAP_IF_NECESSARY = true
1462-
;;
1463-
;; Attempt to create the wrapped queue at max
1464-
;MAX_ATTEMPTS = 10
1465-
;;
1466-
;; Timeout queue creation
1467-
;TIMEOUT = 15m30s
1468-
;;
1469-
;; Create a pool with this many workers
1470-
;WORKERS = 0
1471-
;;
14721436
;; Dynamically scale the worker pool to at this many workers
14731437
;MAX_WORKERS = 10
1474-
;;
1475-
;; Add boost workers when the queue blocks for BLOCK_TIMEOUT
1476-
;BLOCK_TIMEOUT = 1s
1477-
;;
1478-
;; Remove the boost workers after BOOST_TIMEOUT
1479-
;BOOST_TIMEOUT = 5m
1480-
;;
1481-
;; During a boost add BOOST_WORKERS
1482-
;BOOST_WORKERS = 1
14831438

14841439
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14851440
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ In addition there is _`StaticRootPath`_ which can be set as a built-in at build
8989
- `DEFAULT_PUSH_CREATE_PRIVATE`: **true**: Default private when creating a new repository with push-to-create.
9090
- `MAX_CREATION_LIMIT`: **-1**: Global maximum creation limit of repositories per user,
9191
`-1` means no limit.
92-
- `PULL_REQUEST_QUEUE_LENGTH`: **1000**: Length of pull request patch test queue, make it. **DEPRECATED** use `LENGTH` in `[queue.pr_patch_checker]`.
93-
as large as possible. Use caution when editing this value.
94-
- `MIRROR_QUEUE_LENGTH`: **1000**: Patch test queue length, increase if pull request patch
95-
testing starts hanging. **DEPRECATED** use `LENGTH` in `[queue.mirror]`.
9692
- `PREFERRED_LICENSES`: **Apache License 2.0,MIT License**: Preferred Licenses to place at
9793
the top of the list. Name must match file name in options/license or custom/options/license.
9894
- `DISABLE_HTTP_GIT`: **false**: Disable the ability to interact with repositories over the
@@ -466,10 +462,6 @@ relation to port exhaustion.
466462
- `ISSUE_INDEXER_NAME`: **gitea_issues**: Issue indexer name, available when ISSUE_INDEXER_TYPE is elasticsearch
467463
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch. Relative paths will be made absolute against _`AppWorkPath`_.
468464
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
469-
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
470-
- `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]`. Relative paths will be made absolute against `%(APP_DATA_PATH)s`.
471-
- `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]`.
472-
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number. **DEPRECATED** use settings in `[queue.issue_indexer]`.
473465

474466
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
475467
- `REPO_INDEXER_TYPE`: **bleve**: Code search engine type, could be `bleve` or `elasticsearch`.
@@ -480,7 +472,6 @@ relation to port exhaustion.
480472
- `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.
481473
- `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`.
482474
- `REPO_INDEXER_EXCLUDE_VENDORED`: **true**: Exclude vendored files from index.
483-
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request. **DEPRECATED** use settings in `[queue.issue_indexer]`.
484475
- `MAX_FILE_SIZE`: **1048576**: Maximum size in bytes of files to be indexed.
485476
- `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 -1 to never timeout.
486477

@@ -496,15 +487,7 @@ Configuration at `[queue]` will set defaults for queues with overrides for indiv
496487
- `QUEUE_NAME`: **_queue**: The suffix for default redis and disk queue name. Individual queues will default to **`name`**`QUEUE_NAME` but can be overridden in the specific `queue.name` section.
497488
- `SET_NAME`: **_unique**: The suffix that will be added to the default redis and disk queue `set` name for unique queues. Individual queues will default to
498489
**`name`**`QUEUE_NAME`_`SET_NAME`_ but can be overridden in the specific `queue.name` section.
499-
- `WRAP_IF_NECESSARY`: **true**: Will wrap queues with a timeoutable queue if the selected queue is not ready to be created - (Only relevant for the level queue.)
500-
- `MAX_ATTEMPTS`: **10**: Maximum number of attempts to create the wrapped queue
501-
- `TIMEOUT`: **GRACEFUL_HAMMER_TIME + 30s**: Timeout the creation of the wrapped queue if it takes longer than this to create.
502-
- Queues by default come with a dynamically scaling worker pool. The following settings configure this:
503-
- `WORKERS`: **0**: Number of initial workers for the queue.
504490
- `MAX_WORKERS`: **10**: Maximum number of worker go-routines for the queue.
505-
- `BLOCK_TIMEOUT`: **1s**: If the queue blocks for this time, boost the number of workers - the `BLOCK_TIMEOUT` will then be doubled before boosting again whilst the boost is ongoing.
506-
- `BOOST_TIMEOUT`: **5m**: Boost workers will timeout after this long.
507-
- `BOOST_WORKERS`: **1**: This many workers will be added to the worker pool if there is a boost.
508491

509492
Gitea creates the following non-unique queues:
510493

modules/queue/base_levelqueue_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ func TestBaseLevelDB(t *testing.T) {
1616
setting.AppDataPath = oldAppDataPath
1717
}()
1818

19-
testQueueBasic(t, newBaseLevelQueueSimple, toBaseConfig("baseLevelQueue", &IniConfig{Length: 10}), false)
20-
testQueueBasic(t, newBaseLevelQueueUnique, toBaseConfig("baseLevelQueueUnique", &IniConfig{Length: 10}), true)
19+
testQueueBasic(t, newBaseLevelQueueSimple, toBaseConfig("baseLevelQueue", setting.QueueSettings{Length: 10}), false)
20+
testQueueBasic(t, newBaseLevelQueueUnique, toBaseConfig("baseLevelQueueUnique", setting.QueueSettings{Length: 10}), true)
2121
}

modules/queue/base_redis_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"code.gitea.io/gitea/modules/nosql"
14+
"code.gitea.io/gitea/modules/setting"
1415

1516
"github.com/stretchr/testify/assert"
1617
)
@@ -65,6 +66,6 @@ func TestBaseRedis(t *testing.T) {
6566
}
6667
}
6768

68-
testQueueBasic(t, newBaseRedisSimple, toBaseConfig("baseRedis", &IniConfig{Length: 10}), false)
69-
testQueueBasic(t, newBaseRedisUnique, toBaseConfig("baseRedisUnique", &IniConfig{Length: 10}), true)
69+
testQueueBasic(t, newBaseRedisSimple, toBaseConfig("baseRedis", setting.QueueSettings{Length: 10}), false)
70+
testQueueBasic(t, newBaseRedisUnique, toBaseConfig("baseRedisUnique", setting.QueueSettings{Length: 10}), true)
7071
}

modules/queue/config.go

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package queue
55

66
import (
77
"path/filepath"
8-
"unicode"
98

109
"code.gitea.io/gitea/modules/setting"
1110
)
@@ -20,48 +19,15 @@ type BaseConfig struct {
2019
QueueFullName, SetFullName string
2120
}
2221

23-
type IniConfig struct {
24-
Type string
25-
Datadir string
26-
ConnStr string
27-
Length int
28-
29-
QueueName, SetName string
30-
31-
BatchLength int
32-
Workers int
33-
}
34-
35-
var iniConfigDefault = IniConfig{
36-
Type: "level", // dummy, channel, level(leveldb,levelqueue,persistable-channel), redis
37-
Datadir: "queues/", // relative to AppDataPath
38-
Length: 1000, // queue length before a channel queue will block
39-
40-
QueueName: "_queue", // the suffix of the default redis/disk queue name
41-
SetName: "_unique", // the suffix of the default redis/disk unique queue set name (for unique queue)
42-
BatchLength: 20,
43-
Workers: 1,
44-
}
45-
46-
func joinQueueFullName(managedName, suffixOrName, suffixDefault string) string {
47-
if suffixOrName == "" {
48-
suffixOrName = suffixDefault
49-
}
50-
if unicode.IsLetter(rune(suffixOrName[0])) {
51-
return suffixOrName
52-
}
53-
return managedName + suffixOrName
54-
}
55-
56-
func toBaseConfig(managedName string, iniCfg *IniConfig) *BaseConfig {
22+
func toBaseConfig(managedName string, queueSetting setting.QueueSettings) *BaseConfig {
5723
baseConfig := &BaseConfig{
5824
ManagedName: managedName,
5925

60-
ConnStr: iniCfg.ConnStr,
61-
Length: iniCfg.Length,
26+
ConnStr: queueSetting.ConnStr,
27+
Length: queueSetting.Length,
6228
}
6329
// data dir
64-
baseConfig.DataFullDir = iniCfg.Datadir
30+
baseConfig.DataFullDir = queueSetting.Datadir
6531
if baseConfig.DataFullDir == "" {
6632
baseConfig.DataFullDir = "queues/"
6733
}
@@ -71,7 +37,10 @@ func toBaseConfig(managedName string, iniCfg *IniConfig) *BaseConfig {
7137
}
7238

7339
// queue name and set name
74-
baseConfig.QueueFullName = joinQueueFullName(managedName, iniCfg.QueueName, "_queue")
75-
baseConfig.SetFullName = joinQueueFullName(managedName, iniCfg.SetName, "_unique")
40+
baseConfig.QueueFullName = managedName + queueSetting.QueueName
41+
baseConfig.SetFullName = baseConfig.QueueFullName + queueSetting.SetName
42+
if baseConfig.SetFullName == baseConfig.QueueFullName {
43+
baseConfig.SetFullName += "_unique"
44+
}
7645
return baseConfig
7746
}

modules/queue/manager_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@ LENGTH = 100
2828
BATCH_LENGTH = 20
2929
CONN_STR = "addrs=127.0.0.1:6379 db=0"
3030
QUEUE_NAME = "_queue1"
31-
SET_NAME = "_unique1"
32-
WORKERS = 1
3331
3432
[queue.sub]
3533
TYPE = level
3634
DATADIR = queues-dir2
3735
LENGTH = 102
3836
BATCH_LENGTH = 22
3937
CONN_STR =
40-
QUEUE_NAME = "q2"
41-
SET_NAME = "u2"
42-
WORKERS = 2
38+
QUEUE_NAME = "_q2"
39+
SET_NAME = "_u2"
40+
MAX_WORKERS = 2
4341
`)
4442

4543
assert.NoError(t, err)
@@ -52,8 +50,8 @@ WORKERS = 2
5250
assert.Equal(t, 20, q1.batchLength)
5351
assert.Equal(t, "addrs=127.0.0.1:6379 db=0", q1.baseConfig.ConnStr)
5452
assert.Equal(t, "default_queue1", q1.baseConfig.QueueFullName)
55-
assert.Equal(t, "default_unique1", q1.baseConfig.SetFullName)
56-
assert.Equal(t, 1, q1.GetWorkerMaxNumber())
53+
assert.Equal(t, "default_queue1_unique", q1.baseConfig.SetFullName)
54+
assert.Equal(t, 10, q1.GetWorkerMaxNumber())
5755
assert.Equal(t, 0, q1.GetWorkerNumber())
5856
assert.Equal(t, 0, q1.GetWorkerActiveNumber())
5957
assert.Equal(t, 0, q1.GetQueueItemNumber())
@@ -67,8 +65,8 @@ WORKERS = 2
6765
assert.Equal(t, 102, q2.baseConfig.Length)
6866
assert.Equal(t, 22, q2.batchLength)
6967
assert.Equal(t, "", q2.baseConfig.ConnStr)
70-
assert.Equal(t, "q2", q2.baseConfig.QueueFullName)
71-
assert.Equal(t, "u2", q2.baseConfig.SetFullName)
68+
assert.Equal(t, "sub_q2", q2.baseConfig.QueueFullName)
69+
assert.Equal(t, "sub_q2_u2", q2.baseConfig.SetFullName)
7270
assert.Equal(t, 2, q2.GetWorkerMaxNumber())
7371
assert.Equal(t, 0, q2.GetWorkerNumber())
7472
assert.Equal(t, 0, q2.GetWorkerActiveNumber())

modules/queue/workerqueue.go

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,17 @@ func getNewQueueFn(t string) (string, func(cfg *BaseConfig, unique bool) (baseQu
182182
}
183183
}
184184

185-
func NewWorkerPoolQueueByIniConfig[T any](name string, iniCfg IniConfig, handler HandlerFuncT[T], unique bool) *WorkerPoolQueue[T] {
185+
func NewWorkerPoolQueueByIniConfig[T any](name string, queueSetting setting.QueueSettings, handler HandlerFuncT[T], unique bool) *WorkerPoolQueue[T] {
186186
if handler == nil {
187187
log.Debug("Use dummy queue for %q because handler is nil and caller doesn't want to process the queue items", name)
188-
iniCfg.Type = "dummy"
189-
}
190-
191-
if iniCfg.Length <= 0 {
192-
iniCfg.Length = iniConfigDefault.Length
193-
}
194-
if iniCfg.Workers <= 0 {
195-
iniCfg.Workers = iniConfigDefault.Workers
196-
}
197-
if iniCfg.BatchLength <= 0 {
198-
iniCfg.BatchLength = iniConfigDefault.BatchLength
188+
queueSetting.Type = "dummy"
199189
}
200190

201191
var w WorkerPoolQueue[T]
202192
var err error
203-
queueType, newQueueFn := getNewQueueFn(iniCfg.Type)
193+
queueType, newQueueFn := getNewQueueFn(queueSetting.Type)
204194
w.baseQueueType = queueType
205-
w.baseConfig = toBaseConfig(name, &iniCfg)
195+
w.baseConfig = toBaseConfig(name, queueSetting)
206196
w.baseQueue, err = newQueueFn(w.baseConfig, unique)
207197
if err != nil {
208198
log.Error("Failed to create queue %q: %v", name, err)
@@ -213,8 +203,8 @@ func NewWorkerPoolQueueByIniConfig[T any](name string, iniCfg IniConfig, handler
213203
w.ctxRun, w.ctxRunCancel = context.WithCancel(graceful.GetManager().ShutdownContext())
214204
w.batchChan = make(chan []T)
215205
w.flushChan = make(chan flushChanType)
216-
w.workerMaxNum = iniCfg.Workers
217-
w.batchLength = iniCfg.BatchLength
206+
w.workerMaxNum = queueSetting.MaxWorkers
207+
w.batchLength = queueSetting.BatchLength
218208

219209
w.origHandler = handler
220210
w.safeHandler = func(t ...T) (unhandled []T) {
@@ -239,24 +229,12 @@ func CreateUniqueQueue[T any](name string, handler HandlerFuncT[T]) *WorkerPoolQ
239229
}
240230

241231
func createWorkerPoolQueue[T any](name string, cfgProvider setting.ConfigProvider, handler HandlerFuncT[T], unique bool) *WorkerPoolQueue[T] {
242-
// FIXME: legacy ini options should be dropped and removed
243-
iniCfg := iniConfigDefault
244-
if sec, err := cfgProvider.GetSection("queue"); err == nil {
245-
if err = sec.MapTo(&iniCfg); err != nil {
246-
log.Error("Failed to map queue common config for %q: %v", name, err)
247-
return nil
248-
}
249-
}
250-
if sec, err := cfgProvider.GetSection("queue." + name); err == nil {
251-
if err = sec.MapTo(&iniCfg); err != nil {
252-
log.Error("Failed to map queue spec config for %q: %v", name, err)
253-
return nil
254-
}
255-
if sec.HasKey("CONN_STR") {
256-
iniCfg.ConnStr = sec.Key("CONN_STR").String()
257-
}
232+
queueSetting, err := setting.GetQueueSettings(cfgProvider, name)
233+
if err != nil {
234+
log.Error("Failed to get queue settings for %q: %v", name, err)
235+
return nil
258236
}
259-
w := NewWorkerPoolQueueByIniConfig(name, iniCfg, handler, unique)
237+
w := NewWorkerPoolQueueByIniConfig(name, queueSetting, handler, unique)
260238
GetManager().AddManagedQueue(w)
261239
return w
262240
}

0 commit comments

Comments
 (0)