config

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-2-Clause Imports: 9 Imported by: 2

Documentation

Overview

Package config sets up the configuration for the server. The configuration settings may be from the default built-in configuration, read from a file, read from an io.Reader or specifically set.

Typically the default built-in configuration is created using config.Default and then settings from a configuration file applied using config.Load, as this allows for omitted values in the configuration file to use the defaults. The configuration is not used directly, instead it should be passed to the various package level Config methods by the main function.

The default server configuration is documented in docs/configuration-file.txt

Index

Constants

View Source
const DefaultCfg = `` /* 499-byte string literal not displayed */

DefaultCfg is the default built-in server configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.0.19

type Config struct {
	Server    Server
	Quota     Quota
	Stats     Stats
	Inventory Inventory
	Login     Login
	Debug     Debug
	Greeting  string
}

Config represents the server's configuration.

func Default added in v0.0.19

func Default() Config

Default returns the default, built-in server configuration. Failure to create the default built-in configuration is fatal.

func (Config) Load added in v0.0.19

func (c Config) Load(path string) (Config, error)

Load loads the configuration specified by the passed path. The passed path may be relative or absolute, a path ending in a path separator (in which case the default file 'config.wrj' will be used) or a configuration file name (which will be prefixed with the default path e.g. '../data').

The receiver is used as a base configuration and the loaded configuration is applied over it. This allows settings omitted from the loaded configuration to use any defaults set in the base configuration. Returns the new configuration and a nil error on success. On failure returns a copy of the base configuration and a non-nil error.

func (Config) Read added in v0.0.19

func (c Config) Read(r io.Reader) (Config, error)

Read reads configuration settings from the passed io.Reader. The receiver is used as a base configuration and the read settings are applied over it. This allows settings omitted from the read configuration to use any defaults set in the base configuration. Returns the new configuration and nil error on success. On failure returns a copy of the base configuration and a non-nil error.

type Debug added in v0.0.6

type Debug struct {
	LongLog bool
	Panic   bool
	Events  bool
	Things  bool
	Quota   bool
}

type Inventory

type Inventory struct {
	CrowdSize int
}

type Login

type Login struct {
	AccountLength  int
	PasswordLength int
	SaltLength     int
	Timeout        time.Duration
}

type Quota added in v0.0.14

type Quota struct {
	Slots  int
	Window time.Duration
	Stats  int
}

type Server

type Server struct {
	Host        string
	Port        string
	IdleTimeout time.Duration
	MaxPlayers  int
	LogClient   bool
	DataPath    string // Calculated data path without trailing separator
}

type Stats

type Stats struct {
	Rate time.Duration
	GC   bool
}

Jump to

Keyboard shortcuts

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