db

package
v0.0.0-...-116ca14 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddAgentTag = `` /* 145-byte string literal not displayed */
View Source
var CheckConnection = "SELECT 1"
View Source
var CleanPkiCertificatesQuery = `DELETE FROM certificates WHERE not_after < NOW()`
View Source
var CollectLogPartsQuery = "SELECT array_to_string(array_agg(log_parts.content ORDER BY number, job_id), '') AS content FROM log_parts WHERE job_id=$1"
View Source
var CountAgentsQuery = "SELECT count(*) FROM agents %s %s"
View Source
var CountAllJobsQuery = "SELECT count(*) FROM jobs %s %s"
View Source
var DeleteAgentQuery = `DELETE FROM agents WHERE agent_id=$1`
View Source
var DeleteAgentTagQuery = `` /* 138-byte string literal not displayed */
View Source
var DeleteJobsOldQuery = `
	DELETE FROM jobs
	WHERE id IN
	(
		SELECT DISTINCT id
		FROM jobs
		WHERE (updated_at <= NOW() - INTERVAL '1 day' * $1)
	)
`
View Source
var DeleteLocksQuery = `` /* 141-byte string literal not displayed */
View Source
var DeleteLogPartsQuery = `DELETE FROM log_parts WHERE job_id=$1`
View Source
var DeletePkiTokensQuery = `DELETE FROM tokens WHERE created_at < NOW() - INTERVAL '1 second' * $1`

pki

View Source
var DeleteQuery = "DELETE FROM "

Global

View Source
var FailJobsNonHeartbeatQuery = `` /* 168-byte string literal not displayed */
View Source
var FailJobsTimeoutQuery = `` /* 214-byte string literal not displayed */
View Source
var GetAgentQuery = `` /* 194-byte string literal not displayed */
View Source
var GetAgentsQuery = `` /* 217-byte string literal not displayed */

Agents

View Source
var GetAllJobsQuery = "SELECT * FROM jobs %s order by created_at DESC %s"
View Source
var GetJobQuery = "SELECT * FROM jobs WHERE id=$1"
View Source
var GetLockQuery = "SELECT * FROM locks WHERE lock_id=$1"

Locks

View Source
var GetLogPartQuery = `SELECT * FROM log_parts WHERE job_id=$1 AND number=$2`

Log parts

View Source
var GetLogPartsToAggregateQuery = `` /* 167-byte string literal not displayed */
View Source
var GetLogQuery = "SELECT * FROM logs WHERE job_id=$1"

Log

View Source
var GetTokenQuery = `SELECT profile, subject FROM tokens WHERE id=$1 AND created_at > NOW() - INTERVAL '1 hour' FOR UPDATE`
View Source
var InsertAgentQuery = `` /* 160-byte string literal not displayed */
View Source
var InsertCertificateQuery = `` /* 176-byte string literal not displayed */
View Source
var InsertJobQuery = `` /* 178-byte string literal not displayed */

Jobs

View Source
var InsertLockQuery = `INSERT INTO locks(lock_id,agent_id,created_at) VALUES($1,$2,$3) returning lock_id`
View Source
var InsertLogPartQuery = `INSERT INTO log_parts(job_id,number,content,final,created_at) VALUES($1,$2,$3,$4,$5) returning job_id;`
View Source
var InsertLogQuery = "INSERT INTO logs(job_id,content,created_at,updated_at) VALUES($1,$2,$3,$4) returning job_id"
View Source
var InsertTokenQuery = `INSERT INTO tokens (id, profile, subject) VALUES($1, $2, $3)`
View Source
var InsertTokenWithCreatedAtQuery = `INSERT INTO tokens (id, profile, subject,created_at) VALUES($1, $2, $3, $4)`
View Source
var UpdateAgentWithRegistration = `` /* 208-byte string literal not displayed */
View Source
var UpdateJobQuery = `UPDATE jobs SET status=GREATEST(status, $1), updated_at=$2 WHERE id=$3`

Only allow increasing the status value This means a job status can not decrease e.g. don't go from executing -> pending, failed/complete -> executing

Functions

func DeleteAllRowsFromTable

func DeleteAllRowsFromTable(db *sql.DB, table string) (sql.Result, error)

func NewConnection

func NewConnection(dbConfigFile, env string) (*sql.DB, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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