config

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Common    CommonConf
	Eval      EvalConf
	Email     EmailConf
	Frontend  FrontendConf
	Donations DonationConf
)

Functions

func GetFlagVal

func GetFlagVal[T any](name string) (T, bool)

func Load

func Load() error

func LoadConfigV2

func LoadConfigV2() error

func Save

func Save() error

func SaveConfigV2

func SaveConfigV2() error

func SetConfigPath

func SetConfigPath(path string)

func SetConfigV2Path

func SetConfigV2Path(path string)

Types

type CommonConf

type CommonConf struct {
	LogDir      string `toml:"log_dir"`
	DataDir     string `toml:"data_dir"`
	Debug       bool   `toml:"debug"`
	HostPrefix  string `toml:"host_prefix"`
	DefaultLang string `toml:"default_language"`

	DBDSN string `toml:"db_dsn"`

	TestMaxMemKB int `toml:"test_max_mem_kb"`
}

CommonConf is the data required for all services

type DonationConf

type DonationConf struct {
	BuyMeACoffeeName  string `toml:"buy_coffee_name"`
	BMACWebhookSecret string `toml:"bmac_webhook_secret"`

	PayPalButtonID string `toml:"paypal_button_id"`
}

type EmailConf

type EmailConf struct {
	Enabled bool `toml:"enabled"`

	Host     string `toml:"host"`
	Username string `toml:"username"`
	Password string `toml:"password"`
}

EmailConf is the data required for the email part

type EvalConf

type EvalConf struct {
	IsolatePath string `toml:"isolatePath"`
	// Address       string `toml:"address"`
	NumConcurrent int   `toml:"num_concurrent"`
	GlobalMaxMem  int64 `toml:"global_max_mem_kb"`

	StartingBox int `toml:"starting_box"`
}

EvalConf is the data required for the eval service

type Flag

type Flag[T any] interface {
	Value() T
	Update(T)
	InternalName() string
	HumanName() string
}

func GenFlag

func GenFlag[T any](name string, defaultVal T, readableName string) Flag[T]

func GetFlag

func GetFlag[T any](name string) (Flag[T], bool)

func GetFlags

func GetFlags[T any]() []Flag[T]

type FrontendConf

type FrontendConf struct {
	// Note that BannedHotProblems only counts for problems that are sorted
	// using the hotness filter (that is, had submissions in the last 7 days)
	// Basically, banned problems are considered to have had 0 submissions in the last 7 days
	BannedHotProblems []int `toml:"banned_hot_problems"`
}

Jump to

Keyboard shortcuts

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