config

package
v0.0.0-...-5733806 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 11 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 configT](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"`
	Port        int    `toml:"port"`
	DefaultLang string `toml:"default_language"`

	DBDSN string `toml:"db_dsn"`

	TestMaxMemKB int `toml:"test_max_mem_kb"`

	UpdatesWebhook string `toml:"updates_webhook"`
}

CommonConf is the data required for all services

type DonationConf

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

	PayPalButtonID string `toml:"paypal_button_id"`
}

type EmailConf

type EmailConf struct {
	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"`
	CompilePath string `toml:"compilePath"`
	// 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 configT] interface {
	Value() T
	Update(T)
	InternalName() string
	HumanName() string
}

func FlagList

func FlagList[T configT](name string) []Flag[T]

func GenFlag

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

func GetFlag

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

func GetFlags

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

type FrontendConf

type FrontendConf struct {
	PinnedProblemList int `toml:"pinned_problem_list"`

	// 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"`

	RootProblemList int `toml:"root_problem_list"`
}

Jump to

Keyboard shortcuts

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