config

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{
	Port: 8080,
	LobbySettingDefaults: LobbySettingDefaults{
		Public:             "false",
		DrawingTime:        "120",
		Rounds:             "4",
		MaxPlayers:         "12",
		CustomWordsPerTurn: "3",
		ClientsPerIPLimit:  "1",
		Language:           "english",
	},
	CORS: CORS{
		AllowedOrigins:   []string{"*"},
		AllowCredentials: false,
	},
	LobbyCleanup: LobbyCleanup{
		Interval:                  90 * time.Second,
		PlayerInactivityThreshold: 75 * time.Second,
	},
}

Functions

This section is empty.

Types

type CORS added in v0.8.3

type CORS struct {
	AllowedOrigins   []string `env:"ALLOWED_ORIGINS"`
	AllowCredentials bool     `env:"ALLOW_CREDENTIALS"`
}

type Config

type Config struct {
	// NetworkAddress is empty by default, since that implies listening on
	// all interfaces. For development usecases, on windows for example, this
	// is very annoying, as windows will nag you with firewall prompts.
	NetworkAddress string `env:"NETWORK_ADDRESS"`
	// RootPath is the path directly after the domain and before the
	// scribblers paths. For example if you host scribblers on painting.com
	// but already host a different website on that domain, then your API paths
	// might have to look like this: painting.com/scribblers/v1
	RootPath       string `env:"ROOT_PATH"`
	CPUProfilePath string `env:"CPU_PROFILE_PATH"`
	// LobbySettingDefaults is used for the server side rendering of the lobby
	// creation page. It doesn't affect the default values of lobbies created
	// via the API.
	LobbySettingDefaults LobbySettingDefaults `envPrefix:"LOBBY_SETTING_DEFAULTS_"`
	Port                 uint16               `env:"PORT"`
	CORS                 CORS                 `envPrefix:"CORS_"`
	LobbyCleanup         LobbyCleanup         `envPrefix:"LOBBY_CLEANUP_"`
}

func Load

func Load() (*Config, error)

Load loads the configuration from the environment. If a .env file is available, it will be loaded as well. Values found in the environment will overwrite whatever is load from the .env file.

type LobbyCleanup added in v0.8.3

type LobbyCleanup struct {
	// Interval is the interval in which the cleanup routine will run. If set
	// to `0`, the cleanup routine will be disabled.
	Interval time.Duration `env:"INTERVAL"`
	// PlayerInactivityThreshold is the time after which a player counts as
	// inactivity and won't keep the lobby up. Note that cleaning up a lobby can
	// therefore take up to Interval + PlayerInactivityThreshold.
	PlayerInactivityThreshold time.Duration `env:"PLAYER_INACTIVITY_THRESHOLD"`
}

type LobbySettingDefaults added in v0.8.3

type LobbySettingDefaults struct {
	Public             string `env:"PUBLIC"`
	DrawingTime        string `env:"DRAWING_TIME"`
	Rounds             string `env:"ROUNDS"`
	MaxPlayers         string `env:"MAX_PLAYERS"`
	CustomWords        string `env:"CUSTOM_WORDS"`
	CustomWordsPerTurn string `env:"CUSTOM_WORDS_PER_TURN"`
	ClientsPerIPLimit  string `env:"CLIENTS_PER_IP_LIMIT"`
	Language           string `env:"LANGUAGE"`
}

Jump to

Keyboard shortcuts

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