-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
46 lines (40 loc) · 1.04 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package rocketmq5Kit
import (
rmq_client "github.com/apache/rocketmq-clients/golang/v5"
"github.com/apache/rocketmq-clients/golang/v5/credentials"
"github.com/richelieu42/chimera/v2/src/copyKit"
"github.com/richelieu42/chimera/v2/src/core/errorKit"
"github.com/richelieu42/chimera/v2/src/core/strKit"
)
type (
Config struct {
rmq_client.Config
TopicToVerify string
}
)
var (
defaultCredentials = &credentials.SessionCredentials{
AccessKey: "",
AccessSecret: "",
SecurityToken: "",
}
)
// processConfig Consumer和Producer通用
func processConfig(baseConfig *rmq_client.Config) (*rmq_client.Config, error) {
if baseConfig == nil {
return nil, errorKit.New("baseConfig == nil")
}
// 深拷贝(为了不修改传参baseConfig)
config, err := copyKit.DeepCopy(baseConfig)
if err != nil {
return nil, err
}
if strKit.IsEmpty(config.Endpoint) {
return nil, errorKit.New("config.Endpoint is empty")
}
config.ConsumerGroup = ""
if config.Credentials == nil {
config.Credentials = defaultCredentials
}
return config, nil
}