dbsqlc

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type JobCancelParams

type JobCancelParams struct {
	Now               *string
	CancelAttemptedAt string
	ID                int64
}

type JobCountByAllStatesRow added in v0.24.0

type JobCountByAllStatesRow struct {
	State string
	Count int64
}

type JobCountByQueueAndStateRow added in v0.24.0

type JobCountByQueueAndStateRow struct {
	Queue          string
	CountAvailable int64
	CountRunning   int64
}

type JobDeleteBeforeParams

type JobDeleteBeforeParams struct {
	CancelledFinalizedAtHorizon string
	CompletedFinalizedAtHorizon string
	DiscardedFinalizedAtHorizon string
	Max                         int64
	QueuesExcludedEmpty         bool
	QueuesExcluded              []string
}

type JobGetAvailableParams

type JobGetAvailableParams struct {
	Now       *string
	Queue     string
	MaxToLock int64
}

type JobGetStuckParams

type JobGetStuckParams struct {
	StuckHorizon string
	Max          int64
}

type JobInsertFastNoReturningParams

type JobInsertFastNoReturningParams struct {
	Args         []byte
	CreatedAt    *string
	Kind         string
	MaxAttempts  int64
	Metadata     []byte
	Priority     int64
	Queue        string
	ScheduledAt  *string
	State        string
	Tags         []byte
	UniqueKey    []byte
	UniqueStates *int64
}

type JobInsertFastParams

type JobInsertFastParams struct {
	ID           *int64
	Args         []byte
	CreatedAt    *string
	Kind         string
	MaxAttempts  int64
	Metadata     []byte
	Priority     int64
	Queue        string
	ScheduledAt  *string
	State        string
	Tags         []byte
	UniqueKey    []byte
	UniqueStates *int64
}

type JobInsertFullParams

type JobInsertFullParams struct {
	Args         []byte
	Attempt      int64
	AttemptedAt  *string
	AttemptedBy  []byte
	CreatedAt    *string
	Errors       []byte
	FinalizedAt  *string
	Kind         string
	MaxAttempts  int64
	Metadata     []byte
	Priority     int64
	Queue        string
	ScheduledAt  *string
	State        string
	Tags         []byte
	UniqueKey    []byte
	UniqueStates *int64
}

type JobKindListParams added in v0.24.0

type JobKindListParams struct {
	Match   string
	After   string
	Exclude []string
	Max     int64
}

type JobRescueParams

type JobRescueParams struct {
	Error       []byte
	FinalizedAt *string
	ScheduledAt time.Time
	State       string
	ID          int64
}

type JobRetryParams

type JobRetryParams struct {
	Now *string
	ID  int64
}

type JobScheduleGetCollisionParams

type JobScheduleGetCollisionParams struct {
	ID        int64
	UniqueKey []byte
}

type JobScheduleGetEligibleParams

type JobScheduleGetEligibleParams struct {
	Now *string
	Max int64
}

type JobScheduleSetDiscardedParams

type JobScheduleSetDiscardedParams struct {
	Now *string
	ID  []int64
}

type JobSetMetadataIfNotRunningParams

type JobSetMetadataIfNotRunningParams struct {
	MetadataUpdates []byte
	ID              int64
}

type JobSetStateIfRunningParams

type JobSetStateIfRunningParams struct {
	State               string
	AttemptDoUpdate     bool
	Attempt             int64
	ErrorsDoUpdate      bool
	Error               []byte
	Now                 *string
	FinalizedAtDoUpdate bool
	FinalizedAt         *time.Time
	MetadataDoMerge     bool
	MetadataUpdates     []byte
	ScheduledAtDoUpdate bool
	ScheduledAt         time.Time
	ID                  int64
}

type JobUpdateFullParams added in v0.29.0

type JobUpdateFullParams struct {
	AttemptDoUpdate     bool
	Attempt             int64
	AttemptedAtDoUpdate bool
	AttemptedAt         *time.Time
	AttemptedByDoUpdate bool
	AttemptedBy         []byte
	ErrorsDoUpdate      bool
	Errors              []byte
	FinalizedAtDoUpdate bool
	FinalizedAt         *time.Time
	MaxAttemptsDoUpdate bool
	MaxAttempts         int64
	MetadataDoUpdate    bool
	Metadata            []byte
	StateDoUpdate       bool
	State               string
	ID                  int64
}

