@@ -63,16 +63,19 @@ func (c *Controllor) initRecvs(env string) []recvs.AcceptorRecvItf {
63
63
switch utils .Settings .Get ("settings.acceptor.recvs.plugins" ).(type ) {
64
64
case map [string ]interface {}:
65
65
for name := range utils .Settings .Get ("settings.acceptor.recvs.plugins" ).(map [string ]interface {}) {
66
+ if ! StringListContains (utils .Settings .GetStringSlice ("settings.acceptor.recvs.plugins." + name + ".active_env" ), env ) {
67
+ utils .Logger .Info ("recv not support current env" , zap .String ("name" , name ), zap .String ("env" , env ))
68
+ continue
69
+ }
70
+
66
71
switch utils .Settings .GetString ("settings.acceptor.recvs.plugins." + name + ".type" ) {
67
72
case "fluentd" :
68
- if StringListContains (utils .Settings .GetStringSlice ("settings.acceptor.recvs.plugins." + name + ".active_env" ), env ) {
69
- receivers = append (receivers , recvs .NewFluentdRecv (& recvs.FluentdRecvCfg {
70
- Name : name ,
71
- Addr : utils .Settings .GetString ("settings.acceptor.recvs.plugins." + name + ".addr" ),
72
- TagKey : utils .Settings .GetString ("settings.acceptor.recvs.plugins." + name + ".tag_key" ),
73
- IsRewriteTagFromTagKey : utils .Settings .GetBool ("settings.acceptor.recvs.plugins." + name + ".is_rewrite_tag_from_tag_key" ),
74
- }))
75
- }
73
+ receivers = append (receivers , recvs .NewFluentdRecv (& recvs.FluentdRecvCfg {
74
+ Name : name ,
75
+ Addr : utils .Settings .GetString ("settings.acceptor.recvs.plugins." + name + ".addr" ),
76
+ TagKey : utils .Settings .GetString ("settings.acceptor.recvs.plugins." + name + ".tag_key" ),
77
+ IsRewriteTagFromTagKey : utils .Settings .GetBool ("settings.acceptor.recvs.plugins." + name + ".is_rewrite_tag_from_tag_key" ),
78
+ }))
76
79
case "rsyslog" :
77
80
receivers = append (receivers , recvs .NewRsyslogRecv (& recvs.RsyslogCfg {
78
81
Name : name ,
@@ -147,7 +150,7 @@ func (c *Controllor) initAcceptor(journal *Journal, receivers []recvs.AcceptorRe
147
150
acceptor := NewAcceptor (& AcceptorCfg {
148
151
MsgPool : c .msgPool ,
149
152
Journal : journal ,
150
- MaxRotateId : utils .Settings .GetInt64 ("settings.acceptor.max_rotate_id" ),
153
+ MaxRotateID : utils .Settings .GetInt64 ("settings.acceptor.max_rotate_id" ),
151
154
AsyncOutChanSize : utils .Settings .GetInt ("settings.acceptor.async_out_chan_size" ),
152
155
SyncOutChanSize : utils .Settings .GetInt ("settings.acceptor.sync_out_chan_size" ),
153
156
},
@@ -354,57 +357,64 @@ func StringListContains(ls []string, v string) bool {
354
357
355
358
func (c * Controllor ) initSenders (env string ) []senders.SenderItf {
356
359
ss := []senders.SenderItf {}
357
-
358
360
switch utils .Settings .Get ("settings.producer.plugins" ).(type ) {
359
361
case map [string ]interface {}:
360
362
for name := range utils .Settings .Get ("settings.producer.plugins" ).(map [string ]interface {}) {
363
+ if ! StringListContains (utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".active_env" ), env ) {
364
+ utils .Logger .Info ("sender not support current env" , zap .String ("name" , name ), zap .String ("env" , env ))
365
+ continue
366
+ }
367
+
361
368
switch utils .Settings .GetString ("settings.producer.plugins." + name + ".type" ) {
362
369
case "fluentd" :
363
- if StringListContains (utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".active_env" ), env ) {
364
- ss = append (ss , senders .NewFluentSender (& senders.FluentSenderCfg {
365
- Name : name ,
366
- Addr : utils .Settings .GetString ("settings.producer.plugins." + name + ".addr" ),
367
- BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
368
- MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
369
- RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
370
- InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
371
- NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
372
- Tags : utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" ), // do not append env
373
- IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
374
- }))
375
- }
370
+ ss = append (ss , senders .NewFluentSender (& senders.FluentSenderCfg {
371
+ Name : name ,
372
+ Addr : utils .Settings .GetString ("settings.producer.plugins." + name + ".addr" ),
373
+ BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
374
+ MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
375
+ RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
376
+ InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
377
+ NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
378
+ Tags : utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" ), // do not append env
379
+ IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
380
+ }))
376
381
case "kafka" :
377
- if StringListContains (utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".active_env" ), env ) {
378
- ss = append (ss , senders .NewKafkaSender (& senders.KafkaSenderCfg {
379
- Name : name ,
380
- Brokers : utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".brokers." + env ),
381
- Topic : utils .Settings .GetString ("settings.producer.plugins." + name + ".topic" ),
382
- TagKey : utils .Settings .GetString ("settings.producer.plugins." + name + ".tag_key" ),
383
- BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
384
- MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
385
- RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
386
- InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
387
- NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
388
- Tags : libs .LoadTagsAppendEnv (env , utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" )),
389
- IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
390
- }))
391
- }
382
+ ss = append (ss , senders .NewKafkaSender (& senders.KafkaSenderCfg {
383
+ Name : name ,
384
+ Brokers : utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".brokers." + env ),
385
+ Topic : utils .Settings .GetString ("settings.producer.plugins." + name + ".topic" ),
386
+ TagKey : utils .Settings .GetString ("settings.producer.plugins." + name + ".tag_key" ),
387
+ BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
388
+ MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
389
+ RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
390
+ InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
391
+ NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
392
+ Tags : libs .LoadTagsAppendEnv (env , utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" )),
393
+ IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
394
+ }))
392
395
case "es" :
393
- if StringListContains (utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".active_env" ), env ) {
394
- ss = append (ss , senders .NewElasticSearchSender (& senders.ElasticSearchSenderCfg {
395
- Name : name ,
396
- BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
397
- Addr : utils .Settings .GetString ("settings.producer.plugins." + name + ".addr" ),
398
- MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
399
- RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
400
- InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
401
- NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
402
- TagKey : utils .Settings .GetString ("settings.producer.plugins." + name + ".tag_key" ),
403
- Tags : libs .LoadTagsAppendEnv (env , utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" )),
404
- TagIndexMap : senders .LoadESTagIndexMap (env , utils .Settings .Get ("settings.producer.plugins." + name + ".indices" )),
405
- IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
406
- }))
407
- }
396
+ ss = append (ss , senders .NewElasticSearchSender (& senders.ElasticSearchSenderCfg {
397
+ Name : name ,
398
+ BatchSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".msg_batch_size" ),
399
+ Addr : utils .Settings .GetString ("settings.producer.plugins." + name + ".addr" ),
400
+ MaxWait : utils .Settings .GetDuration ("settings.producer.plugins." + name + ".max_wait_sec" ) * time .Second ,
401
+ RetryChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".retry_chan_len" ),
402
+ InChanSize : utils .Settings .GetInt ("settings.producer.sender_inchan_size" ),
403
+ NFork : utils .Settings .GetInt ("settings.producer.plugins." + name + ".forks" ),
404
+ TagKey : utils .Settings .GetString ("settings.producer.plugins." + name + ".tag_key" ),
405
+ Tags : libs .LoadTagsAppendEnv (env , utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" )),
406
+ TagIndexMap : senders .LoadESTagIndexMap (env , utils .Settings .Get ("settings.producer.plugins." + name + ".indices" )),
407
+ IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
408
+ }))
409
+ case "null" :
410
+ ss = append (ss , senders .NewNullSender (& senders.NullSenderCfg {
411
+ Name : name ,
412
+ Tags : libs .LoadTagsAppendEnv (env , utils .Settings .GetStringSlice ("settings.producer.plugins." + name + ".tags" )),
413
+ LogLevel : utils .Settings .GetString ("settings.producer.plugins." + name + ".log_level" ),
414
+ InChanSize : utils .Settings .GetInt ("settings.producer.plugins." + name + ".sender_inchan_size" ),
415
+ IsCommit : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_commit" ),
416
+ IsDiscardWhenBlocked : utils .Settings .GetBool ("settings.producer.plugins." + name + ".is_discard_when_blocked" ),
417
+ }))
408
418
default :
409
419
utils .Logger .Panic ("unknown sender type" ,
410
420
zap .String ("sender_type" , utils .Settings .GetString ("settings.producer.plugins." + name + ".type" )),
0 commit comments