dataRT/config/mongo.go

103 lines
1.9 KiB
Go
Raw Normal View History

2025-09-05 18:35:46 +08:00
package config
type mongoConfig struct {
2025-09-19 16:17:46 +08:00
Addrs []string `json:"addrs" yaml:"addrs"`
2025-09-05 18:35:46 +08:00
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
AuthSource string `josn:"authsource" yaml:"authsource"`
AuthMechanism string `json:"authmechanism" yaml:"authmechanism"`
}
func NewMongoConfig() *mongoConfig {
return new(mongoConfig)
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) GetAddrs() []string {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
return conf.Addrs
2025-09-05 18:35:46 +08:00
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) SetAddrs(addrs []string) *mongoConfig {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
conf.Addrs = addrs
return conf
2025-09-05 18:35:46 +08:00
}
func (conf *mongoConfig) GetUsername() string {
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
2025-09-05 18:35:46 +08:00
return conf.Username
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) SetUsername(username string) *mongoConfig {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
conf.Username = username
2025-09-19 16:17:46 +08:00
return conf
2025-09-05 18:35:46 +08:00
}
func (conf *mongoConfig) GetPassword() string {
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
2025-09-05 18:35:46 +08:00
return conf.Password
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) SetPassword(password string) *mongoConfig {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
conf.Password = password
2025-09-19 16:17:46 +08:00
return conf
2025-09-05 18:35:46 +08:00
}
func (conf *mongoConfig) GetAuthSource() string {
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
2025-09-05 18:35:46 +08:00
return conf.AuthSource
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) SetAuthSource(authSource string) *mongoConfig {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
conf.AuthSource = authSource
2025-09-19 16:17:46 +08:00
return conf
2025-09-05 18:35:46 +08:00
}
func (conf *mongoConfig) GetAuthMechanism() string {
if conf == nil {
panic("mongo config is nil")
}
2025-09-19 16:17:46 +08:00
2025-09-05 18:35:46 +08:00
return conf.AuthMechanism
}
2025-09-19 16:17:46 +08:00
func (conf *mongoConfig) SetAuthMechanism(authMechanism string) *mongoConfig {
2025-09-05 18:35:46 +08:00
if conf == nil {
panic("mongo config is nil")
}
conf.AuthMechanism = authMechanism
2025-09-19 16:17:46 +08:00
return conf
2025-09-05 18:35:46 +08:00
}
func mongoConfigName() string {
return "mongo.json"
}