103 lines
1.9 KiB
Go
103 lines
1.9 KiB
Go
package config
|
|
|
|
type mongoConfig struct {
|
|
Addrs []string `json:"addrs" yaml:"addrs"`
|
|
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) GetAddrs() []string {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
|
|
return conf.Addrs
|
|
}
|
|
|
|
func (conf *mongoConfig) SetAddrs(addrs []string) *mongoConfig {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
conf.Addrs = addrs
|
|
|
|
return conf
|
|
}
|
|
|
|
func (conf *mongoConfig) GetUsername() string {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
|
|
return conf.Username
|
|
}
|
|
|
|
func (conf *mongoConfig) SetUsername(username string) *mongoConfig {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
conf.Username = username
|
|
|
|
return conf
|
|
}
|
|
|
|
func (conf *mongoConfig) GetPassword() string {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
|
|
return conf.Password
|
|
}
|
|
|
|
func (conf *mongoConfig) SetPassword(password string) *mongoConfig {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
conf.Password = password
|
|
|
|
return conf
|
|
}
|
|
|
|
func (conf *mongoConfig) GetAuthSource() string {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
|
|
return conf.AuthSource
|
|
}
|
|
|
|
func (conf *mongoConfig) SetAuthSource(authSource string) *mongoConfig {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
conf.AuthSource = authSource
|
|
|
|
return conf
|
|
}
|
|
|
|
func (conf *mongoConfig) GetAuthMechanism() string {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
|
|
return conf.AuthMechanism
|
|
}
|
|
|
|
func (conf *mongoConfig) SetAuthMechanism(authMechanism string) *mongoConfig {
|
|
if conf == nil {
|
|
panic("mongo config is nil")
|
|
}
|
|
conf.AuthMechanism = authMechanism
|
|
|
|
return conf
|
|
}
|
|
|
|
func mongoConfigName() string {
|
|
return "mongo.json"
|
|
}
|