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

daycry / jobs / 21140192718

19 Jan 2026 01:58PM UTC coverage: 62.567% (-0.1%) from 62.662%
21140192718

push

github

daycry
Delegate job removal from QueueCompletionStrategy

QueueCompletionStrategy no longer calls removeJob on success or failure. Responsibility for job removal is now delegated to QueueRunCommand/RequeueHelper for improved metrics and consistency. Updated tests to reflect that removeJob is not called by the strategy.

1160 of 1854 relevant lines covered (62.57%)

4.74 hits per line

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

83.87
/src/Queues/SyncQueue.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\Queues;
15

16
use Daycry\Jobs\Execution\ExecutionContext;
17
use Daycry\Jobs\Execution\JobLifecycleCoordinator;
18
use Daycry\Jobs\Interfaces\QueueInterface;
19
use Daycry\Jobs\Interfaces\WorkerInterface;
20
/**
21
 * Synchronous (in-process) queue implementation.
22
 *
23
 * Contract notes:
24
 *  - enqueue(): executes the job immediately through JobExecutor and returns a synthetic identifier.
25
 *  - No watch()/removeJob(): it is not a WorkerInterface implementation by design.
26
 *
27
 * Use cases: testing, local development, or fallback when no async backend is desired.
28
 */
29
use Daycry\Jobs\Job;
30
use Daycry\Jobs\Job as DomainJob;
31

32
class SyncQueue extends BaseQueue implements QueueInterface, WorkerInterface
33
{
34
    public function enqueue(object $data): string
35
    {
36
        $identifier = $this->generateId(prefix: 'sync', bytes: 6);
2✔
37
        if ($data instanceof Job) {
2✔
38
            $job = $data; // preserve callbackDescriptor & closures
2✔
39
        } else {
40
            $data->identifier = $identifier;
×
41
            $job              = Job::fromQueueRecord($data);
×
42
        }
43

44
        $cfg = config('Jobs');
2✔
45
        if ($data instanceof Job) {
2✔
46
            $queueName = $job->getQueue() ?? 'default';
2✔
47
        } else {
48
            $queueName = $job->getQueue() ?? ($data->queue ?? 'default');
×
49
        }
50
        $context = new ExecutionContext(
2✔
51
            source: 'queue',
2✔
52
            maxRetries: $job->getMaxRetries() ?? 0,
2✔
53
            notifyOnSuccess: method_exists($job, 'shouldNotifyOnSuccess') ? $job->shouldNotifyOnSuccess() : false,
2✔
54
            notifyOnFailure: method_exists($job, 'shouldNotifyOnFailure') ? $job->shouldNotifyOnFailure() : false,
2✔
55
            singleInstance: $job->isSingleInstance(),
2✔
56
            queueName: $queueName,
2✔
57
            queueWorker: $this,
2✔
58
            retryConfig: [
2✔
59
                'strategy'   => $cfg->retryBackoffStrategy,
2✔
60
                'base'       => $cfg->retryBackoffBase,
2✔
61
                'multiplier' => $cfg->retryBackoffMultiplier,
2✔
62
                'jitter'     => $cfg->retryBackoffJitter,
2✔
63
                'max'        => $cfg->retryBackoffMax,
2✔
64
            ],
2✔
65
            eventsEnabled: true,
2✔
66
            meta: [],
2✔
67
        );
2✔
68

69
        (new JobLifecycleCoordinator())->run($job, $context);
2✔
70

71
        return $identifier;
2✔
72
    }
73

74
    // WorkerInterface implementation (minimal / no-op)
75
    public function watch(string $queue)
76
    {
77
        return null; // Sync queue doesn't support pulling jobs (they run immediately)
×
78
    }
79

80
    public function removeJob(DomainJob $job, bool $recreate = false): bool
81
    {
82
        // In sync mode retries would already have been performed inline; nothing to remove.
83
        return true;
×
84
    }
85
}
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