settings

package
v0.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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

func SetValue

func SetValue(name string, value any) error

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

func (*Bool) Default

func (b *Bool) Default() bool

func (*Bool) DefaultInterface

func (b *Bool) DefaultInterface() any

func (*Bool) DefaultString

func (b *Bool) DefaultString() string

func (*Bool) Get

func (b *Bool) Get() bool

func (*Bool) Group

func (d *Bool) Group() model.SettingGroup

func (*Bool) Init

func (b *Bool) Init(value string) error

func (*Bool) InitPriority added in v0.4.2

func (d *Bool) InitPriority() int

func (*Bool) Inited added in v0.7.4

func (d *Bool) Inited() bool

func (*Bool) Interface

func (b *Bool) Interface() any

func (*Bool) Name

func (d *Bool) Name() string

func (*Bool) Parse

func (b *Bool) Parse(value string) (bool, error)

func (*Bool) Set

func (b *Bool) Set(v bool) (err error)

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) SetString

func (b *Bool) SetString(value string) error

func (*Bool) String

func (b *Bool) String() string

func (*Bool) Stringify

func (b *Bool) Stringify(value bool) string

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) Default

func (f *Float64) Default() float64

func (*Float64) DefaultInterface

func (f *Float64) DefaultInterface() any

func (*Float64) DefaultString

func (f *Float64) DefaultString() string

func (*Float64) Get

func (f *Float64) Get() float64

func (*Float64) Group

func (d *Float64) Group() model.SettingGroup

func (*Float64) Init

func (f *Float64) Init(value string) error

func (*Float64) InitPriority added in v0.4.2

func (d *Float64) InitPriority() int

func (*Float64) Inited added in v0.7.4

func (d *Float64) Inited() bool

func (*Float64) Interface

func (f *Float64) Interface() any

func (*Float64) Name

func (d *Float64) Name() string

func (*Float64) Parse

func (f *Float64) Parse(value string) (float64, error)

func (*Float64) Set

func (f *Float64) Set(v float64) (err error)

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) SetString

func (f *Float64) SetString(value string) error

func (*Float64) String

func (f *Float64) String() string

func (*Float64) Stringify

func (f *Float64) Stringify(value float64) string

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) Default

func (i *Int64) Default() int64

func (*Int64) DefaultInterface

func (i *Int64) DefaultInterface() any

func (*Int64) DefaultString

func (i *Int64) DefaultString() string

func (*Int64) Get

func (i *Int64) Get() int64

func (*Int64) Group

func (d *Int64) Group() model.SettingGroup

func (*Int64) Init

func (i *Int64) Init(value string) error

func (*Int64) InitPriority added in v0.4.2

func (d *Int64) InitPriority() int

func (*Int64) Inited added in v0.7.4

func (d *Int64) Inited() bool

func (*Int64) Interface

func (i *Int64) Interface() any

func (*Int64) Name

func (d *Int64) Name() string

func (*Int64) Parse

func (i *Int64) Parse(value string) (int64, error)

func (*Int64) Set

func (i *Int64) Set(v int64) (err error)

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) SetString

func (i *Int64) SetString(value string) error

func (*Int64) String

func (i *Int64) String() string

func (*Int64) Stringify

func (i *Int64) Stringify(value int64) string

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

func PopNeedInit() (Setting, bool)

type String

type String struct {
	// contains filtered or unexported fields
}

func (*String) Default

func (s *String) Default() string

func (*String) DefaultInterface

func (s *String) DefaultInterface() any

func (*String) DefaultString

func (s *String) DefaultString() string

func (*String) Get

func (s *String) Get() string

func (*String) Group

func (d *String) Group() model.SettingGroup

func (*String) Init

func (s *String) Init(value string) error

func (*String) InitPriority added in v0.4.2

func (d *String) InitPriority() int

func (*String) Inited added in v0.7.4

func (d *String) Inited() bool

func (*String) Interface

func (s *String) Interface() any

func (*String) Name

func (d *String) Name() string

func (*String) Parse

func (s *String) Parse(value string) (string, error)

func (*String) Set

func (s *String) Set(v string) (err error)

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) SetString

func (s *String) SetString(value string) error

func (*String) String

func (s *String) String() string

func (*String) Stringify

func (s *String) Stringify(value string) string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL