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

daycry / jobs / 21145580946

19 Jan 2026 04:55PM UTC coverage: 58.025% (-4.5%) from 62.567%
21145580946

push

github

daycry
Add security, performance, and health features; simplify architecture

Introduces shell command whitelisting, smart token detection, per-queue rate limiting, dead letter queue, job timeout protection, config caching, and a health monitoring command. Refactors architecture by consolidating traits, removing the CompletionStrategy pattern, and unifying retry policies under RetryPolicyFixed. Updates documentation and tests to reflect new features and architectural changes, ensuring backward compatibility and improved reliability.

143 of 340 new or added lines in 20 files covered. (42.06%)

1 existing line in 1 file now uncovered.

1193 of 2056 relevant lines covered (58.03%)

4.44 hits per line

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

14.29
/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
    {
34
        $config  = ConfigCache::get();
1✔
35
        $dlqName = $config->deadLetterQueue;
1✔
36

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

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

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

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

60
        // Push to DLQ
61
        try {
NEW
62
            $dlqJob->push();
×
NEW
63
            log_message('info', "Job {$job->getName()} moved to DLQ after {$attempts} attempts. Reason: {$reason}");
×
NEW
64
        } catch (Throwable $e) {
×
NEW
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
    {
NEW
74
        $config  = ConfigCache::get();
×
NEW
75
        $dlqName = $config->deadLetterQueue;
×
76

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

81
        // This would require queue backend support to count jobs
NEW
82
        return [
×
NEW
83
            'enabled' => true,
×
NEW
84
            'queue'   => $dlqName,
×
NEW
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