sqlc

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCtx

func FromCtx(ctx context.Context) string

func NewCtx

func NewCtx(ctx context.Context, owner string) context.Context

func NewScopedPgx

func NewScopedPgx(ctx context.Context, dsn string) (*pgxpool.Pool, error)

Types

type BatchCreateJobsBatchResults added in v0.1.10

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

func (*BatchCreateJobsBatchResults) Close added in v0.1.10

func (*BatchCreateJobsBatchResults) Exec added in v0.1.10

func (b *BatchCreateJobsBatchResults) Exec(f func(int, error))

type BatchCreateJobsParams added in v0.1.10

type BatchCreateJobsParams struct {
	Expr             string             `json:"expr"`
	Name             interface{}        `json:"name"`
	State            string             `json:"state"`
	Executor         string             `json:"executor"`
	StartAt          pgtype.Timestamptz `json:"start_at"`
	Timeout          interface{}        `json:"timeout"`
	Meta             []byte             `json:"meta"`
	Owner            interface{}        `json:"owner"`
	Retries          interface{}        `json:"retries"`
	DeduplicationKey pgtype.Text        `json:"deduplication_key"`
}

type BatchUpdateFailedJobsBatchResults

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

func (*BatchUpdateFailedJobsBatchResults) Close

func (*BatchUpdateFailedJobsBatchResults) Exec

func (b *BatchUpdateFailedJobsBatchResults) Exec(f func(int, error))

type BatchUpdateFailedJobsParams

type BatchUpdateFailedJobsParams struct {
	State    string `json:"state"`
	Expr     string `json:"expr"`
	ID       int64  `json:"id"`
	Executor string `json:"executor"`
}

type BatchUpdateJobsBatchResults

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

func (*BatchUpdateJobsBatchResults) Close

func (*BatchUpdateJobsBatchResults) Exec

func (b *BatchUpdateJobsBatchResults) Exec(f func(int, error))

type BatchUpdateJobsParams

type BatchUpdateJobsParams struct {
	State    string     `json:"state"`
	Expr     string     `json:"expr"`
	Status   TinyStatus `json:"status"`
	Retries  int32      `json:"retries"`
	ID       int64      `json:"id"`
	Executor string     `json:"executor"`
}

type CountJobsInStatusParams

type CountJobsInStatusParams struct {
	Executor string     `json:"executor"`
	Status   TinyStatus `json:"status"`
}

type CreateJobParams

type CreateJobParams struct {
	Expr             string             `json:"expr"`
	Name             interface{}        `json:"name"`
	State            string             `json:"state"`
	Executor         string             `json:"executor"`
	StartAt          pgtype.Timestamptz `json:"start_at"`
	Timeout          interface{}        `json:"timeout"`
	Meta             []byte             `json:"meta"`
	Owner            interface{}        `json:"owner"`
	Retries          interface{}        `json:"retries"`
	DeduplicationKey pgtype.Text        `json:"deduplication_key"`
}

type CronNextRunParams

type CronNextRunParams struct {
	From pgtype.Timestamptz `json:"from"`
	Expr string             `json:"expr"`
}

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 DeleteJobByIDParams

type DeleteJobByIDParams struct {
	ID       int64  `json:"id"`
	Executor string `json:"executor"`
}

type DeleteJobByNameParams

type DeleteJobByNameParams struct {
	Name     string `json:"name"`
	Executor string `json:"executor"`
}

type FetchDueJobsParams

type FetchDueJobsParams struct {
	Limit    int32  `json:"limit"`
	Executor string `json:"executor"`
}

type GetJobByIDParams

type GetJobByIDParams struct {
	ID       int64  `json:"id"`
	Executor string `json:"executor"`
}

type GetJobByNameParams

type GetJobByNameParams struct {
	Name     string `json:"name"`
	Executor string `json:"executor"`
}

type NextParams

type NextParams struct {
	From pgtype.Timestamptz `json:"from"`
	Expr string             `json:"expr"`
}

type NullTinyStatus

type NullTinyStatus struct {
	TinyStatus TinyStatus
	Valid      bool // Valid is true if TinyStatus is not NULL
}

