@@ -107,51 +107,71 @@ func NewQueueService() {
107
107
Queue .SetName = sec .Key ("SET_NAME" ).MustString ("" )
108
108
109
109
// Now handle the old issue_indexer configuration
110
+ // FIXME: DEPRECATED to be removed in v1.18.0
110
111
section := Cfg .Section ("queue.issue_indexer" )
111
112
directlySet := toDirectlySetKeysMap (section )
112
113
if ! directlySet ["TYPE" ] && defaultType == "" {
113
- switch Indexer . IssueQueueType {
114
- case LevelQueueType :
114
+ switch typ := Cfg . Section ( "indexer" ). Key ( "ISSUE_INDEXER_QUEUE_TYPE" ). MustString ( "" ); typ {
115
+ case "levelqueue" :
115
116
_ , _ = section .NewKey ("TYPE" , "level" )
116
- case ChannelQueueType :
117
+ case "channel" :
117
118
_ , _ = section .NewKey ("TYPE" , "persistable-channel" )
118
- case RedisQueueType :
119
+ case "redis" :
119
120
_ , _ = section .NewKey ("TYPE" , "redis" )
120
121
case "" :
121
122
_ , _ = section .NewKey ("TYPE" , "level" )
122
123
default :
123
- log .Fatal ("Unsupported indexer queue type: %v" ,
124
- Indexer .IssueQueueType )
124
+ log .Fatal ("Unsupported indexer queue type: %v" , typ )
125
125
}
126
126
}
127
- if ! directlySet ["LENGTH" ] && Indexer .UpdateQueueLength != 0 {
128
- _ , _ = section .NewKey ("LENGTH" , strconv .Itoa (Indexer .UpdateQueueLength ))
127
+ if ! directlySet ["LENGTH" ] {
128
+ length := Cfg .Section ("indexer" ).Key ("UPDATE_BUFFER_LEN" ).MustInt (0 )
129
+ if length != 0 {
130
+ _ , _ = section .NewKey ("LENGTH" , strconv .Itoa (length ))
131
+ }
129
132
}
130
- if ! directlySet ["BATCH_LENGTH" ] && Indexer .IssueQueueBatchNumber != 0 {
131
- _ , _ = section .NewKey ("BATCH_LENGTH" , strconv .Itoa (Indexer .IssueQueueBatchNumber ))
133
+ if ! directlySet ["BATCH_LENGTH" ] {
134
+ fallback := Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_BATCH_NUMBER" ).MustInt (0 )
135
+ if fallback != 0 {
136
+ _ , _ = section .NewKey ("BATCH_LENGTH" , strconv .Itoa (fallback ))
137
+ }
132
138
}
133
- if ! directlySet ["DATADIR" ] && Indexer .IssueQueueDir != "" {
134
- _ , _ = section .NewKey ("DATADIR" , Indexer .IssueQueueDir )
139
+ if ! directlySet ["DATADIR" ] {
140
+ queueDir := filepath .ToSlash (Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_DIR" ).MustString ("" ))
141
+ if queueDir != "" {
142
+ _ , _ = section .NewKey ("DATADIR" , queueDir )
143
+ }
135
144
}
136
- if ! directlySet ["CONN_STR" ] && Indexer .IssueQueueConnStr != "" {
137
- _ , _ = section .NewKey ("CONN_STR" , Indexer .IssueQueueConnStr )
145
+ if ! directlySet ["CONN_STR" ] {
146
+ connStr := Cfg .Section ("indexer" ).Key ("ISSUE_INDEXER_QUEUE_CONN_STR" ).MustString ("" )
147
+ if connStr != "" {
148
+ _ , _ = section .NewKey ("CONN_STR" , connStr )
149
+ }
138
150
}
139
151
152
+ // FIXME: DEPRECATED to be removed in v1.18.0
153
+ // - will need to set default for [queue.*)] LENGTH appropriately though though
154
+
140
155
// Handle the old mailer configuration
141
- handleOldLengthConfiguration ("mailer" , Cfg . Section ( "mailer" ). Key ( "SEND_BUFFER_LEN" ). MustInt ( 100 ) )
156
+ handleOldLengthConfiguration ("mailer" , "mailer" , "SEND_BUFFER_LEN" , 100 )
142
157
143
158
// Handle the old test pull requests configuration
144
159
// Please note this will be a unique queue
145
- handleOldLengthConfiguration ("pr_patch_checker" , Cfg . Section ( "repository" ). Key ( "PULL_REQUEST_QUEUE_LENGTH" ). MustInt ( 1000 ) )
160
+ handleOldLengthConfiguration ("pr_patch_checker" , "repository" , "PULL_REQUEST_QUEUE_LENGTH" , 1000 )
146
161
147
162
// Handle the old mirror queue configuration
148
163
// Please note this will be a unique queue
149
- handleOldLengthConfiguration ("mirror" , Cfg . Section ( "repository" ). Key ( "MIRROR_QUEUE_LENGTH" ). MustInt ( 1000 ) )
164
+ handleOldLengthConfiguration ("mirror" , "repository" , "MIRROR_QUEUE_LENGTH" , 1000 )
150
165
}
151
166
152
167
// handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but
153
168
// if that is left unset then we should fallback to the older configuration. (Except where the new length woul be <=0)
154
- func handleOldLengthConfiguration (queueName string , value int ) {
169
+ func handleOldLengthConfiguration (queueName , oldSection , oldKey string , defaultValue int ) {
170
+ if Cfg .Section (oldSection ).HasKey (oldKey ) {
171
+ 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
+ }
173
+ value := Cfg .Section (oldSection ).Key (oldKey ).MustInt (defaultValue )
174
+
155
175
// Don't override with 0
156
176
if value <= 0 {
157
177
return
0 commit comments