settings

package
v0.3.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Settings      = make(map[string]Setting)
	GroupSettings = make(map[model.SettingGroup][]Setting)
)
View Source
var (
	DisableCreateRoom    = NewBoolSetting("disable_create_room", false, model.SettingGroupRoom)
	RoomMustNeedPwd      = NewBoolSetting("room_must_need_pwd", false, model.SettingGroupRoom)
	CreateRoomNeedReview = NewBoolSetting("create_room_need_review", false, model.SettingGroupRoom)
	// 48 hours
	RoomTTL = NewInt64Setting("room_ttl", 48, model.SettingGroupRoom)
)
View Source
var (
	DisableUserSignup = NewBoolSetting("disable_user_signup", false, model.SettingGroupUser)
	SignupNeedReview  = NewBoolSetting("signup_need_review", false, model.SettingGroupUser)
	UserMaxRoomCount  = NewInt64Setting("user_max_room_count", 3, 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)
)
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")
	}))
)

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

func NewBoolSetting

func NewBoolSetting(k string, v bool, g model.SettingGroup, options ...BoolSettingOption) BoolSetting

type BoolSettingOption

type BoolSettingOption func(*Bool)

func WithBeforeInitBool

func WithBeforeInitBool(beforeInit func(BoolSetting, bool) (bool, error)) BoolSettingOption

func WithBeforeSetBool

func WithBeforeSetBool(beforeSet func(BoolSetting, bool) (bool, error)) BoolSettingOption

type Float64

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

func NewFloat64Setting

func NewFloat64Setting(k string, v float64, g model.SettingGroup, options ...Float64SettingOption) *Float64

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

type Float64SettingOption

type Float64SettingOption func(*Float64)

func WithBeforeInitFloat64

func WithBeforeInitFloat64(beforeInit func(Float64Setting, float64) (float64, error)) Float64SettingOption

func WithBeforeSetFloat64

func WithBeforeSetFloat64(beforeSet func(Float64Setting, float64) (float64, error)) Float64SettingOption

func WithValidatorFloat64

func WithValidatorFloat64(validator func(float64) error) Float64SettingOption

type Int64

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

func NewInt64Setting

func NewInt64Setting(k string, v int64, g model.SettingGroup, options ...Int64SettingOption) *Int64

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

type Int64SettingOption

type Int64SettingOption func(*Int64)

func WithBeforeInitInt64

func WithBeforeInitInt64(beforeInit func(Int64Setting, int64) (int64, error)) Int64SettingOption

func WithBeforeSetInt64

func WithBeforeSetInt64(beforeSet func(Int64Setting, int64) (int64, error)) 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
	String() string
	SetString(string) error
	DefaultString() string
	DefaultInterface() any
	Interface() any
}

type String

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

func NewStringSetting

func NewStringSetting(k string, v string, g model.SettingGroup, options ...StringSettingOption) *String

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

type StringSettingOption

type StringSettingOption func(*String)

func WithBeforeInitString

func WithBeforeInitString(beforeInit func(StringSetting, string) (string, error)) StringSettingOption

func WithBeforeSetString

func WithBeforeSetString(beforeSet func(StringSetting, string) (string, error)) 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