Skip to content

Commit 392a565

Browse files
refactor: remove duplicate Job class from Queue.php — Job lives in Job.php
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 918cd18 commit 392a565

1 file changed

Lines changed: 0 additions & 72 deletions

File tree

‎Tina4/Queue.php‎

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -38,78 +38,6 @@
3838
use Tina4\Queue\KafkaBackend;
3939
use Tina4\Queue\MongoBackend;
4040

41-
/**
42-
* Job — Wraps a queue job with lifecycle methods.
43-
*/
44-
class Job
45-
{
46-
public string $id;
47-
public mixed $payload;
48-
public string $status;
49-
public int $attempts;
50-
public ?string $error;
51-
private Queue $queue;
52-
private string $topic;
53-
54-
public function __construct(array $data, Queue $queue, string $topic)
55-
{
56-
$this->id = $data['id'];
57-
$this->payload = $data['payload'];
58-
$this->status = $data['status'] ?? 'reserved';
59-
$this->attempts = $data['attempts'] ?? 0;
60-
$this->error = $data['error'] ?? null;
61-
$this->queue = $queue;
62-
$this->topic = $topic;
63-
}
64-
65-
/**
66-
* Mark this job as completed (removes it from the queue).
67-
*/
68-
public function complete(): void
69-
{
70-
$this->status = 'completed';
71-
}
72-
73-
/**
74-
* Mark this job as failed with a reason.
75-
*/
76-
public function fail(string $reason = ''): void
77-
{
78-
$this->status = 'failed';
79-
$this->error = $reason;
80-
$this->attempts++;
81-
$this->queue->writeFailed($this->topic, [
82-
'id' => $this->id,
83-
'payload' => $this->payload,
84-
'status' => 'failed',
85-
'attempts' => $this->attempts,
86-
'error' => $reason,
87-
]);
88-
}
89-
90-
/**
91-
* Reject this job with a reason. Alias for fail().
92-
*/
93-
public function reject(string $reason = ''): void
94-
{
95-
$this->fail($reason);
96-
}
97-
98-
/**
99-
* Get the raw job data as array.
100-
*/
101-
public function toArray(): array
102-
{
103-
return [
104-
'id' => $this->id,
105-
'payload' => $this->payload,
106-
'status' => $this->status,
107-
'attempts' => $this->attempts,
108-
'error' => $this->error,
109-
];
110-
}
111-
}
112-
11341
class Queue
11442
{
11543
private string $backend;

0 commit comments

Comments
 (0)