configs

package
v0.0.0-...-654e1bf Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WireSet = wire.NewSet(
	NewConfig,
	wire.FieldsOf(new(Config), "Auth"),
	wire.FieldsOf(new(Config), "Database"),
	wire.FieldsOf(new(Config), "Log"),
	wire.FieldsOf(new(Config), "Cache"),
	wire.FieldsOf(new(Config), "HTTP"),
	wire.FieldsOf(new(Config), "GRPC"),
	wire.FieldsOf(new(Config), "MQ"),
	wire.FieldsOf(new(Config), "Judge"),
	wire.FieldsOf(new(Config), "Cron"),
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Name     string `yaml:"name"`
	Password string `yaml:"password"`
}

type Auth

type Auth struct {
	Hash  Hash  `yaml:"hash"`
	Token Token `yaml:"token"`
}

type Cache

type Cache struct {
	Type     CacheType `yaml:"type"`
	Addr     string    `yaml:"addr"`
	Username string    `yaml:"username"`
	Password string    `yaml:"password"`
	DB       int       `yaml:"db"`
}

type CacheType

type CacheType string
const (
	CacheTypeInMemory CacheType = "in_memory"
	CacheTypeRedis    CacheType = "redis"
)

type Compile

type Compile struct {
	Image           string   `yaml:"image"`
	Timeout         string   `yaml:"timeout"`
	Memory          string   `yaml:"memory"`
	CPUs            float32  `yaml:"cpus"`
	CommandTemplate []string `yaml:"command_template"`
	SourceFileName  string   `yaml:"source_file_name"`
	ProgramFileName string   `yaml:"program_file_name"`
}

func (*Compile) GetMemoryInBytes

func (c *Compile) GetMemoryInBytes() (uint64, error)

func (*Compile) GetTimeoutInTimeDuration

func (c *Compile) GetTimeoutInTimeDuration() (time.Duration, error)

type Config

type Config struct {
	Auth     Auth     `yaml:"auth"`
	Database Database `yaml:"database"`
	Log      Log      `yaml:"log"`
	Cache    Cache    `yaml:"cache"`
	HTTP     HTTP     `yaml:"http"`
	GRPC     GRPC     `yaml:"grpc"`
	MQ       MQ       `yaml:"mq"`
	Judge    Judge    `yaml:"judge"`
	Cron     Cron     `yaml:"cron"`
}

func NewConfig

func NewConfig(configFilePath ConfigFilePath) (Config, error)

type ConfigFilePath

type ConfigFilePath string

type CreateSystemAccounts

type CreateSystemAccounts struct {
	Schedule string  `yaml:"schedule"`
	Admin    Account `yaml:"admin"`
	Worker   Account `yaml:"worker"`
}

type Cron

type Cron struct {
	CreateSystemAccounts CreateSystemAccounts `yaml:"create_system_accounts"`
}

type Database

type Database struct {
	Type     string `yaml:"type"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
}

type Execute

type Execute struct {
	Image           string   `yaml:"image"`
	CPUs            float32  `yaml:"cpus"`
	Memory          string   `yaml:"memory"`
	Timeout         string   `yaml:"timeout"`
	CommandTemplate []string `yaml:"command_template"`
}

func (Execute) GetMemoryInBytes

func (e Execute) GetMemoryInBytes() (uint64, error)

func (Execute) GetTimeoutInTimeDuration

func (e Execute) GetTimeoutInTimeDuration() (time.Duration, error)

type GRPC

type GRPC struct {
	Address string `yaml:"address"`
}

type HTTP

type HTTP struct {
	Address string `yaml:"address"`
}

type Hash

type Hash struct {
	Cost int `yaml:"cost"`
}

type Judge

type Judge struct {
	Languages []Language `yaml:"languages"`
}

type Language

type Language struct {
	Value   string   `yaml:"value"`
	Name    string   `yaml:"name"`
	Compile *Compile `yaml:"compile"`
	Execute *Execute `yaml:"execute"`
}

type Log

type Log struct {
	Level string `yaml:"level"`
}

type MQ

type MQ struct {
	Addresses       []string `yaml:"addresses"`
	ClientID        string   `yaml:"client_id"`
	ConsumerGroupID string   `yaml:"consumer_group_id"`
	Topic           string   `yaml:"topic"`
	NumPartitions   int      `yaml:"num_partitions"`
}

type Token

type Token struct {
	Duration            string `yaml:"duration"`
	RS512KeyPairBitSize uint16 `yaml:"rs512_key_pair_bit_size"`
}

func (*Token) GetTokenDuration

func (t *Token) GetTokenDuration() time.Duration

Jump to

Keyboard shortcuts

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