config

package
v0.0.0-...-ca8de47 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConnectionRetryMaxInterval indicates the maximum interval to retry icecast
	// connections
	ConnectionRetryMaxInterval = time.Second * 2
	// ConnectionRetryMaxElapsedTime indicates how long to try retry before
	// erroring out completely. Set to 0 means it never errors out
	ConnectionRetryMaxElapsedTime = time.Second * 0
)

Variables

This section is empty.

Functions

func NewRand

func NewRand(lock bool) *rand.Rand

NewRand returns a fresh *rand.Rand seeded with either a crypto random seed or the current time if that fails to succeed

func Value

func Value[T any](cfg Config, fn func(Config) T) func() T

func Values

func Values[T1, T2 any](cfg Config, fn func(Config) (T1, T2)) func() (T1, T2)

Types

type AddrPort

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

func MustParseAddrPort

func MustParseAddrPort(s string) AddrPort

func ParseAddrPort

func ParseAddrPort(s string) (AddrPort, error)

func (AddrPort) Addr

func (ap AddrPort) Addr() netip.Addr

func (AddrPort) MarshalText

func (ap AddrPort) MarshalText() ([]byte, error)

func (AddrPort) Port

func (ap AddrPort) Port() uint16

func (AddrPort) String

func (ap AddrPort) String() string

func (*AddrPort) UnmarshalText

func (ap *AddrPort) UnmarshalText(text []byte) error

type BackOff

type BackOff interface {
	backoff.BackOffContext
	GetElapsedTime() time.Duration
}

func NewConnectionBackoff

func NewConnectionBackoff(ctx context.Context) BackOff

NewConnectionBackoff returns a new backoff set to the intended configuration for connection retrying

type Config

type Config struct {

	// RPC helpers, call these to get an RPC interface to
	// the named component
	Streamer radio.StreamerService
	Manager  radio.ManagerService
	Tracker  radio.ListenerTrackerService
	Queue    radio.QueueService
	IRC      radio.AnnounceService
	// contains filtered or unexported fields
}

Config is a type-safe wrapper around the config type

func Load

func Load(r io.Reader) (Config, error)

Load loads a configuration file from the reader given, it expects TOML as input

func LoadFile

func LoadFile(filenames ...string) (Config, error)

LoadFile loads a configuration file from the filename given

func TestConfig

func TestConfig() Config

TestConfig returns default config with RPC services disabled

func (Config) Conf

func (c Config) Conf() config

Conf returns the configuration stored inside

NOTE: Conf returns a shallow-copy of the config value stored inside; so do not edit

any slices or maps that might be inside

func (Config) LoadAndUpdate

func (c Config) LoadAndUpdate(filenames ...string) error

func (*Config) OnReload

func (c *Config) OnReload(cb func())

func (Config) Save

func (c Config) Save(w io.Writer) error

Save writes the configuration to w in TOML format

func (Config) StoreConf

func (c Config) StoreConf(new config)

StoreConf stores the configuration passed

func (Config) TriggerReload

func (c Config) TriggerReload()

type Duration

type Duration time.Duration

Duration is a time.Duration that supports Text(Un)Marshaler

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type Loader

type Loader func() (Config, error)

Loader is a typed function that returns a Config, used to pass in a pre-set Load or LoadFile call from a closure

type URL

type URL string

func (URL) MarshalText

func (u URL) MarshalText() ([]byte, error)

func (URL) URL

func (u URL) URL() *url.URL

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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