@@ -107,51 +107,71 @@ func NewQueueService() {
107107 Queue .SetName = sec .Key ("SET_NAME" ).MustString ("" )
108108
109109 // Now handle the old issue_indexer configuration
110+ // FIXME: DEPRECATED to be removed in v1.18.0
110111 section := Cfg .Section ("queue.issue_indexer" )
111112 directlySet := toDirectlySetKeysMap (section )
112113 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" :
115116 _ , _ = section .NewKey ("TYPE" , "level" )
116- case ChannelQueueType :
117+ case "channel" :
117118 _ , _ = section .NewKey ("TYPE" , "persistable-channel" )
118- case RedisQueueType :
119+ case "redis" :
119120 _ , _ = section .NewKey ("TYPE" , "redis" )
120121 case "" :
121122 _ , _ = section .NewKey ("TYPE" , "level" )
122123 default :
123- log .Fatal ("Unsupported indexer queue type: %v" ,
124- Indexer .IssueQueueType )
124+ log .Fatal ("Unsupported indexer queue type: %v" , typ )
125125 }
126126 }
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+ }
129132 }
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+ }
132138 }
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+ }
135144 }
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+ }
138150 }
139151
152+ // FIXME: DEPRECATED to be removed in v1.18.0
153+ // - will need to set default for [queue.*)] LENGTH appropriately though though
154+
140155 // 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 )
142157
143158 // Handle the old test pull requests configuration
144159 // 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 )
146161
147162 // Handle the old mirror queue configuration
148163 // 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 )
150165}
151166
152167// handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but
153168// 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+
155175 // Don't override with 0
156176 if value <= 0 {
157177 return
0 commit comments