chore(queue): support NSQ as backend. (#600)
This commit is contained in:
@@ -62,6 +62,13 @@ huawei:
|
||||
appid: "YOUR_APP_ID"
|
||||
max_retry: 0 # resend fail notification, default value zero is disabled
|
||||
|
||||
queue:
|
||||
engine: "local" # support "local", "nsq", default value is "local"
|
||||
nsq:
|
||||
addr: 127.0.0.1:4150
|
||||
topic: gorush
|
||||
channel: ch
|
||||
|
||||
ios:
|
||||
enabled: false
|
||||
key_path: ""
|
||||
@@ -106,6 +113,7 @@ type ConfYaml struct {
|
||||
Android SectionAndroid `yaml:"android"`
|
||||
Huawei SectionHuawei `yaml:"huawei"`
|
||||
Ios SectionIos `yaml:"ios"`
|
||||
Queue SectionQueue `yaml:"queue"`
|
||||
Log SectionLog `yaml:"log"`
|
||||
Stat SectionStat `yaml:"stat"`
|
||||
GRPC SectionGRPC `yaml:"grpc"`
|
||||
@@ -201,6 +209,19 @@ type SectionStat struct {
|
||||
BadgerDB SectionBadgerDB `yaml:"badgerdb"`
|
||||
}
|
||||
|
||||
// SectionQueue is sub section of config.
|
||||
type SectionQueue struct {
|
||||
Engine string `yaml:"engine"`
|
||||
NSQ SectionNSQ `yaml:"nsq"`
|
||||
}
|
||||
|
||||
// SectionNSQ is sub section of config.
|
||||
type SectionNSQ struct {
|
||||
Addr string `yaml:"addr"`
|
||||
Topic string `yaml:"topic"`
|
||||
Channel string `yaml:"channel"`
|
||||
}
|
||||
|
||||
// SectionRedis is sub section of config.
|
||||
type SectionRedis struct {
|
||||
Addr string `yaml:"addr"`
|
||||
@@ -341,6 +362,12 @@ func LoadConf(confPath ...string) (ConfYaml, error) {
|
||||
conf.Log.ErrorLevel = viper.GetString("log.error_level")
|
||||
conf.Log.HideToken = viper.GetBool("log.hide_token")
|
||||
|
||||
// Queue Engine
|
||||
conf.Queue.Engine = viper.GetString("queue.engine")
|
||||
conf.Queue.NSQ.Addr = viper.GetString("queue.nsq.addr")
|
||||
conf.Queue.NSQ.Topic = viper.GetString("queue.nsq.topic")
|
||||
conf.Queue.NSQ.Channel = viper.GetString("queue.nsq.channel")
|
||||
|
||||
// Stat Engine
|
||||
conf.Stat.Engine = viper.GetString("stat.engine")
|
||||
conf.Stat.Redis.Addr = viper.GetString("stat.redis.addr")
|
||||
|
||||
@@ -88,6 +88,12 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.KeyID)
|
||||
assert.Equal(suite.T(), "", suite.ConfGorushDefault.Ios.TeamID)
|
||||
|
||||
// queue
|
||||
assert.Equal(suite.T(), "local", suite.ConfGorushDefault.Queue.Engine)
|
||||
assert.Equal(suite.T(), "127.0.0.1:4150", suite.ConfGorushDefault.Queue.NSQ.Addr)
|
||||
assert.Equal(suite.T(), "gorush", suite.ConfGorushDefault.Queue.NSQ.Topic)
|
||||
assert.Equal(suite.T(), "ch", suite.ConfGorushDefault.Queue.NSQ.Channel)
|
||||
|
||||
// log
|
||||
assert.Equal(suite.T(), "string", suite.ConfGorushDefault.Log.Format)
|
||||
assert.Equal(suite.T(), "stdout", suite.ConfGorushDefault.Log.AccessLog)
|
||||
|
||||
7
config/testdata/config.yml
vendored
7
config/testdata/config.yml
vendored
@@ -49,6 +49,13 @@ huawei:
|
||||
appid: "YOUR_APP_ID"
|
||||
max_retry: 0 # resend fail notification, default value zero is disabled
|
||||
|
||||
queue:
|
||||
engine: "nsq" # support "local", "nsq", default value is "local"
|
||||
nsq:
|
||||
addr: 127.0.0.1:4150
|
||||
topic: gorush
|
||||
channel: ch
|
||||
|
||||
ios:
|
||||
enabled: false
|
||||
key_path: "key.pem"
|
||||
|
||||
Reference in New Issue
Block a user