Versions in this module Expand all Collapse all v0 v0.4.0 Jul 10, 2024 Changes in this version + const DefaultStatusField type Status + const Done + const Failed + const Queued type Task + Status Status type TaskQueryConfig + StatusField string v0.3.5 Jul 1, 2024 Changes in this version + const DefaultRunAtField type Task + RunAt time.Time + type TaskFunc func(tx *sql.Tx, args any) (any, error) type TaskQueryConfig + RunAtField string + type TaskRegistry struct + func NewTaskRegistry() *TaskRegistry + func (r *TaskRegistry) ApplyAsync(tx *sql.Tx, name string, args any, countdown *int, eta *time.Time) error + func (r *TaskRegistry) Call(tx *sql.Tx, name string, args any) (any, error) + func (r *TaskRegistry) Delay(tx *sql.Tx, name string, args any, countdown *int, eta *time.Time) error + func (r *TaskRegistry) Register(name string, f TaskFunc) + func (r *TaskRegistry) Unregister(name string) v0.3.4 Jun 29, 2024 v0.3.3 Jun 28, 2024 v0.3.2 Jun 28, 2024 v0.3.1 Jun 28, 2024 Changes in this version + type PostgresTaskRepository struct + func (r *PostgresTaskRepository) Create(tx *sql.Tx, t *Task) error + func (r *PostgresTaskRepository) CreateTable(tx *sql.Tx) error + func (r *PostgresTaskRepository) DeleteAll(tx *sql.Tx) error + func (r *PostgresTaskRepository) DeleteOld(tx *sql.Tx, moment time.Time) (int, error) + func (r *PostgresTaskRepository) FindNext(tx *sql.Tx) (*Task, error) + func (r *PostgresTaskRepository) Save(tx *sql.Tx, t *Task) error type TaskRepository + func NewPostgresTaskRepository(config ...TaskQueryConfig) TaskRepository v0.3.0 Jun 28, 2024 Changes in this version + const DefaultArgsField + const DefaultCreatedAtField + const DefaultErrorField + const DefaultFinishedAtField + const DefaultFuncField + const DefaultIdField + const DefaultIsProcessedField + const DefaultIsSuccessField + const DefaultResultField + const DefaultStartedAtField + const DefaultTableName + type PostgresQueueRepository struct + func (r *PostgresQueueRepository) Create(tx *sql.Tx, t *Task) error + func (r *PostgresQueueRepository) CreateTable(tx *sql.Tx) error + func (r *PostgresQueueRepository) DeleteAll(tx *sql.Tx) error + func (r *PostgresQueueRepository) DeleteOld(tx *sql.Tx, moment time.Time) (int, error) + func (r *PostgresQueueRepository) FindNext(tx *sql.Tx) (*Task, error) + func (r *PostgresQueueRepository) Save(tx *sql.Tx, t *Task) error + type Status uint8 + type Task struct + Args any + CreatedAt time.Time + Error *string + FinishedAt *time.Time + Func string + Id int + IsProcessed bool + IsSuccess *bool + Result any + StartedAt *time.Time + func (e Task) LogValue() slog.Value + type TaskHandler func(tx *sql.Tx, task *Task) error + type TaskQueryConfig struct + ArgsField string + CreatedAtField string + ErrorField string + FinishedAtField string + FuncField string + IdField string + IsProcessedField string + IsSuccessField string + ResultField string + StartedAtField string + TableName string + type TaskRepository interface + Create func(tx *sql.Tx, task *Task) error + DeleteOld func(tx *sql.Tx, t time.Time) (int, error) + FindNext func(tx *sql.Tx) (*Task, error) + Save func(tx *sql.Tx, task *Task) error + func NewPostgresQueueRepository(config ...TaskQueryConfig) TaskRepository + type Worker struct + func NewWorker(db *sql.DB, config *WorkerConfig) *Worker + func (w *Worker) Start() + func (w *Worker) StartContext(ctx context.Context) + func (w *Worker) Stop() + type WorkerConfig struct + Cron string + Handler TaskHandler + Log *slog.Logger + Repository TaskRepository