queries

package
v0.0.0-...-9db51f9 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cols

func Cols() []string

func Contains

func Contains(data []string, term string) bool

func WrapError

func WrapError(err error) error

Types

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type NamedArgConverter

type NamedArgConverter interface {
	ToNamedArgs() (map[string]interface{}, error)
}

type PodUsageHourly

type PodUsageHourly struct {
	PodUid                   pgtype.UUID        `db:"pod_uid"`
	ClusterID                int                `db:"cluster_id"`
	Timestamp                pgtype.Timestamptz `db:"timestamp"`
	MemoryBytesMax           float64            `db:"memory_bytes_max"`
	MemoryBytesMin           float64            `db:"memory_bytes_min"`
	MemoryBytesTotal         float64            `db:"memory_bytes_total"`
	MemoryBytesTotalReadings int32              `db:"memory_bytes_total_readings"`
	MemoryBytesAvg           float64            `db:"memory_bytes_avg"`
	CpuCoresMax              float64            `db:"cpu_cores_max"`
	CpuCoresMin              float64            `db:"cpu_cores_min"`
	CpuCoresTotal            float64            `db:"cpu_cores_total"`
	CpuCoresTotalReadings    int32              `db:"cpu_cores_total_readings"`
	CpuCoresAvg              float64            `db:"cpu_cores_avg"`
}

type Queries

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

func New

func New(ctx context.Context, db DBTX, clusterName string) (*Queries, error)

func (*Queries) ActiveObjectCount

func (q *Queries) ActiveObjectCount(ctx context.Context) (int, error)

func (*Queries) CreateCluster

func (q *Queries) CreateCluster(ctx context.Context, name string) (int, error)

func (*Queries) DeleteObject

func (q *Queries) DeleteObject(ctx context.Context, uid string) error

func (*Queries) DeleteObjects

func (q *Queries) DeleteObjects(ctx context.Context, kind string, ignoreUids []pgtype.UUID) (int, error)

func (*Queries) GetClusterID

func (q *Queries) GetClusterID(ctx context.Context, name string) (int, error)

func (*Queries) GetOrCreateCluster

func (q *Queries) GetOrCreateCluster(ctx context.Context, name string) (int, error)

func (*Queries) ListPodUsageHourly

func (q *Queries) ListPodUsageHourly(ctx context.Context) ([]PodUsageHourly, error)

func (*Queries) UpsertObject

func (q *Queries) UpsertObject(ctx context.Context, kind string, object any) error

func (*Queries) UpsertPodUsedCPU

func (q *Queries) UpsertPodUsedCPU(ctx context.Context, arg []UpsertPodUsedCPUParams) error

func (*Queries) UpsertPodUsedMemory

func (q *Queries) UpsertPodUsedMemory(ctx context.Context, arg []UpsertPodUsedMemoryParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

func (*Queries) WorkloadAgg

func (q *Queries) WorkloadAgg(ctx context.Context, req WorkloadAggRequest) (*WorkloadAggResult, error)

type UpsertPodUsedCPUParams

type UpsertPodUsedCPUParams struct {
	ClusterID int                `db:"cluster_id"`
	PodUid    pgtype.UUID        `db:"pod_uid"`
	Timestamp pgtype.Timestamptz `db:"timestamp"`
	CpuCores  float64            `db:"cpu_cores"`
}

type UpsertPodUsedMemoryParams

type UpsertPodUsedMemoryParams struct {
	ClusterID   int                `db:"cluster_id"`
	PodUid      pgtype.UUID        `db:"pod_uid"`
	Timestamp   pgtype.Timestamptz `db:"timestamp"`
	MemoryBytes float64            `db:"memory_bytes"`
}

type Workload

type Workload struct {
	Namespace string
	Name      string
}

type WorkloadAggRequest

type WorkloadAggRequest struct {
	Cols    []string
	OrderBy string
	Start   time.Time
	End     time.Time
}

func (WorkloadAggRequest) Validate

func (w WorkloadAggRequest) Validate() error

nolint:cyclop

type WorkloadAggResult

type WorkloadAggResult struct {
	Columns      []string
	Rows         [][]string
	SQLQuery     string
	SQLQueryArgs []interface{}
}

Jump to

Keyboard shortcuts

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