Skip to content

Commit

Permalink
refactor: mq add raw config (#636)
Browse files Browse the repository at this point in the history
Co-authored-by: hjxp <[email protected]>
  • Loading branch information
hjxp and hjxp authored Dec 27, 2022
1 parent cb16659 commit a684aa4
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/client/rocketmq/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,42 @@ func RawConfig(key string) *Config {
}
return config
}

// RawPushConsumerConfig 返push consume回配置
func RawPushConsumerConfig(key string) *PushConsumerConfig {
var pushConsumerConfig = DefaultConfig().PushConsumer
if err := conf.UnmarshalKey(key, &pushConsumerConfig, conf.TagName("toml")); err != nil {
xlog.Jupiter().Panic("unmarshal config", xlog.FieldErr(err), xlog.String("key", key), xlog.Any("config", pushConsumerConfig))
}

if xdebug.IsDevelopmentMode() {
xdebug.PrettyJsonPrint(key, pushConsumerConfig)
}
return pushConsumerConfig
}

// RawPullConsumerConfig 返回pull consume配置
func RawPullConsumerConfig(key string) *PullConsumerConfig {
var pullConsumerConfig = DefaultConfig().PullConsumer
if err := conf.UnmarshalKey(key, &pullConsumerConfig, conf.TagName("toml")); err != nil {
xlog.Jupiter().Panic("unmarshal config", xlog.FieldErr(err), xlog.String("key", key), xlog.Any("config", pullConsumerConfig))
}

if xdebug.IsDevelopmentMode() {
xdebug.PrettyJsonPrint(key, pullConsumerConfig)
}
return pullConsumerConfig
}

// RawProducerConfig 返回produce配置
func RawProducerConfig(key string) *ProducerConfig {
var producerConfig = DefaultConfig().Producer
if err := conf.UnmarshalKey(key, &producerConfig, conf.TagName("toml")); err != nil {
xlog.Jupiter().Panic("unmarshal config", xlog.FieldErr(err), xlog.String("key", key), xlog.Any("config", producerConfig))
}

if xdebug.IsDevelopmentMode() {
xdebug.PrettyJsonPrint(key, producerConfig)
}
return producerConfig
}

0 comments on commit a684aa4

Please sign in to comment.