• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / jobs / 21442227581

28 Jan 2026 02:30PM UTC coverage: 56.301% (-3.1%) from 59.413%
21442227581

push

github

daycry
Improve queue handling and job execution logic

Refactor queue worker to support background execution and improve job fetching logic. Update JobLifecycleCoordinator to prioritize job-specific and default timeouts without a global cap. Replace custom UUID generation with service-based UUID v7 in JobLogger. Ensure queue scheduling uses application timezone for consistency.

13 of 24 new or added lines in 5 files covered. (54.17%)

63 existing lines in 4 files now uncovered.

1175 of 2087 relevant lines covered (56.3%)

4.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Libraries/DeadLetterQueue.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Queues.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Jobs\Libraries;
15

16
use Daycry\Jobs\Job;
17
use Throwable;
18

19
/**
20
 * Dead Letter Queue manager.
21
 * Handles jobs that have permanently failed after exhausting all retries.
22
 */
23
class DeadLetterQueue
24
{
25
    /**
26
     * Move a job to the dead letter queue.
27
     *
28
     * @param Job    $job      Failed job
29
     * @param string $reason   Failure reason
30
     * @param int    $attempts Number of attempts made
31
     */
32
    public function store(Job $job, string $reason, int $attempts): void
33
    {
UNCOV
34
        $config  = ConfigCache::get();
×
UNCOV
35
        $dlqName = $config->deadLetterQueue;
×
36

UNCOV
37
        if (! $dlqName) {
×
UNCOV
38
            return; // DLQ disabled
×
39
        }
40

41
        // Add metadata about the failure
42
        $metadata = [
×
43
            'dlq_reason'     => $reason,
×
44
            'dlq_timestamp'  => date('Y-m-d H:i:s'),
×
45
            'dlq_attempts'   => $attempts,
×
46
            'original_queue' => $job->getQueue(),
×
47
        ];
×
48

49
        // Create a new job instance for DLQ
50
        $dlqJob = clone $job;
×
51
        $dlqJob->queue($dlqName);
×
52

53
        // Store metadata in payload if possible
54
        $payload = $dlqJob->getPayload();
×
55
        if (is_array($payload)) {
×
56
            $payload['_dlq_metadata'] = $metadata;
×
57
            $dlqJob->setPayload($payload);
×
58
        }
59

60
        // Push to DLQ
61
        try {
62
            $dlqJob->push();
×
63
            log_message('info', "Job {$job->getName()} moved to DLQ after {$attempts} attempts. Reason: {$reason}");
×
64
        } catch (Throwable $e) {
×
65
            log_message('error', "Failed to store job in DLQ: {$e->getMessage()}");
×
66
        }
67
    }
68

69
    /**
70
     * Get statistics about dead letter queue.
71
     */
72
    public function getStats(): array
73
    {
74
        $config  = ConfigCache::get();
×
75
        $dlqName = $config->deadLetterQueue;
×
76

77
        if (! $dlqName) {
×
78
            return ['enabled' => false];
×
79
        }
80

81
        // This would require queue backend support to count jobs
82
        return [
×
83
            'enabled' => true,
×
84
            'queue'   => $dlqName,
×
85
        ];
×
86
    }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc