class JoobQ::FailHandler(T)

Overview

The FailHandler module in JoobQ is responsible for managing jobs that encounter errors during execution. This fail handler provides robust retry logic with exponential backoff, detailed logging, and dead letter queue management to ensure reliability and traceability of job failures.

Key Features

1. Enhanced Logging

The FailHandler includes more detailed logging capabilities:

2. Retry Logic with Exponential Backoff

The FailHandler will retry jobs up to a specified maximum number of retries (job.retries). The retry delay is calculated using an exponential backoff strategy to avoid overwhelming the system:

3. Dead Letter Queue Handling

When a job exhausts its retry attempts, it is moved to a "dead letter" queue for further inspection and manual intervention:

Usage

The FailHandler is automatically invoked when a job execution fails:

JoobQ::FailHandler.call(job, start_time, exception, queue)

The method takes four parameters:

Exponential Backoff Calculation

The backoff is calculated using the formula:

(2 ** retry_count) * base_delay

Logging Examples

Configuration

Future Improvements

Defined in:

joobq/fail_handler.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(queue : BaseQueue, metrics : Metrics) #

[View source]

Instance Method Detail

def handle_failure(job : T, ex : Exception) #

[View source]