func (*NullTinyStatus) Scan

func (ns *NullTinyStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTinyStatus) Value

func (ns NullTinyStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Querier

type Querier interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	BeginTx(ctx context.Context, opts pgx.TxOptions) (pgx.Tx, error)
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	SendBatch(ctx context.Context, batch *pgx.Batch) pgx.BatchResults
	Close()
}

Querier provides abstraction for passing both pgxpool.Conn, pgx.Conn and pgx.Tx as possible datasources

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) BatchCreateJobs added in v0.1.10

func (*Queries) BatchUpdateJobs

func (*Queries) CountJobsInStatus

func (q *Queries) CountJobsInStatus(ctx context.Context, arg CountJobsInStatusParams) (int64, error)

func (*Queries) CreateJob

func (q *Queries) CreateJob(ctx context.Context, arg CreateJobParams) (TinyJob, error)

on conflict on constraint job_name_owner_key do ...

func (*Queries) CronNextRun

func (q *Queries) CronNextRun(ctx context.Context, arg CronNextRunParams) (pgtype.Timestamptz, error)

func (*Queries) DeleteJobByID

func (q *Queries) DeleteJobByID(ctx context.Context, arg DeleteJobByIDParams) (TinyJob, error)

func (*Queries) DeleteJobByName

func (q *Queries) DeleteJobByName(ctx context.Context, arg DeleteJobByNameParams) (TinyJob, error)

func (*Queries) FetchDueJobs

func (q *Queries) FetchDueJobs(ctx context.Context, arg FetchDueJobsParams) ([]TinyJob, error)

func (*Queries) GetJobByID

func (q *Queries) GetJobByID(ctx context.Context, arg GetJobByIDParams) (TinyJob, error)

func (*Queries) GetJobByName

func (q *Queries) GetJobByName(ctx context.Context, arg GetJobByNameParams) (TinyJob, error)

func (*Queries) LastUpdate added in v0.1.10

func (q *Queries) LastUpdate(ctx context.Context, executor string) (pgtype.Timestamptz, error)

func (*Queries) Next

func (q *Queries) Next(ctx context.Context, arg NextParams) (pgtype.Timestamptz, error)

func (*Queries) ResetTimeoutJobs

func (q *Queries) ResetTimeoutJobs(ctx context.Context, executor string) ([]int64, error)

func (*Queries) RestartJob

func (q *Queries) RestartJob(ctx context.Context, arg RestartJobParams) (TinyJob, error)

func (*Queries) SearchJobs

func (q *Queries) SearchJobs(ctx context.Context, arg SearchJobsParams) ([]TinyJob, error)

func (*Queries) SearchJobsByMeta

func (q *Queries) SearchJobsByMeta(ctx context.Context, arg SearchJobsByMetaParams) ([]SearchJobsByMetaRow, error)

func (*Queries) StopJob

func (q *Queries) StopJob(ctx context.Context, arg StopJobParams) (TinyJob, error)

Cannot stop a currently running task as it is outside of control for now Possible to add a notification system to listen on those kind of events

func (*Queries) UpdateExprByID

func (q *Queries) UpdateExprByID(ctx context.Context, arg UpdateExprByIDParams) (TinyJob, error)

func (*Queries) UpdateJobByID

func (q *Queries) UpdateJobByID(ctx context.Context, arg UpdateJobByIDParams) (TinyJob, error)

func (*Queries) UpdateJobByName

func (q *Queries) UpdateJobByName(ctx context.Context, arg UpdateJobByNameParams) (TinyJob, error)

func (*Queries) UpdateStateByID

func (q *Queries) UpdateStateByID(ctx context.Context, arg UpdateStateByIDParams) (TinyJob, error)

func (*Queries) ValidateExprFormat

func (q *Queries) ValidateExprFormat(ctx context.Context, dollar_1 string) (bool, error)

func (*Queries) WithTx

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

type RestartJobParams

type RestartJobParams struct {
	ID       int64  `json:"id"`
	Executor string `json:"executor"`
}

type ScopedPgx

type ScopedPgx struct {
	*pgxpool.Pool
}

