package repository

import "github.com/go-arrower/arrower/contexts/admin/internal/interfaces/repository"

Index

Types

type PostgresJobsRepository

type PostgresJobsRepository struct {
	postgres.BaseRepository[*models.Queries]
}

func NewPostgresJobsRepository

func NewPostgresJobsRepository(pg *pgxpool.Pool) *PostgresJobsRepository

func (*PostgresJobsRepository) DeleteByID

func (repo *PostgresJobsRepository) DeleteByID(ctx context.Context, jobID string) error

DeleteByID attempts to delete a Job with the given jobID. If a Job is currently processed by a worker, the row in the db is locked until the worker succeeds or fails. In this case the delete command would block until the lock is freed (which potentially could take a long time). Because of that, delete will time out after, assuming that if the database needs longer to execute the query, it means the row is locked.

func (*PostgresJobsRepository) FindAllQueueNames

func (repo *PostgresJobsRepository) FindAllQueueNames(ctx context.Context) (jobs.QueueNames, error)

func (*PostgresJobsRepository) FinishedJobs

func (repo *PostgresJobsRepository) FinishedJobs(ctx context.Context, filter jobs.Filter) ([]jobs.Job, error)

func (*PostgresJobsRepository) FinishedJobsTotal

func (repo *PostgresJobsRepository) FinishedJobsTotal(ctx context.Context, filter jobs.Filter) (int64, error)

func (*PostgresJobsRepository) PendingJobs

func (repo *PostgresJobsRepository) PendingJobs(ctx context.Context, queue jobs.QueueName) ([]jobs.Job, error)

func (*PostgresJobsRepository) QueueKPIs

func (repo *PostgresJobsRepository) QueueKPIs(ctx context.Context, queue jobs.QueueName) (jobs.QueueKPIs, error)

func (*PostgresJobsRepository) RunJobAt

func (repo *PostgresJobsRepository) RunJobAt(ctx context.Context, jobID string, runAt time.Time) error

RunJobAt attempts to reschedule a Job with the given runAt time.

RunJobAt will time out after one second, assuming that if the database needs longer to execute the query, it means the row is locked by an active worker processing the job.

func (*PostgresJobsRepository) Schedules

func (repo *PostgresJobsRepository) Schedules(ctx context.Context) ([]jobs.Schedule, error)

func (*PostgresJobsRepository) WorkerPools

func (repo *PostgresJobsRepository) WorkerPools(ctx context.Context) ([]jobs.WorkerPool, error)

Source Files

jobs.postgres.repository.go

Directories

PathSynopsis
contexts/admin/internal/interfaces/repository/models
Version
v0.0.0-20250311203644-ab26c1152cb4 (latest)
Published
Mar 11, 2025
Platform
linux/amd64
Imports
11 packages
Last checked
15 minutes ago

Tools for package owners.