@@ -39,8 +39,12 @@ var Queue = QueueSettings{}
39
39
40
40
// GetQueueSettings returns the queue settings for the appropriately named queue
41
41
func GetQueueSettings (name string ) QueueSettings {
42
+ return getQueueSettings (Cfg , name )
43
+ }
44
+
45
+ func getQueueSettings (rootCfg Config , name string ) QueueSettings {
42
46
q := QueueSettings {}
43
- sec := Cfg .Section ("queue." + name )
47
+ sec := rootCfg .Section ("queue." + name )
44
48
q .Name = name
45
49
46
50
// DataDir is not directly inheritable
@@ -85,7 +89,11 @@ func GetQueueSettings(name string) QueueSettings {
85
89
// ParseQueueSettings sets up the default settings for Queues
86
90
// This is exported for tests to be able to use the queue
87
91
func ParseQueueSettings () {
88
- sec := Cfg .Section ("queue" )
92
+ parseQueueSettings (Cfg )
93
+ }
94
+
95
+ func parseQueueSettings (rootCfg Config ) {
96
+ sec := rootCfg .Section ("queue" )
89
97
Queue .DataDir = filepath .ToSlash (sec .Key ("DATADIR" ).MustString ("queues/" ))
90
98
if ! filepath .IsAbs (Queue .DataDir ) {
91
99
Queue .DataDir = filepath .ToSlash (filepath .Join (AppDataPath , Queue .DataDir ))
@@ -108,10 +116,10 @@ func ParseQueueSettings() {
108
116
109
117
// Now handle the old issue_indexer configuration
110
118
// FIXME: DEPRECATED to be removed in v1.18.0
111
- section := Cfg .Section ("queue.issue_indexer" )
119
+ section := rootCfg .Section ("queue.issue_indexer" )
112
120
directlySet := toDirectlySetKeysSet (section )
113
121
if ! directlySet .Contains ("TYPE" ) && defaultType == "" {
114
- switch typ := Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_TYPE" ).MustString ("" ); typ {
122
+ switch typ := rootCfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_TYPE" ).MustString ("" ); typ {
115
123
case "levelqueue" :
116
124
_ , _ = section .NewKey ("TYPE" , "level" )
117
125
case "channel" :
@@ -125,25 +133,25 @@ func ParseQueueSettings() {
125
133
}
126
134
}
127
135
if ! directlySet .Contains ("LENGTH" ) {
128
- length := Cfg .Section ("indexer" ).Key ("UPDATE_BUFFER_LEN" ).MustInt (0 )
136
+ length := rootCfg .Section ("indexer" ).Key ("UPDATE_BUFFER_LEN" ).MustInt (0 )
129
137
if length != 0 {
130
138
_ , _ = section .NewKey ("LENGTH" , strconv .Itoa (length ))
131
139
}
132
140
}
133
141
if ! directlySet .Contains ("BATCH_LENGTH" ) {
134
- fallback := Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_BATCH_NUMBER" ).MustInt (0 )
142
+ fallback := rootCfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_BATCH_NUMBER" ).MustInt (0 )
135
143
if fallback != 0 {
136
144
_ , _ = section .NewKey ("BATCH_LENGTH" , strconv .Itoa (fallback ))
137
145
}
138
146
}
139
147
if ! directlySet .Contains ("DATADIR" ) {
140
- queueDir := filepath .ToSlash (Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_DIR" ).MustString ("" ))
148
+ queueDir := filepath .ToSlash (rootCfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_DIR" ).MustString ("" ))
141
149
if queueDir != "" {
142
150
_ , _ = section .NewKey ("DATADIR" , queueDir )
143
151
}
144
152
}
145
153
if ! directlySet .Contains ("CONN_STR" ) {
146
- connStr := Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_CONN_STR" ).MustString ("" )
154
+ connStr := rootCfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_CONN_STR" ).MustString ("" )
147
155
if connStr != "" {
148
156
_ , _ = section .NewKey ("CONN_STR" , connStr )
149
157
}
@@ -153,31 +161,31 @@ func ParseQueueSettings() {
153
161
// - will need to set default for [queue.*)] LENGTH appropriately though though
154
162
155
163
// Handle the old mailer configuration
156
- handleOldLengthConfiguration ("mailer" , "mailer" , "SEND_BUFFER_LEN" , 100 )
164
+ handleOldLengthConfiguration (rootCfg , "mailer" , "mailer" , "SEND_BUFFER_LEN" , 100 )
157
165
158
166
// Handle the old test pull requests configuration
159
167
// Please note this will be a unique queue
160
- handleOldLengthConfiguration ("pr_patch_checker" , "repository" , "PULL_REQUEST_QUEUE_LENGTH" , 1000 )
168
+ handleOldLengthConfiguration (rootCfg , "pr_patch_checker" , "repository" , "PULL_REQUEST_QUEUE_LENGTH" , 1000 )
161
169
162
170
// Handle the old mirror queue configuration
163
171
// Please note this will be a unique queue
164
- handleOldLengthConfiguration ("mirror" , "repository" , "MIRROR_QUEUE_LENGTH" , 1000 )
172
+ handleOldLengthConfiguration (rootCfg , "mirror" , "repository" , "MIRROR_QUEUE_LENGTH" , 1000 )
165
173
}
166
174
167
175
// handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but
168
176
// if that is left unset then we should fallback to the older configuration. (Except where the new length woul be <=0)
169
- func handleOldLengthConfiguration (queueName , oldSection , oldKey string , defaultValue int ) {
170
- if Cfg .Section (oldSection ).HasKey (oldKey ) {
177
+ func handleOldLengthConfiguration (rootCfg Config , queueName , oldSection , oldKey string , defaultValue int ) {
178
+ if rootCfg .Section (oldSection ).HasKey (oldKey ) {
171
179
log .Error ("Deprecated fallback for %s queue length `[%s]` `%s` present. Use `[queue.%s]` `LENGTH`. This will be removed in v1.18.0" , queueName , queueName , oldSection , oldKey )
172
180
}
173
- value := Cfg .Section (oldSection ).Key (oldKey ).MustInt (defaultValue )
181
+ value := rootCfg .Section (oldSection ).Key (oldKey ).MustInt (defaultValue )
174
182
175
183
// Don't override with 0
176
184
if value <= 0 {
177
185
return
178
186
}
179
187
180
- section := Cfg .Section ("queue." + queueName )
188
+ section := rootCfg .Section ("queue." + queueName )
181
189
directlySet := toDirectlySetKeysSet (section )
182
190
if ! directlySet .Contains ("LENGTH" ) {
183
191
_ , _ = section .NewKey ("LENGTH" , strconv .Itoa (value ))
0 commit comments