diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-01-20 18:00:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 18:00:38 +0100 |
commit | 1d98d205f5825f40110e6628b61a97c91ac7f72d (patch) | |
tree | 2326229027b9ba388732a912bff07ce4320aaf7c /modules/setting/queue.go | |
parent | 16d378fefc0a569f2a7aed29e6c7f288b3d83f02 (diff) | |
download | gitea-1d98d205f5825f40110e6628b61a97c91ac7f72d.tar.gz gitea-1d98d205f5825f40110e6628b61a97c91ac7f72d.zip |
Enable deprecation error for v1.17.0 (#18341)
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/setting/queue.go')
-rw-r--r-- | modules/setting/queue.go | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/modules/setting/queue.go b/modules/setting/queue.go index 56a036aeef..cb86cbdfe0 100644 --- a/modules/setting/queue.go +++ b/modules/setting/queue.go @@ -107,51 +107,71 @@ func NewQueueService() { Queue.SetName = sec.Key("SET_NAME").MustString("") // Now handle the old issue_indexer configuration + // FIXME: DEPRECATED to be removed in v1.18.0 section := Cfg.Section("queue.issue_indexer") directlySet := toDirectlySetKeysMap(section) if !directlySet["TYPE"] && defaultType == "" { - switch Indexer.IssueQueueType { - case LevelQueueType: + switch typ := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(""); typ { + case "levelqueue": _, _ = section.NewKey("TYPE", "level") - case ChannelQueueType: + case "channel": _, _ = section.NewKey("TYPE", "persistable-channel") - case RedisQueueType: + case "redis": _, _ = section.NewKey("TYPE", "redis") case "": _, _ = section.NewKey("TYPE", "level") default: - log.Fatal("Unsupported indexer queue type: %v", - Indexer.IssueQueueType) + log.Fatal("Unsupported indexer queue type: %v", typ) } } - if !directlySet["LENGTH"] && Indexer.UpdateQueueLength != 0 { - _, _ = section.NewKey("LENGTH", strconv.Itoa(Indexer.UpdateQueueLength)) + if !directlySet["LENGTH"] { + length := Cfg.Section("indexer").Key("UPDATE_BUFFER_LEN").MustInt(0) + if length != 0 { + _, _ = section.NewKey("LENGTH", strconv.Itoa(length)) + } } - if !directlySet["BATCH_LENGTH"] && Indexer.IssueQueueBatchNumber != 0 { - _, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(Indexer.IssueQueueBatchNumber)) + if !directlySet["BATCH_LENGTH"] { + fallback := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(0) + if fallback != 0 { + _, _ = section.NewKey("BATCH_LENGTH", strconv.Itoa(fallback)) + } } - if !directlySet["DATADIR"] && Indexer.IssueQueueDir != "" { - _, _ = section.NewKey("DATADIR", Indexer.IssueQueueDir) + if !directlySet["DATADIR"] { + queueDir := filepath.ToSlash(Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_DIR").MustString("")) + if queueDir != "" { + _, _ = section.NewKey("DATADIR", queueDir) + } } - if !directlySet["CONN_STR"] && Indexer.IssueQueueConnStr != "" { - _, _ = section.NewKey("CONN_STR", Indexer.IssueQueueConnStr) + if !directlySet["CONN_STR"] { + connStr := Cfg.Section("indexer").Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("") + if connStr != "" { + _, _ = section.NewKey("CONN_STR", connStr) + } } + // FIXME: DEPRECATED to be removed in v1.18.0 + // - will need to set default for [queue.*)] LENGTH appropriately though though + // Handle the old mailer configuration - handleOldLengthConfiguration("mailer", Cfg.Section("mailer").Key("SEND_BUFFER_LEN").MustInt(100)) + handleOldLengthConfiguration("mailer", "mailer", "SEND_BUFFER_LEN", 100) // Handle the old test pull requests configuration // Please note this will be a unique queue - handleOldLengthConfiguration("pr_patch_checker", Cfg.Section("repository").Key("PULL_REQUEST_QUEUE_LENGTH").MustInt(1000)) + handleOldLengthConfiguration("pr_patch_checker", "repository", "PULL_REQUEST_QUEUE_LENGTH", 1000) // Handle the old mirror queue configuration // Please note this will be a unique queue - handleOldLengthConfiguration("mirror", Cfg.Section("repository").Key("MIRROR_QUEUE_LENGTH").MustInt(1000)) + handleOldLengthConfiguration("mirror", "repository", "MIRROR_QUEUE_LENGTH", 1000) } // handleOldLengthConfiguration allows fallback to older configuration. `[queue.name]` `LENGTH` will override this configuration, but // if that is left unset then we should fallback to the older configuration. (Except where the new length woul be <=0) -func handleOldLengthConfiguration(queueName string, value int) { +func handleOldLengthConfiguration(queueName, oldSection, oldKey string, defaultValue int) { + if Cfg.Section(oldSection).HasKey(oldKey) { + 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) + } + value := Cfg.Section(oldSection).Key(oldKey).MustInt(defaultValue) + // Don't override with 0 if value <= 0 { return |