diff options
author | zeripath <art27@cantab.net> | 2020-01-16 17:55:36 +0000 |
---|---|---|
committer | Antoine GIRARD <sapk@users.noreply.github.com> | 2020-01-16 18:55:36 +0100 |
commit | c76c70a16ce6c1d472059ea3e03206abb5ed884d (patch) | |
tree | 25902cbd062be6fdbefe9417ca33c96acab5809a /modules | |
parent | 06cd3e03a24e23d2d838cda6eb1edd5e7474ad42 (diff) | |
download | gitea-c76c70a16ce6c1d472059ea3e03206abb5ed884d.tar.gz gitea-c76c70a16ce6c1d472059ea3e03206abb5ed884d.zip |
Move mailer to use a queue (#9789)
* Move mailer to use a queue
* Make sectionMap map[string]bool
* Ensure that Message is json encodable
Diffstat (limited to 'modules')
-rw-r--r-- | modules/setting/queue.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/setting/queue.go b/modules/setting/queue.go index c91ff55acd..8c07685855 100644 --- a/modules/setting/queue.go +++ b/modules/setting/queue.go @@ -103,11 +103,11 @@ func NewQueueService() { // Now handle the old issue_indexer configuration section := Cfg.Section("queue.issue_indexer") - issueIndexerSectionMap := map[string]string{} + sectionMap := map[string]bool{} for _, key := range section.Keys() { - issueIndexerSectionMap[key.Name()] = key.Value() + sectionMap[key.Name()] = true } - if _, ok := issueIndexerSectionMap["TYPE"]; !ok { + if _, ok := sectionMap["TYPE"]; !ok { switch Indexer.IssueQueueType { case LevelQueueType: section.Key("TYPE").SetValue("level") @@ -120,18 +120,28 @@ func NewQueueService() { Indexer.IssueQueueType) } } - if _, ok := issueIndexerSectionMap["LENGTH"]; !ok { + if _, ok := sectionMap["LENGTH"]; !ok { section.Key("LENGTH").SetValue(fmt.Sprintf("%d", Indexer.UpdateQueueLength)) } - if _, ok := issueIndexerSectionMap["BATCH_LENGTH"]; !ok { + if _, ok := sectionMap["BATCH_LENGTH"]; !ok { section.Key("BATCH_LENGTH").SetValue(fmt.Sprintf("%d", Indexer.IssueQueueBatchNumber)) } - if _, ok := issueIndexerSectionMap["DATADIR"]; !ok { + if _, ok := sectionMap["DATADIR"]; !ok { section.Key("DATADIR").SetValue(Indexer.IssueQueueDir) } - if _, ok := issueIndexerSectionMap["CONN_STR"]; !ok { + if _, ok := sectionMap["CONN_STR"]; !ok { section.Key("CONN_STR").SetValue(Indexer.IssueQueueConnStr) } + + // Handle the old mailer configuration + section = Cfg.Section("queue.mailer") + sectionMap = map[string]bool{} + for _, key := range section.Keys() { + sectionMap[key.Name()] = true + } + if _, ok := sectionMap["LENGTH"]; !ok { + section.Key("LENGTH").SetValue(fmt.Sprintf("%d", Cfg.Section("mailer").Key("SEND_BUFFER_LEN").MustInt(100))) + } } // ParseQueueConnStr parses a queue connection string |