2022-03-21 22:27:35 +00:00
|
|
|
package internal
|
|
|
|
|
|
|
|
const (
|
|
|
|
// InvalidConfigValue is the constant value for invalid config values
|
|
|
|
// which must be changed for production configurations before successful
|
|
|
|
// startup
|
|
|
|
InvalidConfigValue = "INVALID CONFIG VALUE - PLEASE CHANGE THIS VALUE"
|
|
|
|
|
|
|
|
// DefaultDebug is the default debug mode
|
|
|
|
DefaultDebug = false
|
|
|
|
|
|
|
|
// DefaultStore is the default data store used for accounts, sessions, etc
|
2022-03-21 23:54:02 +00:00
|
|
|
DefaultStore = "bitcask://saltyim.db"
|
2022-03-21 22:27:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewConfig() *Config {
|
|
|
|
return &Config{
|
|
|
|
Debug: DefaultDebug,
|
|
|
|
Store: DefaultStore,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Option is a function that takes a config struct and modifies it
|
|
|
|
type Option func(*Config) error
|
|
|
|
|
|
|
|
// WithDebug sets the debug mode lfag
|
|
|
|
func WithDebug(debug bool) Option {
|
|
|
|
return func(cfg *Config) error {
|
|
|
|
cfg.Debug = debug
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithStore sets the store to use for accounts, sessions, etc.
|
|
|
|
func WithStore(store string) Option {
|
|
|
|
return func(cfg *Config) error {
|
|
|
|
cfg.Store = store
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|