dao

package
v0.0.0-...-3c36f29 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Id              = "id"
	RunId           = "run-id"
	Key             = "key"
	Template        = "template"
	TemplateVersion = "template-version"
	TemplateTitle   = "template-title"
	Status          = "status"
	Index           = "index"
	RetriesLeft     = "retries-left"
	CreatedAt       = "created-at"
	UUID            = "uuid"
	StatusOwner     = "status-owner"
	HeartBeat       = "heartbeat"
	CompleteBy      = "complete-by"
	Now             = "now"
	State           = "state"
	Label           = "label"
	Name            = "name"
	Tags            = "tags"
)

Variables

View Source
var GitCommit string
View Source
var IsRemote = false

Functions

func CountMigrationTx

func CountMigrationTx(tx *sqlx.Tx, count *int) error

func CreateMigration

func CreateMigration(tx *sqlx.Tx) (sql.Result, error)

func DeleteRunsTx

func DeleteRunsTx(tx *sqlx.Tx, deleteRunsQuery *api.DeleteQuery) error

func GetMigration

func GetMigration(tx *sqlx.Tx, version *int) error

func GetRunAndStepUUIDByLabelTx

func GetRunAndStepUUIDByLabelTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, label string, runReturnAttributes []string) (api.RunRecord, uuid.UUID, api.Context, error)

func GetRunLabelAndContextByStepUUIDTx

func GetRunLabelAndContextByStepUUIDTx(tx *sqlx.Tx, options api.Options, stepUUID uuid.UUID, runReturnAttributes []string) (api.RunRecord, api.Context, string, error)

func GetRunsTx

func GetRunsTx(tx *sqlx.Tx, getQuery *api.GetRunsQuery) ([]api.RunRecord, error)

func GetStepByLabelTx

func GetStepByLabelTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, label string, attributes []string) (api.StepRecord, error)

func GetStepTx

func GetStepTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, index int, attributes []string) (api.StepRecord, error)

func GetStepsTx

func GetStepsTx(tx *sqlx.Tx, getQuery *api.GetStepsQuery) ([]api.StepRecord, error)

func InitLogrus

func InitLogrus(out io.Writer, level log.Level)

func ListRunsTx

func ListRunsTx(tx *sqlx.Tx, query *api.ListQuery) ([]api.RunRecord, *api.RangeResult, error)

func ListStepsTx

func ListStepsTx(tx *sqlx.Tx, query *api.ListQuery) ([]api.StepRecord, *api.RangeResult, error)

func ResetRunCompleteByTx

func ResetRunCompleteByTx(tx *sqlx.Tx, id uuid.UUID)

func UpdateMigration

func UpdateMigration(tx *sqlx.Tx, version int) (sql.Result, error)

Types

type DAO

type DAO struct {
	Parameters                   ParametersType
	CompleteByPendingInterval    int64
	MaxOpenConnections           int
	MaxIdleConnections           int
	ConnectionMaxIdleTimeSeconds int64
	ConnectionMaxLifeTimeSeconds int64
	DB                           DBI
}

func New

func New(parameters *ParametersType) (*DAO, error)

func (*DAO) Transactional

func (d *DAO) Transactional(transactionalFunction func(tx *sqlx.Tx) error) (err error)

func (*DAO) UpdateManyStatusAndHeartBeatByLabelTx

func (d *DAO) UpdateManyStatusAndHeartBeatByLabelTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, labels []string, newStatus api.StepStatusType, newStatusOwner string, prevStatus []api.StepStatusType, context api.Context, completeBy *int64) []UUIDAndStatusOwner

func (*DAO) UpdateManyStatusAndHeartBeatByUUIDTx

func (d *DAO) UpdateManyStatusAndHeartBeatByUUIDTx(tx *sqlx.Tx, options api.Options, uuids []uuid.UUID, newStatus api.StepStatusType, newStatusOwner string, prevStatus []api.StepStatusType, context api.Context, completeBy *int64) []UUIDAndStatusOwner

func (*DAO) UpdateManyStepsPartsBeatTx

func (d *DAO) UpdateManyStepsPartsBeatTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, indices []int, newStatus api.StepStatusType, newStatusOwner string, prevStatus []api.StepStatusType, completeBy *int64, retriesLeft *int, context api.Context, state *api.State) []UUIDAndStatusOwner

func (*DAO) UpdateRunStatusTx

func (d *DAO) UpdateRunStatusTx(tx *sqlx.Tx, options api.Options, id uuid.UUID, newStatus api.RunStatusType, prevStatus *api.RunStatusType, completeBy *int64)

func (*DAO) UpdateStepHeartBeat

func (d *DAO) UpdateStepHeartBeat(options api.Options, stepUUID uuid.UUID, statusOwner string) error

func (*DAO) UpdateStepPartsTx

func (d *DAO) UpdateStepPartsTx(tx *sqlx.Tx, options api.Options, runId uuid.UUID, index int, newStatus api.StepStatusType, newStatusOwner string, completeBy *int64, retriesLeft *int, context api.Context, state *api.State) UUIDAndStatusOwner

