cloudsql

package
v0.0.0-...-350d524 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package cloudsql implements the interface to interact with the Cloud SQL API.

Index

Constants

View Source
const InsertBuildsTemplate = "" /* 177-byte string literal not displayed */

InsertBuildsTemplate is the constant string template for how we will insert builds into the Cloud SQL PSQL database. The table name will need to be provided. "ON CONFLICT DO NOTHING" is added so that in the case of a duplicated build being inserted neither an error is returned nor, rows updated.

View Source
const SelectBuildsTemplate = `` /* 348-byte string literal not displayed */

SelectBuildsTemplate will be used as the basis to fetch the required builds for timed Event configs. The table name and where clause items will need to be provided.

NOTE: The rank function here creates groupings of ("build_target", "milestone") pairs and gives the newest a value of rank 1. Using this we can ignore all but the latest image for the given build_target and milestone.

View Source
const SelectWhereClauseItem = "(\"build_target\" = '%s' AND \"milestone\" = %d)"

Variables

This section is empty.

Functions

func ConvertPSQLRowToBuild

func ConvertPSQLRowToBuild(Row *PSQLBuildRow) *kronpb.Build

ConvertPSQLRowToBuild converts a PSQLBuildRow into a kronpb.Build type.

func RowToSlice

func RowToSlice(row *PSQLBuildRow) []any

RowToSlice converts the row type to a slice of field pointers. This is required when passing to the generic variadic functions for sql insertion.

func ScanBuildRows

func ScanBuildRows(rows pgx.Rows) (any, error)

ScanBuildRows handles row scans when querying build rows.

Types

type Client

type Client interface {
	Connect(ctx context.Context, user, password, databaseName, connectionName string) error
	Read(ctx context.Context, query string, handleScanRows func(rows pgx.Rows) (any, error)) (any, error)
	Exec(ctx context.Context, sqlCommand string, insertArgs ...any) (int, error)
}

func InitBuildsClient

func InitBuildsClient(ctx context.Context, isProd, isWriter bool) (Client, error)

InitBuildsClient initialize a PSQL client for for the kron-builds table.

type PSQLBuildRow

type PSQLBuildRow struct {
	BuildUUID   string
	RunUUID     string
	CreateTime  pgtype.Timestamptz
	Bbid        int64
	BuildTarget string
	Milestone   int64
	Version     string
	ImagePath   string
	Board       string
	Variant     string
}

PSQLBuildRow is a PSQL compliant version of the kronpb.Build type. The difference here is that for the PSQL adapter we need to use pgtype.Timestamptz for timestamps rather than timestamppb.Timestamp.

func ConvertBuildToPSQLRow

func ConvertBuildToPSQLRow(build *kronpb.Build) (*PSQLBuildRow, error)

ConvertBuildToPSQLRow converts a kronpb.Build into a PSQLBuildRow type.

Jump to

Keyboard shortcuts

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