Versions in this module Expand all Collapse all v0 v0.1.0 Oct 31, 2026 Changes in this version + const DefaultMaxRetries + const DefaultPriority + var ErrTaskConflict = dharatype.ErrTaskConflict + var ErrTaskNotAvailable = dharatype.ErrTaskNotAvailable + var ErrTaskNotDead = dharatype.ErrTaskNotDead + var ErrTaskNotFound = dharatype.ErrTaskNotFound + var ErrTaskOwnershipLost = dharatype.ErrTaskOwnershipLost + var MigrationFS fs.FS = mustSub(migrationsRoot, "migrations") + type Client struct + func NewClient(pool *pgxpool.Pool) *Client + func (c *Client) CancelTask(ctx context.Context, id string) (*Task, error) + func (c *Client) Enqueue(ctx context.Context, taskType string, payload any, opts ...EnqueueOption) (*EnqueueResult, error) + func (c *Client) EnqueueTx(ctx context.Context, tx pgx.Tx, taskType string, payload any, ...) (*EnqueueResult, error) + func (c *Client) GetTask(ctx context.Context, id string) (*Task, error) + func (c *Client) Insert(ctx context.Context, params InsertParams) (*EnqueueResult, error) + func (c *Client) InsertTx(ctx context.Context, tx pgx.Tx, params InsertParams) (*EnqueueResult, error) + func (c *Client) ListTasks(ctx context.Context, filter TaskListFilter) ([]Task, int, error) + func (c *Client) Metrics() MetricsSnapshot + func (c *Client) MetricsHandler() http.Handler + func (c *Client) QueueMetrics(ctx context.Context) (*QueueMetrics, error) + func (c *Client) RetryTask(ctx context.Context, id string) (*Task, error) + type EnqueueOption func(*InsertParams) + func WithIdempotencyKey(key string) EnqueueOption + func WithMaxRetries(maxRetries int) EnqueueOption + func WithPriority(priority int) EnqueueOption + func WithRunAt(runAt time.Time) EnqueueOption + type EnqueueResult struct + Duplicate bool + Task *Task + type HandlerFunc = dharatype.HandlerFunc + type InsertParams struct + IdempotencyKey *string + MaxRetries *int + Payload json.RawMessage + Priority *int + RunAt *time.Time + Type string + func (p *InsertParams) Normalize(now time.Time) + func (p *InsertParams) Validate(now time.Time) error + type MetricsSnapshot struct + ClaimErrorsTotal int64 + ReaperFailuresTotal int64 + TaskAttemptFailuresTotal int64 + TasksCanceledTotal int64 + TasksCompletedTotal int64 + TasksDeadTotal int64 + TasksEnqueuedTotal int64 + TasksReapedTotal int64 + TasksRetriedTotal int64 + WorkersActive int64 + WorkersInflight int64 + type MigrationResult struct + Skipped int + Versions []string + func Migrate(ctx context.Context, pool *pgxpool.Pool) (MigrationResult, error) + func MigrateDown(ctx context.Context, pool *pgxpool.Pool, steps int) (MigrationResult, error) + func MigrateDownWith(ctx context.Context, pool *pgxpool.Pool, fsys fs.FS, steps int) (MigrationResult, error) + func MigrateWith(ctx context.Context, pool *pgxpool.Pool, fsys fs.FS) (MigrationResult, error) + type QueueMetrics struct + TasksCanceled int64 + TasksCompleted int64 + TasksDead int64 + TasksPending int64 + TasksPendingDelayed int64 + TasksPendingReady int64 + TasksRunning int64 + type Task struct + Attempts int + CompletedAt *time.Time + CreatedAt time.Time + ID uuid.UUID + IdempotencyKey *string + LastError *string + MaxRetries int + Priority int + RunAt time.Time + StartedAt *time.Time + Status TaskStatus + Type string + UpdatedAt time.Time + type TaskListFilter = dharatype.TaskListFilter + type TaskListResult struct + Tasks []Task + Total int + type TaskStatus string + const TaskStatusCanceled + const TaskStatusCompleted + const TaskStatusDead + const TaskStatusPending + const TaskStatusRunning + type ValidationError = dharatype.ValidationError + type Worker struct + func NewWorker(pool *pgxpool.Pool, opts ...WorkerOption) *Worker + func (w *Worker) Metrics() MetricsSnapshot + func (w *Worker) MetricsHandler() http.Handler + func (w *Worker) RegisterHandler(taskType string, handler HandlerFunc) + func (w *Worker) Start(ctx context.Context) error + func (w *Worker) Stop() + type WorkerOption func(*workerConfig) + func WithBaseBackoff(d time.Duration) WorkerOption + func WithHandlerTimeout(d time.Duration) WorkerOption + func WithHeartbeatInterval(d time.Duration) WorkerOption + func WithLogger(l *slog.Logger) WorkerOption + func WithMaxBackoff(d time.Duration) WorkerOption + func WithMaxWorkers(n int) WorkerOption + func WithPollInterval(d time.Duration) WorkerOption + func WithReaperInterval(d time.Duration) WorkerOption + func WithShutdownTimeout(d time.Duration) WorkerOption + func WithStuckThreshold(d time.Duration) WorkerOption + func WithWorkerPrefix(prefix string) WorkerOption