File tree 5 files changed +32
-1
lines changed
5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,14 @@ queue:
183
183
group : gorush
184
184
consumer : gorush
185
185
stream_name : gorush
186
+ redis :
187
+ addr : 127.0.0.1:6379
188
+ group : gorush
189
+ consumer : gorush
190
+ stream_name : gorush
191
+ with_tls : false
192
+ username : " "
193
+ password : " "
186
194
187
195
ios :
188
196
enabled : false
Original file line number Diff line number Diff line change 82
82
group: gorush
83
83
consumer: gorush
84
84
stream_name: gorush
85
+ with_tls: false
86
+ username: ""
87
+ password: ""
85
88
86
89
ios:
87
90
enabled: false
@@ -255,9 +258,12 @@ type SectionNATS struct {
255
258
// SectionRedisQueue is sub section of config.
256
259
type SectionRedisQueue struct {
257
260
Addr string `yaml:"addr"`
261
+ Username string `yaml:"username"`
262
+ Password string `yaml:"password"`
258
263
StreamName string `yaml:"stream_name"`
259
264
Group string `yaml:"group"`
260
265
Consumer string `yaml:"consumer"`
266
+ WithTLS bool `yaml:"with_tls"`
261
267
}
262
268
263
269
// SectionRedis is sub section of config.
@@ -424,6 +430,9 @@ func LoadConf(confPath ...string) (*ConfYaml, error) {
424
430
conf .Queue .Redis .StreamName = viper .GetString ("queue.redis.stream_name" )
425
431
conf .Queue .Redis .Group = viper .GetString ("queue.redis.group" )
426
432
conf .Queue .Redis .Consumer = viper .GetString ("queue.redis.consumer" )
433
+ conf .Queue .Redis .WithTLS = viper .GetBool ("queue.redis.with_tls" )
434
+ conf .Queue .Redis .Username = viper .GetString ("queue.redis.username" )
435
+ conf .Queue .Redis .Password = viper .GetString ("queue.redis.password" )
427
436
428
437
// Stat Engine
429
438
conf .Stat .Engine = viper .GetString ("stat.engine" )
Original file line number Diff line number Diff line change @@ -113,6 +113,9 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
113
113
assert .Equal (suite .T (), "gorush" , suite .ConfGorushDefault .Queue .Redis .StreamName )
114
114
assert .Equal (suite .T (), "gorush" , suite .ConfGorushDefault .Queue .Redis .Group )
115
115
assert .Equal (suite .T (), "gorush" , suite .ConfGorushDefault .Queue .Redis .Consumer )
116
+ assert .Equal (suite .T (), "" , suite .ConfGorushDefault .Queue .Redis .Username )
117
+ assert .Equal (suite .T (), "" , suite .ConfGorushDefault .Queue .Redis .Password )
118
+ assert .Equal (suite .T (), false , suite .ConfGorushDefault .Queue .Redis .WithTLS )
116
119
117
120
// log
118
121
assert .Equal (suite .T (), "string" , suite .ConfGorushDefault .Log .Format )
Original file line number Diff line number Diff line change 70
70
group : gorush
71
71
consumer : gorush
72
72
stream_name : gorush
73
+ username : " "
74
+ password : " "
75
+ with_tls : false
73
76
74
77
ios :
75
78
enabled : false
Original file line number Diff line number Diff line change @@ -328,14 +328,22 @@ func main() {
328
328
nats .WithLogger (logx .QueueLogger ()),
329
329
)
330
330
case core .Redis :
331
- w = redisdb .NewWorker (
331
+ opts := [] redisdb.Option {
332
332
redisdb .WithAddr (cfg .Queue .Redis .Addr ),
333
+ redisdb .WithUsername (cfg .Queue .Redis .Username ),
334
+ redisdb .WithPassword (cfg .Queue .Redis .Password ),
333
335
redisdb .WithStreamName (cfg .Queue .Redis .StreamName ),
334
336
redisdb .WithGroup (cfg .Queue .Redis .Group ),
335
337
redisdb .WithConsumer (cfg .Queue .Redis .Consumer ),
336
338
redisdb .WithMaxLength (cfg .Core .QueueNum ),
337
339
redisdb .WithRunFunc (notify .Run (cfg )),
338
340
redisdb .WithLogger (logx .QueueLogger ()),
341
+ }
342
+ if cfg .Queue .Redis .WithTLS {
343
+ opts = append (opts , redisdb .WithTLS ())
344
+ }
345
+ w = redisdb .NewWorker (
346
+ opts ... ,
339
347
)
340
348
default :
341
349
logx .LogError .Fatalf ("we don't support queue engine: %s" , cfg .Queue .Engine )
You can’t perform that action at this time.
0 commit comments