spiral / framework

High-Performance PHP Framework
https://spiral.dev
MIT License
1.82k stars 89 forks source link

[spiral/queue] Adding TaskInterface and Task for the Queue component #1097

Closed msmakouz closed 7 months ago

msmakouz commented 7 months ago
Q A
Bugfix?
Breaks BC?
New feature? ✔️

This change will allow creating a task object from the queue, which will contain all the necessary data for its processing. After introducing scopes, it will be possible to request this object in the task handler and extract the necessary data from it.

use Spiral\Queue\JobHandler;
use Spiral\Queue\TaskInterface;

final class SomeJob extends JobHandler
{
    public function invoke(TaskInterface $task): void
    {
        $payload = $task->getPayload();
        $headers = $task->getHeaders();
        $name = $task->getName();
        $queue = $task->getQueue();
        $id = $task->getId();
    }
}
codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.64%. Comparing base (819a092) to head (31c0458).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1097 +/- ## ========================================= Coverage 89.64% 89.64% - Complexity 6355 6361 +6 ========================================= Files 830 831 +1 Lines 17923 17935 +12 ========================================= + Hits 16067 16078 +11 - Misses 1856 1857 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.