recovery

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package recovery provides job recovery and orphan detection for GopherQueue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RecoveryConfig

type RecoveryConfig struct {
	// How often to scan for stuck jobs
	ScanInterval time.Duration

	// How long a job can be running before considered stuck
	VisibilityTimeout time.Duration

	// Maximum jobs to recover per scan
	BatchSize int
}

RecoveryConfig configures recovery behavior.

func DefaultRecoveryConfig

func DefaultRecoveryConfig() *RecoveryConfig

DefaultRecoveryConfig returns sensible defaults.

type RecoveryManager

type RecoveryManager interface {
	// Start begins the recovery manager.
	Start(ctx context.Context) error

	// Stop gracefully shuts down the recovery manager.
	Stop(ctx context.Context) error

	// RecoverStuckJobs scans for and recovers stuck jobs.
	RecoverStuckJobs(ctx context.Context) (int, error)

	// RecoverOrphanedJobs scans for and recovers orphaned jobs.
	RecoverOrphanedJobs(ctx context.Context) (int, error)

	// Stats returns recovery statistics.
	Stats() *RecoveryStats

	// IsHealthy returns whether the recovery manager is operating normally.
	IsHealthy() bool
}

RecoveryManager handles detection and recovery of stuck jobs.

type RecoveryStats

type RecoveryStats struct {
	StuckJobsRecovered    int64         `json:"stuck_jobs_recovered"`
	OrphanedJobsRecovered int64         `json:"orphaned_jobs_recovered"`
	LastRecoveryTime      time.Time     `json:"last_recovery_time"`
	LastRecoveryDuration  time.Duration `json:"last_recovery_duration"`
	Healthy               bool          `json:"healthy"`
}

RecoveryStats contains recovery metrics.

type SimpleRecoveryManager

type SimpleRecoveryManager struct {
	// contains filtered or unexported fields
}

SimpleRecoveryManager is a basic recovery manager implementation.

func NewSimpleRecoveryManager

func NewSimpleRecoveryManager(store persistence.JobStore, config *RecoveryConfig) *SimpleRecoveryManager

NewSimpleRecoveryManager creates a new recovery manager.

func (*SimpleRecoveryManager) IsHealthy

func (r *SimpleRecoveryManager) IsHealthy() bool

IsHealthy returns whether the recovery manager is operating normally.

func (*SimpleRecoveryManager) RecoverOrphanedJobs

func (r *SimpleRecoveryManager) RecoverOrphanedJobs(ctx context.Context) (int, error)

RecoverOrphanedJobs scans for and recovers orphaned jobs.

func (*SimpleRecoveryManager) RecoverStuckJobs

func (r *SimpleRecoveryManager) RecoverStuckJobs(ctx context.Context) (int, error)

RecoverStuckJobs scans for and recovers stuck jobs.

func (*SimpleRecoveryManager) Start

Start begins the recovery manager.

func (*SimpleRecoveryManager) Stats

Stats returns recovery statistics.

func (*SimpleRecoveryManager) Stop

Stop gracefully shuts down the recovery manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL