Documentation ¶
Index ¶
- Constants
- func AssertRetentionSchedule(ctx context.Context, db *sql.DB, queueName string, taskType queue.TaskType, ...) (err error)
- func AssertRetentionScheduleWithSpec(ctx context.Context, db *sql.DB, spec RetentionTaskSpec) (err error)
- func NewDequeuer(db *sql.DB, dbListener *pq.Listener, cfg config.Queue) queue.Dequeuer
- func NewDequeuerWithMetrics(db *sql.DB, dbListener *pq.Listener, cfg config.Queue) queue.Dequeuer
- func NewQueuer(db *sql.DB) queue.Queuer
- func NewQueuerWithMetrics(db *sql.DB) queue.Queuer
- func NewRetentionHandler(db *sql.DB) queue.TaskHandler
- func NewScheduler(db *sql.DB) queue.Scheduler
- func NewSchedulerWithMetrics(db *sql.DB) queue.Scheduler
- func SetupTables(ctx context.Context, db db.SQLDB, references []ForeignReference) (err error)
- type ForeignReference
- type RetentionTaskSpec
Constants ¶
const ( // MaintenanceTaskQueue task queue name used for all the periodic maintenance jobs. // These are internal queue internal tasks MaintenanceTaskQueue string = "queue-maintenance" // RetentionTask is finished task cleanup type RetentionTask queue.TaskType = "retention" )
const ( // TasksTable is the name of the Postgres table that is used for tasks TasksTable = "tasks" // SchedulesTable is the name of the Postgres table used for schedules SchedulesTable = "schedules" )
Variables ¶
This section is empty.
Functions ¶
func AssertRetentionSchedule ¶
func AssertRetentionSchedule(ctx context.Context, db *sql.DB, queueName string, taskType queue.TaskType, status queue.TaskStatus, age time.Duration) (err error)
AssertRetentionSchedule creates a new queue retention tasks for the supplied queue, finished tasks matching the supplied parameters will be deleted
func AssertRetentionScheduleWithSpec ¶ added in v2.4.1
func AssertRetentionScheduleWithSpec(ctx context.Context, db *sql.DB, spec RetentionTaskSpec) (err error)
AssertRetentionScheduleWithSpec ensures that a queue retention tasks exists with the provided task spec. The task is scheduled for a random minute throughout the hour. Use AssertRetentionSchedule to create simple retention tasks based on queue, type, and age. Callers should only use AssertRetentionScheduleWithSpec when the retention policy by age is not accurate enough for their needs.
An upsert pattern is used to ensure that this retention task is scheduled exactly once.
func NewDequeuer ¶
NewDequeuer creates a new postgres queue dequeuer
func NewDequeuerWithMetrics ¶
NewDequeuerWithMetrics creates a new postgres queue dequeuer with the default metrics enabled
func NewQueuerWithMetrics ¶
NewQueuerWithMetrics creates a new postgres queue queuer with metrics enabled
func NewRetentionHandler ¶
func NewRetentionHandler(db *sql.DB) queue.TaskHandler
NewRetentionHandler creates a task handler that will clean up old finished tasks
func NewScheduler ¶
NewScheduler creates a new postgres task scheduler
func NewSchedulerWithMetrics ¶
NewScheduler creates a new postgres task scheduler with metrics enabled
func SetupTables ¶
SetupTables sets up all the necessary tables, foreign keys and indexes.
This supports both: initial bootstrapping and changing of the reference list. However, it does not apply changes to an existing reference, this will do nothing.
Types ¶
type ForeignReference ¶
type ForeignReference struct { // ColumnName is a name of the colum in the `tasks` and `schedules` tables ColumnName string // ColumnType is a type of the colum in the `tasks` and `schedules` tables ColumnType string // ReferencedTable is a table name this column should be referencing ReferencedTable string // ReferencedColumn is a column name this column should be referencing ReferencedColumn string }
ForeignReference describes a foreign key reference in the queue system
type RetentionTaskSpec ¶ added in v2.4.1
type RetentionTaskSpec struct { handlers.SQLExecTaskSpec QueueName string `json:"queueName"` TaskType queue.TaskType `json:"taskType"` Status queue.TaskStatus `json:"status"` Age time.Duration `json:"age"` }
RetentionTaskSpec defines a SQL task to remove completed tasks that match given criteria.