ScopedPgx is a scoped connection pool that only leverages a lower privileges postgres role that is subject to RLS

type SearchJobsByMetaParams

type SearchJobsByMetaParams struct {
	Offset    int32              `json:"offset"`
	Limit     int32              `json:"limit"`
	Query     string             `json:"query"`
	Statuses  string             `json:"statuses"`
	From      pgtype.Timestamptz `json:"from"`
	To        pgtype.Timestamptz `json:"to"`
	Name      string             `json:"name"`
	IsOneShot bool               `json:"is_one_shot"`
	Executor  string             `json:"executor"`
}

type SearchJobsByMetaRow

type SearchJobsByMetaRow struct {
	ID               int64              `json:"id"`
	Expr             string             `json:"expr"`
	RunAt            pgtype.Timestamptz `json:"run_at"`
	LastRunAt        pgtype.Timestamptz `json:"last_run_at"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	StartAt          pgtype.Timestamptz `json:"start_at"`
	ExecutionAmount  int32              `json:"execution_amount"`
	Retries          int32              `json:"retries"`
	Name             string             `json:"name"`
	Meta             []byte             `json:"meta"`
	Timeout          int32              `json:"timeout"`
	Status           TinyStatus         `json:"status"`
	State            string             `json:"state"`
	Executor         string             `json:"executor"`
	Owner            string             `json:"owner"`
	DeduplicationKey pgtype.Text        `json:"deduplication_key"`
	TotalCount       int64              `json:"total_count"`
}

type SearchJobsParams

type SearchJobsParams struct {
	Offset   int32  `json:"offset"`
	Limit    int32  `json:"limit"`
	Executor string `json:"executor"`
	Query    string `json:"query"`
}

type StopJobParams

type StopJobParams struct {
	ID       int64  `json:"id"`
	Executor string `json:"executor"`
}

type TinyJob

type TinyJob struct {
	ID               int64              `json:"id"`
	Expr             string             `json:"expr"`
	RunAt            pgtype.Timestamptz `json:"run_at"`
	LastRunAt        pgtype.Timestamptz `json:"last_run_at"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	StartAt          pgtype.Timestamptz `json:"start_at"`
	ExecutionAmount  int32              `json:"execution_amount"`
	Retries          int32              `json:"retries"`
	Name             string             `json:"name"`
	Meta             []byte             `json:"meta"`
	Timeout          int32              `json:"timeout"`
	Status           TinyStatus         `json:"status"`
	State            string             `json:"state"`
	Executor         string             `json:"executor"`
	Owner            string             `json:"owner"`
	DeduplicationKey pgtype.Text        `json:"deduplication_key"`
}

type TinyStatus

type TinyStatus string
const (
	TinyStatusREADY   TinyStatus = "READY"
	TinyStatusPENDING TinyStatus = "PENDING"
	TinyStatusFAILURE TinyStatus = "FAILURE"
	TinyStatusSUCCESS TinyStatus = "SUCCESS"
	TinyStatusPAUSED  TinyStatus = "PAUSED"
)

func (*TinyStatus) Scan

func (e *TinyStatus) Scan(src interface{}) error

type UpdateExprByIDParams

type UpdateExprByIDParams struct {
	ID       int64       `json:"id"`
	Executor string      `json:"executor"`
	Expr     interface{} `json:"expr"`
}

type UpdateJobByIDParams

type UpdateJobByIDParams struct {
	ID       int64       `json:"id"`
	Executor string      `json:"executor"`
	Expr     interface{} `json:"expr"`
	State    interface{} `json:"state"`
	Timeout  interface{} `json:"timeout"`
}

type UpdateJobByNameParams

type UpdateJobByNameParams struct {
	Name     string      `json:"name"`
	Executor string      `json:"executor"`
	Expr     interface{} `json:"expr"`
	State    interface{} `json:"state"`
	Timeout  interface{} `json:"timeout"`
}

type UpdateStateByIDParams

type UpdateStateByIDParams struct {
	ID       int64       `json:"id"`
	Executor string      `json:"executor"`
	State    interface{} `json:"state"`
}

Jump to

Keyboard shortcuts

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