dataRT/config/mongo.go

88 lines
1.8 KiB
Go
Raw Normal View History

2025-09-05 18:35:46 +08:00
package config
type mongoConfig struct {
Hosts []string `json:"hosts" yaml:"hosts"`
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)
}
func (conf *mongoConfig) GetHosts() []string {
if conf == nil {
panic("mongo config is nil")
}
return conf.Hosts
}
func (conf *mongoConfig) SetHosts(hosts []string) {
if conf == nil {
panic("mongo config is nil")
}
conf.Hosts = hosts
}
func (conf *mongoConfig) GetUsername() string {
if conf == nil {
panic("mongo config is nil")
}
return conf.Username
}
func (conf *mongoConfig) SetUsername(username string) {
if conf == nil {
panic("mongo config is nil")
}
conf.Username = username
}
func (conf *mongoConfig) GetPassword() string {
if conf == nil {
panic("mongo config is nil")
}
return conf.Password
}
func (conf *mongoConfig) SetPassword(password string) {
if conf == nil {
panic("mongo config is nil")
}
conf.Password = password
}
func (conf *mongoConfig) GetAuthSource() string {
if conf == nil {
panic("mongo config is nil")
}
return conf.AuthSource
}
func (conf *mongoConfig) SetAuthSource(authSource string) {
if conf == nil {
panic("mongo config is nil")
}
conf.AuthSource = authSource
}
func (conf *mongoConfig) GetAuthMechanism() string {
if conf == nil {
panic("mongo config is nil")
}
return conf.AuthMechanism
}
func (conf *mongoConfig) SetAuthMechanism(authMechanism string) {
if conf == nil {
panic("mongo config is nil")
}
conf.AuthMechanism = authMechanism
}
func mongoConfigName() string {
return "mongo.json"
}