Documentation
¶
Overview ¶
Package db creates DB tables, call resource manager interfaces and populates the DB with compute units
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBackupInt = errors.New("backup_interval of less than 1 day is not supported") ErrUpdateInt = errors.New("update_interval and/or max_update_interval must be more than 0s") )
Custom errors.
View Source
var ( // Weights for estimating average values, we do weighted average method using following // values as weight for each DB column // For CPU and GPU, we use CPU time and GPU time as weights // For memory usage, we use Walltime * Mem for CPU as weight and just walltime // for GPU. Weights = map[string]string{ "avg_cpu_usage": "alloc_cputime", "avg_gpu_usage": "alloc_gputime", "avg_cpu_mem_usage": "alloc_cpumemtime", "avg_gpu_mem_usage": "alloc_gpumemtime", } // AdminUsersSources is the list of sources to get admin users from. AdminUsersSources = []string{"ceems", "grafana"} )
View Source
var MigrationsFS embed.FS
View Source
var StatementsFS embed.FS
Functions ¶
Types ¶
type AdminConfig ¶
type AdminConfig struct {
Users []string `yaml:"users"`
Grafana common.GrafanaWebConfig `yaml:"grafana"`
}
AdminConfig is the container for the admin users related config.
func (*AdminConfig) SetDirectory ¶
func (c *AdminConfig) SetDirectory(dir string)
SetDirectory joins any relative file paths with dir.
func (*AdminConfig) UnmarshalYAML ¶
func (c *AdminConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
func (*AdminConfig) Validate ¶
func (c *AdminConfig) Validate() error
Validate validates the config.
type Config ¶
type Config struct {
Logger *slog.Logger
Data DataConfig
Admin AdminConfig
ResourceManager func(*slog.Logger) (*resource.Manager, error)
Updater func(*slog.Logger) (*updater.UnitUpdater, error)
}
Config makes a DB config from config file.
type DataConfig ¶
type DataConfig struct {
Path string `yaml:"path"`
BackupPath string `yaml:"backup_path"`
RetentionPeriod model.Duration `yaml:"retention_period"`
UpdateInterval model.Duration `yaml:"update_interval"`
MaxUpdateInterval model.Duration `yaml:"max_update_interval"`
BackupInterval model.Duration `yaml:"backup_interval"`
LastUpdate DateTime `yaml:"update_from"`
Timezone Timezone `yaml:"time_zone"`
SkipDeleteOldUnits bool
}
DataConfig is the container for the data related config.
func (*DataConfig) UnmarshalYAML ¶
func (c *DataConfig) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface.
Click to show internal directories.
Click to hide internal directories.