type DBI

type DBI interface {
	SQL() *sqlx.DB
	VerifyDBCreation(tx *sqlx.Tx) error
	CreateStepTx(tx *sqlx.Tx, stepRecord *api.StepRecord)
	CreateRunTx(tx *sqlx.Tx, runRecord interface{}, completeBy int64)
	Migrate0(tx *sqlx.Tx) error

	RecoverSteps(DAO *DAO, tx *sqlx.Tx, limit int, disableSkipLocks bool) []UUIDAndGroupId
	GetAndUpdateExpiredRuns(DAO *DAO, tx *sqlx.Tx, limit int, disableSkipLocks bool) []IdAndGroupId
	Notify(tx *sqlx.Tx, channel string, message string)
	// contains filtered or unexported methods
}

type IdAndGroupId

type IdAndGroupId struct {
	Id      uuid.UUID `db:"id" json:"id,omitempty"`
	GroupId uuid.UUID `db:"group_id" json:"group-id,omitempty"`
}

type ParametersType

type ParametersType struct {
	DataSourceName      string
	DatabaseVendor      string
	DatabaseHost        string
	DatabasePort        int64
	DatabaseName        string
	DatabaseSSLMode     bool
	DatabaseUserName    string
	DatabasePassword    string
	DatabaseSchema      string
	DatabaseAutoMigrate bool
}

type PostgreSQLSqlxDB

type PostgreSQLSqlxDB sqlx.DB

func (*PostgreSQLSqlxDB) CreateRunTx

func (db *PostgreSQLSqlxDB) CreateRunTx(tx *sqlx.Tx, runRecord interface{}, completeBy int64)

func (*PostgreSQLSqlxDB) CreateStepTx

func (db *PostgreSQLSqlxDB) CreateStepTx(tx *sqlx.Tx, stepRecord *api.StepRecord)

func (*PostgreSQLSqlxDB) GetAndUpdateExpiredRuns

func (db *PostgreSQLSqlxDB) GetAndUpdateExpiredRuns(DAO *DAO, tx *sqlx.Tx, limit int, disableSkipLocks bool) []IdAndGroupId

func (*PostgreSQLSqlxDB) Migrate0

func (db *PostgreSQLSqlxDB) Migrate0(tx *sqlx.Tx) error

func (*PostgreSQLSqlxDB) Notify

func (db *PostgreSQLSqlxDB) Notify(tx *sqlx.Tx, channel string, message string)

func (*PostgreSQLSqlxDB) RecoverSteps

func (db *PostgreSQLSqlxDB) RecoverSteps(DAO *DAO, tx *sqlx.Tx, limit int, disableSkipLocks bool) []UUIDAndGroupId

func (*PostgreSQLSqlxDB) SQL

func (db *PostgreSQLSqlxDB) SQL() *sqlx.DB

func (*PostgreSQLSqlxDB) VerifyDBCreation

func (db *PostgreSQLSqlxDB) VerifyDBCreation(tx *sqlx.Tx) error

type Sqlite3SqlxDB

type Sqlite3SqlxDB sqlx.DB

func (*Sqlite3SqlxDB) CreateRunTx

func (db *Sqlite3SqlxDB) CreateRunTx(tx *sqlx.Tx, runRecord interface{}, completeBy int64)

func (*Sqlite3SqlxDB) CreateStepTx

func (db *Sqlite3SqlxDB) CreateStepTx(tx *sqlx.Tx, stepRecord *api.StepRecord)

func (*Sqlite3SqlxDB) GetAndUpdateExpiredRuns

func (db *Sqlite3SqlxDB) GetAndUpdateExpiredRuns(DAO *DAO, tx *sqlx.Tx, _ int, _ bool) []IdAndGroupId

func (*Sqlite3SqlxDB) Migrate0

func (db *Sqlite3SqlxDB) Migrate0(tx *sqlx.Tx) error

func (*Sqlite3SqlxDB) Notify

func (db *Sqlite3SqlxDB) Notify(_ *sqlx.Tx, _ string, _ string)

func (*Sqlite3SqlxDB) RecoverSteps

func (db *Sqlite3SqlxDB) RecoverSteps(DAO *DAO, tx *sqlx.Tx, _ int, _ bool) []UUIDAndGroupId

func (*Sqlite3SqlxDB) SQL

func (db *Sqlite3SqlxDB) SQL() *sqlx.DB

func (*Sqlite3SqlxDB) VerifyDBCreation

func (db *Sqlite3SqlxDB) VerifyDBCreation(tx *sqlx.Tx) error

type UUIDAndGroupId

type UUIDAndGroupId struct {
	UUID    uuid.UUID `db:"uuid" json:"uuid,omitempty"`
	GroupId uuid.UUID `db:"group_id" json:"group-id,omitempty"`
}

type UUIDAndStatusOwner

type UUIDAndStatusOwner struct {
	UUID        uuid.UUID
	StatusOwner string
}

Jump to

Keyboard shortcuts

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