type JobUpdateParams

type JobUpdateParams struct {
	MetadataDoMerge bool
	Metadata        []byte
	ID              int64
}

type LeaderAttemptElectParams

type LeaderAttemptElectParams struct {
	LeaderID string
	Now      *string
	TTL      string
}

type LeaderAttemptReelectParams

type LeaderAttemptReelectParams struct {
	LeaderID string
	Now      *string
	TTL      string
}

type LeaderInsertParams

type LeaderInsertParams struct {
	ElectedAt *string
	Now       *string
	ExpiresAt *string
	TTL       string
	LeaderID  string
}

type Queries

type Queries struct {
}

func New

func New() *Queries

func (*Queries) IndexExists

func (q *Queries) IndexExists(ctx context.Context, db DBTX, index string) (int64, error)

func (*Queries) JobCancel

func (q *Queries) JobCancel(ctx context.Context, db DBTX, arg *JobCancelParams) (*RiverJob, error)

Differs by necessity from other drivers because SQLite doesn't support `UPDATE` inside CTEs so we can't retry if running but select otherwise. Instead, the driver uses a transaction to optimisticaly try an update, but perform a subsequent fetch on a not found to return the right status.

I had to invert the last 'AND' expression below (was an 'ANT NOT) due to an sqlc bug. Something about sqlc's SQLite parser cannot detect a parameter inside an `AND NOT`.

func (*Queries) JobCountByAllStates added in v0.24.0

func (q *Queries) JobCountByAllStates(ctx context.Context, db DBTX) ([]*JobCountByAllStatesRow, error)

func (*Queries) JobCountByQueueAndState added in v0.24.0

func (q *Queries) JobCountByQueueAndState(ctx context.Context, db DBTX, queueNames []string) ([]*JobCountByQueueAndStateRow, error)

func (*Queries) JobCountByState

func (q *Queries) JobCountByState(ctx context.Context, db DBTX, state string) (int64, error)

func (*Queries) JobDelete

func (q *Queries) JobDelete(ctx context.Context, db DBTX, id int64) (*RiverJob, error)

Differs by necessity from other drivers because SQLite doesn't support `DELETE` inside CTEs so we can't delete if running but select otherwise. Instead, the driver uses a transaction to optimisticaly try a delete, but perform a subsequent fetch on a not found to return the right status.

func (*Queries) JobDeleteBefore

func (q *Queries) JobDeleteBefore(ctx context.Context, db DBTX, arg *JobDeleteBeforeParams) (sql.Result, error)

func (*Queries) JobDeleteMany added in v0.24.0

func (q *Queries) JobDeleteMany(ctx context.Context, db DBTX, max int64) ([]*RiverJob, error)

func (*Queries) JobGetAvailable

func (q *Queries) JobGetAvailable(ctx context.Context, db DBTX, arg *JobGetAvailableParams) ([]*RiverJob, error)

Differs from the Postgres version in that we don't have `FOR UPDATE SKIP LOCKED`. It doesn't exist in SQLite, but more aptly, there's only one writer on SQLite at a time, so nothing else has the rows locked.

func (*Queries) JobGetByID

func (q *Queries) JobGetByID(ctx context.Context, db DBTX, id int64) (*RiverJob, error)

func (*Queries) JobGetByIDMany

func (q *Queries) JobGetByIDMany(ctx context.Context, db DBTX, id []int64) ([]*RiverJob, error)

func (*Queries) JobGetByKindMany

func (q *Queries) JobGetByKindMany(ctx context.Context, db DBTX, kind []string) ([]*RiverJob, error)

func (*Queries) JobGetStuck

func (q *Queries) JobGetStuck(ctx context.Context, db DBTX, arg *JobGetStuckParams) ([]*RiverJob, error)

func (*Queries) JobInsertFast

func (q *Queries) JobInsertFast(ctx context.Context, db DBTX, arg *JobInsertFastParams) (*RiverJob, error)

Insert a job.

This is supposed to be a batch insert, but various limitations of the combined SQLite + sqlc has left me unable to find a way of injecting many arguments en masse (like how we slightly abuse arrays to pull it off for the Postgres drivers), so we loop over many insert operations instead, with the expectation that this may be fixable in the future. Because SQLite targets will often be local and therefore with a very minimal round trip compared to a network, looping over operations is probably okay performance-wise.

func (*Queries) JobInsertFastNoReturning

func (q *Queries) JobInsertFastNoReturning(ctx context.Context, db DBTX, arg *JobInsertFastNoReturningParams) (int64, error)

func (*Queries) JobInsertFull

func (q *Queries) JobInsertFull(ctx context.Context, db DBTX, arg *JobInsertFullParams) (*RiverJob, error)

func (*Queries) JobKindList added in v0.24.0

func (q *Queries) JobKindList(ctx context.Context, db DBTX, arg *JobKindListParams) ([]string, error)

func (*Queries) JobList

func (q *Queries) JobList(ctx context.Context, db DBTX, max int64) ([]*RiverJob, error)

func (*Queries) JobRescue

func (q *Queries) JobRescue(ctx context.Context, db DBTX, arg *JobRescueParams) error

Rescue a job.

This is supposed to rescue jobs in batches, but various limitations of the combined SQLite + sqlc has left me unable to find a way of injecting many arguments en masse (like how we slightly abuse arrays to pull it off for the Postgres drivers), and SQLite doesn't support `UPDATE` in CTEs, so we loop over many insert operations instead, with the expectation that this may be fixable in the future. Because SQLite targets will often be local and with a very minimal round trip compared to a network, looping over operations is probably okay performance-wise.

func (*Queries) JobRetry

func (q *Queries) JobRetry(ctx context.Context, db DBTX, arg *JobRetryParams) (*RiverJob, error)

Differs by necessity from other drivers because SQLite doesn't support `UPDATE` inside CTEs so we can't retry if running but select otherwise. Instead, the driver uses a transaction to optimisticaly try an update, but perform a subsequent fetch on a not found to return the right status.

I had to invert the last 'AND' expression below (was an 'AND NOT') due to an sqlc bug. Something about sqlc's SQLite parser cannot detect a parameter inside an `AND NOT`. I'll try to get this fixed upstream at some point so we can clean this up and keep it more like the Postgres version.

func (*Queries) JobScheduleGetCollision

func (q *Queries) JobScheduleGetCollision(ctx context.Context, db DBTX, arg *JobScheduleGetCollisionParams) (*RiverJob, error)

func (*Queries) JobScheduleGetEligible

func (q *Queries) JobScheduleGetEligible(ctx context.Context, db DBTX, arg *JobScheduleGetEligibleParams) ([]*RiverJob, error)

func (*Queries) JobScheduleSetAvailable

func (q *Queries) JobScheduleSetAvailable(ctx context.Context, db DBTX, id []int64) ([]*RiverJob, error)

func (*Queries) JobScheduleSetDiscarded

func (q *Queries) JobScheduleSetDiscarded(ctx context.Context, db DBTX, arg *JobScheduleSetDiscardedParams) ([]*RiverJob, error)

func (*Queries) JobSetMetadataIfNotRunning

func (q *Queries) JobSetMetadataIfNotRunning(ctx context.Context, db DBTX, arg *JobSetMetadataIfNotRunningParams) (*RiverJob, error)

This doesn't exist under the Postgres driver, but needed as an extra query for JobSetStateIfRunning to use when falling back to non-running jobs.

func (*Queries) JobSetStateIfRunning

func (q *Queries) JobSetStateIfRunning(ctx context.Context, db DBTX, arg *JobSetStateIfRunningParams) (*RiverJob, error)

Differs significantly from the Postgres version in that it can't do a bulk update, and since sqlc doesn't support `UPDATE` in CTEs, we need separate queries like JobSetMetadataIfNotRunning to do the fallback work.

func (*Queries) JobUpdate

func (q *Queries) JobUpdate(ctx context.Context, db DBTX, arg *JobUpdateParams) (*RiverJob, error)

func (*Queries) JobUpdateFull added in v0.29.0

func (q *Queries) JobUpdateFull(ctx context.Context, db DBTX, arg *JobUpdateFullParams) (*RiverJob, error)

A generalized update for any property on a job. This brings in a large number of parameters and therefore may be more suitable for testing than production.

func (*Queries) LeaderAttemptElect

func (q *Queries) LeaderAttemptElect(ctx context.Context, db DBTX, arg *LeaderAttemptElectParams) (int64, error)

func (*Queries) LeaderAttemptReelect

func (q *Queries) LeaderAttemptReelect(ctx context.Context, db DBTX, arg *LeaderAttemptReelectParams) (int64, error)

func (*Queries) LeaderDeleteExpired

func (q *Queries) LeaderDeleteExpired(ctx context.Context, db DBTX, now *string) (int64, error)

func (*Queries) LeaderGetElectedLeader

func (q *Queries) LeaderGetElectedLeader(ctx context.Context, db DBTX) (*RiverLeader, error)

func (*Queries) LeaderInsert

func (q *Queries) LeaderInsert(ctx context.Context, db DBTX, arg *LeaderInsertParams) (*RiverLeader, error)

func (*Queries) LeaderResign

func (q *Queries) LeaderResign(ctx context.Context, db DBTX, leaderID string) (int64, error)

func (*Queries) QueueCreateOrSetUpdatedAt

func (q *Queries) QueueCreateOrSetUpdatedAt(ctx context.Context, db DBTX, arg *QueueCreateOrSetUpdatedAtParams) (*RiverQueue, error)

func (*Queries) QueueDeleteExpired

func (q *Queries) QueueDeleteExpired(ctx context.Context, db DBTX, arg *QueueDeleteExpiredParams) ([]*RiverQueue, error)

func (*Queries) QueueGet

func (q *Queries) QueueGet(ctx context.Context, db DBTX, name string) (*RiverQueue, error)

func (*Queries) QueueList

func (q *Queries) QueueList(ctx context.Context, db DBTX, max int64) ([]*RiverQueue, error)

func (*Queries) QueueNameList added in v0.24.0

func (q *Queries) QueueNameList(ctx context.Context, db DBTX, arg *QueueNameListParams) ([]string, error)

func (*Queries) QueuePause

func (q *Queries) QueuePause(ctx context.Context, db DBTX, arg *QueuePauseParams) (int64, error)

func (*Queries) QueueResume

func (q *Queries) QueueResume(ctx context.Context, db DBTX, arg *QueueResumeParams) (int64, error)

func (*Queries) QueueUpdate

func (q *Queries) QueueUpdate(ctx context.Context, db DBTX, arg *QueueUpdateParams) (*RiverQueue, error)

func (*Queries) RiverMigrationDeleteAssumingMainMany

func (q *Queries) RiverMigrationDeleteAssumingMainMany(ctx context.Context, db DBTX, version []int64) ([]*RiverMigrationDeleteAssumingMainManyRow, error)

func (*Queries) RiverMigrationDeleteByLineAndVersionMany

func (q *Queries) RiverMigrationDeleteByLineAndVersionMany(ctx context.Context, db DBTX, arg *RiverMigrationDeleteByLineAndVersionManyParams) ([]*RiverMigration, error)

func (*Queries) RiverMigrationGetAllAssumingMain

func (q *Queries) RiverMigrationGetAllAssumingMain(ctx context.Context, db DBTX) ([]*RiverMigrationGetAllAssumingMainRow, error)

This is a compatibility query for getting existing migrations before the `line` column was added to the table in version 005. We need to make sure to only select non-line properties so the query doesn't error on older schemas. (Even if we use `SELECT *` below, sqlc materializes it to a list of column names in the generated query.)

func (*Queries) RiverMigrationGetByLine

func (q *Queries) RiverMigrationGetByLine(ctx context.Context, db DBTX, line string) ([]*RiverMigration, error)

func (*Queries) RiverMigrationInsert

func (q *Queries) RiverMigrationInsert(ctx context.Context, db DBTX, arg *RiverMigrationInsertParams) (*RiverMigration, error)

Insert a migration.

This is supposed to be a batch insert, but various limitations of the combined SQLite + sqlc has left me unable to find a way of injecting many arguments en masse (like how we slightly abuse arrays to pull it off for the Postgres drivers), so we loop over many insert operations instead, with the expectation that this may be fixable in the future. Because SQLite targets will often be local and therefore with a very minimal round trip compared to a network, looping over operations is probably okay performance-wise.

func (*Queries) RiverMigrationInsertAssumingMain

func (q *Queries) RiverMigrationInsertAssumingMain(ctx context.Context, db DBTX, version int64) (*RiverMigrationInsertAssumingMainRow, error)

func (*Queries) TableExists

func (q *Queries) TableExists(ctx context.Context, db DBTX, table string) (int64, error)

type QueueCreateOrSetUpdatedAtParams

type QueueCreateOrSetUpdatedAtParams struct {
	Now       *string
	Metadata  []byte
	Name      string
	PausedAt  *string
	UpdatedAt *string
}

type QueueDeleteExpiredParams

type QueueDeleteExpiredParams struct {
	UpdatedAtHorizon time.Time
	Max              int64
}

type QueueNameListParams added in v0.24.0

type QueueNameListParams struct {
	After   string
	Match   string
	Exclude []string
	Max     int64
}

type QueuePauseParams

type QueuePauseParams struct {
	Now  *string
	Name string
}

type QueueResumeParams

type QueueResumeParams struct {
	Now  *string
	Name string
}

type QueueUpdateParams

type QueueUpdateParams struct {
	MetadataDoUpdate bool
	Metadata         []byte
	Name             string
}

type RiverClient

type RiverClient struct {
	ID        string
	CreatedAt time.Time
	Metadata  []byte
	PausedAt  *time.Time
	UpdatedAt time.Time
}

type RiverClientQueue

type RiverClientQueue struct {
	RiverClientID    string
	Name             string
	CreatedAt        time.Time
	MaxWorkers       int64
	Metadata         []byte
	NumJobsCompleted int64
	NumJobsRunning   int64
	UpdatedAt        time.Time
}

type RiverJob

type RiverJob struct {
	ID           int64
	Args         []byte
	Attempt      int64
	AttemptedAt  *time.Time
	AttemptedBy  []byte
	CreatedAt    time.Time
	Errors       []byte
	FinalizedAt  *time.Time
	Kind         string
	MaxAttempts  int64
	Metadata     []byte
	Priority     int64
	Queue        string
	State        string
	ScheduledAt  time.Time
	Tags         []byte
	UniqueKey    []byte
	UniqueStates *int64
}

type RiverLeader

type RiverLeader struct {
	ElectedAt time.Time
	ExpiresAt time.Time
	LeaderID  string
	Name      string
}

type RiverMigration

type RiverMigration struct {
	Line      string
	Version   int64
	CreatedAt time.Time
}

type RiverMigrationDeleteAssumingMainManyRow

type RiverMigrationDeleteAssumingMainManyRow struct {
	CreatedAt time.Time
	Version   int64
}

type RiverMigrationDeleteByLineAndVersionManyParams

type RiverMigrationDeleteByLineAndVersionManyParams struct {
	Line    string
	Version []int64
}

type RiverMigrationGetAllAssumingMainRow

type RiverMigrationGetAllAssumingMainRow struct {
	CreatedAt time.Time
	Version   int64
}

type RiverMigrationInsertAssumingMainRow

type RiverMigrationInsertAssumingMainRow struct {
	CreatedAt time.Time
	Version   int64
}

type RiverMigrationInsertParams

type RiverMigrationInsertParams struct {
	Line    string
	Version int64
}

type RiverQueue

type RiverQueue struct {
	Name      string
	CreatedAt time.Time
	Metadata  []byte
	PausedAt  *time.Time
	UpdatedAt time.Time
}

type SqliteMaster

type SqliteMaster struct {
	Type     *string
	Name     *string
	TblName  *string
	Rootpage *int64
	Sql      *string
}

Jump to

Keyboard shortcuts

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