Documentation
¶
Overview ¶
Config holds configuration information for trakx.
Index ¶
Constants ¶
View Source
const ( TrackerModeEnabled = "enabled" // http tracker enabled TrackerModeInfo = "info" // http information server, no tracker TrackerModeDisabled = "disabled" // http disabled )
View Source
const ( DebugLevel = "debug" InfoLevel = "info" WarnLevel = "warn" ErrorLevel = "error" )
View Source
const ( // FolderPerm holds the default permission mask for folders FolderPerm = 0700 // FilePerm holds the default permission mask for files FilePerm = 0644 )
Variables ¶
View Source
var ( // CachePath stores the absolute path of the cache directory CachePath string )
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { LogLevel LogLevel ExpvarInterval time.Duration Debug struct { Pprof int NofileLimit uint64 } Announce struct { Base time.Duration Fuzz time.Duration } HTTP struct { Mode string IP string Port int Timeout struct { Read time.Duration Write time.Duration } Threads int } UDP struct { Enabled bool IP string Port int Threads int ConnDB struct { Validate bool Size uint64 Trim time.Duration Expiry time.Duration } } Numwant struct { Default uint Limit uint } DB struct { Type string Backup struct { Frequency time.Duration Type string Path string } Trim time.Duration Expiry time.Duration } Path struct { Log string Pid string } // contains filtered or unexported fields }
var ( // Global instance of config and logger Config *Configuration Logger *zap.Logger )
func Load ¶
func Load() (*Configuration, error)
Load attempts to load the config from the disk or environment. The config file must be named "trakx.yaml". Load searches for the config file in ".", "~/.config/trakx" in order. Environment variables overwrite file configuration, see ./embedded/trakx.yaml for examples. This function is automatically called when the config package is imported.
func (*Configuration) Loaded ¶
func (config *Configuration) Loaded() bool
Loaded returns true if the config was successfully parsed and loaded.
func (*Configuration) Parse ¶
func (config *Configuration) Parse() error
Parse updates logger and limits based on the configuration settings.
func (*Configuration) SetLogLevel ¶
func (conf *Configuration) SetLogLevel(level LogLevel)
SetLogLevel sets the desired loglevel in the in memory configuration and logger
type EmbeddedCache ¶
func GenerateEmbeddedCache ¶
func GenerateEmbeddedCache() (EmbeddedCache, error)
Click to show internal directories.
Click to hide internal directories.