Documentation
¶
Overview ¶
Package recovery provides job recovery and orphan detection for GopherQueue.
Index ¶
- type RecoveryConfig
- type RecoveryManager
- type RecoveryStats
- type SimpleRecoveryManager
- func (r *SimpleRecoveryManager) IsHealthy() bool
- func (r *SimpleRecoveryManager) RecoverOrphanedJobs(ctx context.Context) (int, error)
- func (r *SimpleRecoveryManager) RecoverStuckJobs(ctx context.Context) (int, error)
- func (r *SimpleRecoveryManager) Start(ctx context.Context) error
- func (r *SimpleRecoveryManager) Stats() *RecoveryStats
- func (r *SimpleRecoveryManager) Stop(ctx context.Context) error
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 ¶
func (r *SimpleRecoveryManager) Start(ctx context.Context) error
Start begins the recovery manager.
func (*SimpleRecoveryManager) Stats ¶
func (r *SimpleRecoveryManager) Stats() *RecoveryStats
Stats returns recovery statistics.