Documentation ¶
Index ¶
- Variables
- func SetValue(name string, value any) error
- type Bool
- func (b *Bool) Default() bool
- func (b *Bool) DefaultInterface() any
- func (b *Bool) DefaultString() string
- func (b *Bool) Get() bool
- func (d *Bool) Group() model.SettingGroup
- func (b *Bool) Init(value string) error
- func (d *Bool) InitPriority() int
- func (d *Bool) Inited() bool
- func (b *Bool) Interface() any
- func (d *Bool) Name() string
- func (b *Bool) Parse(value string) (bool, error)
- func (b *Bool) Set(v bool) (err error)
- func (b *Bool) SetAfterInit(afterInit func(BoolSetting, bool))
- func (b *Bool) SetAfterSet(afterSet func(BoolSetting, bool))
- func (b *Bool) SetBeforeInit(beforeInit func(BoolSetting, bool) (bool, error))
- func (b *Bool) SetBeforeSet(beforeSet func(BoolSetting, bool) (bool, error))
- func (d *Bool) SetInitPriority(priority int)
- func (b *Bool) SetString(value string) error
- func (b *Bool) String() string
- func (b *Bool) Stringify(value bool) string
- func (d *Bool) Type() model.SettingType
- type BoolSetting
- func CoverBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
- func LoadBoolSetting(k string) (BoolSetting, bool)
- func LoadOrNewBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
- func NewBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
- type BoolSettingOption
- func WithAfterInitBool(afterInit func(BoolSetting, bool)) BoolSettingOption
- func WithAfterSetBool(afterSet func(BoolSetting, bool)) BoolSettingOption
- func WithBeforeInitBool(beforeInit func(BoolSetting, bool) (bool, error)) BoolSettingOption
- func WithBeforeSetBool(beforeSet func(BoolSetting, bool) (bool, error)) BoolSettingOption
- func WithInitPriorityBool(priority int) BoolSettingOption
- type Float64
- func (f *Float64) Default() float64
- func (f *Float64) DefaultInterface() any
- func (f *Float64) DefaultString() string
- func (f *Float64) Get() float64
- func (d *Float64) Group() model.SettingGroup
- func (f *Float64) Init(value string) error
- func (d *Float64) InitPriority() int
- func (d *Float64) Inited() bool
- func (f *Float64) Interface() any
- func (d *Float64) Name() string
- func (f *Float64) Parse(value string) (float64, error)
- func (f *Float64) Set(v float64) (err error)
- func (f *Float64) SetAfterInit(afterInit func(Float64Setting, float64))
- func (f *Float64) SetAfterSet(afterSet func(Float64Setting, float64))
- func (f *Float64) SetBeforeInit(beforeInit func(Float64Setting, float64) (float64, error))
- func (f *Float64) SetBeforeSet(beforeSet func(Float64Setting, float64) (float64, error))
- func (d *Float64) SetInitPriority(priority int)
- func (f *Float64) SetString(value string) error
- func (f *Float64) String() string
- func (f *Float64) Stringify(value float64) string
- func (d *Float64) Type() model.SettingType
- type Float64Setting
- func CoverFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
- func LoadFloat64Setting(k string) (Float64Setting, bool)
- func LoadOrNewFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
- func NewFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
- type Float64SettingOption
- func WithAfterInitFloat64(afterInit func(Float64Setting, float64)) Float64SettingOption
- func WithAfterSetFloat64(afterSet func(Float64Setting, float64)) Float64SettingOption
- func WithBeforeInitFloat64(beforeInit func(Float64Setting, float64) (float64, error)) Float64SettingOption
- func WithBeforeSetFloat64(beforeSet func(Float64Setting, float64) (float64, error)) Float64SettingOption
- func WithInitPriorityFloat64(priority int) Float64SettingOption
- func WithValidatorFloat64(validator func(float64) error) Float64SettingOption
- type Int64
- func (i *Int64) Default() int64
- func (i *Int64) DefaultInterface() any
- func (i *Int64) DefaultString() string
- func (i *Int64) Get() int64
- func (d *Int64) Group() model.SettingGroup
- func (i *Int64) Init(value string) error
- func (d *Int64) InitPriority() int
- func (d *Int64) Inited() bool
- func (i *Int64) Interface() any
- func (d *Int64) Name() string
- func (i *Int64) Parse(value string) (int64, error)
- func (i *Int64) Set(v int64) (err error)
- func (i *Int64) SetAfterInit(afterInit func(Int64Setting, int64))
- func (i *Int64) SetAfterSet(afterSet func(Int64Setting, int64))
- func (i *Int64) SetBeforeInit(beforeInit func(Int64Setting, int64) (int64, error))
- func (i *Int64) SetBeforeSet(beforeSet func(Int64Setting, int64) (int64, error))
- func (d *Int64) SetInitPriority(priority int)
- func (i *Int64) SetString(value string) error
- func (i *Int64) String() string
- func (i *Int64) Stringify(value int64) string
- func (d *Int64) Type() model.SettingType
- type Int64Setting
- func CoverInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
- func LoadInt64Setting(k string) (Int64Setting, bool)
- func LoadOrNewInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
- func NewInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
- type Int64SettingOption
- func WithAfterInitInt64(afterInit func(Int64Setting, int64)) Int64SettingOption
- func WithAfterSetInt64(afterSet func(Int64Setting, int64)) Int64SettingOption
- func WithBeforeInitInt64(beforeInit func(Int64Setting, int64) (int64, error)) Int64SettingOption
- func WithBeforeSetInt64(beforeSet func(Int64Setting, int64) (int64, error)) Int64SettingOption
- func WithInitPriorityInt64(priority int) Int64SettingOption
- func WithValidatorInt64(validator func(int64) error) Int64SettingOption
- type Setting
- type String
- func (s *String) Default() string
- func (s *String) DefaultInterface() any
- func (s *String) DefaultString() string
- func (s *String) Get() string
- func (d *String) Group() model.SettingGroup
- func (s *String) Init(value string) error
- func (d *String) InitPriority() int
- func (d *String) Inited() bool
- func (s *String) Interface() any
- func (d *String) Name() string
- func (s *String) Parse(value string) (string, error)
- func (s *String) Set(v string) (err error)
- func (s *String) SetAfterInit(afterInit func(StringSetting, string))
- func (s *String) SetAfterSet(afterSet func(StringSetting, string))
- func (s *String) SetBeforeInit(beforeInit func(StringSetting, string) (string, error))
- func (s *String) SetBeforeSet(beforeSet func(StringSetting, string) (string, error))
- func (d *String) SetInitPriority(priority int)
- func (s *String) SetString(value string) error
- func (s *String) String() string
- func (s *String) Stringify(value string) string
- func (d *String) Type() model.SettingType
- type StringSetting
- func CoverStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
- func LoadOrNewStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
- func LoadStringSetting(k string) (StringSetting, bool)
- func NewStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
- type StringSettingOption
- func WithAfterInitString(afterInit func(StringSetting, string)) StringSettingOption
- func WithAfterSetString(afterSet func(StringSetting, string)) StringSettingOption
- func WithBeforeInitString(beforeInit func(StringSetting, string) (string, error)) StringSettingOption
- func WithBeforeSetString(beforeSet func(StringSetting, string) (string, error)) StringSettingOption
- func WithInitPriorityString(priority int) StringSettingOption
- func WithValidatorString(validator func(string) error) StringSettingOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Settings = make(map[string]Setting) GroupSettings = make(map[model.SettingGroup]map[string]Setting) )
View Source
var ( DisableCreateRoom = NewBoolSetting("disable_create_room", false, model.SettingGroupRoom) RoomMustNeedPwd BoolSetting RoomMustNoNeedPwd BoolSetting CreateRoomNeedReview = NewBoolSetting("create_room_need_review", false, model.SettingGroupRoom) // default 48 hours RoomTTL = NewInt64Setting("room_ttl", 48, model.SettingGroupRoom, WithBeforeSetInt64(func(is Int64Setting, i int64) (int64, error) { if i < 1 { return 0, errors.New("room ttl must be greater than 0") } return i, nil })) )
View Source
var ( DisableUserSignup = NewBoolSetting("disable_user_signup", false, model.SettingGroupUser) SignupNeedReview = NewBoolSetting("signup_need_review", false, model.SettingGroupUser) EnablePasswordSignup = NewBoolSetting("enable_password_signup", false, model.SettingGroupUser) PasswordSignupNeedReview = NewBoolSetting("password_signup_need_review", false, model.SettingGroupUser) UserMaxRoomCount = NewInt64Setting("user_max_room_count", 3, model.SettingGroupUser) EnableGuest = NewBoolSetting("enable_guest", true, model.SettingGroupUser) )
View Source
var ( MovieProxy = NewBoolSetting("movie_proxy", true, model.SettingGroupProxy) LiveProxy = NewBoolSetting("live_proxy", true, model.SettingGroupProxy) AllowProxyToLocal = NewBoolSetting("allow_proxy_to_local", false, model.SettingGroupProxy) ProxyCacheEnable = NewBoolSetting("proxy_cache_enable", false, model.SettingGroupProxy) )
View Source
var ( // can watch live streams through the RTMP protocol (without authentication, insecure). RtmpPlayer = NewBoolSetting("rtmp_player", false, model.SettingGroupRtmp) // default use http header host CustomPublishHost = NewStringSetting("custom_publish_host", "", model.SettingGroupRtmp) // disguise the .ts file as a .png file TsDisguisedAsPng = NewBoolSetting("ts_disguised_as_png", true, model.SettingGroupRtmp) )
View Source
var DatabaseVersion = NewStringSetting("database_version", db.CurrentVersion, model.SettingGroupDatabase, WithBeforeSetString(func(ss StringSetting, s string) (string, error) { return "", errors.New("not support change database version") }))
View Source
var ErrSettingAlreadyInited = errors.New("setting already inited")
Functions ¶
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
func (*Bool) DefaultInterface ¶
func (*Bool) DefaultString ¶
func (*Bool) Group ¶
func (d *Bool) Group() model.SettingGroup
func (*Bool) InitPriority ¶ added in v0.4.2
func (d *Bool) InitPriority() int
func (*Bool) SetAfterInit ¶ added in v0.4.5
func (b *Bool) SetAfterInit(afterInit func(BoolSetting, bool))
func (*Bool) SetAfterSet ¶ added in v0.4.5
func (b *Bool) SetAfterSet(afterSet func(BoolSetting, bool))
func (*Bool) SetBeforeInit ¶ added in v0.4.2
func (b *Bool) SetBeforeInit(beforeInit func(BoolSetting, bool) (bool, error))
func (*Bool) SetBeforeSet ¶ added in v0.4.2
func (b *Bool) SetBeforeSet(beforeSet func(BoolSetting, bool) (bool, error))
func (*Bool) SetInitPriority ¶ added in v0.4.2
func (d *Bool) SetInitPriority(priority int)
func (*Bool) Type ¶
func (d *Bool) Type() model.SettingType
type BoolSetting ¶
type BoolSetting interface { Setting Set(bool) error Get() bool Default() bool Parse(string) (bool, error) Stringify(bool) string SetBeforeInit(func(BoolSetting, bool) (bool, error)) SetBeforeSet(func(BoolSetting, bool) (bool, error)) }
func CoverBoolSetting ¶ added in v0.4.2
func CoverBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
func LoadBoolSetting ¶ added in v0.4.2
func LoadBoolSetting(k string) (BoolSetting, bool)
func LoadOrNewBoolSetting ¶ added in v0.4.2
func LoadOrNewBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
func NewBoolSetting ¶
func NewBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting
type BoolSettingOption ¶
type BoolSettingOption func(*Bool)
func WithAfterInitBool ¶ added in v0.4.5
func WithAfterInitBool(afterInit func(BoolSetting, bool)) BoolSettingOption
func WithAfterSetBool ¶ added in v0.4.5
func WithAfterSetBool(afterSet func(BoolSetting, bool)) BoolSettingOption
func WithBeforeInitBool ¶
func WithBeforeInitBool(beforeInit func(BoolSetting, bool) (bool, error)) BoolSettingOption
func WithBeforeSetBool ¶
func WithBeforeSetBool(beforeSet func(BoolSetting, bool) (bool, error)) BoolSettingOption
func WithInitPriorityBool ¶ added in v0.4.2
func WithInitPriorityBool(priority int) BoolSettingOption
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
func (*Float64) DefaultInterface ¶
func (*Float64) DefaultString ¶
func (*Float64) Group ¶
func (d *Float64) Group() model.SettingGroup
func (*Float64) InitPriority ¶ added in v0.4.2
func (d *Float64) InitPriority() int
func (*Float64) SetAfterInit ¶ added in v0.4.5
func (f *Float64) SetAfterInit(afterInit func(Float64Setting, float64))
func (*Float64) SetAfterSet ¶ added in v0.4.5
func (f *Float64) SetAfterSet(afterSet func(Float64Setting, float64))
func (*Float64) SetBeforeInit ¶ added in v0.4.2
func (f *Float64) SetBeforeInit(beforeInit func(Float64Setting, float64) (float64, error))
func (*Float64) SetBeforeSet ¶ added in v0.4.2
func (f *Float64) SetBeforeSet(beforeSet func(Float64Setting, float64) (float64, error))
func (*Float64) SetInitPriority ¶ added in v0.4.2
func (d *Float64) SetInitPriority(priority int)
func (*Float64) Type ¶
func (d *Float64) Type() model.SettingType
type Float64Setting ¶
type Float64Setting interface { Setting Set(float64) error Get() float64 Default() float64 Parse(string) (float64, error) Stringify(float64) string SetBeforeInit(func(Float64Setting, float64) (float64, error)) SetBeforeSet(func(Float64Setting, float64) (float64, error)) }
func CoverFloat64Setting ¶ added in v0.4.2
func CoverFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
func LoadFloat64Setting ¶ added in v0.4.2
func LoadFloat64Setting(k string) (Float64Setting, bool)
func LoadOrNewFloat64Setting ¶ added in v0.4.2
func LoadOrNewFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
func NewFloat64Setting ¶
func NewFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) Float64Setting
type Float64SettingOption ¶
type Float64SettingOption func(*Float64)
func WithAfterInitFloat64 ¶ added in v0.4.5
func WithAfterInitFloat64(afterInit func(Float64Setting, float64)) Float64SettingOption
func WithAfterSetFloat64 ¶ added in v0.4.5
func WithAfterSetFloat64(afterSet func(Float64Setting, float64)) Float64SettingOption
func WithBeforeInitFloat64 ¶
func WithBeforeInitFloat64(beforeInit func(Float64Setting, float64) (float64, error)) Float64SettingOption
func WithBeforeSetFloat64 ¶
func WithBeforeSetFloat64(beforeSet func(Float64Setting, float64) (float64, error)) Float64SettingOption
func WithInitPriorityFloat64 ¶ added in v0.4.2
func WithInitPriorityFloat64(priority int) Float64SettingOption
func WithValidatorFloat64 ¶
func WithValidatorFloat64(validator func(float64) error) Float64SettingOption
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
func (*Int64) DefaultInterface ¶
func (*Int64) DefaultString ¶
func (*Int64) Group ¶
func (d *Int64) Group() model.SettingGroup
func (*Int64) InitPriority ¶ added in v0.4.2
func (d *Int64) InitPriority() int
func (*Int64) SetAfterInit ¶ added in v0.4.5
func (i *Int64) SetAfterInit(afterInit func(Int64Setting, int64))
func (*Int64) SetAfterSet ¶ added in v0.4.5
func (i *Int64) SetAfterSet(afterSet func(Int64Setting, int64))
func (*Int64) SetBeforeInit ¶ added in v0.4.2
func (i *Int64) SetBeforeInit(beforeInit func(Int64Setting, int64) (int64, error))
func (*Int64) SetBeforeSet ¶ added in v0.4.2
func (i *Int64) SetBeforeSet(beforeSet func(Int64Setting, int64) (int64, error))
func (*Int64) SetInitPriority ¶ added in v0.4.2
func (d *Int64) SetInitPriority(priority int)
func (*Int64) Type ¶
func (d *Int64) Type() model.SettingType
type Int64Setting ¶
type Int64Setting interface { Setting Set(int64) error Get() int64 Default() int64 Parse(string) (int64, error) Stringify(int64) string SetBeforeInit(func(Int64Setting, int64) (int64, error)) SetBeforeSet(func(Int64Setting, int64) (int64, error)) }
func CoverInt64Setting ¶ added in v0.4.2
func CoverInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
func LoadInt64Setting ¶ added in v0.4.2
func LoadInt64Setting(k string) (Int64Setting, bool)
func LoadOrNewInt64Setting ¶ added in v0.4.2
func LoadOrNewInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
func NewInt64Setting ¶
func NewInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) Int64Setting
type Int64SettingOption ¶
type Int64SettingOption func(*Int64)
func WithAfterInitInt64 ¶ added in v0.4.5
func WithAfterInitInt64(afterInit func(Int64Setting, int64)) Int64SettingOption
func WithAfterSetInt64 ¶ added in v0.4.5
func WithAfterSetInt64(afterSet func(Int64Setting, int64)) Int64SettingOption
func WithBeforeInitInt64 ¶
func WithBeforeInitInt64(beforeInit func(Int64Setting, int64) (int64, error)) Int64SettingOption
func WithBeforeSetInt64 ¶
func WithBeforeSetInt64(beforeSet func(Int64Setting, int64) (int64, error)) Int64SettingOption
func WithInitPriorityInt64 ¶ added in v0.4.2
func WithInitPriorityInt64(priority int) Int64SettingOption
func WithValidatorInt64 ¶
func WithValidatorInt64(validator func(int64) error) Int64SettingOption
type Setting ¶
type Setting interface { Name() string Type() model.SettingType Group() model.SettingGroup Init(string) error Inited() bool SetInitPriority(int) InitPriority() int String() string SetString(string) error DefaultString() string DefaultInterface() any Interface() any }
func PopNeedInit ¶ added in v0.7.4
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (*String) DefaultInterface ¶
func (*String) DefaultString ¶
func (*String) Group ¶
func (d *String) Group() model.SettingGroup
func (*String) InitPriority ¶ added in v0.4.2
func (d *String) InitPriority() int
func (*String) SetAfterInit ¶ added in v0.4.5
func (s *String) SetAfterInit(afterInit func(StringSetting, string))
func (*String) SetAfterSet ¶ added in v0.4.5
func (s *String) SetAfterSet(afterSet func(StringSetting, string))
func (*String) SetBeforeInit ¶ added in v0.4.2
func (s *String) SetBeforeInit(beforeInit func(StringSetting, string) (string, error))
func (*String) SetBeforeSet ¶ added in v0.4.2
func (s *String) SetBeforeSet(beforeSet func(StringSetting, string) (string, error))
func (*String) SetInitPriority ¶ added in v0.4.2
func (d *String) SetInitPriority(priority int)
func (*String) Type ¶
func (d *String) Type() model.SettingType
type StringSetting ¶
type StringSetting interface { Setting Set(string) error Get() string Default() string Parse(string) (string, error) Stringify(string) string SetBeforeInit(func(StringSetting, string) (string, error)) SetBeforeSet(func(StringSetting, string) (string, error)) }
func CoverStringSetting ¶ added in v0.4.2
func CoverStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
func LoadOrNewStringSetting ¶ added in v0.4.2
func LoadOrNewStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
func LoadStringSetting ¶ added in v0.4.2
func LoadStringSetting(k string) (StringSetting, bool)
func NewStringSetting ¶
func NewStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) StringSetting
type StringSettingOption ¶
type StringSettingOption func(*String)
func WithAfterInitString ¶ added in v0.4.5
func WithAfterInitString(afterInit func(StringSetting, string)) StringSettingOption
func WithAfterSetString ¶ added in v0.4.5
func WithAfterSetString(afterSet func(StringSetting, string)) StringSettingOption
func WithBeforeInitString ¶
func WithBeforeInitString(beforeInit func(StringSetting, string) (string, error)) StringSettingOption
func WithBeforeSetString ¶
func WithBeforeSetString(beforeSet func(StringSetting, string) (string, error)) StringSettingOption
func WithInitPriorityString ¶ added in v0.4.2
func WithInitPriorityString(priority int) StringSettingOption
func WithValidatorString ¶
func WithValidatorString(validator func(string) error) StringSettingOption
Click to show internal directories.
Click to hide internal directories.