db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

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 (

	// 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",
	}

	// Admin users sources
	AdminUsersSources = []string{"ceems", "grafana"}
)
View Source
var MigrationsFS embed.FS
View Source
var StatementsFS embed.FS

Functions

func NewStatsDB

func NewStatsDB(c *Config) (*statsDB, error)

NewStatsDB returns a new instance of statsDB struct

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

type Config

type Config struct {
	Logger          log.Logger
	Data            DataConfig
	Admin           AdminConfig
	ResourceManager func(log.Logger) (*resource.Manager, error)
	Updater         func(log.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"`
	BackupInterval     model.Duration `yaml:"backup_interval"`
	LastUpdateTime     time.Time      `yaml:"update_from"`
	SkipDeleteOldUnits bool
}

DataConfig is the container for the data related config

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator implements DB migrations

func NewMigrator

func NewMigrator(sqlFiles embed.FS, dirName string, logger log.Logger) (*Migrator, error)

NewMigrator returns new instance of Migrator

func (*Migrator) ApplyMigrations

func (m *Migrator) ApplyMigrations(db *sql.DB) error

ApplyMigrations applies DB migrations

Directories

Path Synopsis
Package sqlite3 implements a connect hook around the sqlite3 driver so that the underlying connection can be fetched from the driver for more advanced operations such as backups.
Package sqlite3 implements a connect hook around the sqlite3 driver so that the underlying connection can be fetched from the driver for more advanced operations such as backups.

Jump to

Keyboard shortcuts

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