123456789101112131415161718192021222324252627282930313233343536373839 |
- package mqtt_api
- type Options struct {
- // topic前缀
- topicPrefix string
- // 日志跳过的打印路径
- logSkipPaths []string
- // mqtt配置
- mqttOptions *MqttClientOptions
- }
- func (options Options) GetTopicPrefix() string {
- return options.topicPrefix
- }
- type Option func(options *Options)
- // WithTopicPrefix 设置topic前缀
- func WithTopicPrefix(topicPrefix string) Option {
- return func(options *Options) {
- options.topicPrefix = topicPrefix
- }
- }
- // WithLogSkipPaths 设置日志跳过的打印路径
- func WithLogSkipPaths(logSkipPaths ...string) Option {
- return func(options *Options) {
- options.logSkipPaths = logSkipPaths
- }
- }
- // WithMqttOptions 设置mqtt配置
- func WithMqttOptions(mqttOptions *MqttClientOptions) Option {
- return func(options *Options) {
- options.mqttOptions = mqttOptions
- }
- }
|