Versions in this module Expand all Collapse all v1 v1.7.4 Aug 14, 2026 Changes in this version + const DefaultQueue + var ErrEmptyJobType = errors.New("job type cannot be empty") + var ErrExecutorRunning = errors.New("job: executor is already running") + var ErrJobNotFound = errors.New("job not found") + var ErrJobStateConflict = errors.New("job state conflict") + var ErrNilJob = errors.New("job cannot be nil") + var ErrStopTimeout = errors.New("job: executor stop timed out") + func ReportProgress(ctx context.Context, progress int) + type AttemptError struct + At int64 + Attempt int + Error string + type Config struct + CleanupInterval time.Duration + Concurrency int + HeartbeatInterval time.Duration + JobTimeout time.Duration + ProgressInterval time.Duration + Queues []string + RecoverInterval time.Duration + Retention time.Duration + RetryDelay time.Duration + RetryJitter bool + RetryMaxDelay time.Duration + RetryStrategy RetryStrategy + ShutdownTimeout time.Duration + StaleTimeout time.Duration + func DefaultConfig() Config + func (c Config) Validate() error + func (c Config) WithCleanupInterval(interval time.Duration) Config + func (c Config) WithConcurrency(n int) Config + func (c Config) WithHeartbeatInterval(interval time.Duration) Config + func (c Config) WithJobTimeout(timeout time.Duration) Config + func (c Config) WithProgressInterval(interval time.Duration) Config + func (c Config) WithQueues(queues ...string) Config + func (c Config) WithRecoverInterval(interval time.Duration) Config + func (c Config) WithRetention(d time.Duration) Config + func (c Config) WithRetryDelay(delay time.Duration) Config + func (c Config) WithRetryJitter(jitter bool) Config + func (c Config) WithRetryMaxDelay(delay time.Duration) Config + func (c Config) WithRetryStrategy(strategy RetryStrategy) Config + func (c Config) WithShutdownTimeout(timeout time.Duration) Config + func (c Config) WithStaleTimeout(timeout time.Duration) Config + type Executor struct + func NewExecutor(store Store, handler Handler, config Config) *Executor + func (e *Executor) IsRunning() bool + func (e *Executor) Register(jobType string, handler Handler) *Executor + func (e *Executor) Start(ctx context.Context) error + func (e *Executor) Stop() error + func (e *Executor) WithLogger(log logger.Logger) *Executor + type Failure struct + Error string + Errors []AttemptError + type Handler interface + Execute func(ctx context.Context, job *Job) error + type HandlerFunc func(ctx context.Context, job *Job) error + func (f HandlerFunc) Execute(ctx context.Context, job *Job) error + type Job struct + Attempts int + CompletedAt int64 + CreatedAt int64 + Error string + Errors []AttemptError + HeartbeatAt int64 + ID string + MaxAttempts int + Metadata map[string]string + Payload []byte + Progress int + Queue string + Result []byte + ScheduledAt int64 + StartedAt int64 + Status Status + Type string + func NewJob(jobType string, payload []byte) *Job + func (j *Job) IsTerminal() bool + func (j *Job) WithDelay(delay time.Duration) *Job + func (j *Job) WithMaxAttempts(maxAttempts int) *Job + func (j *Job) WithMetadata(key, value string) *Job + func (j *Job) WithPayload(payload []byte) *Job + func (j *Job) WithQueue(queue string) *Job + func (j *Job) WithScheduleAt(t time.Time) *Job + type JobFilter struct + Limit int + Offset int + Queue string + Since time.Time + Status Status + Type string + Until time.Time + type RetryStrategy string + const RetryStrategyExponential + const RetryStrategyFixed + type SQLStore struct + func NewSQLStore(db *gorm.DB, opts ...SQLStoreOption) (*SQLStore, error) + func (s *SQLStore) Cancel(ctx context.Context, queue, jobID string) error + func (s *SQLStore) Cleanup(ctx context.Context, retainFor time.Duration) (int64, error) + func (s *SQLStore) Complete(ctx context.Context, queue, jobID string, attempt int, result []byte) error + func (s *SQLStore) Delete(ctx context.Context, jobID string) error + func (s *SQLStore) Fail(ctx context.Context, queue, jobID string, attempt int, failure Failure) error + func (s *SQLStore) Get(ctx context.Context, jobID string) (*Job, error) + func (s *SQLStore) GetStats(ctx context.Context, queue string) (*Stats, error) + func (s *SQLStore) Heartbeat(ctx context.Context, queue, jobID string, attempt, progress int) (bool, error) + func (s *SQLStore) List(ctx context.Context, filter JobFilter) ([]*Job, error) + func (s *SQLStore) ListStaleRunning(ctx context.Context, queue string, since time.Time, limit int64) ([]*Job, error) + func (s *SQLStore) PopPending(ctx context.Context, queue string) (*Job, error) + func (s *SQLStore) Requeue(ctx context.Context, queue, jobID string) error + func (s *SQLStore) Retry(ctx context.Context, queue, jobID string, attempt int, retryAt time.Time, ...) error + func (s *SQLStore) Save(ctx context.Context, job *Job) error + type SQLStoreOption func(*SQLStore) + func WithTableName(name string) SQLStoreOption + type Stats struct + Cancelled int64 + Failed int64 + Pending int64 + Running int64 + Success int64 + type Status string + const StatusCancelled + const StatusFailed + const StatusPending + const StatusRunning + const StatusSuccess + type Store interface + Cancel func(ctx context.Context, queue, jobID string) error + Cleanup func(ctx context.Context, retainFor time.Duration) (int64, error) + Complete func(ctx context.Context, queue, jobID string, attempt int, result []byte) error + Delete func(ctx context.Context, jobID string) error + Fail func(ctx context.Context, queue, jobID string, attempt int, failure Failure) error + Get func(ctx context.Context, jobID string) (*Job, error) + GetStats func(ctx context.Context, queue string) (*Stats, error) + Heartbeat func(ctx context.Context, queue, jobID string, attempt, progress int) (bool, error) + List func(ctx context.Context, filter JobFilter) ([]*Job, error) + ListStaleRunning func(ctx context.Context, queue string, since time.Time, limit int64) ([]*Job, error) + PopPending func(ctx context.Context, queue string) (*Job, error) + Requeue func(ctx context.Context, queue, jobID string) error + Retry func(ctx context.Context, queue, jobID string, attempt int, retryAt time.Time, ...) error + Save func(ctx context.Context, job *Job) error