dal

package
v0.316.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package dal provides a data abstraction layer for cron jobs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewQTx

func NewQTx(pool sql.ConnI, tx pgx.Tx) *sql.Queries

Types

type AttemptedCronJob

type AttemptedCronJob struct {
	DidStartExecution bool
	HasMinReplicas    bool
	model.CronJob
}

type DAL

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

func New

func New(pool *pgxpool.Pool) *DAL

func (*DAL) EndCronJob

func (d *DAL) EndCronJob(ctx context.Context, job model.CronJob, next time.Time) (model.CronJob, error)

EndCronJob sets the status from executing to idle and updates the next execution time Can be called on the successful completion of a job, or if the job failed to execute (error or timeout)

func (*DAL) GetCronJobs

func (d *DAL) GetCronJobs(ctx context.Context) ([]model.CronJob, error)

GetCronJobs returns all cron jobs for deployments with min replicas > 0

func (*DAL) GetStaleCronJobs

func (d *DAL) GetStaleCronJobs(ctx context.Context, duration time.Duration) ([]model.CronJob, error)

GetStaleCronJobs returns a list of cron jobs that have been executing longer than the duration

func (*DAL) StartCronJobs

func (d *DAL) StartCronJobs(ctx context.Context, jobs []model.CronJob) (attemptedJobs []AttemptedCronJob, err error)

StartCronJobs returns a full list of results so that the caller can update their list of jobs whether or not they successfully updated the row

Jump to

Keyboard shortcuts

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